diff --git a/README.md b/README.md index bab303e2f..12342cefe 100644 --- a/README.md +++ b/README.md @@ -1,254 +1,6 @@ -

- Coverage Status - Downloads - Downloads - Downloads -

+智慧轮渡大数据平台 -**严肃声明:现在、未来都不会有商业版本,所有代码全部开源!** -**「我喜欢写代码,乐此不疲」** -**「我喜欢做开源,以此为乐」** - -我 🐶 在上海艰苦奋斗,早中晚在 top3 大厂认真搬砖,夜里为开源做贡献。 - -如果这个项目让你有所收获,记得 Star 关注哦,这对我是非常不错的鼓励与支持。 - -## 🐰 版本说明 - -| 版本 | JDK 8 + Spring Boot 2.7 | JDK 17/21 + Spring Boot 3.2 | -|-----------------------------------------------------------------------|--------------------------------------------------------------------------|--------------------------------------------------------------------------------------| -| 【完整版】[yudao-cloud](https://gitee.com/zhijiantianya/yudao-cloud) | [`master`](https://gitee.com/zhijiantianya/yudao-cloud/tree/master/) 分支 | [`master-jdk17`](https://gitee.com/zhijiantianya/yudao-cloud/tree/master-jdk17/) 分支 | -| 【精简版】[yudao-cloud-mini](https://gitee.com/yudaocode/yudao-cloud-mini) | [`master`](https://gitee.com/yudaocode/yudao-cloud-mini/tree/master/) 分支 | [`master-jdk17`](https://gitee.com/yudaocode/yudao-cloud-mini/tree/master-jdk17/) 分支 | - -* 【完整版】:包括系统功能、基础设施、会员中心、数据报表、工作流程、商城系统、微信公众号、CRM、ERP 等功能 -* 【精简版】:只包括系统功能、基础设施功能,不包括会员中心、数据报表、工作流程、商城系统、微信公众号、CRM、ERP 等功能 - -可参考 [《迁移文档》](https://cloud.iocoder.cn/migrate-module/) ,只需要 5-10 分钟,即可将【完整版】按需迁移到【精简版】 - -## 🐶 新手必读 - -* 演示地址【Vue3 + element-plus】: -* 演示地址【Vue3 + vben(ant-design-vue)】: -* 演示地址【Vue2 + element-ui】: -* 启动文档: -* 视频教程: - -## 🐯 平台简介 - -**芋道**,以开发者为中心,打造中国第一流的快速开发平台,全部开源,个人与企业可 100% 免费使用。 - -> 有任何问题,或者想要的功能,可以在 _Issues_ 中提给艿艿。 -> -> 😜 给项目点点 Star 吧,这对我们真的很重要! - -![架构图](/.image/common/yudao-cloud-architecture.png) - -* Java 后端:`master` 分支为 JDK 8 + Spring Boot 2.7,`master-jdk17` 分支为 JDK 17/21 + Spring Boot 3.2 -* 管理后台的电脑端:Vue3 提供 [element-plus](https://gitee.com/yudaocode/yudao-ui-admin-vue3)、[vben(ant-design-vue)](https://gitee.com/yudaocode/yudao-ui-admin-vben) 两个版本,Vue2 提供 [element-ui](https://gitee.com/zhijiantianya/ruoyi-vue-pro/tree/master/yudao-ui-admin) 版本 -* 管理后台的移动端:采用 [uni-app](https://github.com/dcloudio/uni-app) 方案,一份代码多终端适配,同时支持 APP、小程序、H5! -* 后端采用 Spring Cloud Alibaba 微服务架构,注册中心 + 配置中心 Nacos,定时任务 XXL-Job,服务保障 Sentinel,服务网关 Gateway,分布式事务 Seata -* 数据库可使用 MySQL、Oracle、PostgreSQL、SQL Server、MariaDB、国产达梦 DM、TiDB 等,基于 MyBatis Plus、Redis + Redisson 操作 -* 消息队列可使用 Event、Redis、RabbitMQ、Kafka、RocketMQ 等 -* 权限认证使用 Spring Security & Token & Redis,支持多终端、多种用户的认证系统,支持 SSO 单点登录 -* 支持加载动态权限菜单,按钮级别权限控制,Redis 缓存提升性能 -* 支持 SaaS 多租户系统,可自定义每个租户的权限,提供透明化的多租户底层封装 -* 高效率开发,使用代码生成器可以一键生成 Java、Vue 前后端代码、SQL 脚本、接口文档,支持单表、树表、主子表 -* 实时通信,采用 Spring WebSocket 实现,内置 Token 身份校验,支持 WebSocket 集群 -* 集成微信小程序、微信公众号、企业微信、钉钉等三方登陆,集成支付宝、微信等支付与退款 -* 集成阿里云、腾讯云等短信渠道,集成 MinIO、阿里云、腾讯云、七牛云等云存储服务 -* 集成报表设计器、大屏设计器,通过拖拽即可生成酷炫的报表与大屏 - -## 🐳 项目关系 - -![架构演进](/.image/common/yudao-roadmap.png) - -三个项目的功能对比,可见社区共同整理的 [国产开源项目对比](https://www.yuque.com/xiatian-bsgny/lm0ec1/wqf8mn) 表格。 - -### 后端项目 - -| 项目 | Star | 简介 | -|-----------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------| -| [ruoyi-vue-pro](https://gitee.com/zhijiantianya/ruoyi-vue-pro) | [![Gitee star](https://gitee.com/zhijiantianya/ruoyi-vue-pro/badge/star.svg?theme=white)](https://gitee.com/zhijiantianya/ruoyi-vue-pro) [![GitHub stars](https://img.shields.io/github/stars/YunaiV/ruoyi-vue-pro.svg?style=social&label=Stars)](https://github.com/YunaiV/ruoyi-vue-pro) | 基于 Spring Boot 多模块架构 | -| [yudao-cloud](https://gitee.com/zhijiantianya/yudao-cloud) | [![Gitee star](https://gitee.com/zhijiantianya/yudao-cloud/badge/star.svg?theme=white)](https://gitee.com/zhijiantianya/yudao-cloud) [![GitHub stars](https://img.shields.io/github/stars/YunaiV/yudao-cloud.svg?style=social&label=Stars)](https://github.com/YunaiV/yudao-cloud) | 基于 Spring Cloud 微服务架构 | -| [Spring-Boot-Labs](https://gitee.com/yudaocode/SpringBoot-Labs) | [![Gitee star](https://gitee.com/yudaocode/SpringBoot-Labs/badge/star.svg?theme=white)](https://gitee.com/zhijiantianya/yudao-cloud) [![GitHub stars](https://img.shields.io/github/stars/yudaocode/SpringBoot-Labs.svg?style=social&label=Stars)](https://github.com/yudaocode/SpringBoot-Labs) | 系统学习 Spring Boot & Cloud 专栏 | - -### 前端项目 - -| 项目 | Star | 简介 | -|----------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------| -| [yudao-ui-admin-vue3](https://gitee.com/yudaocode/yudao-ui-admin-vue3) | [![Gitee star](https://gitee.com/yudaocode/yudao-ui-admin-vue3/badge/star.svg?theme=white)](https://gitee.com/yudaocode/yudao-ui-admin-vue3) [![GitHub stars](https://img.shields.io/github/stars/yudaocode/yudao-ui-admin-vue3.svg?style=social&label=Stars)](https://github.com/yudaocode/yudao-ui-admin-vue3) | 基于 Vue3 + element-plus 实现的管理后台 | -| [yudao-ui-admin-vben](https://gitee.com/yudaocode/yudao-ui-admin-vben) | [![Gitee star](https://gitee.com/yudaocode/yudao-ui-admin-vben/badge/star.svg?theme=white)](https://gitee.com/yudaocode/yudao-ui-admin-vben) [![GitHub stars](https://img.shields.io/github/stars/yudaocode/yudao-ui-admin-vben.svg?style=social&label=Stars)](https://github.com/yudaocode/yudao-ui-admin-vben) | 基于 Vue3 + vben(ant-design-vue) 实现的管理后台 | -| [yudao-mall-uniapp](https://gitee.com/yudaocode/yudao-mall-uniapp) | [![Gitee star](https://gitee.com/yudaocode/yudao-mall-uniapp/badge/star.svg?theme=white)](https://gitee.com/yudaocode/yudao-mall-uniapp) [![GitHub stars](https://img.shields.io/github/stars/yudaocode/yudao-mall-uniapp.svg?style=social&label=Stars)](https://github.com/yudaocode/yudao-mall-uniapp) | 基于 uni-app 实现的商城小程序 | -| [yudao-ui-admin-vue2](https://gitee.com/yudaocode/yudao-ui-admin-vue2) | [![Gitee star](https://gitee.com/yudaocode/yudao-ui-admin-vue2/badge/star.svg?theme=white)](https://gitee.com/yudaocode/yudao-ui-admin-vue2) [![GitHub stars](https://img.shields.io/github/stars/yudaocode/yudao-ui-admin-vue2.svg?style=social&label=Stars)](https://github.com/yudaocode/yudao-ui-admin-vue2) | 基于 Vue2 + element-ui 实现的管理后台 | -| [yudao-ui-admin-uniapp](https://gitee.com/yudaocode/yudao-ui-admin-uniapp) | [![Gitee star](https://gitee.com/yudaocode/yudao-ui-admin-uniapp/badge/star.svg?theme=white)](https://gitee.com/yudaocode/yudao-ui-admin-uniapp) [![GitHub stars](https://img.shields.io/github/stars/yudaocode/yudao-ui-admin-uniapp.svg?style=social&label=Stars)](https://github.com/yudaocode/yudao-ui-admin-uniapp) | 基于 Vue2 + element-ui 实现的管理后台 | -| [yudao-ui-go-view](https://gitee.com/yudaocode/yudao-ui-go-view) | [![Gitee star](https://gitee.com/yudaocode/yudao-ui-go-view/badge/star.svg?theme=white)](https://gitee.com/yudaocode/yudao-ui-go-view) [![GitHub stars](https://img.shields.io/github/stars/yudaocode/yudao-ui-go-view.svg?style=social&label=Stars)](https://github.com/yudaocode/yudao-ui-go-view) | 基于 Vue3 + naive-ui 实现的大屏报表 | - -## 😎 开源协议 - -**为什么推荐使用本项目?** - -① 本项目采用比 Apache 2.0 更宽松的 [MIT License](https://gitee.com/zhijiantianya/ruoyi-vue-pro/blob/master/LICENSE) 开源协议,个人与企业可 100% 免费使用,不用保留类作者、Copyright 信息。 - -② 代码全部开源,不会像其他项目一样,只开源部分代码,让你无法了解整个项目的架构设计。[国产开源项目对比](https://www.yuque.com/xiatian-bsgny/lm0ec1/wqf8mn) - -![开源项目对比](/.image/common/project-vs.png) - -③ 代码整洁、架构整洁,遵循《阿里巴巴 Java 开发手册》规范,代码注释详细,57000 行 Java 代码,22000 行代码注释。 - -## 🤝 项目外包 - -我们也是接外包滴,如果你有项目想要外包,可以微信联系【**Aix9975**】。 - -团队包含专业的项目经理、架构师、前端工程师、后端工程师、测试工程师、运维工程师,可以提供全流程的外包服务。 - -项目可以是商城、SCRM 系统、OA 系统、物流系统、ERP 系统、CMS 系统、HIS 系统、支付系统、IM 聊天、微信公众号、微信小程序等等。 - -## 🐼 内置功能 - -系统内置多种多种业务功能,可以用于快速你的业务系统: - -![功能分层](/.image/common/ruoyi-vue-pro-biz.png) - -* 通用模块(必选):系统功能、基础设施 -* 通用模块(可选):工作流程、支付系统、数据报表、会员中心 -* 业务系统(按需):ERP 系统、CRM 系统、商城系统、微信公众号 - -> 友情提示:本项目基于 RuoYi-Vue 修改,**重构优化**后端的代码,**美化**前端的界面。 -> -> * 额外新增的功能,我们使用 🚀 标记。 -> * 重新实现的功能,我们使用 ⭐️ 标记。 - -🙂 所有功能,都通过 **单元测试** 保证高质量。 - -### 系统功能 - -| | 功能 | 描述 | -|-----|-------|---------------------------------| -| | 用户管理 | 用户是系统操作者,该功能主要完成系统用户配置 | -| ⭐️ | 在线用户 | 当前系统中活跃用户状态监控,支持手动踢下线 | -| | 角色管理 | 角色菜单权限分配、设置角色按机构进行数据范围权限划分 | -| | 菜单管理 | 配置系统菜单、操作权限、按钮权限标识等,本地缓存提供性能 | -| | 部门管理 | 配置系统组织机构(公司、部门、小组),树结构展现支持数据权限 | -| | 岗位管理 | 配置系统用户所属担任职务 | -| 🚀 | 租户管理 | 配置系统租户,支持 SaaS 场景下的多租户功能 | -| 🚀 | 租户套餐 | 配置租户套餐,自定每个租户的菜单、操作、按钮的权限 | -| | 字典管理 | 对系统中经常使用的一些较为固定的数据进行维护 | -| 🚀 | 短信管理 | 短信渠道、短息模板、短信日志,对接阿里云、腾讯云等主流短信平台 | -| 🚀 | 邮件管理 | 邮箱账号、邮件模版、邮件发送日志,支持所有邮件平台 | -| 🚀 | 站内信 | 系统内的消息通知,提供站内信模版、站内信消息 | -| 🚀 | 操作日志 | 系统正常操作日志记录和查询,集成 Swagger 生成日志内容 | -| ⭐️ | 登录日志 | 系统登录日志记录查询,包含登录异常 | -| 🚀 | 错误码管理 | 系统所有错误码的管理,可在线修改错误提示,无需重启服务 | -| | 通知公告 | 系统通知公告信息发布维护 | -| 🚀 | 敏感词 | 配置系统敏感词,支持标签分组 | -| 🚀 | 应用管理 | 管理 SSO 单点登录的应用,支持多种 OAuth2 授权方式 | -| 🚀 | 地区管理 | 展示省份、城市、区镇等城市信息,支持 IP 对应城市 | - -![功能图](/.image/common/system-feature.png) - -### 工作流程 - -| | 功能 | 描述 | -|-----|-------|----------------------------------------| -| 🚀 | 流程模型 | 配置工作流的流程模型,支持文件导入与在线设计流程图,提供 7 种任务分配规则 | -| 🚀 | 流程表单 | 拖动表单元素生成相应的工作流表单,覆盖 Element UI 所有的表单组件 | -| 🚀 | 用户分组 | 自定义用户分组,可用于工作流的审批分组 | -| 🚀 | 我的流程 | 查看我发起的工作流程,支持新建、取消流程等操作,高亮流程图、审批时间线 | -| 🚀 | 待办任务 | 查看自己【未】审批的工作任务,支持通过、不通过、转发、委派、退回等操作 | -| 🚀 | 已办任务 | 查看自己【已】审批的工作任务,未来会支持回退操作 | -| 🚀 | OA 请假 | 作为业务自定义接入工作流的使用示例,只需创建请求对应的工作流程,即可进行审批 | - -![功能图](/.image/common/bpm-feature.png) - -### 支付系统 - -| | 功能 | 描述 | -|-----|------|---------------------------| -| 🚀 | 应用信息 | 配置商户的应用信息,对接支付宝、微信等多个支付渠道 | -| 🚀 | 支付订单 | 查看用户发起的支付宝、微信等的【支付】订单 | -| 🚀 | 退款订单 | 查看用户发起的支付宝、微信等的【退款】订单 | -| 🚀 | 回调通知 | 查看支付回调业务的【支付】【退款】的通知结果 | -| 🚀 | 接入示例 | 提供接入支付系统的【支付】【退款】的功能实战 | - -### 基础设施 - -| | 功能 | 描述 | -|----|-----------|----------------------------------------------| -| 🚀 | 代码生成 | 前后端代码的生成(Java、Vue、SQL、单元测试),支持 CRUD 下载 | -| 🚀 | 系统接口 | 基于 Swagger 自动生成相关的 RESTful API 接口文档 | -| 🚀 | 数据库文档 | 基于 Screw 自动生成数据库文档,支持导出 Word、HTML、MD 格式 | -| | 表单构建 | 拖动表单元素生成相应的 HTML 代码,支持导出 JSON、Vue 文件 | -| 🚀 | 配置管理 | 对系统动态配置常用参数,支持 SpringBoot 加载 | -| ⭐️ | 定时任务 | 在线(添加、修改、删除)任务调度包含执行结果日志 | -| 🚀 | 文件服务 | 支持将文件存储到 S3(MinIO、阿里云、腾讯云、七牛云)、本地、FTP、数据库等 | -| 🚀 | WebSocket | 提供 WebSocket 接入示例,支持一对一、一对多发送方式 | -| 🚀 | API 日志 | 包括 RESTful API 访问日志、异常日志两部分,方便排查 API 相关的问题 | -| | MySQL 监控 | 监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈 | -| | Redis 监控 | 监控 Redis 数据库的使用情况,使用的 Redis Key 管理 | -| 🚀 | 消息队列 | 基于 Redis 实现消息队列,Stream 提供集群消费,Pub/Sub 提供广播消费 | -| 🚀 | Java 监控 | 基于 Spring Boot Admin 实现 Java 应用的监控 | -| 🚀 | 链路追踪 | 接入 SkyWalking 组件,实现链路追踪 | -| 🚀 | 日志中心 | 接入 SkyWalking 组件,实现日志中心 | -| 🚀 | 服务保障 | 基于 Redis 实现分布式锁、幂等、限流功能,满足高并发场景 | -| 🚀 | 日志服务 | 轻量级日志中心,查看远程服务器的日志 | -| 🚀 | 单元测试 | 基于 JUnit + Mockito 实现单元测试,保证功能的正确性、代码的质量等 | - -![功能图](/.image/common/infra-feature.png) - -### 数据报表 - -| | 功能 | 描述 | -|-----|-------|--------------------| -| 🚀 | 报表设计器 | 支持数据报表、图形报表、打印设计等 | -| 🚀 | 大屏设计器 | 拖拽生成数据大屏,内置几十种图表组件 | - -### 微信公众号 - -| | 功能 | 描述 | -|-----|--------|-------------------------------| -| 🚀 | 账号管理 | 配置接入的微信公众号,可支持多个公众号 | -| 🚀 | 数据统计 | 统计公众号的用户增减、累计用户、消息概况、接口分析等数据 | -| 🚀 | 粉丝管理 | 查看已关注、取关的粉丝列表,可对粉丝进行同步、打标签等操作 | -| 🚀 | 消息管理 | 查看粉丝发送的消息列表,可主动回复粉丝消息 | -| 🚀 | 自动回复 | 自动回复粉丝发送的消息,支持关注回复、消息回复、关键字回复 | -| 🚀 | 标签管理 | 对公众号的标签进行创建、查询、修改、删除等操作 | -| 🚀 | 菜单管理 | 自定义公众号的菜单,也可以从公众号同步菜单 | -| 🚀 | 素材管理 | 管理公众号的图片、语音、视频等素材,支持在线播放语音、视频 | -| 🚀 | 图文草稿箱 | 新增常用的图文素材到草稿箱,可发布到公众号 | -| 🚀 | 图文发表记录 | 查看已发布成功的图文素材,支持删除操作 | - -### 商城系统 - -![功能图](/.image/common/mall-feature.png) - -![功能图](/.image/common/mall-preview.png) - -演示地址: - -### 会员中心 - -| | 功能 | 描述 | -|-----|------|----------------------------------| -| 🚀 | 会员管理 | 会员是 C 端的消费者,该功能用于会员的搜索与管理 | -| 🚀 | 会员标签 | 对会员的标签进行创建、查询、修改、删除等操作 | -| 🚀 | 会员等级 | 对会员的等级、成长值进行管理,可用于订单折扣等会员权益 | -| 🚀 | 会员分组 | 对会员进行分组,用于用户画像、内容推送等运营手段 | -| 🚀 | 积分签到 | 回馈给签到、消费等行为的积分,会员可订单抵现、积分兑换等途径消耗 | - -### ERP 系统 - -![功能图](/.image/common/erp-feature.png) - -演示地址: - -### ERP 系统 - -![功能图](/.image/common/crm-feature.png) - -演示地址: - -## 🐨 技术栈 ### 微服务 @@ -256,16 +8,9 @@ |--------------------------------------------------------------------------|--------------------| | `yudao-dependencies` | Maven 依赖版本管理 | | `yudao-framework` | Java 框架拓展 | -| `yudao-server` | 管理后台 + 用户 APP 的服务端 | | `yudao-module-system` | 系统功能的 Module 模块 | | `yudao-module-member` | 会员中心的 Module 模块 | | `yudao-module-infra` | 基础设施的 Module 模块 | -| `yudao-module-bpm` | 工作流程的 Module 模块 | -| `yudao-module-pay` | 支付系统的 Module 模块 | -| `yudao-module-mall` | 商城系统的 Module 模块 | -| `yudao-module-mp` | 微信公众号的 Module 模块 | -| `yudao-module-report` | 大屏报表 Module 模块 | - ### 框架 | 框架 | 说明 | 版本 | 学习指南 | @@ -334,25 +79,3 @@ | MySQL & Redis | ![MySQL](/.image/MySQL.jpg) | ![Redis](/.image/Redis.jpg) | - | | 监控平台 | ![Java监控](/.image/Java监控.jpg) | ![链路追踪](/.image/链路追踪.jpg) | ![日志中心](/.image/日志中心.jpg) | -### 支付系统 - -| 模块 | biu | biu | biu | -|---------|---------------------------|---------------------------------|---------------------------------| -| 商家 & 应用 | ![商户信息](/.image/商户信息.jpg) | ![应用信息-列表](/.image/应用信息-列表.jpg) | ![应用信息-编辑](/.image/应用信息-编辑.jpg) | -| 支付 & 退款 | ![支付订单](/.image/支付订单.jpg) | ![退款订单](/.image/退款订单.jpg) | --- | -### 数据报表 - -| 模块 | biu | biu | biu | -|-------|---------------------------------|---------------------------------|---------------------------------------| -| 报表设计器 | ![数据报表](/.image/报表设计器-数据报表.jpg) | ![图形报表](/.image/报表设计器-图形报表.jpg) | ![报表设计器-打印设计](/.image/报表设计器-打印设计.jpg) | -| 大屏设计器 | ![大屏列表](/.image/大屏设计器-列表.jpg) | ![大屏预览](/.image/大屏设计器-预览.jpg) | ![大屏编辑](/.image/大屏设计器-编辑.jpg) | - -### 移动端(管理后台) - -| biu | biu | biu | -|----------------------------------|----------------------------------|----------------------------------| -| ![](/.image/admin-uniapp/01.png) | ![](/.image/admin-uniapp/02.png) | ![](/.image/admin-uniapp/03.png) | -| ![](/.image/admin-uniapp/04.png) | ![](/.image/admin-uniapp/05.png) | ![](/.image/admin-uniapp/06.png) | -| ![](/.image/admin-uniapp/07.png) | ![](/.image/admin-uniapp/08.png) | ![](/.image/admin-uniapp/09.png) | - -目前已经实现登录、我的、工作台、编辑资料、头像修改、密码修改、常见问题、关于我们等基础功能。 diff --git a/pom.xml b/pom.xml index f32b152b5..a360312e2 100644 --- a/pom.xml +++ b/pom.xml @@ -15,13 +15,13 @@ yudao-module-system yudao-module-infra yudao-module-member - yudao-module-bpm - yudao-module-pay - yudao-module-report - yudao-module-mp - yudao-module-mall - yudao-module-erp - yudao-module-crm + + + + + + + ${project.artifactId} diff --git a/yudao-module-bpm/pom.xml b/yudao-module-bpm/pom.xml deleted file mode 100644 index 432b97ae4..000000000 --- a/yudao-module-bpm/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - cn.iocoder.cloud - yudao - ${revision} - - 4.0.0 - - yudao-module-bpm-api - yudao-module-bpm-biz - - yudao-module-bpm - pom - - ${project.artifactId} - - bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能。 - 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等 - bpm 解释:https://baike.baidu.com/item/BPM/1933 - - 工作流基于 Flowable 6 实现,分成流程定义、流程表单、流程实例、流程任务等功能模块。 - - - diff --git a/yudao-module-bpm/yudao-module-bpm-api/pom.xml b/yudao-module-bpm/yudao-module-bpm-api/pom.xml deleted file mode 100644 index 470b4b533..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-bpm - ${revision} - - 4.0.0 - yudao-module-bpm-api - jar - - ${project.artifactId} - - bpm 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java deleted file mode 100644 index 37a92219f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * bpm API 包,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.bpm.api; diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApi.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApi.java deleted file mode 100644 index e22152ee5..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApi.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.api.task; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.bpm.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 流程实例") -public interface BpmProcessInstanceApi { - - String PREFIX = ApiConstants.PREFIX + "/process-instance"; - - @PostMapping(PREFIX + "/create") - @Operation(summary = "创建流程实例(提供给内部),返回实例编号") - @Parameter(name = "userId", description = "用户编号", required = true, example = "1") - CommonResult createProcessInstance(@RequestParam("userId") Long userId, - @Valid @RequestBody BpmProcessInstanceCreateReqDTO reqDTO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java deleted file mode 100644 index 033e75d6b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.bpm.api.task.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.List; -import java.util.Map; - -@Schema(description = "RPC 服务 - 流程实例的创建 Request DTO") -@Data -public class BpmProcessInstanceCreateReqDTO { - - @Schema(description = "流程定义的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "leave") - @NotEmpty(message = "流程定义的标识不能为空") - private String processDefinitionKey; - - @Schema(description = "变量实例", requiredMode = Schema.RequiredMode.REQUIRED) - private Map variables; - - @Schema(description = "业务的唯一标识", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "业务的唯一标识不能为空") - private String businessKey; // 例如说,请假申请的编号。通过它,可以查询到对应的实例 - - /** - * 发起人自选审批人 Map - * - * key:taskKey 任务编码 - * value:审批人的数组 - * 例如:{ taskKey1 :[1, 2] },则表示 taskKey1 这个任务,提前设定了,由 userId 为 1,2 的用户进行审批 - */ - @Schema(description = "发起人自选审批人 Map") - private Map> startUserSelectAssignees; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ApiConstants.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ApiConstants.java deleted file mode 100644 index b7c7de9fc..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "bpm-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/bpm"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/DictTypeConstants.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/DictTypeConstants.java deleted file mode 100644 index 7abb3e1db..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/DictTypeConstants.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums; - -/** - * BPM 字典类型的枚举类 - * - * @author 芋道源码 - */ -public interface DictTypeConstants { - - String TASK_ASSIGN_RULE_TYPE = "bpm_task_assign_rule_type"; // 任务分配规则类型 - String TASK_ASSIGN_SCRIPT = "bpm_task_assign_script"; // 任务分配自定义脚本 - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java deleted file mode 100644 index ec167719c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Bpm 错误码枚举类 - *

- * bpm 系统,使用 1-009-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 通用流程处理 模块 1-009-000-000 ========== - - // ========== OA 流程模块 1-009-001-000 ========== - ErrorCode OA_LEAVE_NOT_EXISTS = new ErrorCode(1_009_001_001, "请假申请不存在"); - - // ========== 流程模型 1-009-002-000 ========== - ErrorCode MODEL_KEY_EXISTS = new ErrorCode(1_009_002_000, "已经存在流程标识为【{}】的流程"); - ErrorCode MODEL_NOT_EXISTS = new ErrorCode(1_009_002_001, "流程模型不存在"); - ErrorCode MODEL_KEY_VALID = new ErrorCode(1_009_002_002, "流程标识格式不正确,需要以字母或下划线开头,后接任意字母、数字、中划线、下划线、句点!"); - ErrorCode MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG = new ErrorCode(1_009_002_003, "部署流程失败,原因:流程表单未配置,请点击【修改流程】按钮进行配置"); - ErrorCode MODEL_DEPLOY_FAIL_TASK_CANDIDATE_NOT_CONFIG = new ErrorCode(1_009_002_004, "部署流程失败," + - "原因:用户任务({})未配置审批人,请点击【流程设计】按钮,选择该它的【任务(审批人)】进行配置"); - ErrorCode MODEL_DEPLOY_FAIL_BPMN_START_EVENT_NOT_EXISTS = new ErrorCode(1_009_002_005, "部署流程失败,原因:BPMN 流程图中,没有开始事件"); - ErrorCode MODEL_DEPLOY_FAIL_BPMN_USER_TASK_NAME_NOT_EXISTS = new ErrorCode(1_009_002_006, "部署流程失败,原因:BPMN 流程图中,用户任务({})的名字不存在"); - - // ========== 流程定义 1-009-003-000 ========== - ErrorCode PROCESS_DEFINITION_KEY_NOT_MATCH = new ErrorCode(1_009_003_000, "流程定义的标识期望是({}),当前是({}),请修改 BPMN 流程图"); - ErrorCode PROCESS_DEFINITION_NAME_NOT_MATCH = new ErrorCode(1_009_003_001, "流程定义的名字期望是({}),当前是({}),请修改 BPMN 流程图"); - ErrorCode PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1_009_003_002, "流程定义不存在"); - ErrorCode PROCESS_DEFINITION_IS_SUSPENDED = new ErrorCode(1_009_003_003, "流程定义处于挂起状态"); - - // ========== 流程实例 1-009-004-000 ========== - ErrorCode PROCESS_INSTANCE_NOT_EXISTS = new ErrorCode(1_009_004_000, "流程实例不存在"); - ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS = new ErrorCode(1_009_004_001, "流程取消失败,流程不处于运行中"); - ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF = new ErrorCode(1_009_004_002, "流程取消失败,该流程不是你发起的"); - ErrorCode PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG = new ErrorCode(1_009_004_003, "审批任务({})的审批人未配置"); - ErrorCode PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_EXISTS = new ErrorCode(1_009_004_004, "审批任务({})的审批人({})不存在"); - - // ========== 流程任务 1-009-005-000 ========== - ErrorCode TASK_OPERATE_FAIL_ASSIGN_NOT_SELF = new ErrorCode(1_009_005_001, "操作失败,原因:该任务的审批人不是你"); - ErrorCode TASK_NOT_EXISTS = new ErrorCode(1_009_005_002, "流程任务不存在"); - ErrorCode TASK_IS_PENDING = new ErrorCode(1_009_005_003, "当前任务处于挂起状态,不能操作"); - ErrorCode TASK_TARGET_NODE_NOT_EXISTS = new ErrorCode(1_009_005_004, " 目标节点不存在"); - ErrorCode TASK_RETURN_FAIL_SOURCE_TARGET_ERROR = new ErrorCode(1_009_005_006, "回退任务失败,目标节点是在并行网关上或非同一路线上,不可跳转"); - ErrorCode TASK_DELEGATE_FAIL_USER_REPEAT = new ErrorCode(1_009_005_007, "任务委派失败,委派人和当前审批人为同一人"); - ErrorCode TASK_DELEGATE_FAIL_USER_NOT_EXISTS = new ErrorCode(1_009_005_008, "任务委派失败,被委派人不存在"); - ErrorCode TASK_SIGN_CREATE_USER_NOT_EXIST = new ErrorCode(1_009_005_009, "任务加签:选择的用户不存在"); - ErrorCode TASK_SIGN_CREATE_TYPE_ERROR = new ErrorCode(1_009_005_010, "任务加签:当前任务已经{},不能{}"); - ErrorCode TASK_SIGN_CREATE_USER_REPEAT = new ErrorCode(1_009_005_011, "任务加签失败,加签人与现有审批人[{}]重复"); - ErrorCode TASK_SIGN_DELETE_NO_PARENT = new ErrorCode(1_009_005_012, "任务减签失败,被减签的任务必须是通过加签生成的任务"); - ErrorCode TASK_TRANSFER_FAIL_USER_REPEAT = new ErrorCode(1_009_005_013, "任务转办失败,转办人和当前审批人为同一人"); - ErrorCode TASK_TRANSFER_FAIL_USER_NOT_EXISTS = new ErrorCode(1_009_005_014, "任务转办失败,转办人不存在"); - ErrorCode TASK_CREATE_FAIL_NO_CANDIDATE_USER = new ErrorCode(1_009_006_003, "操作失败,原因:找不到任务的审批人!"); - - // ========== 动态表单模块 1-009-010-000 ========== - ErrorCode FORM_NOT_EXISTS = new ErrorCode(1_009_010_000, "动态表单不存在"); - ErrorCode FORM_FIELD_REPEAT = new ErrorCode(1_009_010_001, "表单项({}) 和 ({}) 使用了相同的字段名({})"); - - // ========== 用户组模块 1-009-011-000 ========== - ErrorCode USER_GROUP_NOT_EXISTS = new ErrorCode(1_009_011_000, "用户分组不存在"); - ErrorCode USER_GROUP_IS_DISABLE = new ErrorCode(1_009_011_001, "名字为【{}】的用户分组已被禁用"); - - // ========== 用户组模块 1-009-012-000 ========== - ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(1_009_012_000, "流程分类不存在"); - ErrorCode CATEGORY_NAME_DUPLICATE = new ErrorCode(1_009_012_001, "流程分类名字【{}】重复"); - ErrorCode CATEGORY_CODE_DUPLICATE = new ErrorCode(1_009_012_002, "流程分类编码【{}】重复"); - - // ========== BPM 流程监听器 1-009-013-000 ========== - ErrorCode PROCESS_LISTENER_NOT_EXISTS = new ErrorCode(1_009_013_000, "流程监听器不存在"); - ErrorCode PROCESS_LISTENER_CLASS_NOT_FOUND = new ErrorCode(1_009_013_001, "流程监听器类({})不存在"); - ErrorCode PROCESS_LISTENER_CLASS_IMPLEMENTS_ERROR = new ErrorCode(1_009_013_002, "流程监听器类({})没有实现接口({})"); - ErrorCode PROCESS_LISTENER_EXPRESSION_INVALID = new ErrorCode(1_009_013_003, "流程监听器表达式({})不合法"); - - // ========== BPM 流程表达式 1-009-014-000 ========== - ErrorCode PROCESS_EXPRESSION_NOT_EXISTS = new ErrorCode(1_009_014_000, "流程表达式不存在"); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java deleted file mode 100644 index 3bca6c82b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.definition; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * BPM 模型的表单类型的枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmModelFormTypeEnum implements IntArrayValuable { - - NORMAL(10, "流程表单"), // 对应 BpmFormDO - CUSTOM(20, "业务表单") // 业务自己定义的表单,自己进行数据的存储 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmModelFormTypeEnum::getType).toArray(); - - private final Integer type; - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmProcessListenerType.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmProcessListenerType.java deleted file mode 100644 index 3dde5dfb5..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmProcessListenerType.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.definition; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * BPM 流程监听器的类型 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmProcessListenerType { - - EXECUTION("execution", "执行监听器"), - TASK("task", "任务执行器"); - - private final String type; - private final String name; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmProcessListenerValueType.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmProcessListenerValueType.java deleted file mode 100644 index 63e23af23..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmProcessListenerValueType.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.definition; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * BPM 流程监听器的值类型 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmProcessListenerValueType { - - CLASS("class", "Java 类"), - DELEGATE_EXPRESSION("delegateExpression", "代理表达式"), - EXPRESSION("expression", "表达式"); - - private final String type; - private final String name; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java deleted file mode 100644 index 79001fccd..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.message; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * Bpm 消息的枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum BpmMessageEnum { - - PROCESS_INSTANCE_APPROVE("bpm_process_instance_approve"), // 流程任务被审批通过时,发送给申请人 - PROCESS_INSTANCE_REJECT("bpm_process_instance_reject"), // 流程任务被审批不通过时,发送给申请人 - TASK_ASSIGNED("bpm_task_assigned"); // 任务被分配时,发送给审批人 - - /** - * 短信模板的标识 - * - * 关联 SmsTemplateDO 的 code 属性 - */ - private final String smsTemplateCode; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmCommentTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmCommentTypeEnum.java deleted file mode 100644 index 8b7b7ce11..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmCommentTypeEnum.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import cn.hutool.core.util.StrUtil; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 流程任务的 Comment 评论类型枚举 - * - * @author kehaiyou - */ -@Getter -@AllArgsConstructor -public enum BpmCommentTypeEnum { - - APPROVE("1", "审批通过", "审批通过,原因是:{}"), - REJECT("2", "不通过", "审批不通过:原因是:{}"), - CANCEL("3", "已取消", "系统自动取消,原因是:{}"), - RETURN("4", "退回", "任务被退回,原因是:{}"), - DELEGATE_START("5", "委派发起", "[{}]将任务委派给[{}],委派理由为:{}"), - DELEGATE_END("6", "委派完成", "[{}]完成委派任务,任务重新回到[{}]手中,审批建议为:{}"), - TRANSFER("7", "转派", "[{}]将任务转派给[{}],转派理由为:{}"), - ADD_SIGN("8", "加签", "[{}]{}给了[{}],理由为:{}"), - SUB_SIGN("9", "减签", "[{}]操作了【减签】,审批人[{}]的任务被取消"), - ; - - /** - * 操作类型 - * - * 由于 BPM Comment 类型为 String,所以这里就不使用 Integer - */ - private final String type; - /** - * 操作名字 - */ - private final String name; - /** - * 操作描述 - */ - private final String comment; - - public String formatComment(Object... params) { - return StrUtil.format(comment, params); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmDeleteReasonEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmDeleteReasonEnum.java deleted file mode 100644 index 802b9d890..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmDeleteReasonEnum.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import cn.hutool.core.util.StrUtil; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 流程实例/任务的删除原因枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmDeleteReasonEnum { - - // ========== 流程实例的独有原因 ========== - - REJECT_TASK("审批不通过任务,原因:{}"), // 场景:用户审批不通过任务。修改文案时,需要注意 isRejectReason 方法 - CANCEL_PROCESS_INSTANCE_BY_START_USER("用户主动取消流程,原因:{}"), // 场景:用户主动取消流程 - CANCEL_PROCESS_INSTANCE_BY_ADMIN("管理员【{}】取消流程,原因:{}"), // 场景:管理员取消流程 - - // ========== 流程任务的独有原因 ========== - - CANCEL_BY_SYSTEM("系统自动取消"), // 场景:非常多,比如说:1)多任务审批已经满足条件,无需审批该任务;2)流程实例被取消,无需审批该任务;等等 - ; - - private final String reason; - - /** - * 格式化理由 - * - * @param args 参数 - * @return 理由 - */ - public String format(Object... args) { - return StrUtil.format(reason, args); - } - - // ========== 逻辑 ========== - - public static boolean isRejectReason(String reason) { - return StrUtil.startWith(reason, "审批不通过任务,原因:"); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java deleted file mode 100644 index 82a4119b5..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 流程实例 ProcessInstance 的状态 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmProcessInstanceStatusEnum implements IntArrayValuable { - - RUNNING(1, "审批中"), - APPROVE(2, "审批通过"), - REJECT(3, "审批不通过"), - CANCEL(4, "已取消"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmProcessInstanceStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 描述 - */ - private final String desc; - - @Override - public int[] array() { - return new int[0]; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskSignTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskSignTypeEnum.java deleted file mode 100644 index b01153d79..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskSignTypeEnum.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import cn.hutool.core.util.ArrayUtil; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 流程任务的加签类型枚举 - * - * @author kehaiyou - */ -@Getter -@AllArgsConstructor -public enum BpmTaskSignTypeEnum { - - /** - * 向前加签,需要前置任务审批完成,才回到原审批人 - */ - BEFORE("before", "向前加签"), - /** - * 向后加签,需要后置任务全部审批完,才会通过原审批人节点 - */ - AFTER("after", "向后加签"); - - /** - * 类型 - */ - private final String type; - /** - * 名字 - */ - private final String name; - - public static String nameOfType(String type) { - for (BpmTaskSignTypeEnum value : values()) { - if (value.type.equals(type)) { - return value.name; - } - } - return null; - } - - public static BpmTaskSignTypeEnum of(String type) { - return ArrayUtil.firstMatch(value -> value.getType().equals(type), values()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskStatusEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskStatusEnum.java deleted file mode 100644 index 40a385a58..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmTaskStatusEnum.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 流程任务 Task 的状态枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -public enum BpmTaskStatusEnum { - - RUNNING(1, "审批中"), - APPROVE(2, "审批通过"), - REJECT(3, "审批不通过"), - CANCEL(4, "已取消"), - - RETURN(5, "已退回"), - DELEGATE(6, "委派中"), - - /** - * 使用场景: - * 1. 任务被向后【加签】时,它在审批通过后,会变成 APPROVING 这个状态,然后等到【加签】出来的任务都被审批后,才会变成 APPROVE 审批通过 - */ - APPROVING(7, "审批通过中"), - /** - * 使用场景: - * 1. 任务被向前【加签】时,它会变成 WAIT 状态,需要等待【加签】出来的任务被审批后,它才能继续变为 RUNNING 继续审批 - * 2. 任务被向后【加签】时,【加签】出来的任务处于 WAIT 状态,它们需要等待该任务被审批后,它们才能继续变为 RUNNING 继续审批 - */ - WAIT(0, "待审批"); - - /** - * 状态 - *

- * 如果新增时,注意 {@link #isEndStatus(Integer)} 是否需要变更 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - /** - * 判断该状态是否已经处于 End 最终状态 - *

- * 主要用于一些状态更新的逻辑,如果已经是最终状态,就不再进行更新 - * - * @param status 状态 - * @return 是否 - */ - public static boolean isEndStatus(Integer status) { - return ObjectUtils.equalsAny(status, - APPROVE.getStatus(), REJECT.getStatus(), CANCEL.getStatus(), - RETURN.getStatus(), APPROVING.getStatus()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/event/BpmProcessInstanceStatusEvent.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/event/BpmProcessInstanceStatusEvent.java deleted file mode 100644 index 474a8657d..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/event/BpmProcessInstanceStatusEvent.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.bpm.event; - -import lombok.Data; -import org.springframework.context.ApplicationEvent; - -import javax.validation.constraints.NotNull; - -/** - * 流程实例的状态(结果)发生变化的 Event - * - * @author 芋道源码 - */ -@SuppressWarnings("ALL") -@Data -public class BpmProcessInstanceStatusEvent extends ApplicationEvent { - - /** - * 流程实例的编号 - */ - @NotNull(message = "流程实例的编号不能为空") - private String id; - /** - * 流程实例的 key - */ - @NotNull(message = "流程实例的 key 不能为空") - private String processDefinitionKey; - /** - * 流程实例的结果 - */ - @NotNull(message = "流程实例的状态不能为空") - private Integer status; - /** - * 流程实例对应的业务标识 - * 例如说,请假 - */ - private String businessKey; - - public BpmProcessInstanceStatusEvent(Object source) { - super(source); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/event/BpmProcessInstanceStatusEventListener.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/event/BpmProcessInstanceStatusEventListener.java deleted file mode 100644 index f8b1863c6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/event/BpmProcessInstanceStatusEventListener.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.bpm.event; - -import cn.hutool.core.util.StrUtil; -import org.springframework.context.ApplicationListener; - -/** - * {@link BpmProcessInstanceStatusEvent} 的监听器 - * - * @author 芋道源码 - */ -public abstract class BpmProcessInstanceStatusEventListener - implements ApplicationListener { - - @Override - public final void onApplicationEvent(BpmProcessInstanceStatusEvent event) { - if (!StrUtil.equals(event.getProcessDefinitionKey(), getProcessDefinitionKey())) { - return; - } - onEvent(event); - } - - /** - * @return 返回监听的流程定义 Key - */ - protected abstract String getProcessDefinitionKey(); - - /** - * 处理事件 - * - * @param event 事件 - */ - protected abstract void onEvent(BpmProcessInstanceStatusEvent event); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/Dockerfile b/yudao-module-bpm/yudao-module-bpm-biz/Dockerfile deleted file mode 100644 index 4febef856..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-bpm-biz -WORKDIR /yudao-module-bpm-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-bpm-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48083 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-bpm/yudao-module-bpm-biz/pom.xml b/yudao-module-bpm/yudao-module-bpm-biz/pom.xml deleted file mode 100644 index 9a54ae6a5..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/pom.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-bpm - ${revision} - - 4.0.0 - yudao-module-bpm-biz - - ${project.artifactId} - - bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能,基于 Flowable 6 版本实现。 - 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等 - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-module-bpm-api - ${revision} - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-data-permission - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - - - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - org.flowable - flowable-spring-boot-starter-process - - - org.flowable - flowable-spring-boot-starter-actuator - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/BpmServerApplication.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/BpmServerApplication.java deleted file mode 100644 index d86a045a2..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/BpmServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class BpmServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(BpmServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java deleted file mode 100644 index 2137e2203..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * bpm API 实现类,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.bpm.api; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java deleted file mode 100644 index 01bf397fd..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.api.task; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * Flowable 流程实例 Api 实现类 - * - * @author 芋道源码 - * @author jason - */ -@RestController -@Validated -public class BpmProcessInstanceApiImpl implements BpmProcessInstanceApi { - - @Resource - private BpmProcessInstanceService processInstanceService; - - @Override - public CommonResult createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO reqDTO) { - return success(processInstanceService.createProcessInstance(userId, reqDTO)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmCategoryController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmCategoryController.java deleted file mode 100644 index a78790554..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmCategoryController.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategorySaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - BPM 流程分类") -@RestController -@RequestMapping("/bpm/category") -@Validated -public class BpmCategoryController { - - @Resource - private BpmCategoryService categoryService; - - @PostMapping("/create") - @Operation(summary = "创建流程分类") - @PreAuthorize("@ss.hasPermission('bpm:category:create')") - public CommonResult createCategory(@Valid @RequestBody BpmCategorySaveReqVO createReqVO) { - return success(categoryService.createCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新流程分类") - @PreAuthorize("@ss.hasPermission('bpm:category:update')") - public CommonResult updateCategory(@Valid @RequestBody BpmCategorySaveReqVO updateReqVO) { - categoryService.updateCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除流程分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:category:delete')") - public CommonResult deleteCategory(@RequestParam("id") Long id) { - categoryService.deleteCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得流程分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:category:query')") - public CommonResult getCategory(@RequestParam("id") Long id) { - BpmCategoryDO category = categoryService.getCategory(id); - return success(BeanUtils.toBean(category, BpmCategoryRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得流程分类分页") - @PreAuthorize("@ss.hasPermission('bpm:category:query')") - public CommonResult> getCategoryPage(@Valid BpmCategoryPageReqVO pageReqVO) { - PageResult pageResult = categoryService.getCategoryPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, BpmCategoryRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获取流程分类的精简信息列表", description = "只包含被开启的分类,主要用于前端的下拉选项") - public CommonResult> getCategorySimpleList() { - List list = categoryService.getCategoryListByStatus(CommonStatusEnum.ENABLE.getStatus()); - list.sort(Comparator.comparingInt(BpmCategoryDO::getSort)); - return success(convertList(list, category -> new BpmCategoryRespVO().setId(category.getId()) - .setName(category.getName()).setCode(category.getCode()))); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java deleted file mode 100644 index 4ec377610..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - 动态表单") -@RestController -@RequestMapping("/bpm/form") -@Validated -public class BpmFormController { - - @Resource - private BpmFormService formService; - - @PostMapping("/create") - @Operation(summary = "创建动态表单") - @PreAuthorize("@ss.hasPermission('bpm:form:create')") - public CommonResult createForm(@Valid @RequestBody BpmFormSaveReqVO createReqVO) { - return success(formService.createForm(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新动态表单") - @PreAuthorize("@ss.hasPermission('bpm:form:update')") - public CommonResult updateForm(@Valid @RequestBody BpmFormSaveReqVO updateReqVO) { - formService.updateForm(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除动态表单") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:form:delete')") - public CommonResult deleteForm(@RequestParam("id") Long id) { - formService.deleteForm(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得动态表单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:form:query')") - public CommonResult getForm(@RequestParam("id") Long id) { - BpmFormDO form = formService.getForm(id); - return success(BeanUtils.toBean(form, BpmFormRespVO.class)); - } - - @GetMapping({"/list-all-simple", "/simple-list"}) - @Operation(summary = "获得动态表单的精简列表", description = "用于表单下拉框") - public CommonResult> getFormSimpleList() { - List list = formService.getFormList(); - return success(convertList(list, formDO -> // 只返回 id、name 字段 - new BpmFormRespVO().setId(formDO.getId()).setName(formDO.getName()))); - } - - @GetMapping("/page") - @Operation(summary = "获得动态表单分页") - @PreAuthorize("@ss.hasPermission('bpm:form:query')") - public CommonResult> getFormPage(@Valid BpmFormPageReqVO pageVO) { - PageResult pageResult = formService.getFormPage(pageVO); - return success(BeanUtils.toBean(pageResult, BpmFormRespVO.class)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java deleted file mode 100644 index 409545023..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java +++ /dev/null @@ -1,148 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.io.IoUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.Model; -import org.flowable.engine.repository.ProcessDefinition; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.io.IOException; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 流程模型") -@RestController -@RequestMapping("/bpm/model") -@Validated -public class BpmModelController { - - @Resource - private BpmModelService modelService; - @Resource - private BpmFormService formService; - @Resource - private BpmCategoryService categoryService; - @Resource - private BpmProcessDefinitionService processDefinitionService; - - @GetMapping("/page") - @Operation(summary = "获得模型分页") - public CommonResult> getModelPage(BpmModelPageReqVO pageVO) { - PageResult pageResult = modelService.getModelPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - // 获得 Form 表单 - Set formIds = convertSet(pageResult.getList(), model -> { - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); - return metaInfo != null ? metaInfo.getFormId() : null; - }); - Map formMap = formService.getFormMap(formIds); - // 获得 Category Map - Map categoryMap = categoryService.getCategoryMap( - convertSet(pageResult.getList(), Model::getCategory)); - // 获得 Deployment Map - Set deploymentIds = new HashSet<>(); - pageResult.getList().forEach(model -> CollectionUtils.addIfNotNull(deploymentIds, model.getDeploymentId())); - Map deploymentMap = processDefinitionService.getDeploymentMap(deploymentIds); - // 获得 ProcessDefinition Map - List processDefinitions = processDefinitionService.getProcessDefinitionListByDeploymentIds(deploymentIds); - Map processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId); - return success(BpmModelConvert.INSTANCE.buildModelPage(pageResult, formMap, categoryMap, deploymentMap, processDefinitionMap)); - } - - @GetMapping("/get") - @Operation(summary = "获得模型") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:model:query')") - public CommonResult getModel(@RequestParam("id") String id) { - Model model = modelService.getModel(id); - if (model == null) { - return null; - } - byte[] bpmnBytes = modelService.getModelBpmnXML(id); - return success(BpmModelConvert.INSTANCE.buildModel(model, bpmnBytes)); - } - - @PostMapping("/create") - @Operation(summary = "新建模型") - @PreAuthorize("@ss.hasPermission('bpm:model:create')") - public CommonResult createModel(@Valid @RequestBody BpmModelCreateReqVO createRetVO) { - return success(modelService.createModel(createRetVO, null)); - } - - @PutMapping("/update") - @Operation(summary = "修改模型") - @PreAuthorize("@ss.hasPermission('bpm:model:update')") - public CommonResult updateModel(@Valid @RequestBody BpmModelUpdateReqVO modelVO) { - modelService.updateModel(modelVO); - return success(true); - } - - @PostMapping("/import") - @Operation(summary = "导入模型") - @PreAuthorize("@ss.hasPermission('bpm:model:import')") - public CommonResult importModel(@Valid BpmModeImportReqVO importReqVO) throws IOException { - BpmModelCreateReqVO createReqVO = BeanUtils.toBean(importReqVO, BpmModelCreateReqVO.class); - // 读取文件 - String bpmnXml = IoUtils.readUtf8(importReqVO.getBpmnFile().getInputStream(), false); - return success(modelService.createModel(createReqVO, bpmnXml)); - } - - @PostMapping("/deploy") - @Operation(summary = "部署模型") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:model:deploy')") - public CommonResult deployModel(@RequestParam("id") String id) { - modelService.deployModel(id); - return success(true); - } - - @PutMapping("/update-state") - @Operation(summary = "修改模型的状态", description = "实际更新的部署的流程定义的状态") - @PreAuthorize("@ss.hasPermission('bpm:model:update')") - public CommonResult updateModelState(@Valid @RequestBody BpmModelUpdateStateReqVO reqVO) { - modelService.updateModelState(reqVO.getId(), reqVO.getState()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除模型") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:model:delete')") - public CommonResult deleteModel(@RequestParam("id") String id) { - modelService.deleteModel(id); - return success(true); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java deleted file mode 100644 index ee23c63e8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java +++ /dev/null @@ -1,114 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmProcessDefinitionConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.BpmTaskCandidateStartUserSelectStrategy; -import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.ProcessDefinition; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 流程定义") -@RestController -@RequestMapping("/bpm/process-definition") -@Validated -public class BpmProcessDefinitionController { - - @Resource - private BpmProcessDefinitionService processDefinitionService; - @Resource - private BpmFormService formService; - @Resource - private BpmCategoryService categoryService; - - @GetMapping("/page") - @Operation(summary = "获得流程定义分页") - @PreAuthorize("@ss.hasPermission('bpm:process-definition:query')") - public CommonResult> getProcessDefinitionPage( - BpmProcessDefinitionPageReqVO pageReqVO) { - PageResult pageResult = processDefinitionService.getProcessDefinitionPage(pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 获得 Category Map - Map categoryMap = categoryService.getCategoryMap( - convertSet(pageResult.getList(), ProcessDefinition::getCategory)); - // 获得 Deployment Map - Map deploymentMap = processDefinitionService.getDeploymentMap( - convertSet(pageResult.getList(), ProcessDefinition::getDeploymentId)); - // 获得 BpmProcessDefinitionInfoDO Map - Map processDefinitionMap = processDefinitionService.getProcessDefinitionInfoMap( - convertSet(pageResult.getList(), ProcessDefinition::getId)); - // 获得 Form Map - Map formMap = formService.getFormMap( - convertSet(processDefinitionMap.values(), BpmProcessDefinitionInfoDO::getFormId)); - return success(BpmProcessDefinitionConvert.INSTANCE.buildProcessDefinitionPage( - pageResult, deploymentMap, processDefinitionMap, formMap, categoryMap)); - } - - @GetMapping ("/list") - @Operation(summary = "获得流程定义列表") - @Parameter(name = "suspensionState", description = "挂起状态", required = true, example = "1") // 参见 Flowable SuspensionState 枚举 - @PreAuthorize("@ss.hasPermission('bpm:process-definition:query')") - public CommonResult> getProcessDefinitionList( - @RequestParam("suspensionState") Integer suspensionState) { - List list = processDefinitionService.getProcessDefinitionListBySuspensionState(suspensionState); - if (CollUtil.isEmpty(list)) { - return success(Collections.emptyList()); - } - - // 获得 BpmProcessDefinitionInfoDO Map - Map processDefinitionMap = processDefinitionService.getProcessDefinitionInfoMap( - convertSet(list, ProcessDefinition::getId)); - return success(BpmProcessDefinitionConvert.INSTANCE.buildProcessDefinitionList( - list, null, processDefinitionMap, null, null)); - } - - @GetMapping ("/get") - @Operation(summary = "获得流程定义") - @Parameter(name = "id", description = "流程编号", required = true, example = "1024") - @Parameter(name = "key", description = "流程定义标识", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:process-definition:query')") - public CommonResult getProcessDefinition( - @RequestParam(value = "id", required = false) String id, - @RequestParam(value = "key", required = false) String key) { - ProcessDefinition processDefinition = id != null ? processDefinitionService.getProcessDefinition(id) - : processDefinitionService.getActiveProcessDefinition(key); - if (processDefinition == null) { - return success(null); - } - BpmnModel bpmnModel = processDefinitionService.getProcessDefinitionBpmnModel(processDefinition.getId()); - List userTaskList = BpmTaskCandidateStartUserSelectStrategy.getStartUserSelectUserTaskList(bpmnModel); - return success(BpmProcessDefinitionConvert.INSTANCE.buildProcessDefinition( - processDefinition, null, null, null, null, bpmnModel, userTaskList)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessExpressionController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessExpressionController.java deleted file mode 100644 index a6e11a03c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessExpressionController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessExpressionDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessExpressionService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - BPM 流程表达式") -@RestController -@RequestMapping("/bpm/process-expression") -@Validated -public class BpmProcessExpressionController { - - @Resource - private BpmProcessExpressionService processExpressionService; - - @PostMapping("/create") - @Operation(summary = "创建流程表达式") - @PreAuthorize("@ss.hasPermission('bpm:process-expression:create')") - public CommonResult createProcessExpression(@Valid @RequestBody BpmProcessExpressionSaveReqVO createReqVO) { - return success(processExpressionService.createProcessExpression(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新流程表达式") - @PreAuthorize("@ss.hasPermission('bpm:process-expression:update')") - public CommonResult updateProcessExpression(@Valid @RequestBody BpmProcessExpressionSaveReqVO updateReqVO) { - processExpressionService.updateProcessExpression(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除流程表达式") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:process-expression:delete')") - public CommonResult deleteProcessExpression(@RequestParam("id") Long id) { - processExpressionService.deleteProcessExpression(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得流程表达式") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:process-expression:query')") - public CommonResult getProcessExpression(@RequestParam("id") Long id) { - BpmProcessExpressionDO processExpression = processExpressionService.getProcessExpression(id); - return success(BeanUtils.toBean(processExpression, BpmProcessExpressionRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得流程表达式分页") - @PreAuthorize("@ss.hasPermission('bpm:process-expression:query')") - public CommonResult> getProcessExpressionPage( - @Valid BpmProcessExpressionPageReqVO pageReqVO) { - PageResult pageResult = processExpressionService.getProcessExpressionPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, BpmProcessExpressionRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessListenerController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessListenerController.java deleted file mode 100644 index c6cc391c3..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessListenerController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessListenerDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessListenerService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - BPM 流程监听器") -@RestController -@RequestMapping("/bpm/process-listener") -@Validated -public class BpmProcessListenerController { - - @Resource - private BpmProcessListenerService processListenerService; - - @PostMapping("/create") - @Operation(summary = "创建流程监听器") - @PreAuthorize("@ss.hasPermission('bpm:process-listener:create')") - public CommonResult createProcessListener(@Valid @RequestBody BpmProcessListenerSaveReqVO createReqVO) { - return success(processListenerService.createProcessListener(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新流程监听器") - @PreAuthorize("@ss.hasPermission('bpm:process-listener:update')") - public CommonResult updateProcessListener(@Valid @RequestBody BpmProcessListenerSaveReqVO updateReqVO) { - processListenerService.updateProcessListener(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除流程监听器") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:process-listener:delete')") - public CommonResult deleteProcessListener(@RequestParam("id") Long id) { - processListenerService.deleteProcessListener(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得流程监听器") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:process-listener:query')") - public CommonResult getProcessListener(@RequestParam("id") Long id) { - BpmProcessListenerDO processListener = processListenerService.getProcessListener(id); - return success(BeanUtils.toBean(processListener, BpmProcessListenerRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得流程监听器分页") - @PreAuthorize("@ss.hasPermission('bpm:process-listener:query')") - public CommonResult> getProcessListenerPage( - @Valid BpmProcessListenerPageReqVO pageReqVO) { - PageResult pageResult = processListenerService.getProcessListenerPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, BpmProcessListenerRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java deleted file mode 100644 index fca7d5b0f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - 用户组") -@RestController -@RequestMapping("/bpm/user-group") -@Validated -public class BpmUserGroupController { - - @Resource - private BpmUserGroupService userGroupService; - - @PostMapping("/create") - @Operation(summary = "创建用户组") - @PreAuthorize("@ss.hasPermission('bpm:user-group:create')") - public CommonResult createUserGroup(@Valid @RequestBody BpmUserGroupSaveReqVO createReqVO) { - return success(userGroupService.createUserGroup(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新用户组") - @PreAuthorize("@ss.hasPermission('bpm:user-group:update')") - public CommonResult updateUserGroup(@Valid @RequestBody BpmUserGroupSaveReqVO updateReqVO) { - userGroupService.updateUserGroup(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除用户组") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:user-group:delete')") - public CommonResult deleteUserGroup(@RequestParam("id") Long id) { - userGroupService.deleteUserGroup(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得用户组") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('bpm:user-group:query')") - public CommonResult getUserGroup(@RequestParam("id") Long id) { - BpmUserGroupDO userGroup = userGroupService.getUserGroup(id); - return success(BeanUtils.toBean(userGroup, BpmUserGroupRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得用户组分页") - @PreAuthorize("@ss.hasPermission('bpm:user-group:query')") - public CommonResult> getUserGroupPage(@Valid BpmUserGroupPageReqVO pageVO) { - PageResult pageResult = userGroupService.getUserGroupPage(pageVO); - return success(BeanUtils.toBean(pageResult, BpmUserGroupRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获取用户组精简信息列表", description = "只包含被开启的用户组,主要用于前端的下拉选项") - public CommonResult> getUserGroupSimpleList() { - List list = userGroupService.getUserGroupListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, group -> new BpmUserGroupRespVO().setId(group.getId()).setName(group.getName()))); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategoryPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategoryPageReqVO.java deleted file mode 100644 index dba816c87..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategoryPageReqVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - BPM 流程分类分页 Request VO") -@Data -public class BpmCategoryPageReqVO extends PageParam { - - @Schema(description = "分类名", example = "王五") - private String name; - - @Schema(description = "分类标志", example = "OA") - private String code; - - @Schema(description = "分类状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategoryRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategoryRespVO.java deleted file mode 100644 index 7ada55a1d..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategoryRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - BPM 流程分类 Response VO") -@Data -public class BpmCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167") - private Long id; - - @Schema(description = "分类名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - @Schema(description = "分类标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "OA") - private String code; - - @Schema(description = "分类描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String description; - - @Schema(description = "分类状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED) - private Integer sort; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategorySaveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategorySaveReqVO.java deleted file mode 100644 index d4865e7f6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/category/BpmCategorySaveReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - BPM 流程分类新增/修改 Request VO") -@Data -public class BpmCategorySaveReqVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167") - private Long id; - - @Schema(description = "分类名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotEmpty(message = "分类名不能为空") - private String name; - - @Schema(description = "分类描述", example = "你猜") - private String description; - - @Schema(description = "分类标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "OA") - @NotEmpty(message = "分类标志不能为空") - private String code; - - @Schema(description = "分类状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "分类状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "分类排序不能为空") - private Integer sort; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionPageReqVO.java deleted file mode 100644 index 37b02f0d9..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionPageReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - BPM 流程表达式分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmProcessExpressionPageReqVO extends PageParam { - - @Schema(description = "表达式名字", example = "李四") - private String name; - - @Schema(description = "表达式状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionRespVO.java deleted file mode 100644 index d877f60a8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression; - -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - BPM 流程表达式 Response VO") -@Data -public class BpmProcessExpressionRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3870") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "表达式名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("表达式名字") - private String name; - - @Schema(description = "表达式状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "表达式", requiredMode = Schema.RequiredMode.REQUIRED) - private String expression; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionSaveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionSaveReqVO.java deleted file mode 100644 index 2755bf80e..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/expression/BpmProcessExpressionSaveReqVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - BPM 流程表达式新增/修改 Request VO") -@Data -public class BpmProcessExpressionSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3870") - private Long id; - - @Schema(description = "表达式名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotEmpty(message = "表达式名字不能为空") - private String name; - - @Schema(description = "表达式状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "表达式状态不能为空") - private Integer status; - - @Schema(description = "表达式", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "表达式不能为空") - private String expression; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java deleted file mode 100644 index a5f508f61..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 动态表单分页 Request VO") -@Data -public class BpmFormPageReqVO extends PageParam { - - @Schema(description = "表单名称", example = "芋道") - private String name; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java deleted file mode 100644 index 832d4d40f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 动态表单 Response VO") -@Data -public class BpmFormRespVO { - - @Schema(description = "表单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "表单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotNull(message = "表单名称不能为空") - private String name; - - @Schema(description = "表单的配置-JSON 字符串", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单的配置不能为空") - private String conf; - - @Schema(description = "表单项的数组-JSON 字符串的数组", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单项的数组不能为空") - private List fields; - - @Schema(description = "表单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "表单状态不能为空") - private Integer status; // 参见 CommonStatusEnum 枚举 - - @Schema(description = "备注", example = "我是备注") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSaveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSaveReqVO.java deleted file mode 100644 index c89085970..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSaveReqVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 动态表单创建/更新 Request VO") -@Data -public class BpmFormSaveReqVO { - - @Schema(description = "表单编号", example = "1024") - private Long id; - - @Schema(description = "表单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotNull(message = "表单名称不能为空") - private String name; - - @Schema(description = "表单的配置-JSON 字符串", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单的配置不能为空") - private String conf; - - @Schema(description = "表单项的数组-JSON 字符串的数组", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "表单项的数组不能为空") - private List fields; - - @Schema(description = "表单状态-参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "表单状态不能为空") - private Integer status; - - @Schema(description = "备注", example = "我是备注") - private String remark; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java deleted file mode 100644 index c3a0a860f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 用户组分页 Request VO") -@Data -public class BpmUserGroupPageReqVO extends PageParam { - - @Schema(description = "编号", example = "1024") - private Long id; - - @Schema(description = "组名", example = "芋道") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - - @DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java deleted file mode 100644 index f20722a8d..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Set; - -@Schema(description = "管理后台 - 用户组 Response VO") -@Data -public class BpmUserGroupRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "组名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String description; - - @Schema(description = "成员编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3") - private Set userIds; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSaveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSaveReqVO.java deleted file mode 100644 index 470eb0e53..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSaveReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.Set; - -@Schema(description = "管理后台 - 用户组创建/修改 Request VO") -@Data -public class BpmUserGroupSaveReqVO { - - @Schema(description = "编号", example = "1024") - private Long id; - - @Schema(description = "组名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotNull(message = "组名不能为空") - private String name; - - @Schema(description = "描述", example = "芋道源码") - private String description; - - @Schema(description = "成员编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3") - @NotNull(message = "成员编号数组不能为空") - private Set userIds; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerPageReqVO.java deleted file mode 100644 index d3b974672..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - BPM 流程监听器分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmProcessListenerPageReqVO extends PageParam { - - @Schema(description = "监听器名字", example = "赵六") - private String name; - - @Schema(description = "监听器类型", example = "execution") - private String type; - - @Schema(description = "监听事件", example = "start") - private String event; - - @Schema(description = "状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerRespVO.java deleted file mode 100644 index f7a484254..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerRespVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - BPM 流程监听器 Response VO") -@Data -public class BpmProcessListenerRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13089") - private Long id; - - @Schema(description = "监听器名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private String name; - - @Schema(description = "监听器类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "execution") - private String type; - - @Schema(description = "监听器状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "监听事件", requiredMode = Schema.RequiredMode.REQUIRED, example = "start") - private String event; - - @Schema(description = "监听器值类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "class") - private String valueType; - - @Schema(description = "监听器值", requiredMode = Schema.RequiredMode.REQUIRED) - private String value; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerSaveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerSaveReqVO.java deleted file mode 100644 index ef022b86c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/listener/BpmProcessListenerSaveReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - BPM 流程监听器新增/修改 Request VO") -@Data -public class BpmProcessListenerSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13089") - private Long id; - - @Schema(description = "监听器名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - @NotEmpty(message = "监听器名字不能为空") - private String name; - - @Schema(description = "监听器类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "execution") - @NotEmpty(message = "监听器类型不能为空") - private String type; - - @Schema(description = "监听器状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "监听器状态不能为空") - private Integer status; - - @Schema(description = "监听事件", requiredMode = Schema.RequiredMode.REQUIRED, example = "start") - @NotEmpty(message = "监听事件不能为空") - private String event; - - @Schema(description = "监听器值类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "class") - @NotEmpty(message = "监听器值类型不能为空") - private String valueType; - - @Schema(description = "监听器值", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "监听器值不能为空") - private String value; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java deleted file mode 100644 index 91d7d7d00..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 流程模型的导入 Request VO 相比流程模型的新建来说,只是多了一个 bpmnFile 文件") -@Data -public class BpmModeImportReqVO extends BpmModelCreateReqVO { - - @Schema(description = "BPMN 文件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "BPMN 文件不能为空") - private MultipartFile bpmnFile; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java deleted file mode 100644 index 9ff845579..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 流程模型的创建 Request VO") -@Data -public class BpmModelCreateReqVO { - - @Schema(description = "流程标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "process_yudao") - @NotEmpty(message = "流程标识不能为空") - private String key; - - @Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotEmpty(message = "流程名称不能为空") - private String name; - - @Schema(description = "流程描述", example = "我是描述") - private String description; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java deleted file mode 100644 index d2767c17f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - - -@Schema(description = "管理后台 - 流程模型分页 Request VO") -@Data -public class BpmModelPageReqVO extends PageParam { - - @Schema(description = "标识,精准匹配", example = "process1641042089407") - private String key; - - @Schema(description = "名字,模糊匹配", example = "芋道") - private String name; - - @Schema(description = "流程分类", example = "1") - private String category; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java deleted file mode 100644 index aad2015c7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程模型 Response VO") -@Data -public class BpmModelRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "流程标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "process_yudao") - private String key; - - @Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "流程图标", example = "https://www.iocoder.cn/yudao.jpg") - private String icon; - - @Schema(description = "流程描述", example = "我是描述") - private String description; - - @Schema(description = "流程分类编码", example = "1") - private String category; - @Schema(description = "流程分类名字", example = "请假") - private String categoryName; - - @Schema(description = "表单类型-参见 bpm_model_form_type 数据字典", example = "1") - private Integer formType; - - @Schema(description = "表单编号", example = "1024") - private Long formId; // 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空 - @Schema(description = "表单名字", example = "请假表单") - private String formName; - - @Schema(description = "自定义表单的提交路径", example = "/bpm/oa/leave/create") - private String formCustomCreatePath; // 使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空 - @Schema(description = "自定义表单的查看路径", example = "/bpm/oa/leave/view") - private String formCustomViewPath; // ,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空 - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "BPMN XML", requiredMode = Schema.RequiredMode.REQUIRED) - private String bpmnXml; - - /** - * 最新部署的流程定义 - */ - private BpmProcessDefinitionRespVO processDefinition; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java deleted file mode 100644 index 231ead168..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.URL; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 流程模型的更新 Request VO") -@Data -public class BpmModelUpdateReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "编号不能为空") - private String id; - - @Schema(description = "流程名称", example = "芋道") - private String name; - - @Schema(description = "流程图标", example = "https://www.iocoder.cn/yudao.jpg") - @URL(message = "流程图标格式不正确") - private String icon; - - @Schema(description = "流程描述", example = "我是描述") - private String description; - - @Schema(description = "流程分类", example = "1") - private String category; - - @Schema(description = "BPMN XML", requiredMode = Schema.RequiredMode.REQUIRED) - private String bpmnXml; - - @Schema(description = "表单类型-参见 bpm_model_form_type 数据字典", example = "1") - @InEnum(BpmModelFormTypeEnum.class) - private Integer formType; - @Schema(description = "表单编号-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", example = "1024") - private Long formId; - @Schema(description = "自定义表单的提交路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/create") - private String formCustomCreatePath; - @Schema(description = "自定义表单的查看路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/view") - private String formCustomViewPath; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java deleted file mode 100644 index 6ef20c3c7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 流程模型更新状态 Request VO") -@Data -public class BpmModelUpdateStateReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private String id; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer state; // 参见 Flowable SuspensionState 枚举 - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java deleted file mode 100644 index 923c4a429..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 流程定义分页 Request VO") -@Data -public class BpmProcessDefinitionPageReqVO extends PageParam { - - @Schema(description = "标识-精准匹配", example = "process1641042089407") - private String key; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java deleted file mode 100644 index 2fb8dd4dc..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 流程定义 Response VO") -@Data -public class BpmProcessDefinitionRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "版本", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer version; - - @Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "流程标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao") - private String key; - - @Schema(description = "流程图标", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/yudao.jpg") - private String icon; - - @Schema(description = "流程描述", example = "我是描述") - private String description; - - @Schema(description = "流程分类", example = "1") - private String category; - @Schema(description = "流程分类名字", example = "请假") - private String categoryName; - - @Schema(description = "表单类型-参见 bpm_model_form_type 数据字典", example = "1") - private Integer formType; - @Schema(description = "表单编号-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", example = "1024") - private Long formId; - @Schema(description = "表单名字", example = "请假表单") - private String formName; - @Schema(description = "表单的配置-JSON 字符串。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", requiredMode = Schema.RequiredMode.REQUIRED) - private String formConf; - @Schema(description = "表单项的数组-JSON 字符串的数组。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", requiredMode = Schema.RequiredMode.REQUIRED) - private List formFields; - @Schema(description = "自定义表单的提交路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/create") - private String formCustomCreatePath; - @Schema(description = "自定义表单的查看路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", - example = "/bpm/oa/leave/view") - private String formCustomViewPath; - - @Schema(description = "中断状态-参见 SuspensionState 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer suspensionState; // 参见 SuspensionState 枚举 - - @Schema(description = "部署时间") - private LocalDateTime deploymentTime; // 需要从对应的 Deployment 读取,非必须返回 - - @Schema(description = "BPMN XML") - private String bpmnXml; // 需要从对应的 BpmnModel 读取,非必须返回 - - @Schema(description = "发起用户需要选择审批人的任务数组") - private List startUserSelectTasks; // 需要从对应的 BpmnModel 读取,非必须返回 - - @Schema(description = "BPMN UserTask 用户任务") - @Data - public static class UserTask { - - @Schema(description = "任务标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "sudo") - private String id; - - @Schema(description = "任务名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http deleted file mode 100644 index 96bbf964d..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http +++ /dev/null @@ -1,12 +0,0 @@ -### 请求 /bpm/oa/leave/create 接口 => 成功 -POST {{baseUrl}}/bpm/oa/leave/create -Content-Type: application/json -tenant-id: 1 -Authorization: Bearer {{token}} - -{ - "startTime": "2022-03-01", - "endTime": "2022-03-05", - "type": 1, - "reason": "我要请假啦啦啦!" -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java deleted file mode 100644 index 47a72800e..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.oa; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; -import cn.iocoder.yudao.module.bpm.service.oa.BpmOALeaveService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -/** - * OA 请假申请 Controller,用于演示自己存储数据,接入工作流的例子 - * - * @author jason - * @author 芋道源码 - */ -@Tag(name = "管理后台 - OA 请假申请") -@RestController -@RequestMapping("/bpm/oa/leave") -@Validated -public class BpmOALeaveController { - - @Resource - private BpmOALeaveService leaveService; - - @PostMapping("/create") - @PreAuthorize("@ss.hasPermission('bpm:oa-leave:create')") - @Operation(summary = "创建请求申请") - public CommonResult createLeave(@Valid @RequestBody BpmOALeaveCreateReqVO createReqVO) { - return success(leaveService.createLeave(getLoginUserId(), createReqVO)); - } - - @GetMapping("/get") - @PreAuthorize("@ss.hasPermission('bpm:oa-leave:query')") - @Operation(summary = "获得请假申请") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getLeave(@RequestParam("id") Long id) { - BpmOALeaveDO leave = leaveService.getLeave(id); - return success(BeanUtils.toBean(leave, BpmOALeaveRespVO.class)); - } - - @GetMapping("/page") - @PreAuthorize("@ss.hasPermission('bpm:oa-leave:query')") - @Operation(summary = "获得请假申请分页") - public CommonResult> getLeavePage(@Valid BpmOALeavePageReqVO pageVO) { - PageResult pageResult = leaveService.getLeavePage(getLoginUserId(), pageVO); - return success(BeanUtils.toBean(pageResult, BpmOALeaveRespVO.class)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java deleted file mode 100644 index 7028708b1..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * OA 示例,用于演示外部业务接入 BPM 工作流的示例 - * 一般的接入方式,只需要调用 接口,后续 Admin 用户在管理后台的【待办事务】进行审批 - */ -package cn.iocoder.yudao.module.bpm.controller.admin.oa; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java deleted file mode 100644 index f843059a1..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 请假申请创建 Request VO") -@Data -public class BpmOALeaveCreateReqVO { - - @Schema(description = "请假的开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "请假的结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "请假类型-参见 bpm_oa_type 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - @Schema(description = "原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "阅读芋道源码") - private String reason; - - @Schema(description = "发起人自选审批人 Map", example = "{taskKey1: [1, 2]}") - private Map> startUserSelectAssignees; - - @AssertTrue(message = "结束时间,需要在开始时间之后") - public boolean isEndTimeValid() { - return !getEndTime().isBefore(getStartTime()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java deleted file mode 100644 index f801e6908..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 请假申请分页 Request VO") -@Data -public class BpmOALeavePageReqVO extends PageParam { - - @Schema(description = "状态", example = "1") - private Integer status; // 参见 BpmProcessInstanceResultEnum 枚举 - - @Schema(description = "请假类型,参见 bpm_oa_type", example = "1") - private Integer type; - - @Schema(description = "原因,模糊匹配", example = "阅读芋道源码") - private String reason; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "申请时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java deleted file mode 100644 index dbfe9d90f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 请假申请 Response VO") -@Data -public class BpmOALeaveRespVO { - - @Schema(description = "请假表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "请假类型,参见 bpm_oa_type 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - @Schema(description = "原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "阅读芋道源码") - private String reason; - - @Schema(description = "申请时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "请假的开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "请假的结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "流程编号") - private String processInstanceId; - - @Schema(description = "审批结果", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; // 参见 BpmProcessInstanceStatusEnum 枚举 - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java deleted file mode 100644 index e74bc626f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import cn.iocoder.yudao.module.bpm.service.task.BpmActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 流程活动实例") -@RestController -@RequestMapping("/bpm/activity") -@Validated -public class BpmActivityController { - - @Resource - private BpmActivityService activityService; - - @GetMapping("/list") - @Operation(summary = "生成指定流程实例的高亮流程图", - description = "只高亮进行中的任务。不过要注意,该接口暂时没用,通过前端的 ProcessViewer.vue 界面的 highlightDiagram 方法生成") - @Parameter(name = "processInstanceId", description = "流程实例的编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getActivityList( - @RequestParam("processInstanceId") String processInstanceId) { - return success(activityService.getActivityListByProcessInstanceId(processInstanceId)); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java deleted file mode 100644 index 309c372e0..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java +++ /dev/null @@ -1,163 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCancelReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstancePageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceRespVO; -import cn.iocoder.yudao.module.bpm.convert.task.BpmProcessInstanceConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; -import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.repository.ProcessDefinition; -import org.flowable.task.api.Task; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 流程实例") // 流程实例,通过流程定义创建的一次“申请” -@RestController -@RequestMapping("/bpm/process-instance") -@Validated -public class BpmProcessInstanceController { - - @Resource - private BpmProcessInstanceService processInstanceService; - @Resource - private BpmTaskService taskService; - @Resource - private BpmProcessDefinitionService processDefinitionService; - @Resource - private BpmCategoryService categoryService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @GetMapping("/my-page") - @Operation(summary = "获得我的实例分页列表", description = "在【我的流程】菜单中,进行调用") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')") - public CommonResult> getProcessInstanceMyPage( - @Valid BpmProcessInstancePageReqVO pageReqVO) { - PageResult pageResult = processInstanceService.getProcessInstancePage( - getLoginUserId(), pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接返回 - Map> taskMap = taskService.getTaskMapByProcessInstanceIds( - convertList(pageResult.getList(), HistoricProcessInstance::getId)); - Map processDefinitionMap = processDefinitionService.getProcessDefinitionMap( - convertSet(pageResult.getList(), HistoricProcessInstance::getProcessDefinitionId)); - Map categoryMap = categoryService.getCategoryMap( - convertSet(processDefinitionMap.values(), ProcessDefinition::getCategory)); - return success(BpmProcessInstanceConvert.INSTANCE.buildProcessInstancePage(pageResult, - processDefinitionMap, categoryMap, taskMap, null, null)); - } - - @GetMapping("/manager-page") - @Operation(summary = "获得管理流程实例的分页列表", description = "在【流程实例】菜单中,进行调用") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:manager-query')") - public CommonResult> getProcessInstanceManagerPage( - @Valid BpmProcessInstancePageReqVO pageReqVO) { - PageResult pageResult = processInstanceService.getProcessInstancePage( - null, pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接返回 - Map> taskMap = taskService.getTaskMapByProcessInstanceIds( - convertList(pageResult.getList(), HistoricProcessInstance::getId)); - Map processDefinitionMap = processDefinitionService.getProcessDefinitionMap( - convertSet(pageResult.getList(), HistoricProcessInstance::getProcessDefinitionId)); - Map categoryMap = categoryService.getCategoryMap( - convertSet(processDefinitionMap.values(), ProcessDefinition::getCategory)); - // 发起人信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), processInstance -> NumberUtils.parseLong(processInstance.getStartUserId()))); - Map deptMap = deptApi.getDeptMap( - convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - return success(BpmProcessInstanceConvert.INSTANCE.buildProcessInstancePage(pageResult, - processDefinitionMap, categoryMap, taskMap, userMap, deptMap)); - } - - @PostMapping("/create") - @Operation(summary = "新建流程实例") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')") - public CommonResult createProcessInstance(@Valid @RequestBody BpmProcessInstanceCreateReqVO createReqVO) { - return success(processInstanceService.createProcessInstance(getLoginUserId(), createReqVO)); - } - - @GetMapping("/get") - @Operation(summary = "获得指定流程实例", description = "在【流程详细】界面中,进行调用") - @Parameter(name = "id", description = "流程实例的编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')") - public CommonResult getProcessInstance(@RequestParam("id") String id) { - HistoricProcessInstance processInstance = processInstanceService.getHistoricProcessInstance(id); - if (processInstance == null) { - return success(null); - } - - // 拼接返回 - ProcessDefinition processDefinition = processDefinitionService.getProcessDefinition( - processInstance.getProcessDefinitionId()); - BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionService.getProcessDefinitionInfo( - processInstance.getProcessDefinitionId()); - String bpmnXml = BpmnModelUtils.getBpmnXml( - processDefinitionService.getProcessDefinitionBpmnModel(processInstance.getProcessDefinitionId())); - AdminUserRespDTO startUser = adminUserApi.getUser(NumberUtils.parseLong(processInstance.getStartUserId())).getCheckedData(); - DeptRespDTO dept = null; - if (startUser != null) { - dept = deptApi.getDept(startUser.getDeptId()).getCheckedData(); - } - return success(BpmProcessInstanceConvert.INSTANCE.buildProcessInstance(processInstance, - processDefinition, processDefinitionInfo, bpmnXml, startUser, dept)); - } - - @DeleteMapping("/cancel-by-start-user") - @Operation(summary = "用户取消流程实例", description = "取消发起的流程") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:cancel')") - public CommonResult cancelProcessInstanceByStartUser( - @Valid @RequestBody BpmProcessInstanceCancelReqVO cancelReqVO) { - processInstanceService.cancelProcessInstanceByStartUser(getLoginUserId(), cancelReqVO); - return success(true); - } - - @DeleteMapping("/cancel-by-admin") - @Operation(summary = "管理员取消流程实例", description = "管理员撤回流程") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:cancel-by-admin')") - public CommonResult cancelProcessInstanceByManager( - @Valid @RequestBody BpmProcessInstanceCancelReqVO cancelReqVO) { - processInstanceService.cancelProcessInstanceByAdmin(getLoginUserId(), cancelReqVO); - return success(true); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceCopyController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceCopyController.java deleted file mode 100644 index cfd2f963d..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceCopyController.java +++ /dev/null @@ -1,79 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.cc.BpmProcessInstanceCopyRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceCopyService; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.flowable.engine.history.HistoricProcessInstance; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 流程实例抄送") -@RestController -@RequestMapping("/bpm/process-instance/copy") -@Validated -public class BpmProcessInstanceCopyController { - - @Resource - private BpmProcessInstanceCopyService processInstanceCopyService; - @Resource - private BpmProcessInstanceService processInstanceService; - @Resource - private BpmTaskService taskService; - - @Resource - private AdminUserApi adminUserApi; - - @GetMapping("/page") - @Operation(summary = "获得抄送流程分页列表") - @PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:query')") - public CommonResult> getProcessInstanceCopyPage( - @Valid BpmProcessInstanceCopyPageReqVO pageReqVO) { - PageResult pageResult = processInstanceCopyService.getProcessInstanceCopyPage( - getLoginUserId(), pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(new PageResult<>(pageResult.getTotal())); - } - - // 拼接返回 - Map taskNameMap = taskService.getTaskNameByTaskIds( - convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getTaskId)); - Map processInstanceMap = processInstanceService.getHistoricProcessInstanceMap( - convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getProcessInstanceId)); - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(pageResult.getList(), - copy -> Stream.of(copy.getStartUserId(), Long.parseLong(copy.getCreator())))); - return success(BeanUtils.toBean(pageResult, BpmProcessInstanceCopyRespVO.class, copyVO -> { - MapUtils.findAndThen(userMap, Long.valueOf(copyVO.getCreator()), user -> copyVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, copyVO.getStartUserId(), user -> copyVO.setStartUserName(user.getNickname())); - MapUtils.findAndThen(taskNameMap, copyVO.getTaskId(), copyVO::setTaskName); - MapUtils.findAndThen(processInstanceMap, copyVO.getProcessInstanceId(), - processInstance -> copyVO.setProcessInstanceStartTime(DateUtils.of(processInstance.getStartTime()))); - })); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java deleted file mode 100644 index d299fd6eb..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java +++ /dev/null @@ -1,224 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.Task; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 流程任务实例") -@RestController -@RequestMapping("/bpm/task") -@Validated -public class BpmTaskController { - - @Resource - private BpmTaskService taskService; - @Resource - private BpmProcessInstanceService processInstanceService; - @Resource - private BpmFormService formService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @GetMapping("todo-page") - @Operation(summary = "获取 Todo 待办任务分页") - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getTaskTodoPage(@Valid BpmTaskPageReqVO pageVO) { - PageResult pageResult = taskService.getTaskTodoPage(getLoginUserId(), pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 拼接数据 - Map processInstanceMap = processInstanceService.getProcessInstanceMap( - convertSet(pageResult.getList(), Task::getProcessInstanceId)); - Map userMap = adminUserApi.getUserMap( - convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); - return success(BpmTaskConvert.INSTANCE.buildTodoTaskPage(pageResult, processInstanceMap, userMap)); - } - - @GetMapping("done-page") - @Operation(summary = "获取 Done 已办任务分页") - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getTaskDonePage(@Valid BpmTaskPageReqVO pageVO) { - PageResult pageResult = taskService.getTaskDonePage(getLoginUserId(), pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 拼接数据 - Map processInstanceMap = processInstanceService.getHistoricProcessInstanceMap( - convertSet(pageResult.getList(), HistoricTaskInstance::getProcessInstanceId)); - Map userMap = adminUserApi.getUserMap( - convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); - return success(BpmTaskConvert.INSTANCE.buildTaskPage(pageResult, processInstanceMap, userMap, null)); - } - - @GetMapping("manager-page") - @Operation(summary = "获取全部任务的分页", description = "用于【流程任务】菜单") - @PreAuthorize("@ss.hasPermission('bpm:task:mananger-query')") - public CommonResult> getTaskManagerPage(@Valid BpmTaskPageReqVO pageVO) { - PageResult pageResult = taskService.getTaskPage(getLoginUserId(), pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 拼接数据 - Map processInstanceMap = processInstanceService.getHistoricProcessInstanceMap( - convertSet(pageResult.getList(), HistoricTaskInstance::getProcessInstanceId)); - // 获得 User 和 Dept Map - Set userIds = convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())); - userIds.addAll(convertSet(pageResult.getList(), task -> NumberUtils.parseLong(task.getAssignee()))); - Map userMap = adminUserApi.getUserMap(userIds); - Map deptMap = deptApi.getDeptMap( - convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - return success(BpmTaskConvert.INSTANCE.buildTaskPage(pageResult, processInstanceMap, userMap, deptMap)); - } - - @GetMapping("/list-by-process-instance-id") - @Operation(summary = "获得指定流程实例的任务列表", description = "包括完成的、未完成的") - @Parameter(name = "processInstanceId", description = "流程实例的编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getTaskListByProcessInstanceId( - @RequestParam("processInstanceId") String processInstanceId) { - List taskList = taskService.getTaskListByProcessInstanceId(processInstanceId); - if (CollUtil.isEmpty(taskList)) { - return success(Collections.emptyList()); - } - - // 拼接数据 - HistoricProcessInstance processInstance = processInstanceService.getHistoricProcessInstance(processInstanceId); - // 获得 User 和 Dept Map - Set userIds = convertSetByFlatMap(taskList, task -> - Stream.of(NumberUtils.parseLong(task.getAssignee()), NumberUtils.parseLong(task.getOwner()))); - userIds.add(NumberUtils.parseLong(processInstance.getStartUserId())); - Map userMap = adminUserApi.getUserMap(userIds); - Map deptMap = deptApi.getDeptMap( - convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 获得 Form Map - Map formMap = formService.getFormMap( - convertSet(taskList, task -> NumberUtils.parseLong(task.getFormKey()))); - return success(BpmTaskConvert.INSTANCE.buildTaskListByProcessInstanceId(taskList, processInstance, - formMap, userMap, deptMap)); - } - - @PutMapping("/approve") - @Operation(summary = "通过任务") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult approveTask(@Valid @RequestBody BpmTaskApproveReqVO reqVO) { - taskService.approveTask(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/reject") - @Operation(summary = "不通过任务") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult rejectTask(@Valid @RequestBody BpmTaskRejectReqVO reqVO) { - taskService.rejectTask(getLoginUserId(), reqVO); - return success(true); - } - - @GetMapping("/list-by-return") - @Operation(summary = "获取所有可回退的节点", description = "用于【流程详情】的【回退】按钮") - @Parameter(name = "taskId", description = "当前任务ID", required = true) - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult> getTaskListByReturn(@RequestParam("id") String id) { - List userTaskList = taskService.getUserTaskListByReturn(id); - return success(convertList(userTaskList, userTask -> // 只返回 id 和 name - new BpmTaskRespVO().setName(userTask.getName()).setTaskDefinitionKey(userTask.getId()))); - } - - @PutMapping("/return") - @Operation(summary = "回退任务", description = "用于【流程详情】的【回退】按钮") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult returnTask(@Valid @RequestBody BpmTaskReturnReqVO reqVO) { - taskService.returnTask(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/delegate") - @Operation(summary = "委派任务", description = "用于【流程详情】的【委派】按钮") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult delegateTask(@Valid @RequestBody BpmTaskDelegateReqVO reqVO) { - taskService.delegateTask(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/transfer") - @Operation(summary = "转派任务", description = "用于【流程详情】的【转派】按钮") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult transferTask(@Valid @RequestBody BpmTaskTransferReqVO reqVO) { - taskService.transferTask(getLoginUserId(), reqVO); - return success(true); - } - - @PutMapping("/create-sign") - @Operation(summary = "加签", description = "before 前加签,after 后加签") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult createSignTask(@Valid @RequestBody BpmTaskSignCreateReqVO reqVO) { - taskService.createSignTask(getLoginUserId(), reqVO); - return success(true); - } - - @DeleteMapping("/delete-sign") - @Operation(summary = "减签") - @PreAuthorize("@ss.hasPermission('bpm:task:update')") - public CommonResult deleteSignTask(@Valid @RequestBody BpmTaskSignDeleteReqVO reqVO) { - taskService.deleteSignTask(getLoginUserId(), reqVO); - return success(true); - } - - @GetMapping("/list-by-parent-task-id") - @Operation(summary = "获得指定父级任务的子任务列表") // 目前用于,减签的时候,获得子任务列表 - @Parameter(name = "parentTaskId", description = "父级任务编号", required = true) - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public CommonResult> getTaskListByParentTaskId(@RequestParam("parentTaskId") String parentTaskId) { - List taskList = taskService.getTaskListByParentTaskId(parentTaskId); - if (CollUtil.isEmpty(taskList)) { - return success(Collections.emptyList()); - } - // 拼接数据 - Map userMap = adminUserApi.getUserMap(convertSetByFlatMap(taskList, - user -> Stream.of(NumberUtils.parseLong(user.getAssignee()), NumberUtils.parseLong(user.getOwner())))); - Map deptMap = deptApi.getDeptMap( - convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - return success(BpmTaskConvert.INSTANCE.buildTaskListByParentTaskId(taskList, userMap, deptMap)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java deleted file mode 100644 index 8f959e093..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程活动的 Response VO") -@Data -public class BpmActivityRespVO { - - @Schema(description = "流程活动的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String key; - @Schema(description = "流程活动的类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "StartEvent") - private String type; - - @Schema(description = "流程活动的开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - @Schema(description = "流程活动的结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "关联的流程任务的编号", example = "2048") - private String taskId; // 关联的流程任务,只有 UserTask 等类型才有 - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/cc/BpmProcessInstanceCopyRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/cc/BpmProcessInstanceCopyRespVO.java deleted file mode 100644 index 4b397fc1c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/cc/BpmProcessInstanceCopyRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.cc; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程实例抄送的分页 Item Response VO") -@Data -public class BpmProcessInstanceCopyRespVO { - - @Schema(description = "抄送主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "发起人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Long startUserId; - @Schema(description = "发起人昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String startUserName; - - @Schema(description = "流程实例编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "A233") - private String processInstanceId; - @Schema(description = "流程实例的名称") - private String processInstanceName; - @Schema(description = "流程实例的发起时间") - private LocalDateTime processInstanceStartTime; - - @Schema(description = "发起抄送的任务编号") - private String taskId; - @Schema(description = "发起抄送的任务名称") - private String taskName; - - @Schema(description = "抄送人") - private String creator; - @Schema(description = "抄送人昵称") - private String creatorName; - - @Schema(description = "抄送时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java deleted file mode 100644 index 496c72c61..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 流程实例的取消 Request VO") -@Data -public class BpmProcessInstanceCancelReqVO { - - @Schema(description = "流程实例的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "流程实例的编号不能为空") - private String id; - - @Schema(description = "取消原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "不请假了!") - @NotEmpty(message = "取消原因不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCopyPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCopyPageReqVO.java deleted file mode 100644 index b702afd2b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCopyPageReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 流程实例抄送的分页 Request VO") -@Data -public class BpmProcessInstanceCopyPageReqVO extends PageParam { - - @Schema(description = "流程名称", example = "芋道") - private String processInstanceName; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java deleted file mode 100644 index 207daeeff..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.List; -import java.util.Map; - -@Schema(description = "管理后台 - 流程实例的创建 Request VO") -@Data -public class BpmProcessInstanceCreateReqVO { - - @Schema(description = "流程定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "流程定义编号不能为空") - private String processDefinitionId; - - @Schema(description = "变量实例(动态表单)") - private Map variables; - - @Schema(description = "发起人自选审批人 Map", example = "{taskKey1: [1, 2]}") - private Map> startUserSelectAssignees; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageReqVO.java deleted file mode 100644 index bc658eb87..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 流程实例分页 Request VO") -@Data -public class BpmProcessInstancePageReqVO extends PageParam { - - @Schema(description = "流程名称", example = "芋道") - private String name; - - @Schema(description = "流程定义的编号", example = "2048") - private String processDefinitionId; - - @Schema(description = "流程实例的状态", example = "1") - @InEnum(BpmProcessInstanceStatusEnum.class) - private Integer status; - - @Schema(description = "流程分类", example = "1") - private String category; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "发起用户编号", example = "1024") - private Long startUserId; // 注意,只有在【流程实例】菜单,才使用该参数 - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java deleted file mode 100644 index ac6b90c7e..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance; - -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - -@Schema(description = "管理后台 - 流程实例的 Response VO") -@Data -public class BpmProcessInstanceRespVO { - - @Schema(description = "流程实例的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "流程分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String category; - @Schema(description = "流程分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "请假") - private String categoryName; - - @Schema(description = "流程实例的状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; // 参见 BpmProcessInstanceStatusEnum 枚举 - - @Schema(description = "发起时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "持续时间", example = "1000") - private Long durationInMillis; - - @Schema(description = "提交的表单值", requiredMode = Schema.RequiredMode.REQUIRED) - private Map formVariables; - - @Schema(description = "业务的唯一标识-例如说,请假申请的编号", example = "1") - private String businessKey; - - /** - * 发起流程的用户 - */ - private User startUser; - - @Schema(description = "流程定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private String processDefinitionId; - /** - * 流程定义 - */ - private BpmProcessDefinitionRespVO processDefinition; - - /** - * 当前审批中的任务 - */ - private List tasks; // 仅在流程实例分页才返回 - - @Schema(description = "用户信息") - @Data - public static class User { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String nickname; - - @Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long deptId; - @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "研发部") - private String deptName; - - } - - @Schema(description = "流程任务") - @Data - public static class Task { - - @Schema(description = "流程任务的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java deleted file mode 100644 index 5d35a0e81..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.Collection; -import java.util.Map; - -@Schema(description = "管理后台 - 通过流程任务的 Request VO") -@Data -public class BpmTaskApproveReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!") - @NotEmpty(message = "审批意见不能为空") - private String reason; - - @Schema(description = "抄送的用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2") - private Collection copyUserIds; - - @Schema(description = "变量实例(动态表单)", requiredMode = Schema.RequiredMode.REQUIRED) - private Map variables; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDelegateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDelegateReqVO.java deleted file mode 100644 index 96c42deb8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDelegateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 委派流程任务的 Request VO") -@Data -public class BpmTaskDelegateReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "被委派人 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "被委派人 ID 不能为空") - private Long delegateUserId; - - @Schema(description = "委派原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "做不了决定,需要你先帮忙瞅瞅") - @NotEmpty(message = "委派原因不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskPageReqVO.java deleted file mode 100644 index b03b265f1..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskPageReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 流程任务的的分页 Request VO") // 待办、已办,都使用该分页 -@Data -public class BpmTaskPageReqVO extends PageParam { - - @Schema(description = "流程任务名", example = "芋道") - private String name; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java deleted file mode 100644 index ebbc0fdaa..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 不通过流程任务的 Request VO") -@Data -public class BpmTaskRejectReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "不错不错!") - @NotEmpty(message = "审批意见不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java deleted file mode 100644 index 7f5177b94..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - -@Schema(description = "管理后台 - 流程任务 Response VO") -@Data -public class BpmTaskRespVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "任务名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "持续时间", example = "1000") - private Long durationInMillis; - - @Schema(description = "任务状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer status; // 参见 BpmTaskStatusEnum 枚举 - - @Schema(description = "审批理由", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private String reason; - - /** - * 负责人的用户信息 - */ - private BpmProcessInstanceRespVO.User ownerUser; - /** - * 审核的用户信息 - */ - private BpmProcessInstanceRespVO.User assigneeUser; - - @Schema(description = "任务定义的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "Activity_one") - private String taskDefinitionKey; - - @Schema(description = "所属流程实例编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8888") - private String processInstanceId; - /** - * 所属流程实例 - */ - private ProcessInstance processInstance; - - @Schema(description = "父任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String parentTaskId; - @Schema(description = "子任务列表(由加签生成)", requiredMode = Schema.RequiredMode.REQUIRED, example = "childrenTask") - private List children; - - @Schema(description = "表单编号", example = "1024") - private Long formId; - @Schema(description = "表单名字", example = "请假表单") - private String formName; - @Schema(description = "表单的配置-JSON 字符串") - private String formConf; - @Schema(description = "表单项的数组") - private List formFields; - @Schema(description = "提交的表单值", requiredMode = Schema.RequiredMode.REQUIRED) - private Map formVariables; - - @Data - @Schema(description = "流程实例") - public static class ProcessInstance { - - @Schema(description = "流程实例编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String id; - - @Schema(description = "流程实例名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "提交时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "流程定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private String processDefinitionId; - - /** - * 发起人的用户信息 - */ - private BpmProcessInstanceRespVO.User startUser; - - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskReturnReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskReturnReqVO.java deleted file mode 100644 index 49a2316ca..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskReturnReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 回退流程任务的 Request VO") -@Data -public class BpmTaskReturnReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "回退到的任务 Key", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotEmpty(message = "回退到的任务 Key 不能为空") - private String targetTaskDefinitionKey; - - @Schema(description = "回退意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "我就是想驳回") - @NotEmpty(message = "回退意见不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSignCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSignCreateReqVO.java deleted file mode 100644 index e2a153239..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSignCreateReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.Set; - -@Schema(description = "管理后台 - 加签任务的创建(加签) Request VO") -@Data -public class BpmTaskSignCreateReqVO { - - @Schema(description = "需要加签的任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "加签的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - @NotEmpty(message = "加签用户不能为空") - private Set userIds; - - @Schema(description = "加签类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "before") - @NotEmpty(message = "加签类型不能为空") - private String type; // 参见 BpmTaskSignTypeEnum 枚举 - - @Schema(description = "加签原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "需要加签") - @NotEmpty(message = "加签原因不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSignDeleteReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSignDeleteReqVO.java deleted file mode 100644 index 721968cc6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSignDeleteReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 加签任务的删除(减签) Request VO") -@Data -public class BpmTaskSignDeleteReqVO { - - @Schema(description = "被减签的任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "加签原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "需要减签") - @NotEmpty(message = "加签原因不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTransferReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTransferReqVO.java deleted file mode 100644 index 79f0af456..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTransferReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 流程任务的转办 Request VO") -@Data -public class BpmTaskTransferReqVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotEmpty(message = "任务编号不能为空") - private String id; - - @Schema(description = "新审批人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "新审批人的用户编号不能为空") - private Long assigneeUserId; - - @Schema(description = "转办原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "做不了决定,需要你先帮忙瞅瞅") - @NotEmpty(message = "转办原因不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java deleted file mode 100644 index e8d285e35..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.bpm.controller.app; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java deleted file mode 100644 index d1930bd6a..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.bpm.controller; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java deleted file mode 100644 index 3fe5cc068..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.definition; - -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelUpdateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import org.flowable.common.engine.impl.db.SuspensionState; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.Model; -import org.flowable.engine.repository.ProcessDefinition; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** - * 流程模型 Convert - * - * @author yunlongn - */ -@Mapper -public interface BpmModelConvert { - - BpmModelConvert INSTANCE = Mappers.getMapper(BpmModelConvert.class); - - default PageResult buildModelPage(PageResult pageResult, - Map formMap, - Map categoryMap, Map deploymentMap, - Map processDefinitionMap) { - List list = CollectionUtils.convertList(pageResult.getList(), model -> { - BpmModelMetaInfoRespDTO metaInfo = buildMetaInfo(model); - BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null; - BpmCategoryDO category = categoryMap.get(model.getCategory()); - Deployment deployment = model.getDeploymentId() != null ? deploymentMap.get(model.getDeploymentId()) : null; - ProcessDefinition processDefinition = model.getDeploymentId() != null ? processDefinitionMap.get(model.getDeploymentId()) : null; - return buildModel0(model, metaInfo, form, category, deployment, processDefinition); - }); - return new PageResult<>(list, pageResult.getTotal()); - } - - default BpmModelRespVO buildModel(Model model, - byte[] bpmnBytes) { - BpmModelMetaInfoRespDTO metaInfo = buildMetaInfo(model); - BpmModelRespVO modelVO = buildModel0(model, metaInfo, null, null, null, null); - if (ArrayUtil.isNotEmpty(bpmnBytes)) { - modelVO.setBpmnXml(new String(bpmnBytes)); - } - return modelVO; - } - - default BpmModelRespVO buildModel0(Model model, - BpmModelMetaInfoRespDTO metaInfo, BpmFormDO form, BpmCategoryDO category, - Deployment deployment, ProcessDefinition processDefinition) { - BpmModelRespVO modelRespVO = new BpmModelRespVO().setId(model.getId()).setName(model.getName()) - .setKey(model.getKey()).setCategory(model.getCategory()) - .setCreateTime(DateUtils.of(model.getCreateTime())); - // Form - if (metaInfo != null) { - modelRespVO.setFormType(metaInfo.getFormType()).setFormId(metaInfo.getFormId()) - .setFormCustomCreatePath(metaInfo.getFormCustomCreatePath()) - .setFormCustomViewPath(metaInfo.getFormCustomViewPath()); - modelRespVO.setIcon(metaInfo.getIcon()).setDescription(metaInfo.getDescription()); - } - if (form != null) { - modelRespVO.setFormId(form.getId()).setFormName(form.getName()); - } - // Category - if (category != null) { - modelRespVO.setCategoryName(category.getName()); - } - // ProcessDefinition - if (processDefinition != null) { - modelRespVO.setProcessDefinition(BeanUtils.toBean(processDefinition, BpmProcessDefinitionRespVO.class)); - modelRespVO.getProcessDefinition().setSuspensionState(processDefinition.isSuspended() ? - SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode()); - if (deployment != null) { - modelRespVO.getProcessDefinition().setDeploymentTime(DateUtils.of(deployment.getDeploymentTime())); - } - } - return modelRespVO; - } - - default void copyToCreateModel(Model model, BpmModelCreateReqVO bean) { - model.setName(bean.getName()); - model.setKey(bean.getKey()); - model.setMetaInfo(buildMetaInfoStr(null, - null, bean.getDescription(), - null, null, null, null)); - } - - default void copyToUpdateModel(Model model, BpmModelUpdateReqVO bean) { - model.setName(bean.getName()); - model.setCategory(bean.getCategory()); - model.setMetaInfo(buildMetaInfoStr(buildMetaInfo(model), - bean.getIcon(), bean.getDescription(), - bean.getFormType(), bean.getFormId(), bean.getFormCustomCreatePath(), bean.getFormCustomViewPath())); - } - - default String buildMetaInfoStr(BpmModelMetaInfoRespDTO metaInfo, - String icon, String description, - Integer formType, Long formId, String formCustomCreatePath, String formCustomViewPath) { - if (metaInfo == null) { - metaInfo = new BpmModelMetaInfoRespDTO(); - } - // 只有非空,才进行设置,避免更新时的覆盖 - if (StrUtil.isNotEmpty(icon)) { - metaInfo.setIcon(icon); - } - if (StrUtil.isNotEmpty(description)) { - metaInfo.setDescription(description); - } - if (Objects.nonNull(formType)) { - metaInfo.setFormType(formType); - metaInfo.setFormId(formId); - metaInfo.setFormCustomCreatePath(formCustomCreatePath); - metaInfo.setFormCustomViewPath(formCustomViewPath); - } - return JsonUtils.toJsonString(metaInfo); - } - - default BpmModelMetaInfoRespDTO buildMetaInfo(Model model) { - return JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java deleted file mode 100644 index 0e767d787..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.definition; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.UserTask; -import org.flowable.common.engine.impl.db.SuspensionState; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.ProcessDefinition; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.MappingTarget; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * Bpm 流程定义的 Convert - * - * @author yunlong.li - */ -@Mapper -public interface BpmProcessDefinitionConvert { - - BpmProcessDefinitionConvert INSTANCE = Mappers.getMapper(BpmProcessDefinitionConvert.class); - - default PageResult buildProcessDefinitionPage(PageResult page, - Map deploymentMap, - Map processDefinitionInfoMap, - Map formMap, - Map categoryMap) { - List list = buildProcessDefinitionList(page.getList(), deploymentMap, processDefinitionInfoMap, formMap, categoryMap); - return new PageResult<>(list, page.getTotal()); - } - - default List buildProcessDefinitionList(List list, - Map deploymentMap, - Map processDefinitionInfoMap, - Map formMap, - Map categoryMap) { - return CollectionUtils.convertList(list, definition -> { - Deployment deployment = MapUtil.get(deploymentMap, definition.getDeploymentId(), Deployment.class); - BpmProcessDefinitionInfoDO processDefinitionInfo = MapUtil.get(processDefinitionInfoMap, definition.getId(), BpmProcessDefinitionInfoDO.class); - BpmFormDO form = null; - if (processDefinitionInfo != null) { - form = MapUtil.get(formMap, processDefinitionInfo.getFormId(), BpmFormDO.class); - } - BpmCategoryDO category = MapUtil.get(categoryMap, definition.getCategory(), BpmCategoryDO.class); - return buildProcessDefinition(definition, deployment, processDefinitionInfo, form, category, null, null); - }); - } - - default BpmProcessDefinitionRespVO buildProcessDefinition(ProcessDefinition definition, - Deployment deployment, - BpmProcessDefinitionInfoDO processDefinitionInfo, - BpmFormDO form, - BpmCategoryDO category, - BpmnModel bpmnModel, - List startUserSelectUserTaskList) { - BpmProcessDefinitionRespVO respVO = BeanUtils.toBean(definition, BpmProcessDefinitionRespVO.class); - respVO.setSuspensionState(definition.isSuspended() ? SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode()); - // Deployment - if (deployment != null) { - respVO.setDeploymentTime(LocalDateTimeUtil.of(deployment.getDeploymentTime())); - } - // BpmProcessDefinitionInfoDO - if (processDefinitionInfo != null) { - copyTo(processDefinitionInfo, respVO); - // Form - if (form != null) { - respVO.setFormName(form.getName()); - } - } - // Category - if (category != null) { - respVO.setCategoryName(category.getName()); - } - // BpmnModel - if (bpmnModel != null) { - respVO.setBpmnXml(BpmnModelUtils.getBpmnXml(bpmnModel)); - respVO.setStartUserSelectTasks(BeanUtils.toBean(startUserSelectUserTaskList, BpmProcessDefinitionRespVO.UserTask.class)); - } - return respVO; - } - - @Mapping(source = "from.id", target = "to.id", ignore = true) - void copyTo(BpmProcessDefinitionInfoDO from, @MappingTarget BpmProcessDefinitionRespVO to); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java deleted file mode 100644 index 99b7bebf2..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.message; - -import cn.iocoder.yudao.module.system.api.sms.dto.send.SmsSendSingleToUserReqDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.Map; - -@Mapper -public interface BpmMessageConvert { - - BpmMessageConvert INSTANCE = Mappers.getMapper(BpmMessageConvert.class); - - @Mapping(target = "mobile", ignore = true) - @Mapping(source = "userId", target = "userId") - @Mapping(source = "templateCode", target = "templateCode") - @Mapping(source = "templateParams", target = "templateParams") - SmsSendSingleToUserReqDTO convert(Long userId, String templateCode, Map templateParams); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java deleted file mode 100644 index 6db6ebc46..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 POJO 类的实体转换 - * - * 目前使用 MapStruct 框架 - */ -package cn.iocoder.yudao.module.bpm.convert; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java deleted file mode 100644 index 3cb674c1c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; - -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import org.flowable.engine.history.HistoricActivityInstance; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * BPM 活动 Convert - * - * @author 芋道源码 - */ -@Mapper(uses = DateUtils.class) -public interface BpmActivityConvert { - - BpmActivityConvert INSTANCE = Mappers.getMapper(BpmActivityConvert.class); - - List convertList(List list); - - @Mappings({ - @Mapping(source = "activityId", target = "key"), - @Mapping(source = "activityType", target = "type") - }) - BpmActivityRespVO convert(HistoricActivityInstance bean); -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java deleted file mode 100644 index 0d4a63244..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.repository.ProcessDefinition; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.Task; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.MappingTarget; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 流程实例 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BpmProcessInstanceConvert { - - BpmProcessInstanceConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceConvert.class); - - default PageResult buildProcessInstancePage(PageResult pageResult, - Map processDefinitionMap, - Map categoryMap, - Map> taskMap, - Map userMap, - Map deptMap) { - PageResult vpPageResult = BeanUtils.toBean(pageResult, BpmProcessInstanceRespVO.class); - for (int i = 0; i < pageResult.getList().size(); i++) { - BpmProcessInstanceRespVO respVO = vpPageResult.getList().get(i); - respVO.setStatus(FlowableUtils.getProcessInstanceStatus(pageResult.getList().get(i))); - MapUtils.findAndThen(processDefinitionMap, respVO.getProcessDefinitionId(), - processDefinition -> respVO.setCategory(processDefinition.getCategory())); - MapUtils.findAndThen(categoryMap, respVO.getCategory(), category -> respVO.setCategoryName(category.getName())); - respVO.setTasks(BeanUtils.toBean(taskMap.get(respVO.getId()), BpmProcessInstanceRespVO.Task.class)); - // user - if (userMap != null) { - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(pageResult.getList().get(i).getStartUserId())); - if (startUser != null) { - respVO.setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class)); - MapUtils.findAndThen(deptMap, startUser.getDeptId(), dept -> respVO.getStartUser().setDeptName(dept.getName())); - } - } - } - return vpPageResult; - } - - default BpmProcessInstanceRespVO buildProcessInstance(HistoricProcessInstance processInstance, - ProcessDefinition processDefinition, - BpmProcessDefinitionInfoDO processDefinitionExt, - String bpmnXml, - AdminUserRespDTO startUser, - DeptRespDTO dept) { - BpmProcessInstanceRespVO respVO = BeanUtils.toBean(processInstance, BpmProcessInstanceRespVO.class); - respVO.setStatus(FlowableUtils.getProcessInstanceStatus(processInstance)); - respVO.setFormVariables(FlowableUtils.getProcessInstanceFormVariable(processInstance)); - // definition - respVO.setProcessDefinition(BeanUtils.toBean(processDefinition, BpmProcessDefinitionRespVO.class)); - copyTo(processDefinitionExt, respVO.getProcessDefinition()); - respVO.getProcessDefinition().setBpmnXml(bpmnXml); - // user - if (startUser != null) { - respVO.setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class)); - if (dept != null) { - respVO.getStartUser().setDeptName(dept.getName()); - } - } - return respVO; - } - - @Mapping(source = "from.id", target = "to.id", ignore = true) - void copyTo(BpmProcessDefinitionInfoDO from, @MappingTarget BpmProcessDefinitionRespVO to); - - default BpmProcessInstanceStatusEvent buildProcessInstanceStatusEvent(Object source, HistoricProcessInstance instance, Integer status) { - return new BpmProcessInstanceStatusEvent(source).setId(instance.getId()).setStatus(status) - .setProcessDefinitionKey(instance.getProcessDefinitionKey()).setBusinessKey(instance.getBusinessKey()); - } - - default BpmProcessInstanceStatusEvent buildProcessInstanceStatusEvent(Object source, ProcessInstance instance, Integer status) {; - return new BpmProcessInstanceStatusEvent(source).setId(instance.getId()).setStatus(status) - .setProcessDefinitionKey(instance.getProcessDefinitionKey()).setBusinessKey(instance.getBusinessKey()); - } - - default BpmMessageSendWhenProcessInstanceApproveReqDTO buildProcessInstanceApproveMessage(ProcessInstance instance) { - return new BpmMessageSendWhenProcessInstanceApproveReqDTO() - .setStartUserId(NumberUtils.parseLong(instance.getStartUserId())) - .setProcessInstanceId(instance.getId()) - .setProcessInstanceName(instance.getName()); - } - - default BpmMessageSendWhenProcessInstanceRejectReqDTO buildProcessInstanceRejectMessage(ProcessInstance instance, String reason) { - return new BpmMessageSendWhenProcessInstanceRejectReqDTO() - .setProcessInstanceName(instance.getName()) - .setProcessInstanceId(instance.getId()) - .setReason(reason) - .setStartUserId(NumberUtils.parseLong(instance.getStartUserId())); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java deleted file mode 100644 index 5f4e915d3..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java +++ /dev/null @@ -1,176 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceRespVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.Task; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * Bpm 任务 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BpmTaskConvert { - - BpmTaskConvert INSTANCE = Mappers.getMapper(BpmTaskConvert.class); - - default PageResult buildTodoTaskPage(PageResult pageResult, - Map processInstanceMap, - Map userMap) { - return BeanUtils.toBean(pageResult, BpmTaskRespVO.class, taskVO -> { - ProcessInstance processInstance = processInstanceMap.get(taskVO.getProcessInstanceId()); - if (processInstance == null) { - return; - } - taskVO.setProcessInstance(BeanUtils.toBean(processInstance, BpmTaskRespVO.ProcessInstance.class)); - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); - taskVO.getProcessInstance().setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class)); - }); - } - - default PageResult buildTaskPage(PageResult pageResult, - Map processInstanceMap, - Map userMap, - Map deptMap) { - List taskVOList = CollectionUtils.convertList(pageResult.getList(), task -> { - BpmTaskRespVO taskVO = BeanUtils.toBean(task, BpmTaskRespVO.class); - taskVO.setStatus(FlowableUtils.getTaskStatus(task)).setReason(FlowableUtils.getTaskReason(task)); - // 用户信息 - AdminUserRespDTO assignUser = userMap.get(NumberUtils.parseLong(task.getAssignee())); - if (assignUser != null) { - taskVO.setAssigneeUser(BeanUtils.toBean(assignUser, BpmProcessInstanceRespVO.User.class)); - findAndThen(deptMap, assignUser.getDeptId(), dept -> taskVO.getAssigneeUser().setDeptName(dept.getName())); - } - // 流程实例 - HistoricProcessInstance processInstance = processInstanceMap.get(taskVO.getProcessInstanceId()); - if (processInstance != null) { - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); - taskVO.setProcessInstance(BeanUtils.toBean(processInstance, BpmTaskRespVO.ProcessInstance.class)); - taskVO.getProcessInstance().setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class)); - } - return taskVO; - }); - return new PageResult<>(taskVOList, pageResult.getTotal()); - } - - default List buildTaskListByProcessInstanceId(List taskList, - HistoricProcessInstance processInstance, - Map formMap, - Map userMap, - Map deptMap) { - List taskVOList = CollectionUtils.convertList(taskList, task -> { - BpmTaskRespVO taskVO = BeanUtils.toBean(task, BpmTaskRespVO.class); - taskVO.setStatus(FlowableUtils.getTaskStatus(task)).setReason(FlowableUtils.getTaskReason(task)); - // 流程实例 - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); - taskVO.setProcessInstance(BeanUtils.toBean(processInstance, BpmTaskRespVO.ProcessInstance.class)); - taskVO.getProcessInstance().setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class)); - // 表单信息 - BpmFormDO form = MapUtil.get(formMap, NumberUtils.parseLong(task.getFormKey()), BpmFormDO.class); - if (form != null) { - taskVO.setFormId(form.getId()).setFormName(form.getName()).setFormConf(form.getConf()) - .setFormFields(form.getFields()).setFormVariables(FlowableUtils.getTaskFormVariable(task)); - } - // 用户信息 - AdminUserRespDTO assignUser = userMap.get(NumberUtils.parseLong(task.getAssignee())); - if (assignUser != null) { - taskVO.setAssigneeUser(BeanUtils.toBean(assignUser, BpmProcessInstanceRespVO.User.class)); - findAndThen(deptMap, assignUser.getDeptId(), dept -> taskVO.getAssigneeUser().setDeptName(dept.getName())); - } - AdminUserRespDTO ownerUser = userMap.get(NumberUtils.parseLong(task.getOwner())); - if (ownerUser != null) { - taskVO.setOwnerUser(BeanUtils.toBean(ownerUser, BpmProcessInstanceRespVO.User.class)); - findAndThen(deptMap, ownerUser.getDeptId(), dept -> taskVO.getOwnerUser().setDeptName(dept.getName())); - } - return taskVO; - }); - - // 拼接父子关系 - Map> childrenTaskMap = convertMultiMap( - filterList(taskVOList, r -> StrUtil.isNotEmpty(r.getParentTaskId())), - BpmTaskRespVO::getParentTaskId); - for (BpmTaskRespVO taskVO : taskVOList) { - taskVO.setChildren(childrenTaskMap.get(taskVO.getId())); - } - return filterList(taskVOList, r -> StrUtil.isEmpty(r.getParentTaskId())); - } - - default List buildTaskListByParentTaskId(List taskList, - Map userMap, - Map deptMap) { - return convertList(taskList, task -> BeanUtils.toBean(task, BpmTaskRespVO.class, taskVO -> { - AdminUserRespDTO assignUser = userMap.get(NumberUtils.parseLong(task.getAssignee())); - if (assignUser != null) { - taskVO.setAssigneeUser(BeanUtils.toBean(assignUser, BpmProcessInstanceRespVO.User.class)); - DeptRespDTO dept = deptMap.get(assignUser.getDeptId()); - if (dept != null) { - taskVO.getAssigneeUser().setDeptName(dept.getName()); - } - } - AdminUserRespDTO ownerUser = userMap.get(NumberUtils.parseLong(task.getOwner())); - if (ownerUser != null) { - taskVO.setOwnerUser(BeanUtils.toBean(ownerUser, BpmProcessInstanceRespVO.User.class)); - findAndThen(deptMap, ownerUser.getDeptId(), dept -> taskVO.getOwnerUser().setDeptName(dept.getName())); - } - })); - } - - default BpmMessageSendWhenTaskCreatedReqDTO convert(ProcessInstance processInstance, AdminUserRespDTO startUser, - Task task) { - BpmMessageSendWhenTaskCreatedReqDTO reqDTO = new BpmMessageSendWhenTaskCreatedReqDTO(); - reqDTO.setProcessInstanceId(processInstance.getProcessInstanceId()) - .setProcessInstanceName(processInstance.getName()).setStartUserId(startUser.getId()) - .setStartUserNickname(startUser.getNickname()).setTaskId(task.getId()).setTaskName(task.getName()) - .setAssigneeUserId(NumberUtils.parseLong(task.getAssignee())); - return reqDTO; - } - - /** - * 将父任务的属性,拷贝到子任务(加签任务) - * - * 为什么不使用 mapstruct 映射?因为 TaskEntityImpl 还有很多其他属性,这里我们只设置我们需要的。 - * 使用 mapstruct 会将里面嵌套的各个属性值都设置进去,会出现意想不到的问题。 - * - * @param parentTask 父任务 - * @param childTask 加签任务 - */ - default void copyTo(TaskEntityImpl parentTask, TaskEntityImpl childTask) { - childTask.setName(parentTask.getName()); - childTask.setDescription(parentTask.getDescription()); - childTask.setCategory(parentTask.getCategory()); - childTask.setParentTaskId(parentTask.getId()); - childTask.setProcessDefinitionId(parentTask.getProcessDefinitionId()); - childTask.setProcessInstanceId(parentTask.getProcessInstanceId()); -// childTask.setExecutionId(parentTask.getExecutionId()); // TODO 芋艿:新加的,不太确定;尴尬,不加时,子任务不通过会失败(报错);加了,子任务审批通过会失败(报错) - childTask.setTaskDefinitionKey(parentTask.getTaskDefinitionKey()); - childTask.setTaskDefinitionId(parentTask.getTaskDefinitionId()); - childTask.setPriority(parentTask.getPriority()); - childTask.setCreateTime(new Date()); - childTask.setTenantId(parentTask.getTenantId()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md deleted file mode 100644 index 8153487b7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmCategoryDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmCategoryDO.java deleted file mode 100644 index 01c71ebac..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmCategoryDO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * BPM 流程分类 DO - * - * @author 芋道源码 - */ -@TableName("bpm_category") -@KeySequence("bpm_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmCategoryDO extends BaseDO { - - /** - * 分类编号 - */ - @TableId - private Long id; - /** - * 分类名 - */ - private String name; - /** - * 分类标志 - */ - private String code; - /** - * 分类描述 - */ - private String description; - /** - * 分类状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 分类排序 - */ - private Integer sort; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java deleted file mode 100644 index 1d86d3630..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -/** - * BPM 工作流的表单定义 - * 用于工作流的申请表单,需要动态配置的场景 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_form", autoResultMap = true) -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmFormDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 表单名 - */ - private String name; - /** - * 状态 - */ - private Integer status; - /** - * 表单的配置 - */ - private String conf; - /** - * 表单项的数组 - * - * 目前直接将 https://github.com/JakHuang/form-generator 生成的 JSON 串,直接保存 - * 定义:https://github.com/JakHuang/form-generator/issues/46 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List fields; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionInfoDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionInfoDO.java deleted file mode 100644 index d8aa68947..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionInfoDO.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -/** - * BPM 流程定义的拓信息 - * 主要解决 Flowable {@link org.flowable.engine.repository.ProcessDefinition} 不支持拓展字段,所以新建该表 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_process_definition_info", autoResultMap = true) -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmProcessDefinitionInfoDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 流程定义的编号 - * - * 关联 ProcessDefinition 的 id 属性 - */ - private String processDefinitionId; - /** - * 流程模型的编号 - * - * 关联 Model 的 id 属性 - */ - private String modelId; - - /** - * 图标 - */ - private String icon; - /** - * 描述 - */ - private String description; - - /** - * 表单类型 - * - * 关联 {@link BpmModelFormTypeEnum} - */ - private Integer formType; - /** - * 动态表单编号 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - * - * 关联 {@link BpmFormDO#getId()} - */ - private Long formId; - /** - * 表单的配置 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - * - * 冗余 {@link BpmFormDO#getConf()} - */ - private String formConf; - /** - * 表单项的数组 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - * - * 冗余 {@link BpmFormDO#getFields()} ()} - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List formFields; - /** - * 自定义表单的提交路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomCreatePath; - /** - * 自定义表单的查看路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomViewPath; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessExpressionDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessExpressionDO.java deleted file mode 100644 index 18494b68d..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessExpressionDO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * BPM 流程表达式 DO - * - * @author 芋道源码 - */ -@TableName("bpm_process_expression") -@KeySequence("bpm_process_expression_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmProcessExpressionDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 表达式名字 - */ - private String name; - /** - * 表达式状态 - * - * 枚举 {@link TODO common_status 对应的类} - */ - private Integer status; - /** - * 表达式 - */ - private String expression; - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessListenerDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessListenerDO.java deleted file mode 100644 index 56be88ff3..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessListenerDO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * BPM 流程监听器 DO - * - * 目的:本质上它是流程监听器的模版,用于 BPMN 在设计时,直接选择这些模版 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_process_listener") -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmProcessListenerDO extends BaseDO { - - /** - * 主键 ID,自增 - */ - @TableId - private Long id; - /** - * 监听器名字 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 监听类型 - * - * 枚举 {@link cn.iocoder.yudao.module.bpm.enums.definition.BpmProcessListenerType} - * - * 1. execution:ExecutionListener 执行监听器 - * 2. task:TaskListener 任务监听器 - */ - private String type; - /** - * 监听事件 - * - * execution 时:start、end - * task 时:create 创建、assignment 指派、complete 完成、delete 删除、update 更新、timeout 超时 - */ - private String event; - - /** - * 值类型 - * - * 1. class:Java 类,ExecutionListener 需要 {@link org.flowable.engine.delegate.JavaDelegate},TaskListener 需要 {@link org.flowable.engine.delegate.TaskListener} - * 2. delegateExpression:委托表达式,在 class 的基础上,需要注册到 Spring 容器里,后续表达式通过 Spring Bean 名称即可 - * 3. expression:表达式,一个普通类的普通方法,将这个普通类注册到 Spring 容器中,然后表达式中还可以执行这个类中的方法 - */ - private String valueType; - /** - * 值 - */ - private String value; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java deleted file mode 100644 index 0a8da0f9b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.Set; - -/** - * BPM 用户组 - * - * @author 芋道源码 - */ -@TableName(value = "bpm_user_group", autoResultMap = true) -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmUserGroupDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - /** - * 组名 - */ - private String name; - /** - * 描述 - */ - private String description; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 成员用户编号数组 - */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) - private Set userIds; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java deleted file mode 100644 index 0bef074bc..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.oa; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.time.LocalDateTime; - -/** - * OA 请假申请 DO - * - * {@link #day} 请假天数,目前先简单做。一般是分成请假上午和下午,可以是 1 整天,可以是 0.5 半天 - * - * @author jason - * @author 芋道源码 - */ -@TableName("bpm_oa_leave") -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmOALeaveDO extends BaseDO { - - /** - * 请假表单主键 - */ - @TableId - private Long id; - /** - * 申请人的用户编号 - * - * 关联 AdminUserDO 的 id 属性 - */ - private Long userId; - /** - * 请假类型 - */ - private String type; - /** - * 原因 - */ - private String reason; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 请假天数 - */ - private Long day; - /** - * 审批结果 - * - * 枚举 {@link BpmTaskStatusEnum} - * 考虑到简单,所以直接复用了 BpmProcessInstanceStatusEnum 枚举,也可以自己定义一个枚举哈 - */ - private Integer status; - - /** - * 对应的流程编号 - * - * 关联 ProcessInstance 的 id 属性 - */ - private String processInstanceId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceCopyDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceCopyDO.java deleted file mode 100644 index a464f58fa..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceCopyDO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.task; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 流程抄送 DO - * - * @author kyle - * @since 2024-01-22 - */ -@TableName(value = "bpm_process_instance_copy", autoResultMap = true) -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BpmProcessInstanceCopyDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 发起人 Id - * - * 冗余 ProcessInstance 的 startUserId 字段 - */ - private Long startUserId; - /** - * 流程名 - * - * 冗余 ProcessInstance 的 name 字段 - */ - private String processInstanceName; - /** - * 流程实例的编号 - * - * 关联 ProcessInstance 的 id 属性 - */ - private String processInstanceId; - /** - * 流程分类 - * - * 冗余 ProcessInstance 的 category 字段 - */ - private String category; - - /** - * 任务主键 - * - * 关联 Task 的 id 属性 - */ - private String taskId; - /** - * 任务名称 - * - * 冗余 Task 的 name 属性 - */ - private String taskName; - - /** - * 用户编号(被抄送的用户编号) - * - * 关联 system_users 的 id 属性 - */ - private Long userId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/category/BpmCategoryMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/category/BpmCategoryMapper.java deleted file mode 100644 index 5fc8236e8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/category/BpmCategoryMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.category; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * BPM 流程分类 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface BpmCategoryMapper extends BaseMapperX { - - default PageResult selectPage(BpmCategoryPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BpmCategoryDO::getName, reqVO.getName()) - .likeIfPresent(BpmCategoryDO::getCode, reqVO.getCode()) - .eqIfPresent(BpmCategoryDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BpmCategoryDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(BpmCategoryDO::getSort)); - } - - default BpmCategoryDO selectByName(String name) { - return selectOne(BpmCategoryDO::getName, name); - } - - default BpmCategoryDO selectByCode(String code) { - return selectOne(BpmCategoryDO::getCode, code); - } - - default List selectListByCode(Collection codes) { - return selectList(BpmCategoryDO::getCode, codes); - } - - default List selectListByStatus(Integer status) { - return selectList(BpmCategoryDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java deleted file mode 100644 index 633bac06f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 动态表单 Mapper - * - * @author 风里雾里 - */ -@Mapper -public interface BpmFormMapper extends BaseMapperX { - - default PageResult selectPage(BpmFormPageReqVO reqVO) { - return selectPage(reqVO, new QueryWrapperX() - .likeIfPresent("name", reqVO.getName()) - .orderByDesc("id")); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionInfoMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionInfoMapper.java deleted file mode 100644 index b868fdce6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionInfoMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface BpmProcessDefinitionInfoMapper extends BaseMapperX { - - default List selectListByProcessDefinitionIds(Collection processDefinitionIds) { - return selectList(BpmProcessDefinitionInfoDO::getProcessDefinitionId, processDefinitionIds); - } - - default BpmProcessDefinitionInfoDO selectByProcessDefinitionId(String processDefinitionId) { - return selectOne(BpmProcessDefinitionInfoDO::getProcessDefinitionId, processDefinitionId); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessExpressionMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessExpressionMapper.java deleted file mode 100644 index 81af6d54a..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessExpressionMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessExpressionDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * BPM 流程表达式 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface BpmProcessExpressionMapper extends BaseMapperX { - - default PageResult selectPage(BpmProcessExpressionPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BpmProcessExpressionDO::getName, reqVO.getName()) - .eqIfPresent(BpmProcessExpressionDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BpmProcessExpressionDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BpmProcessExpressionDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessListenerMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessListenerMapper.java deleted file mode 100644 index 10ccd2fba..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessListenerMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessListenerDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * BPM 流程监听器 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface BpmProcessListenerMapper extends BaseMapperX { - - default PageResult selectPage(BpmProcessListenerPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BpmProcessListenerDO::getName, reqVO.getName()) - .eqIfPresent(BpmProcessListenerDO::getType, reqVO.getType()) - .eqIfPresent(BpmProcessListenerDO::getEvent, reqVO.getEvent()) - .eqIfPresent(BpmProcessListenerDO::getStatus, reqVO.getStatus()) - .orderByDesc(BpmProcessListenerDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java deleted file mode 100644 index bb8d96c2b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 用户组 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface BpmUserGroupMapper extends BaseMapperX { - - default PageResult selectPage(BpmUserGroupPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BpmUserGroupDO::getName, reqVO.getName()) - .eqIfPresent(BpmUserGroupDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BpmUserGroupDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BpmUserGroupDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(BpmUserGroupDO::getStatus, status); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java deleted file mode 100644 index 305ddca86..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.oa; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 请假申请 Mapper - * - * @author jason - * @author 芋道源码 - */ -@Mapper -public interface BpmOALeaveMapper extends BaseMapperX { - - default PageResult selectPage(Long userId, BpmOALeavePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BpmOALeaveDO::getUserId, userId) - .eqIfPresent(BpmOALeaveDO::getStatus, reqVO.getStatus()) - .eqIfPresent(BpmOALeaveDO::getType, reqVO.getType()) - .likeIfPresent(BpmOALeaveDO::getReason, reqVO.getReason()) - .betweenIfPresent(BpmOALeaveDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BpmOALeaveDO::getId)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceCopyMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceCopyMapper.java deleted file mode 100644 index c5ec50f65..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceCopyMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface BpmProcessInstanceCopyMapper extends BaseMapperX { - - default PageResult selectPage(Long loginUserId, BpmProcessInstanceCopyPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BpmProcessInstanceCopyDO::getUserId, loginUserId) - .likeIfPresent(BpmProcessInstanceCopyDO::getProcessInstanceName, reqVO.getProcessInstanceName()) - .betweenIfPresent(BpmProcessInstanceCopyDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BpmProcessInstanceCopyDO::getId)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java deleted file mode 100644 index 8e69fdc75..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java +++ /dev/null @@ -1,91 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.config; - -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.BpmActivityBehaviorFactory; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.event.BpmProcessInstanceEventPublisher; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.flowable.common.engine.api.delegate.event.FlowableEventListener; -import org.flowable.spring.SpringProcessEngineConfiguration; -import org.flowable.spring.boot.EngineConfigurationConfigurer; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.task.AsyncListenableTaskExecutor; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -import java.util.List; - -/** - * BPM 模块的 Flowable 配置类 - * - * @author jason - */ -@Configuration(proxyBeanMethods = false) -public class BpmFlowableConfiguration { - - /** - * 参考 {@link org.flowable.spring.boot.FlowableJobConfiguration} 类,创建对应的 AsyncListenableTaskExecutor Bean - * - * 如果不创建,会导致项目启动时,Flowable 报错的问题 - */ - @Bean(name = "applicationTaskExecutor") - @ConditionalOnMissingBean(name = "applicationTaskExecutor") - public AsyncListenableTaskExecutor taskExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(8); - executor.setMaxPoolSize(8); - executor.setQueueCapacity(100); - executor.setThreadNamePrefix("flowable-task-Executor-"); - executor.setAwaitTerminationSeconds(30); - executor.setWaitForTasksToCompleteOnShutdown(true); - executor.setAllowCoreThreadTimeOut(true); - executor.initialize(); - return executor; - } - - /** - * BPM 模块的 ProcessEngineConfigurationConfigurer 实现类: - * - * 1. 设置各种监听器 - * 2. 设置自定义的 ActivityBehaviorFactory 实现 - */ - @Bean - public EngineConfigurationConfigurer bpmProcessEngineConfigurationConfigurer( - ObjectProvider listeners, - BpmActivityBehaviorFactory bpmActivityBehaviorFactory) { - return configuration -> { - // 注册监听器,例如说 BpmActivityEventListener - configuration.setEventListeners(ListUtil.toList(listeners.iterator())); - // 设置 ActivityBehaviorFactory 实现类,用于流程任务的审核人的自定义 - configuration.setActivityBehaviorFactory(bpmActivityBehaviorFactory); - }; - } - - // =========== 审批人相关的 Bean ========== - - @Bean - public BpmActivityBehaviorFactory bpmActivityBehaviorFactory(BpmTaskCandidateInvoker bpmTaskCandidateInvoker) { - BpmActivityBehaviorFactory bpmActivityBehaviorFactory = new BpmActivityBehaviorFactory(); - bpmActivityBehaviorFactory.setTaskCandidateInvoker(bpmTaskCandidateInvoker); - return bpmActivityBehaviorFactory; - } - - @Bean - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") // adminUserApi 可以注入成功 - public BpmTaskCandidateInvoker bpmTaskCandidateInvoker(List strategyList, - AdminUserApi adminUserApi) { - return new BpmTaskCandidateInvoker(strategyList, adminUserApi); - } - - // =========== 自己拓展的 Bean ========== - - @Bean - public BpmProcessInstanceEventPublisher processInstanceEventPublisher(ApplicationEventPublisher publisher) { - return new BpmProcessInstanceEventPublisher(publisher); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java deleted file mode 100644 index b5278f5ab..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; - -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; -import lombok.Setter; -import org.flowable.bpmn.model.Activity; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior; -import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior; -import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior; -import org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior; -import org.flowable.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory; - -/** - * 自定义的 ActivityBehaviorFactory 实现类,目的如下: - * 1. 自定义 {@link #createUserTaskActivityBehavior(UserTask)}:实现自定义的流程任务的 assignee 负责人的分配 - * - * @author 芋道源码 - */ -@Setter -public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory { - - private BpmTaskCandidateInvoker taskCandidateInvoker; - - @Override - public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask) { - return new BpmUserTaskActivityBehavior(userTask) - .setTaskCandidateInvoker(taskCandidateInvoker); - } - - @Override - public ParallelMultiInstanceBehavior createParallelMultiInstanceBehavior(Activity activity, - AbstractBpmnActivityBehavior behavior) { - return new BpmParallelMultiInstanceBehavior(activity, behavior) - .setTaskCandidateInvoker(taskCandidateInvoker); - } - - @Override - public SequentialMultiInstanceBehavior createSequentialMultiInstanceBehavior(Activity activity, - AbstractBpmnActivityBehavior behavior) { - return new BpmSequentialMultiInstanceBehavior(activity, behavior) - .setTaskCandidateInvoker(taskCandidateInvoker); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java deleted file mode 100644 index 2e1143815..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; - -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import lombok.Setter; -import org.flowable.bpmn.model.Activity; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior; -import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior; - -import java.util.Set; - -/** - * 自定义的【并行】的【多个】流程任务的 assignee 负责人的分配 - * 第一步,基于分配规则,计算出分配任务的【多个】候选人们。 - * 第二步,将【多个】任务候选人们,设置到 DelegateExecution 的 collectionVariable 变量中,以便 BpmUserTaskActivityBehavior 使用它 - * - * @author kemengkai - * @since 2022-04-21 16:57 - */ -@Setter -public class BpmParallelMultiInstanceBehavior extends ParallelMultiInstanceBehavior { - - private BpmTaskCandidateInvoker taskCandidateInvoker; - - public BpmParallelMultiInstanceBehavior(Activity activity, - AbstractBpmnActivityBehavior innerActivityBehavior) { - super(activity, innerActivityBehavior); - } - - /** - * 重写该方法,主要实现两个功能: - * 1. 忽略原有的 collectionVariable、collectionElementVariable 表达式,而是采用自己定义的 - * 2. 获得任务的处理人,并设置到 collectionVariable 中,用于 BpmUserTaskActivityBehavior 从中可以获取任务的处理人 - * - * 注意,多个任务实例,每个任务实例对应一个处理人,所以返回的数量就是任务处理人的数量 - * - * @param execution 执行任务 - * @return 数量 - */ - @Override - protected int resolveNrOfInstances(DelegateExecution execution) { - // 第一步,设置 collectionVariable 和 CollectionVariable - // 从 execution.getVariable() 读取所有任务处理人的 key - super.collectionExpression = null; // collectionExpression 和 collectionVariable 是互斥的 - super.collectionVariable = FlowableUtils.formatExecutionCollectionVariable(execution.getCurrentActivityId()); - // 从 execution.getVariable() 读取当前所有任务处理的人的 key - super.collectionElementVariable = FlowableUtils.formatExecutionCollectionElementVariable(execution.getCurrentActivityId()); - - // 第二步,获取任务的所有处理人 - Set assigneeUserIds = taskCandidateInvoker.calculateUsers(execution); - execution.setVariable(super.collectionVariable, assigneeUserIds); - return assigneeUserIds.size(); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmSequentialMultiInstanceBehavior.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmSequentialMultiInstanceBehavior.java deleted file mode 100644 index 6beb6e7bb..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmSequentialMultiInstanceBehavior.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; - -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import lombok.Setter; -import org.flowable.bpmn.model.Activity; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior; -import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior; - -import java.util.LinkedHashSet; -import java.util.Set; - -/** - * 自定义的【串行】的【多个】流程任务的 assignee 负责人的分配 - * - * 本质上,实现和 {@link BpmParallelMultiInstanceBehavior} 一样,只是继承的类不一样 - * - * @author 芋道源码 - */ -@Setter -public class BpmSequentialMultiInstanceBehavior extends SequentialMultiInstanceBehavior { - - private BpmTaskCandidateInvoker taskCandidateInvoker; - - public BpmSequentialMultiInstanceBehavior(Activity activity, AbstractBpmnActivityBehavior innerActivityBehavior) { - super(activity, innerActivityBehavior); - } - - /** - * 逻辑和 {@link BpmParallelMultiInstanceBehavior#resolveNrOfInstances(DelegateExecution)} 类似 - * - * 差异的点:是在【第二步】的时候,需要返回 LinkedHashSet 集合!因为它需要有序! - */ - @Override - protected int resolveNrOfInstances(DelegateExecution execution) { - // 第一步,设置 collectionVariable 和 CollectionVariable - // 从 execution.getVariable() 读取所有任务处理人的 key - super.collectionExpression = null; // collectionExpression 和 collectionVariable 是互斥的 - super.collectionVariable = FlowableUtils.formatExecutionCollectionVariable(execution.getCurrentActivityId()); - // 从 execution.getVariable() 读取当前所有任务处理的人的 key - super.collectionElementVariable = FlowableUtils.formatExecutionCollectionElementVariable(execution.getCurrentActivityId()); - - // 第二步,获取任务的所有处理人 - Set assigneeUserIds = new LinkedHashSet<>(taskCandidateInvoker.calculateUsers(execution)); // 保证有序!!! - execution.setVariable(super.collectionVariable, assigneeUserIds); - return assigneeUserIds.size(); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java deleted file mode 100644 index c49465273..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.UserTask; -import org.flowable.common.engine.impl.el.ExpressionManager; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.util.TaskHelper; -import org.flowable.task.service.TaskService; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; - -import java.util.List; -import java.util.Set; - -/** - * 自定义的【单个】流程任务的 assignee 负责人的分配 - * 第一步,基于分配规则,计算出分配任务的【单个】候选人。如果找不到,则直接报业务异常,不继续执行后续的流程; - * 第二步,随机选择一个候选人,则选择作为 assignee 负责人。 - * - * @author 芋道源码 - */ -@Slf4j -public class BpmUserTaskActivityBehavior extends UserTaskActivityBehavior { - - @Setter - private BpmTaskCandidateInvoker taskCandidateInvoker; - - public BpmUserTaskActivityBehavior(UserTask userTask) { - super(userTask); - } - - @Override - protected void handleAssignments(TaskService taskService, String assignee, String owner, - List candidateUsers, List candidateGroups, TaskEntity task, ExpressionManager expressionManager, - DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) { - // 第一步,获得任务的候选用户 - Long assigneeUserId = calculateTaskCandidateUsers(execution); - Assert.notNull(assigneeUserId, "任务处理人不能为空"); - // 第二步,设置作为负责人 - TaskHelper.changeTaskAssignee(task, String.valueOf(assigneeUserId)); - } - - private Long calculateTaskCandidateUsers(DelegateExecution execution) { - // 情况一,如果是多实例的任务,例如说会签、或签等情况,则从 Variable 中获取。 - // 顺序审批可见 BpmSequentialMultiInstanceBehavior,并发审批可见 BpmSequentialMultiInstanceBehavior - if (super.multiInstanceActivityBehavior != null) { - return execution.getVariable(super.multiInstanceActivityBehavior.getCollectionElementVariable(), Long.class); - } - - // 情况二,如果非多实例的任务,则计算任务处理人 - // 第一步,先计算可处理该任务的处理人们 - Set candidateUserIds = taskCandidateInvoker.calculateUsers(execution); - // 第二步,后随机选择一个任务的处理人 - // 疑问:为什么一定要选择一个任务处理人? - // 解答:项目对 bpm 的任务是责任到人,所以每个任务有且仅有一个处理人。 - // 如果希望一个任务可以同时被多个人处理,可以考虑使用 BpmParallelMultiInstanceBehavior 实现的会签 or 或签。 - int index = RandomUtil.randomInt(candidateUserIds.size()); - return CollUtil.get(candidateUserIds, index); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvoker.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvoker.java deleted file mode 100644 index c0c7ca0d9..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvoker.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.google.common.annotations.VisibleForTesting; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.delegate.DelegateExecution; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.MODEL_DEPLOY_FAIL_TASK_CANDIDATE_NOT_CONFIG; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.TASK_CREATE_FAIL_NO_CANDIDATE_USER; - -/** - * {@link BpmTaskCandidateStrategy} 的调用者,用于调用对应的策略,实现任务的候选人的计算 - * - * @author 芋道源码 - */ -@Slf4j -public class BpmTaskCandidateInvoker { - - private final Map strategyMap = new HashMap<>(); - - private final AdminUserApi adminUserApi; - - public BpmTaskCandidateInvoker(List strategyList, - AdminUserApi adminUserApi) { - strategyList.forEach(strategy -> { - BpmTaskCandidateStrategy oldStrategy = strategyMap.put(strategy.getStrategy(), strategy); - Assert.isNull(oldStrategy, "策略(%s) 重复", strategy.getStrategy()); - }); - this.adminUserApi = adminUserApi; - } - - /** - * 校验流程模型的任务分配规则全部都配置了 - * 目的:如果有规则未配置,会导致流程任务找不到负责人,进而流程无法进行下去! - * - * @param bpmnBytes BPMN XML - */ - public void validateBpmnConfig(byte[] bpmnBytes) { - BpmnModel bpmnModel = BpmnModelUtils.getBpmnModel(bpmnBytes); - assert bpmnModel != null; - List userTaskList = BpmnModelUtils.getBpmnModelElements(bpmnModel, UserTask.class); - // 遍历所有的 UserTask,校验审批人配置 - userTaskList.forEach(userTask -> { - // 1. 非空校验 - Integer strategy = BpmnModelUtils.parseCandidateStrategy(userTask); - String param = BpmnModelUtils.parseCandidateParam(userTask); - if (strategy == null) { - throw exception(MODEL_DEPLOY_FAIL_TASK_CANDIDATE_NOT_CONFIG, userTask.getName()); - } - BpmTaskCandidateStrategy candidateStrategy = getCandidateStrategy(strategy); - if (candidateStrategy.isParamRequired() && StrUtil.isBlank(param)) { - throw exception(MODEL_DEPLOY_FAIL_TASK_CANDIDATE_NOT_CONFIG, userTask.getName()); - } - // 2. 具体策略校验 - getCandidateStrategy(strategy).validateParam(param); - }); - } - - /** - * 计算任务的候选人 - * - * @param execution 执行任务 - * @return 用户编号集合 - */ - @DataPermission(enable = false) // 忽略数据权限,避免因为过滤,导致找不到候选人 - public Set calculateUsers(DelegateExecution execution) { - Integer strategy = BpmnModelUtils.parseCandidateStrategy(execution.getCurrentFlowElement()); - String param = BpmnModelUtils.parseCandidateParam(execution.getCurrentFlowElement()); - // 1.1 计算任务的候选人 - Set userIds = getCandidateStrategy(strategy).calculateUsers(execution, param); - // 1.2 移除被禁用的用户 - removeDisableUsers(userIds); - - // 2. 校验是否有候选人 - if (CollUtil.isEmpty(userIds)) { - log.error("[calculateUsers][流程任务({}/{}/{}) 任务规则({}/{}) 找不到候选人]", execution.getId(), - execution.getProcessDefinitionId(), execution.getCurrentActivityId(), strategy, param); - throw exception(TASK_CREATE_FAIL_NO_CANDIDATE_USER); - } - return userIds; - } - - @VisibleForTesting - void removeDisableUsers(Set assigneeUserIds) { - if (CollUtil.isEmpty(assigneeUserIds)) { - return; - } - Map userMap = adminUserApi.getUserMap(assigneeUserIds); - assigneeUserIds.removeIf(id -> { - AdminUserRespDTO user = userMap.get(id); - return user == null || !CommonStatusEnum.ENABLE.getStatus().equals(user.getStatus()); - }); - } - - private BpmTaskCandidateStrategy getCandidateStrategy(Integer strategy) { - BpmTaskCandidateStrategyEnum strategyEnum = BpmTaskCandidateStrategyEnum.valueOf(strategy); - Assert.notNull(strategyEnum, "策略(%s) 不存在", strategy); - BpmTaskCandidateStrategy strategyObj = strategyMap.get(strategyEnum); - Assert.notNull(strategyObj, "策略(%s) 不存在", strategy); - return strategyObj; - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateStrategy.java deleted file mode 100644 index 1534d39c2..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateStrategy.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate; - -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import org.flowable.engine.delegate.DelegateExecution; - -import java.util.Set; - -/** - * BPM 任务的候选人的策略接口 - * - * 例如说:分配审批人 - * - * @author 芋道源码 - */ -public interface BpmTaskCandidateStrategy { - - /** - * 对应策略 - * - * @return 策略 - */ - BpmTaskCandidateStrategyEnum getStrategy(); - - /** - * 校验参数 - * - * @param param 参数 - */ - void validateParam(String param); - - /** - * 基于执行任务,获得任务的候选用户们 - * - * @param execution 执行任务 - * @return 用户编号集合 - */ - Set calculateUsers(DelegateExecution execution, String param); - - /** - * 是否一定要输入参数 - * - * @return 是否 - */ - default boolean isParamRequired() { - return true; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpression.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpression.java deleted file mode 100644 index 25482e818..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpression.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.expression; - -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.runtime.ProcessInstance; -import org.springframework.stereotype.Component; -import org.springframework.util.Assert; - -import javax.annotation.Resource; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static java.util.Collections.emptySet; - -/** - * 分配给发起人的 Leader 审批的 Expression 流程表达式 - * 目前 Leader 的定义是,发起人所在部门的 Leader - * - * @author 芋道源码 - */ -@Component -public class BpmTaskAssignLeaderExpression { - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @Resource - private BpmProcessInstanceService processInstanceService; - - /** - * 计算审批的候选人 - * - * @param execution 流程执行实体 - * @param level 指定级别 - * @return 指定级别的领导 - */ - public Set calculateUsers(DelegateExecution execution, int level) { - Assert.isTrue(level > 0, "level 必须大于 0"); - // 获得发起人 - ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId()); - Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId()); - // 获得对应 leve 的部门 - DeptRespDTO dept = null; - for (int i = 0; i < level; i++) { - // 获得 level 对应的部门 - if (dept == null) { - dept = getStartUserDept(startUserId); - if (dept == null) { // 找不到发起人的部门,所以无法使用该规则 - return emptySet(); - } - } else { - DeptRespDTO parentDept = deptApi.getDept(dept.getParentId()).getCheckedData(); - if (parentDept == null) { // 找不到父级部门,所以只好结束寻找。原因是:例如说,级别比较高的人,所在部门层级比较少 - break; - } - dept = parentDept; - } - } - return dept.getLeaderUserId() != null ? asSet(dept.getLeaderUserId()) : emptySet(); - } - - private DeptRespDTO getStartUserDept(Long startUserId) { - AdminUserRespDTO startUser = adminUserApi.getUser(startUserId).getCheckedData(); - if (startUser.getDeptId() == null) { // 找不到部门,所以无法使用该规则 - return null; - } - return deptApi.getDept(startUser.getDeptId()).getCheckedData(); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignStartUserExpression.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignStartUserExpression.java deleted file mode 100644 index 2c7de5a2b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignStartUserExpression.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.expression; - -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl; -import org.flowable.engine.runtime.ProcessInstance; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Set; - -/** - * 分配给发起人审批的 Expression 流程表达式 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskAssignStartUserExpression { - - @Resource - private BpmProcessInstanceService processInstanceService; - - /** - * 计算审批的候选人 - * - * @param execution 流程执行实体 - * @return 发起人 - */ - public Set calculateUsers(ExecutionEntityImpl execution) { - ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId()); - Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId()); - return SetUtils.asSet(startUserId); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptLeaderStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptLeaderStrategy.java deleted file mode 100644 index 30e948c8f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptLeaderStrategy.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -/** - * 部门的负责人 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author kyle - */ -@Component -public class BpmTaskCandidateDeptLeaderStrategy implements BpmTaskCandidateStrategy { - - @Resource - private DeptApi deptApi; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.DEPT_LEADER; - } - - @Override - public void validateParam(String param) { - Set deptIds = StrUtils.splitToLongSet(param); - deptApi.validateDeptList(deptIds); - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - Set deptIds = StrUtils.splitToLongSet(param); - List depts = deptApi.getDeptList(deptIds).getCheckedData(); - return convertSet(depts, DeptRespDTO::getLeaderUserId); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptMemberStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptMemberStrategy.java deleted file mode 100644 index ad1c57367..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptMemberStrategy.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -/** - * 部门的成员 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author kyle - */ -@Component -public class BpmTaskCandidateDeptMemberStrategy implements BpmTaskCandidateStrategy { - - @Resource - private DeptApi deptApi; - @Resource - private AdminUserApi adminUserApi; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.DEPT_MEMBER; - } - - @Override - public void validateParam(String param) { - Set deptIds = StrUtils.splitToLongSet(param); - deptApi.validateDeptList(deptIds); - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - Set deptIds = StrUtils.splitToLongSet(param); - List users = adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(); - return convertSet(users, AdminUserRespDTO::getId); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategy.java deleted file mode 100644 index e0f9dabe5..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategy.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.hutool.core.convert.Convert; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import java.util.Set; - -/** - * 流程表达式 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrategy { - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.EXPRESSION; - } - - @Override - public void validateParam(String param) { - // do nothing 因为它基本做不了校验 - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - Object result = FlowableUtils.getExpressionValue(execution, param); - return Convert.toSet(Long.class, result); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategy.java deleted file mode 100644 index da1aa3944..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategy.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; - -/** - * 用户组 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author kyle - */ -@Component -public class BpmTaskCandidateGroupStrategy implements BpmTaskCandidateStrategy { - - @Resource - private BpmUserGroupService userGroupService; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.USER_GROUP; - } - - @Override - public void validateParam(String param) { - Set groupIds = StrUtils.splitToLongSet(param); - userGroupService.getUserGroupList(groupIds); - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - Set groupIds = StrUtils.splitToLongSet(param); - List groups = userGroupService.getUserGroupList(groupIds); - return convertSetByFlatMap(groups, BpmUserGroupDO::getUserIds, Collection::stream); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidatePostStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidatePostStrategy.java deleted file mode 100644 index b23cf5733..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidatePostStrategy.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.system.api.dept.PostApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -/** - * 岗位 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author kyle - */ -@Component -public class BpmTaskCandidatePostStrategy implements BpmTaskCandidateStrategy { - - @Resource - private PostApi postApi; - @Resource - private AdminUserApi adminUserApi; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.POST; - } - - @Override - public void validateParam(String param) { - Set postIds = StrUtils.splitToLongSet(param); - postApi.validPostList(postIds); - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - Set postIds = StrUtils.splitToLongSet(param); - List users = adminUserApi.getUserListByPostIds(postIds).getCheckedData(); - return convertSet(users, AdminUserRespDTO::getId); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateRoleStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateRoleStrategy.java deleted file mode 100644 index d44b388f6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateRoleStrategy.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.permission.RoleApi; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Set; - -/** - * 角色 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author kyle - */ -@Component -public class BpmTaskCandidateRoleStrategy implements BpmTaskCandidateStrategy { - - @Resource - private RoleApi roleApi; - @Resource - private PermissionApi permissionApi; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.ROLE; - } - - @Override - public void validateParam(String param) { - Set roleIds = StrUtils.splitToLongSet(param); - roleApi.validRoleList(roleIds); - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - Set roleIds = StrUtils.splitToLongSet(param); - return permissionApi.getUserRoleIdListByRoleIds(roleIds).getCheckedData(); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateStartUserSelectStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateStartUserSelectStrategy.java deleted file mode 100644 index 36750effb..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateStartUserSelectStrategy.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.runtime.ProcessInstance; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.*; - -/** - * 发起人自选 {@link BpmTaskCandidateUserStrategy} 实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskCandidateStartUserSelectStrategy implements BpmTaskCandidateStrategy { - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private BpmProcessInstanceService processInstanceService; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.START_USER_SELECT; - } - - @Override - public void validateParam(String param) {} - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId()); - Assert.notNull(processInstance, "流程实例({})不能为空", execution.getProcessInstanceId()); - Map> startUserSelectAssignees = FlowableUtils.getStartUserSelectAssignees(processInstance); - Assert.notNull(startUserSelectAssignees, "流程实例({}) 的发起人自选审批人不能为空", - execution.getProcessInstanceId()); - // 获得审批人 - List assignees = startUserSelectAssignees.get(execution.getCurrentActivityId()); - return new LinkedHashSet<>(assignees); - } - - @Override - public boolean isParamRequired() { - return false; - } - - /** - * 获得发起人自选审批人的 UserTask 列表 - * - * @param bpmnModel BPMN 模型 - * @return UserTask 列表 - */ - public static List getStartUserSelectUserTaskList(BpmnModel bpmnModel) { - if (bpmnModel == null) { - return null; - } - List userTaskList = BpmnModelUtils.getBpmnModelElements(bpmnModel, UserTask.class); - if (CollUtil.isEmpty(userTaskList)) { - return null; - } - userTaskList.removeIf(userTask -> !Objects.equals(BpmnModelUtils.parseCandidateStrategy(userTask), - BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy())); - return userTaskList; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateUserStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateUserStrategy.java deleted file mode 100644 index a6daec0e0..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateUserStrategy.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Set; - -/** - * 用户 {@link BpmTaskCandidateStrategy} 实现类 - * - * @author kyle - */ -@Component -public class BpmTaskCandidateUserStrategy implements BpmTaskCandidateStrategy { - - @Resource - private AdminUserApi adminUserApi; - - @Override - public BpmTaskCandidateStrategyEnum getStrategy() { - return BpmTaskCandidateStrategyEnum.USER; - } - - @Override - public void validateParam(String param) { - adminUserApi.validateUserList(StrUtils.splitToLongSet(param)); - } - - @Override - public Set calculateUsers(DelegateExecution execution, String param) { - return StrUtils.splitToLongSet(param); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmConstants.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmConstants.java deleted file mode 100644 index e965d2281..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmConstants.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums; - -import org.flowable.engine.runtime.ProcessInstance; - -/** - * BPM 通用常量 - * - * @author 芋道源码 - */ -public class BpmConstants { - - /** - * 流程实例的变量 - 状态 - * - * @see ProcessInstance#getProcessVariables() - */ - public static final String PROCESS_INSTANCE_VARIABLE_STATUS = "PROCESS_STATUS"; - /** - * 流程实例的变量 - 发起用户选择的审批人 Map - * - * @see ProcessInstance#getProcessVariables() - */ - public static final String PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES = "PROCESS_START_USER_SELECT_ASSIGNEES"; - - /** - * 任务的变量 - 状态 - * - * @see org.flowable.task.api.Task#getTaskLocalVariables() - */ - public static final String TASK_VARIABLE_STATUS = "TASK_STATUS"; - /** - * 任务的变量 - 理由 - * - * 例如说:审批通过、不通过的理由 - * - * @see org.flowable.task.api.Task#getTaskLocalVariables() - */ - public static final String TASK_VARIABLE_REASON = "TASK_REASON"; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmTaskCandidateStrategyEnum.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmTaskCandidateStrategyEnum.java deleted file mode 100644 index a8b538501..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmTaskCandidateStrategyEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums; - -import cn.hutool.core.util.ArrayUtil; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * BPM 任务的候选人策略枚举 - * - * 例如说:分配给指定人审批 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum BpmTaskCandidateStrategyEnum { - - ROLE(10, "角色"), - DEPT_MEMBER(20, "部门的成员"), // 包括负责人 - DEPT_LEADER(21, "部门的负责人"), - POST(22, "岗位"), - USER(30, "用户"), - START_USER_SELECT(35, "发起人自选"), // 申请人自己,可在提交申请时选择此节点的审批人 - USER_GROUP(40, "用户组"), - EXPRESSION(60, "流程表达式"), // 表达式 ExpressionManager - ; - - /** - * 类型 - */ - private final Integer strategy; - /** - * 描述 - */ - private final String description; - - public static BpmTaskCandidateStrategyEnum valueOf(Integer strategy) { - return ArrayUtil.firstMatch(o -> o.getStrategy().equals(strategy), values()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java deleted file mode 100644 index 3eb6981ef..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums; - -/** - * BPMN XML 常量信息 - * - * @author 芋道源码 - */ -public interface BpmnModelConstants { - - String BPMN_FILE_SUFFIX = ".bpmn"; - - /** - * BPMN 中的命名空间 - */ - String NAMESPACE = "http://flowable.org/bpmn"; - - /** - * BPMN UserTask 的扩展属性,用于标记候选人策略 - */ - String USER_TASK_CANDIDATE_STRATEGY = "candidateStrategy"; - /** - * BPMN UserTask 的扩展属性,用于标记候选人参数 - */ - String USER_TASK_CANDIDATE_PARAM = "candidateParam"; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/event/BpmProcessInstanceEventPublisher.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/event/BpmProcessInstanceEventPublisher.java deleted file mode 100644 index efeda8afa..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/event/BpmProcessInstanceEventPublisher.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.event; - -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent; -import lombok.AllArgsConstructor; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; - -/** - * {@link BpmProcessInstanceStatusEvent} 的生产者 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Validated -public class BpmProcessInstanceEventPublisher { - - private final ApplicationEventPublisher publisher; - - public void sendProcessInstanceResultEvent(@Valid BpmProcessInstanceStatusEvent event) { - publisher.publishEvent(event); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java deleted file mode 100644 index f6d0a28c0..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener; - -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import com.google.common.collect.ImmutableSet; -import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent; -import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType; -import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener; -import org.flowable.engine.delegate.event.FlowableCancelledEvent; -import org.flowable.engine.runtime.ProcessInstance; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Set; - -/** - * 监听 {@link ProcessInstance} 的状态变更,更新其对应的 status 状态 - * - * @author jason - */ -@Component -public class BpmProcessInstanceEventListener extends AbstractFlowableEngineEventListener { - - @Resource - @Lazy - private BpmProcessInstanceService processInstanceService; - - public static final Set PROCESS_INSTANCE_EVENTS = ImmutableSet.builder() - .add(FlowableEngineEventType.PROCESS_CANCELLED) - .add(FlowableEngineEventType.PROCESS_COMPLETED) - .build(); - - public BpmProcessInstanceEventListener(){ - super(PROCESS_INSTANCE_EVENTS); - } - - @Override - protected void processCancelled(FlowableCancelledEvent event) { - processInstanceService.updateProcessInstanceWhenCancel(event); - } - - @Override - protected void processCompleted(FlowableEngineEntityEvent event) { - processInstanceService.updateProcessInstanceWhenApprove((ProcessInstance)event.getEntity()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java deleted file mode 100644 index 8cb40412c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.bpm.service.task.BpmActivityService; -import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; -import com.google.common.collect.ImmutableSet; -import lombok.extern.slf4j.Slf4j; -import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent; -import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType; -import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener; -import org.flowable.engine.delegate.event.FlowableActivityCancelledEvent; -import org.flowable.engine.history.HistoricActivityInstance; -import org.flowable.task.api.Task; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Set; - -/** - * 监听 {@link Task} 的开始与完成 - * - * @author jason - */ -@Component -@Slf4j -public class BpmTaskEventListener extends AbstractFlowableEngineEventListener { - - @Resource - @Lazy // 解决循环依赖 - private BpmTaskService taskService; - @Resource - @Lazy // 解决循环依赖 - private BpmActivityService activityService; - - public static final Set TASK_EVENTS = ImmutableSet.builder() - .add(FlowableEngineEventType.TASK_CREATED) - .add(FlowableEngineEventType.TASK_ASSIGNED) -// .add(FlowableEngineEventType.TASK_COMPLETED) // 由于审批通过时,已经记录了 task 的 status 为通过,所以不需要监听了。 - .add(FlowableEngineEventType.ACTIVITY_CANCELLED) - .build(); - - public BpmTaskEventListener(){ - super(TASK_EVENTS); - } - - @Override - protected void taskCreated(FlowableEngineEntityEvent event) { - taskService.updateTaskStatusWhenCreated((Task) event.getEntity()); - } - - @Override - protected void taskAssigned(FlowableEngineEntityEvent event) { - taskService.updateTaskExtAssign((Task)event.getEntity()); - } - - @Override - protected void activityCancelled(FlowableActivityCancelledEvent event) { - List activityList = activityService.getHistoricActivityListByExecutionId(event.getExecutionId()); - if (CollUtil.isEmpty(activityList)) { - log.error("[activityCancelled][使用 executionId({}) 查找不到对应的活动实例]", event.getExecutionId()); - return; - } - // 遍历处理 - activityList.forEach(activity -> { - if (StrUtil.isEmpty(activity.getTaskId())) { - return; - } - taskService.updateTaskStatusWhenCanceled(activity.getTaskId()); - }); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoDelegateClassExecutionListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoDelegateClassExecutionListener.java deleted file mode 100644 index 0ce920e3f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoDelegateClassExecutionListener.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.exection; - -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.delegate.JavaDelegate; - -/** - * 类型为 class 的 ExecutionListener 监听器示例 - * - * @author 芋道源码 - */ -@Slf4j -public class DemoDelegateClassExecutionListener implements JavaDelegate { - - @Override - public void execute(DelegateExecution execution) { - log.info("[execute][execution({}) 被调用!变量有:{}]", execution.getId(), - execution.getCurrentFlowableListener().getFieldExtensions()); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoDelegateExpressionExecutionListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoDelegateExpressionExecutionListener.java deleted file mode 100644 index 00f3504ac..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoDelegateExpressionExecutionListener.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.exection; - -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.delegate.JavaDelegate; -import org.springframework.stereotype.Component; - -/** - * 类型为 delegateExpression 的 ExecutionListener 监听器示例 - * - * 和 {@link DemoDelegateClassExecutionListener} 的差异是,需要注册到 Spring 中 - */ -@Component -@Slf4j -public class DemoDelegateExpressionExecutionListener implements JavaDelegate { - - @Override - public void execute(DelegateExecution execution) { - log.info("[execute][execution({}) 被调用!变量有:{}]", execution.getId(), - execution.getCurrentFlowableListener().getFieldExtensions()); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoSpringExpressionExecutionListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoSpringExpressionExecutionListener.java deleted file mode 100644 index 949140fdf..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/exection/DemoSpringExpressionExecutionListener.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.exection; - -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.delegate.DelegateExecution; -import org.springframework.stereotype.Component; - -/** - * 类型为 expression 的 ExecutionListener 监听器示例 - * - * 和 {@link DemoDelegateClassExecutionListener} 的差异是,需要注册到 Spring 中,但不用实现 {@link org.flowable.engine.delegate.JavaDelegate} 接口 - */ -@Component -@Slf4j -public class DemoSpringExpressionExecutionListener { - - public void execute(DelegateExecution execution) { - log.info("[execute][execution({}) 被调用!变量有:{}]", execution.getId(), - execution.getCurrentFlowableListener().getFieldExtensions()); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoDelegateClassTaskListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoDelegateClassTaskListener.java deleted file mode 100644 index dee2b9587..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoDelegateClassTaskListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.task; - -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.delegate.TaskListener; -import org.flowable.task.service.delegate.DelegateTask; - -/** - * 类型为 class 的 TaskListener 监听器示例 - * - * @author 芋道源码 - */ -@Slf4j -public class DemoDelegateClassTaskListener implements TaskListener { - - @Override - public void notify(DelegateTask delegateTask) { - log.info("[execute][task({}) 被调用]", delegateTask.getId()); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoDelegateExpressionTaskListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoDelegateExpressionTaskListener.java deleted file mode 100644 index e554ff83f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoDelegateExpressionTaskListener.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.task; - -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.delegate.TaskListener; -import org.flowable.task.service.delegate.DelegateTask; -import org.springframework.stereotype.Component; - -/** - * 类型为 delegateExpression 的 TaskListener 监听器示例 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class DemoDelegateExpressionTaskListener implements TaskListener { - - @Override - public void notify(DelegateTask delegateTask) { - log.info("[execute][task({}) 被调用]", delegateTask.getId()); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoSpringExpressionTaskListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoSpringExpressionTaskListener.java deleted file mode 100644 index 0917abd57..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/demo/task/DemoSpringExpressionTaskListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.task; - -import lombok.extern.slf4j.Slf4j; -import org.flowable.task.service.delegate.DelegateTask; -import org.springframework.stereotype.Component; - -/** - * 类型为 expression 的 TaskListener 监听器示例 - * - * @author 芋道源码 - */ -@Slf4j -@Component -public class DemoSpringExpressionTaskListener { - - public void notify(DelegateTask delegateTask) { - log.info("[execute][task({}) 被调用]", delegateTask.getId()); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java deleted file mode 100644 index 3a812eb25..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java +++ /dev/null @@ -1,332 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.util; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; -import org.flowable.bpmn.converter.BpmnXMLConverter; -import org.flowable.bpmn.model.Process; -import org.flowable.bpmn.model.*; -import org.flowable.common.engine.impl.util.io.BytesStreamSource; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * 流程模型转操作工具类 - */ -public class BpmnModelUtils { - - public static Integer parseCandidateStrategy(FlowElement userTask) { - return NumberUtils.parseInt(userTask.getAttributeValue( - BpmnModelConstants.NAMESPACE, BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY)); - } - - public static String parseCandidateParam(FlowElement userTask) { - return userTask.getAttributeValue( - BpmnModelConstants.NAMESPACE, BpmnModelConstants.USER_TASK_CANDIDATE_PARAM); - } - - /** - * 根据节点,获取入口连线 - * - * @param source 起始节点 - * @return 入口连线列表 - */ - public static List getElementIncomingFlows(FlowElement source) { - if (source instanceof FlowNode) { - return ((FlowNode) source).getIncomingFlows(); - } - return new ArrayList<>(); - } - - /** - * 根据节点,获取出口连线 - * - * @param source 起始节点 - * @return 出口连线列表 - */ - public static List getElementOutgoingFlows(FlowElement source) { - if (source instanceof FlowNode) { - return ((FlowNode) source).getOutgoingFlows(); - } - return new ArrayList<>(); - } - - /** - * 获取流程元素信息 - * - * @param model bpmnModel 对象 - * @param flowElementId 元素 ID - * @return 元素信息 - */ - public static FlowElement getFlowElementById(BpmnModel model, String flowElementId) { - Process process = model.getMainProcess(); - return process.getFlowElement(flowElementId); - } - - /** - * 获得 BPMN 流程中,指定的元素们 - * - * @param model 模型 - * @param clazz 指定元素。例如说,{@link UserTask}、{@link Gateway} 等等 - * @return 元素们 - */ - public static List getBpmnModelElements(BpmnModel model, Class clazz) { - List result = new ArrayList<>(); - model.getProcesses().forEach(process -> { - process.getFlowElements().forEach(flowElement -> { - if (flowElement.getClass().isAssignableFrom(clazz)) { - result.add((T) flowElement); - } - }); - }); - return result; - } - - public static StartEvent getStartEvent(BpmnModel model) { - Process process = model.getMainProcess(); - // 从 initialFlowElement 找 - FlowElement startElement = process.getInitialFlowElement(); - if (startElement instanceof StartEvent) { - return (StartEvent) startElement; - } - // 从 flowElementList 找 - return (StartEvent) CollUtil.findOne(process.getFlowElements(), flowElement -> flowElement instanceof StartEvent); - } - - public static BpmnModel getBpmnModel(byte[] bpmnBytes) { - if (ArrayUtil.isEmpty(bpmnBytes)) { - return null; - } - BpmnXMLConverter converter = new BpmnXMLConverter(); - // 补充说明:由于在 Flowable 中自定义了属性,所以 validateSchema 传递 false - return converter.convertToBpmnModel(new BytesStreamSource(bpmnBytes), false, false); - } - - public static String getBpmnXml(BpmnModel model) { - if (model == null) { - return null; - } - BpmnXMLConverter converter = new BpmnXMLConverter(); - return new String(converter.convertToXML(model)); - } - - // ========== 遍历相关的方法 ========== - - /** - * 找到 source 节点之前的所有用户任务节点 - * - * @param source 起始节点 - * @param hasSequenceFlow 已经经过的连线的 ID,用于判断线路是否重复 - * @param userTaskList 已找到的用户任务节点 - * @return 用户任务节点 数组 - */ - public static List getPreviousUserTaskList(FlowElement source, Set hasSequenceFlow, List userTaskList) { - userTaskList = userTaskList == null ? new ArrayList<>() : userTaskList; - hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; - // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 - if (source instanceof StartEvent && source.getSubProcess() != null) { - userTaskList = getPreviousUserTaskList(source.getSubProcess(), hasSequenceFlow, userTaskList); - } - - // 根据类型,获取入口连线 - List sequenceFlows = getElementIncomingFlows(source); - if (sequenceFlows == null) { - return userTaskList; - } - // 循环找到目标元素 - for (SequenceFlow sequenceFlow : sequenceFlows) { - // 如果发现连线重复,说明循环了,跳过这个循环 - if (hasSequenceFlow.contains(sequenceFlow.getId())) { - continue; - } - // 添加已经走过的连线 - hasSequenceFlow.add(sequenceFlow.getId()); - // 类型为用户节点,则新增父级节点 - if (sequenceFlow.getSourceFlowElement() instanceof UserTask) { - userTaskList.add((UserTask) sequenceFlow.getSourceFlowElement()); - } - // 类型为子流程,则添加子流程开始节点出口处相连的节点 - if (sequenceFlow.getSourceFlowElement() instanceof SubProcess) { - // 获取子流程用户任务节点 - List childUserTaskList = findChildProcessUserTaskList((StartEvent) ((SubProcess) sequenceFlow.getSourceFlowElement()).getFlowElements().toArray()[0], null, null); - // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 - if (CollUtil.isNotEmpty(childUserTaskList)) { - userTaskList.addAll(childUserTaskList); - } - } - // 继续迭代 - userTaskList = getPreviousUserTaskList(sequenceFlow.getSourceFlowElement(), hasSequenceFlow, userTaskList); - } - return userTaskList; - } - - /** - * 迭代获取子流程用户任务节点 - * - * @param source 起始节点 - * @param hasSequenceFlow 已经经过的连线的 ID,用于判断线路是否重复 - * @param userTaskList 需要撤回的用户任务列表 - * @return 用户任务节点 - */ - public static List findChildProcessUserTaskList(FlowElement source, Set hasSequenceFlow, List userTaskList) { - hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; - userTaskList = userTaskList == null ? new ArrayList<>() : userTaskList; - - // 根据类型,获取出口连线 - List sequenceFlows = getElementOutgoingFlows(source); - if (sequenceFlows == null) { - return userTaskList; - } - // 循环找到目标元素 - for (SequenceFlow sequenceFlow : sequenceFlows) { - // 如果发现连线重复,说明循环了,跳过这个循环 - if (hasSequenceFlow.contains(sequenceFlow.getId())) { - continue; - } - // 添加已经走过的连线 - hasSequenceFlow.add(sequenceFlow.getId()); - // 如果为用户任务类型,且任务节点的 Key 正在运行的任务中存在,添加 - if (sequenceFlow.getTargetFlowElement() instanceof UserTask) { - userTaskList.add((UserTask) sequenceFlow.getTargetFlowElement()); - continue; - } - // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 - if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { - List childUserTaskList = findChildProcessUserTaskList((FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), hasSequenceFlow, null); - // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 - if (CollUtil.isNotEmpty(childUserTaskList)) { - userTaskList.addAll(childUserTaskList); - continue; - } - } - // 继续迭代 - userTaskList = findChildProcessUserTaskList(sequenceFlow.getTargetFlowElement(), hasSequenceFlow, userTaskList); - } - return userTaskList; - } - - - /** - * 迭代从后向前扫描,判断目标节点相对于当前节点是否是串行 - * 不存在直接回退到子流程中的情况,但存在从子流程出去到父流程情况 - * - * @param source 起始节点 - * @param target 目标节点 - * @param visitedElements 已经经过的连线的 ID,用于判断线路是否重复 - * @return 结果 - */ - public static boolean isSequentialReachable(FlowElement source, FlowElement target, Set visitedElements) { - visitedElements = visitedElements == null ? new HashSet<>() : visitedElements; - // 不能是开始事件和子流程 - if (source instanceof StartEvent && isInEventSubprocess(source)) { - return false; - } - - // 根据类型,获取入口连线 - List sequenceFlows = getElementIncomingFlows(source); - if (CollUtil.isEmpty(sequenceFlows)) { - return true; - } - // 循环找到目标元素 - for (SequenceFlow sequenceFlow : sequenceFlows) { - // 如果发现连线重复,说明循环了,跳过这个循环 - if (visitedElements.contains(sequenceFlow.getId())) { - continue; - } - // 添加已经走过的连线 - visitedElements.add(sequenceFlow.getId()); - // 这条线路存在目标节点,这条线路完成,进入下个线路 - FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement(); - if (target.getId().equals(sourceFlowElement.getId())) { - continue; - } - // 如果目标节点为并行网关,则不继续 - if (sourceFlowElement instanceof ParallelGateway) { - return false; - } - // 否则就继续迭代 - if (!isSequentialReachable(sourceFlowElement, target, visitedElements)) { - return false; - } - } - return true; - } - - /** - * 判断当前节点是否属于不同的子流程 - * - * @param flowElement 被判断的节点 - * @return true 表示属于子流程 - */ - private static boolean isInEventSubprocess(FlowElement flowElement) { - FlowElementsContainer flowElementsContainer = flowElement.getParentContainer(); - while (flowElementsContainer != null) { - if (flowElementsContainer instanceof EventSubProcess) { - return true; - } - - if (flowElementsContainer instanceof FlowElement) { - flowElementsContainer = ((FlowElement) flowElementsContainer).getParentContainer(); - } else { - flowElementsContainer = null; - } - } - return false; - } - - /** - * 根据正在运行的任务节点,迭代获取子级任务节点列表,向后找 - * - * @param source 起始节点 - * @param runTaskKeyList 正在运行的任务 Key,用于校验任务节点是否是正在运行的节点 - * @param hasSequenceFlow 已经经过的连线的 ID,用于判断线路是否重复 - * @param userTaskList 需要撤回的用户任务列表 - * @return 子级任务节点列表 - */ - public static List iteratorFindChildUserTasks(FlowElement source, List runTaskKeyList, - Set hasSequenceFlow, List userTaskList) { - hasSequenceFlow = hasSequenceFlow == null ? new HashSet<>() : hasSequenceFlow; - userTaskList = userTaskList == null ? new ArrayList<>() : userTaskList; - // 如果该节点为开始节点,且存在上级子节点,则顺着上级子节点继续迭代 - if (source instanceof StartEvent && source.getSubProcess() != null) { - userTaskList = iteratorFindChildUserTasks(source.getSubProcess(), runTaskKeyList, hasSequenceFlow, userTaskList); - } - - // 根据类型,获取出口连线 - List sequenceFlows = getElementOutgoingFlows(source); - if (sequenceFlows == null) { - return userTaskList; - } - // 循环找到目标元素 - for (SequenceFlow sequenceFlow : sequenceFlows) { - // 如果发现连线重复,说明循环了,跳过这个循环 - if (hasSequenceFlow.contains(sequenceFlow.getId())) { - continue; - } - // 添加已经走过的连线 - hasSequenceFlow.add(sequenceFlow.getId()); - // 如果为用户任务类型,且任务节点的 Key 正在运行的任务中存在,添加 - if (sequenceFlow.getTargetFlowElement() instanceof UserTask && runTaskKeyList.contains((sequenceFlow.getTargetFlowElement()).getId())) { - userTaskList.add((UserTask) sequenceFlow.getTargetFlowElement()); - continue; - } - // 如果节点为子流程节点情况,则从节点中的第一个节点开始获取 - if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) { - List childUserTaskList = iteratorFindChildUserTasks((FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements().toArray()[0]), runTaskKeyList, hasSequenceFlow, null); - // 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续 - if (CollUtil.isNotEmpty(childUserTaskList)) { - userTaskList.addAll(childUserTaskList); - continue; - } - } - // 继续迭代 - userTaskList = iteratorFindChildUserTasks(sequenceFlow.getTargetFlowElement(), runTaskKeyList, hasSequenceFlow, userTaskList); - } - return userTaskList; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/FlowableUtils.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/FlowableUtils.java deleted file mode 100644 index a8ee4e7f9..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/FlowableUtils.java +++ /dev/null @@ -1,180 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.util; - -import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants; -import org.flowable.common.engine.api.delegate.Expression; -import org.flowable.common.engine.api.variable.VariableContainer; -import org.flowable.common.engine.impl.el.ExpressionManager; -import org.flowable.common.engine.impl.identity.Authentication; -import org.flowable.engine.ProcessEngineConfiguration; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.util.CommandContextUtil; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.TaskInfo; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Flowable 相关的工具方法 - * - * @author 芋道源码 - */ -public class FlowableUtils { - - // ========== User 相关的工具方法 ========== - - public static void setAuthenticatedUserId(Long userId) { - Authentication.setAuthenticatedUserId(String.valueOf(userId)); - } - - public static void clearAuthenticatedUserId() { - Authentication.setAuthenticatedUserId(null); - } - - public static String getTenantId() { - Long tenantId = TenantContextHolder.getTenantId(); - return tenantId != null ? String.valueOf(tenantId) : ProcessEngineConfiguration.NO_TENANT_ID; - } - - // ========== Execution 相关的工具方法 ========== - - /** - * 格式化多实例(并签、或签)的 collectionVariable 变量(多实例对应的多审批人列表) - * - * @param activityId 活动编号 - * @return collectionVariable 变量 - */ - public static String formatExecutionCollectionVariable(String activityId) { - return activityId + "_assignees"; - } - - /** - * 格式化多实例(并签、或签)的 collectionElementVariable 变量(当前实例对应的一个审批人) - * - * @param activityId 活动编号 - * @return collectionElementVariable 变量 - */ - public static String formatExecutionCollectionElementVariable(String activityId) { - return activityId + "_assignee"; - } - - // ========== ProcessInstance 相关的工具方法 ========== - - public static Integer getProcessInstanceStatus(ProcessInstance processInstance) { - return getProcessInstanceStatus(processInstance.getProcessVariables()); - } - - public static Integer getProcessInstanceStatus(HistoricProcessInstance processInstance) { - return getProcessInstanceStatus(processInstance.getProcessVariables()); - } - - /** - * 获得流程实例的状态 - * - * @param processVariables 流程实例的 variables - * @return 状态 - */ - private static Integer getProcessInstanceStatus(Map processVariables) { - return (Integer) processVariables.get(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS); - } - - /** - * 获得流程实例的表单 - * - * @param processInstance 流程实例 - * @return 表单 - */ - public static Map getProcessInstanceFormVariable(HistoricProcessInstance processInstance) { - Map formVariables = new HashMap<>(processInstance.getProcessVariables()); - filterProcessInstanceFormVariable(formVariables); - return formVariables; - } - - /** - * 过滤流程实例的表单 - * - * 为什么要过滤?目前使用 processVariables 存储所有流程实例的拓展字段,需要过滤掉一部分的系统字段,从而实现表单的展示 - * - * @param processVariables 流程实例的 variables - * @return 过滤后的表单 - */ - public static Map filterProcessInstanceFormVariable(Map processVariables) { - processVariables.remove(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS); - return processVariables; - } - - /** - * 获得流程实例的发起用户选择的审批人 Map - * - * @param processInstance 流程实例 - * @return 发起用户选择的审批人 Map - */ - @SuppressWarnings("unchecked") - public static Map> getStartUserSelectAssignees(ProcessInstance processInstance) { - return (Map>) processInstance.getProcessVariables().get( - BpmConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES); - } - - // ========== Task 相关的工具方法 ========== - - /** - * 获得任务的状态 - * - * @param task 任务 - * @return 状态 - */ - public static Integer getTaskStatus(TaskInfo task) { - return (Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS); - } - - /** - * 获得任务的审批原因 - * - * @param task 任务 - * @return 审批原因 - */ - public static String getTaskReason(TaskInfo task) { - return (String) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_REASON); - } - - /** - * 获得任务的表单 - * - * @param task 任务 - * @return 表单 - */ - public static Map getTaskFormVariable(TaskInfo task) { - Map formVariables = new HashMap<>(task.getTaskLocalVariables()); - filterTaskFormVariable(formVariables); - return formVariables; - } - - /** - * 过滤任务的表单 - * - * 为什么要过滤?目前使用 taskLocalVariables 存储所有任务的拓展字段,需要过滤掉一部分的系统字段,从而实现表单的展示 - * - * @param taskLocalVariables 任务的 taskLocalVariables - * @return 过滤后的表单 - */ - public static Map filterTaskFormVariable(Map taskLocalVariables) { - taskLocalVariables.remove(BpmConstants.TASK_VARIABLE_STATUS); - taskLocalVariables.remove(BpmConstants.TASK_VARIABLE_REASON); - return taskLocalVariables; - } - - // ========== Expression 相关的工具方法 ========== - - public static Object getExpressionValue(VariableContainer variableContainer, String expressionString) { - ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(); - assert processEngineConfiguration != null; - ExpressionManager expressionManager = processEngineConfiguration.getExpressionManager(); - assert expressionManager != null; - Expression expression = expressionManager.createExpression(expressionString); - return expression.getValue(variableContainer); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java deleted file mode 100644 index 52fdb7f93..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 bpm 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.bpm.framework; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/config/RpcConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index 6459263cb..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.rpc.config; - -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.PostApi; -import cn.iocoder.yudao.module.system.api.dict.DictDataApi; -import cn.iocoder.yudao.module.system.api.permission.RoleApi; -import cn.iocoder.yudao.module.system.api.sms.SmsSendApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {RoleApi.class, DeptApi.class, PostApi.class, AdminUserApi.class, SmsSendApi.class, DictDataApi.class}) -public class RpcConfiguration { -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/package-info.java deleted file mode 100644 index d34205cec..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.bpm.framework.rpc; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/security/config/SecurityConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 163886c65..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Bpm 模块的 Security 配置 - */ -@Configuration(proxyBeanMethods = false, value = "bpmSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("bpmAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // TODO 芋艿:这个每个项目都需要重复配置,得捉摸有没通用的方案 - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - } - - }; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/security/core/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/security/core/package-info.java deleted file mode 100644 index 6d9f5a508..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.bpm.framework.security.core; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/config/BpmWebConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/config/BpmWebConfiguration.java deleted file mode 100644 index aa730198a..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/config/BpmWebConfiguration.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.web.config; - -import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum; -import cn.iocoder.yudao.module.bpm.framework.web.core.FlowableWebFilter; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * bpm 模块的 web 组件的 Configuration - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -public class BpmWebConfiguration { - - /** - * 配置 Flowable Web 过滤器 - */ - @Bean - public FilterRegistrationBean flowableWebFilter() { - FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); - registrationBean.setFilter(new FlowableWebFilter()); - registrationBean.setOrder(WebFilterOrderEnum.FLOWABLE_FILTER); - return registrationBean; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/core/FlowableWebFilter.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/core/FlowableWebFilter.java deleted file mode 100644 index 37c95a9f7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/core/FlowableWebFilter.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.web.core; - -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import org.springframework.web.filter.OncePerRequestFilter; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Flowable Web 过滤器,将 userId 设置到 {@link org.flowable.common.engine.impl.identity.Authentication} 中 - * - * @author jason - */ -public class FlowableWebFilter extends OncePerRequestFilter { - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) - throws ServletException, IOException { - try { - // 设置工作流的用户 - Long userId = SecurityFrameworkUtils.getLoginUserId(); - if (userId != null) { - FlowableUtils.setAuthenticatedUserId(userId); - } - // 过滤 - chain.doFilter(request, response); - } finally { - // 清理 - FlowableUtils.clearAuthenticatedUserId(); - } - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/package-info.java deleted file mode 100644 index c01417081..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/web/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * bpm 模块的 web 配置 - */ -package cn.iocoder.yudao.module.bpm.framework.web; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java deleted file mode 100644 index 9d02824f6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能,基于 Flowable 6 版本实现。 - * 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等 - * - * bpm 解释:https://baike.baidu.com/item/BPM/1933 - * - * 1. Controller URL:以 /bpm/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 bpm_ 开头,方便在数据库中区分 - * - * 注意,由于 Bpm 模块下,容易和其它模块重名,所以类名都加载 Bpm 的前缀~ - */ -package cn.iocoder.yudao.module.bpm; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmCategoryService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmCategoryService.java deleted file mode 100644 index e267d3055..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmCategoryService.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategorySaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * BPM 流程分类 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmCategoryService { - - /** - * 创建流程分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCategory(@Valid BpmCategorySaveReqVO createReqVO); - - /** - * 更新流程分类 - * - * @param updateReqVO 更新信息 - */ - void updateCategory(@Valid BpmCategorySaveReqVO updateReqVO); - - /** - * 删除流程分类 - * - * @param id 编号 - */ - void deleteCategory(Long id); - - /** - * 获得流程分类 - * - * @param id 编号 - * @return BPM 流程分类 - */ - BpmCategoryDO getCategory(Long id); - - /** - * 获得流程分类分页 - * - * @param pageReqVO 分页查询 - * @return 流程分类分页 - */ - PageResult getCategoryPage(BpmCategoryPageReqVO pageReqVO); - - /** - * 获得流程分类 Map,基于指定编码 - * - * @param codes 编号数组 - * @return 流程分类 Map - */ - default Map getCategoryMap(Collection codes) { - return convertMap(getCategoryListByCode(codes), BpmCategoryDO::getCode); - } - - /** - * 获得流程分类列表,基于指定编码 - * - * @return 流程分类列表 - */ - List getCategoryListByCode(Collection codes); - - /** - * 获得流程分类列表,基于指定状态 - * - * @param status 状态 - * @return 流程分类列表 - */ - List getCategoryListByStatus(Integer status); - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmCategoryServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmCategoryServiceImpl.java deleted file mode 100644 index d76eb98e9..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmCategoryServiceImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategorySaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.category.BpmCategoryMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * BPM 流程分类 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BpmCategoryServiceImpl implements BpmCategoryService { - - @Resource - private BpmCategoryMapper bpmCategoryMapper; - - @Override - public Long createCategory(BpmCategorySaveReqVO createReqVO) { - // 校验唯一 - validateCategoryNameUnique(createReqVO); - validateCategoryCodeUnique(createReqVO); - // 插入 - BpmCategoryDO category = BeanUtils.toBean(createReqVO, BpmCategoryDO.class); - bpmCategoryMapper.insert(category); - return category.getId(); - } - - @Override - public void updateCategory(BpmCategorySaveReqVO updateReqVO) { - // 校验存在 - validateCategoryExists(updateReqVO.getId()); - validateCategoryNameUnique(updateReqVO); - validateCategoryCodeUnique(updateReqVO); - // 更新 - BpmCategoryDO updateObj = BeanUtils.toBean(updateReqVO, BpmCategoryDO.class); - bpmCategoryMapper.updateById(updateObj); - } - - private void validateCategoryNameUnique(BpmCategorySaveReqVO updateReqVO) { - BpmCategoryDO category = bpmCategoryMapper.selectByName(updateReqVO.getName()); - if (category == null - || ObjUtil.equal(category.getId(), updateReqVO.getId())) { - return; - } - throw exception(CATEGORY_NAME_DUPLICATE, updateReqVO.getName()); - } - - private void validateCategoryCodeUnique(BpmCategorySaveReqVO updateReqVO) { - BpmCategoryDO category = bpmCategoryMapper.selectByCode(updateReqVO.getCode()); - if (category == null - || ObjUtil.equal(category.getId(), updateReqVO.getId())) { - return; - } - throw exception(CATEGORY_CODE_DUPLICATE, updateReqVO.getCode()); - } - - @Override - public void deleteCategory(Long id) { - // 校验存在 - validateCategoryExists(id); - // 删除 - bpmCategoryMapper.deleteById(id); - } - - private void validateCategoryExists(Long id) { - if (bpmCategoryMapper.selectById(id) == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - } - - @Override - public BpmCategoryDO getCategory(Long id) { - return bpmCategoryMapper.selectById(id); - } - - @Override - public PageResult getCategoryPage(BpmCategoryPageReqVO pageReqVO) { - return bpmCategoryMapper.selectPage(pageReqVO); - } - - @Override - public List getCategoryListByCode(Collection codes) { - if (CollUtil.isEmpty(codes)) { - return Collections.emptyList(); - } - return bpmCategoryMapper.selectListByCode(codes); - } - - @Override - public List getCategoryListByStatus(Integer status) { - return bpmCategoryMapper.selectListByStatus(status); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java deleted file mode 100644 index cf421e190..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - - -/** - * 动态表单 Service 接口 - * - * @author @风里雾里 - */ -public interface BpmFormService { - - /** - * 创建动态表单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createForm(@Valid BpmFormSaveReqVO createReqVO); - - /** - * 更新动态表单 - * - * @param updateReqVO 更新信息 - */ - void updateForm(@Valid BpmFormSaveReqVO updateReqVO); - - /** - * 删除动态表单 - * - * @param id 编号 - */ - void deleteForm(Long id); - - /** - * 获得动态表单 - * - * @param id 编号 - * @return 动态表单 - */ - BpmFormDO getForm(Long id); - - /** - * 获得动态表单列表 - * - * @return 动态表单列表 - */ - List getFormList(); - - /** - * 获得动态表单列表 - * - * @param ids 编号 - * @return 动态表单列表 - */ - List getFormList(Collection ids); - - /** - * 获得动态表单 Map - * - * @param ids 编号 - * @return 动态表单 Map - */ - default Map getFormMap(Collection ids) { - return CollectionUtils.convertMap(this.getFormList(ids), BpmFormDO::getId); - } - - /** - * 获得动态表单分页 - * - * @param pageReqVO 分页查询 - * @return 动态表单分页 - */ - PageResult getFormPage(BpmFormPageReqVO pageReqVO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java deleted file mode 100644 index 51d022dac..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmFormMapper; -import cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmFormFieldRespDTO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; - -/** - * 动态表单 Service 实现类 - * - * @author 风里雾里 - */ -@Service -@Validated -public class BpmFormServiceImpl implements BpmFormService { - - @Resource - private BpmFormMapper formMapper; - - @Override - public Long createForm(BpmFormSaveReqVO createReqVO) { - this.validateFields(createReqVO.getFields()); - // 插入 - BpmFormDO form = BeanUtils.toBean(createReqVO, BpmFormDO.class); - formMapper.insert(form); - // 返回 - return form.getId(); - } - - @Override - public void updateForm(BpmFormSaveReqVO updateReqVO) { - validateFields(updateReqVO.getFields()); - // 校验存在 - validateFormExists(updateReqVO.getId()); - // 更新 - BpmFormDO updateObj = BeanUtils.toBean(updateReqVO, BpmFormDO.class); - formMapper.updateById(updateObj); - } - - @Override - public void deleteForm(Long id) { - // 校验存在 - this.validateFormExists(id); - // 删除 - formMapper.deleteById(id); - } - - private void validateFormExists(Long id) { - if (formMapper.selectById(id) == null) { - throw exception(ErrorCodeConstants.FORM_NOT_EXISTS); - } - } - - @Override - public BpmFormDO getForm(Long id) { - return formMapper.selectById(id); - } - - @Override - public List getFormList() { - return formMapper.selectList(); - } - - @Override - public List getFormList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return formMapper.selectBatchIds(ids); - } - - @Override - public PageResult getFormPage(BpmFormPageReqVO pageReqVO) { - return formMapper.selectPage(pageReqVO); - } - - /** - * 校验 Field,避免 field 重复 - * - * @param fields field 数组 - */ - private void validateFields(List fields) { - if (true) { // TODO 芋艿:兼容 Vue3 工作流:因为采用了新的表单设计器,所以暂时不校验 - return; - } - Map fieldMap = new HashMap<>(); // key 是 vModel,value 是 label - for (String field : fields) { - BpmFormFieldRespDTO fieldDTO = JsonUtils.parseObject(field, BpmFormFieldRespDTO.class); - Assert.notNull(fieldDTO); - String oldLabel = fieldMap.put(fieldDTO.getVModel(), fieldDTO.getLabel()); - // 如果不存在,则直接返回 - if (oldLabel == null) { - continue; - } - // 如果存在,则报错 - throw exception(ErrorCodeConstants.FORM_FIELD_REPEAT, oldLabel, fieldDTO.getLabel(), fieldDTO.getVModel()); - } - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java deleted file mode 100644 index ef50bf7f8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelUpdateReqVO; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.engine.repository.Model; - -import javax.validation.Valid; - -/** - * Flowable流程模型接口 - * - * @author yunlongn - */ -public interface BpmModelService { - - /** - * 获得流程模型分页 - * - * @param pageVO 分页查询 - * @return 流程模型分页 - */ - PageResult getModelPage(BpmModelPageReqVO pageVO); - - /** - * 创建流程模型 - * - * @param modelVO 创建信息 - * @param bpmnXml BPMN XML - * @return 创建的流程模型的编号 - */ - String createModel(@Valid BpmModelCreateReqVO modelVO, String bpmnXml); - - /** - * 获得流程模块 - * - * @param id 编号 - * @return 流程模型 - */ - Model getModel(String id); - - /** - * 获得流程模型的 BPMN XML - * - * @param id 编号 - * @return BPMN XML - */ - byte[] getModelBpmnXML(String id); - - /** - * 修改流程模型 - * - * @param updateReqVO 更新信息 - */ - void updateModel(@Valid BpmModelUpdateReqVO updateReqVO); - - /** - * 将流程模型,部署成一个流程定义 - * - * @param id 编号 - */ - void deployModel(String id); - - /** - * 删除模型 - * - * @param id 编号 - */ - void deleteModel(String id); - - /** - * 修改模型的状态,实际更新的部署的流程定义的状态 - * - * @param id 编号 - * @param state 状态 - */ - void updateModelState(String id, Integer state); - - /** - * 获得流程定义编号对应的 BPMN Model - * - * @param processDefinitionId 流程定义编号 - * @return BPMN Model - */ - BpmnModel getBpmnModelByDefinitionId(String processDefinitionId); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java deleted file mode 100644 index 0f20f66c8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java +++ /dev/null @@ -1,278 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelUpdateReqVO; -import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.StartEvent; -import org.flowable.bpmn.model.UserTask; -import org.flowable.common.engine.impl.db.SuspensionState; -import org.flowable.engine.RepositoryService; -import org.flowable.engine.repository.Model; -import org.flowable.engine.repository.ModelQuery; -import org.flowable.engine.repository.ProcessDefinition; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.ObjectUtils; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * Flowable流程模型实现 - * 主要进行 Flowable {@link Model} 的维护 - * - * @author yunlongn - * @author 芋道源码 - * @author jason - */ -@Service -@Validated -@Slf4j -public class BpmModelServiceImpl implements BpmModelService { - - @Resource - private RepositoryService repositoryService; - @Resource - private BpmProcessDefinitionService processDefinitionService; - @Resource - private BpmFormService bpmFormService; - - @Resource - private BpmTaskCandidateInvoker taskCandidateInvoker; - - @Override - public PageResult getModelPage(BpmModelPageReqVO pageVO) { - ModelQuery modelQuery = repositoryService.createModelQuery(); - if (StrUtil.isNotBlank(pageVO.getKey())) { - modelQuery.modelKey(pageVO.getKey()); - } - if (StrUtil.isNotBlank(pageVO.getName())) { - modelQuery.modelNameLike("%" + pageVO.getName() + "%"); // 模糊匹配 - } - if (StrUtil.isNotBlank(pageVO.getCategory())) { - modelQuery.modelCategory(pageVO.getCategory()); - } - // 执行查询 - long count = modelQuery.count(); - if (count == 0) { - return PageResult.empty(count); - } - List models = modelQuery - .modelTenantId(FlowableUtils.getTenantId()) - .orderByCreateTime().desc() - .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - return new PageResult<>(models, count); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public String createModel(@Valid BpmModelCreateReqVO createReqVO, String bpmnXml) { - if (!ValidationUtils.isXmlNCName(createReqVO.getKey())) { - throw exception(MODEL_KEY_VALID); - } - // 校验流程标识已经存在 - Model keyModel = getModelByKey(createReqVO.getKey()); - if (keyModel != null) { - throw exception(MODEL_KEY_EXISTS, createReqVO.getKey()); - } - - // 创建流程定义 - Model model = repositoryService.newModel(); - BpmModelConvert.INSTANCE.copyToCreateModel(model, createReqVO); - model.setTenantId(FlowableUtils.getTenantId()); - // 保存流程定义 - repositoryService.saveModel(model); - // 保存 BPMN XML - saveModelBpmnXml(model, bpmnXml); - return model.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 - public void updateModel(@Valid BpmModelUpdateReqVO updateReqVO) { - // 校验流程模型存在 - Model model = getModel(updateReqVO.getId()); - if (model == null) { - throw exception(MODEL_NOT_EXISTS); - } - - // 修改流程定义 - BpmModelConvert.INSTANCE.copyToUpdateModel(model, updateReqVO); - // 更新模型 - repositoryService.saveModel(model); - // 更新 BPMN XML - saveModelBpmnXml(model, updateReqVO.getBpmnXml()); - } - - @Override - @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 - public void deployModel(String id) { - // 1.1 校验流程模型存在 - Model model = getModel(id); - if (ObjectUtils.isEmpty(model)) { - throw exception(MODEL_NOT_EXISTS); - } - // 1.2 校验流程图 - byte[] bpmnBytes = getModelBpmnXML(model.getId()); - validateBpmnXml(bpmnBytes); - // 1.3 校验表单已配 - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); - BpmFormDO form = validateFormConfig(metaInfo); - // 1.4 校验任务分配规则已配置 - taskCandidateInvoker.validateBpmnConfig(bpmnBytes); - - // 2.1 创建流程定义 - String definitionId = processDefinitionService.createProcessDefinition(model, metaInfo, bpmnBytes, form); - - // 2.2 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。 - updateProcessDefinitionSuspended(model.getDeploymentId()); - - // 2.3 更新 model 的 deploymentId,进行关联 - ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId); - model.setDeploymentId(definition.getDeploymentId()); - repositoryService.saveModel(model); - } - - private void validateBpmnXml(byte[] bpmnBytes) { - BpmnModel bpmnModel = BpmnModelUtils.getBpmnModel(bpmnBytes); - if (bpmnModel == null) { - throw exception(MODEL_NOT_EXISTS); - } - // 1. 没有 StartEvent - StartEvent startEvent = BpmnModelUtils.getStartEvent(bpmnModel); - if (startEvent == null) { - throw exception(MODEL_DEPLOY_FAIL_BPMN_START_EVENT_NOT_EXISTS); - } - // 2. 校验 UserTask 的 name 都配置了 - List userTasks = BpmnModelUtils.getBpmnModelElements(bpmnModel, UserTask.class); - userTasks.forEach(userTask -> { - if (StrUtil.isEmpty(userTask.getName())) { - throw exception(MODEL_DEPLOY_FAIL_BPMN_USER_TASK_NAME_NOT_EXISTS, userTask.getId()); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteModel(String id) { - // 校验流程模型存在 - Model model = getModel(id); - if (model == null) { - throw exception(MODEL_NOT_EXISTS); - } - // 执行删除 - repositoryService.deleteModel(id); - // 禁用流程定义 - updateProcessDefinitionSuspended(model.getDeploymentId()); - } - - @Override - public void updateModelState(String id, Integer state) { - // 1.1 校验流程模型存在 - Model model = getModel(id); - if (model == null) { - throw exception(MODEL_NOT_EXISTS); - } - // 1.2 校验流程定义存在 - ProcessDefinition definition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId()); - if (definition == null) { - throw exception(PROCESS_DEFINITION_NOT_EXISTS); - } - - // 2. 更新状态 - processDefinitionService.updateProcessDefinitionState(definition.getId(), state); - } - - @Override - public BpmnModel getBpmnModelByDefinitionId(String processDefinitionId) { - return repositoryService.getBpmnModel(processDefinitionId); - } - - /** - * 校验流程表单已配置 - * - * @param metaInfo 流程模型元数据 - * @return 表单配置 - */ - private BpmFormDO validateFormConfig(BpmModelMetaInfoRespDTO metaInfo) { - if (metaInfo == null || metaInfo.getFormType() == null) { - throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG); - } - // 校验表单存在 - if (Objects.equals(metaInfo.getFormType(), BpmModelFormTypeEnum.NORMAL.getType())) { - if (metaInfo.getFormId() == null) { - throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG); - } - BpmFormDO form = bpmFormService.getForm(metaInfo.getFormId()); - if (form == null) { - throw exception(FORM_NOT_EXISTS); - } - return form; - } else { - if (StrUtil.isEmpty(metaInfo.getFormCustomCreatePath()) || StrUtil.isEmpty(metaInfo.getFormCustomViewPath())) { - throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG); - } - return null; - } - } - - private void saveModelBpmnXml(Model model, String bpmnXml) { - if (StrUtil.isEmpty(bpmnXml)) { - return; - } - repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(bpmnXml)); - } - - /** - * 挂起 deploymentId 对应的流程定义 - * - * 注意:这里一个 deploymentId 只关联一个流程定义 - * - * @param deploymentId 流程发布Id - */ - private void updateProcessDefinitionSuspended(String deploymentId) { - if (StrUtil.isEmpty(deploymentId)) { - return; - } - ProcessDefinition oldDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(deploymentId); - if (oldDefinition == null) { - return; - } - processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode()); - } - - private Model getModelByKey(String key) { - return repositoryService.createModelQuery().modelKey(key).singleResult(); - } - - @Override - public Model getModel(String id) { - return repositoryService.getModel(id); - } - - @Override - public byte[] getModelBpmnXML(String id) { - return repositoryService.getModelEditorSource(id); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java deleted file mode 100644 index 5e2e2f805..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java +++ /dev/null @@ -1,162 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.Model; -import org.flowable.engine.repository.ProcessDefinition; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * Flowable流程定义接口 - * - * @author yunlong.li - * @author ZJQ - * @author 芋道源码 - */ -public interface BpmProcessDefinitionService { - - /** - * 获得流程定义分页 - * - * @param pageReqVO 分页入参 - * @return 流程定义 Page - */ - PageResult getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO); - - /** - * 获得流程定义列表 - * - * @param suspensionState 中断状态 - * @return 流程定义列表 - */ - List getProcessDefinitionListBySuspensionState(Integer suspensionState); - - /** - * 基于流程模型,创建流程定义 - * - * @param model 流程模型 - * @param modelMetaInfo 流程模型元信息 - * @param bpmnBytes BPMN XML 字节数组 - * @param form 表单 - * @return 流程编号 - */ - String createProcessDefinition(Model model, BpmModelMetaInfoRespDTO modelMetaInfo, byte[] bpmnBytes, BpmFormDO form); - - /** - * 更新流程定义状态 - * - * @param id 流程定义的编号 - * @param state 状态 - */ - void updateProcessDefinitionState(String id, Integer state); - - /** - * 获得流程定义对应的 BPMN - * - * @param id 流程定义编号 - * @return BPMN - */ - BpmnModel getProcessDefinitionBpmnModel(String id); - - /** - * 获得流程定义的信息 - * - * @param id 流程定义编号 - * @return 流程定义信息 - */ - BpmProcessDefinitionInfoDO getProcessDefinitionInfo(String id); - - /** - * 获得流程定义的信息 List - * - * @param ids 流程定义编号数组 - * @return 流程额定义信息数组 - */ - List getProcessDefinitionInfoList(Collection ids); - - default Map getProcessDefinitionInfoMap(Set ids) { - return convertMap(getProcessDefinitionInfoList(ids), BpmProcessDefinitionInfoDO::getProcessDefinitionId); - } - - /** - * 获得流程定义编号对应的 ProcessDefinition - * - * @param id 流程定义编号 - * @return 流程定义 - */ - ProcessDefinition getProcessDefinition(String id); - - /** - * 获得 ids 对应的 ProcessDefinition 数组 - * - * @param ids 编号的数组 - * @return 流程定义的数组 - */ - List getProcessDefinitionList(Set ids); - - default Map getProcessDefinitionMap(Set ids) { - return convertMap(getProcessDefinitionList(ids), ProcessDefinition::getId); - } - - /** - * 获得 deploymentId 对应的 ProcessDefinition - * - * @param deploymentId 部署编号 - * @return 流程定义 - */ - ProcessDefinition getProcessDefinitionByDeploymentId(String deploymentId); - - /** - * 获得 deploymentIds 对应的 ProcessDefinition 数组 - * - * @param deploymentIds 部署编号的数组 - * @return 流程定义的数组 - */ - List getProcessDefinitionListByDeploymentIds(Set deploymentIds); - - /** - * 获得流程定义标识对应的激活的流程定义 - * - * @param key 流程定义的标识 - * @return 流程定义 - */ - ProcessDefinition getActiveProcessDefinition(String key); - - /** - * 获得 ids 对应的 Deployment Map - * - * @param ids 部署编号的数组 - * @return 流程部署 Map - */ - default Map getDeploymentMap(Set ids) { - return convertMap(getDeploymentList(ids), Deployment::getId); - } - - /** - * 获得 ids 对应的 Deployment 数组 - * - * @param ids 部署编号的数组 - * @return 流程部署的数组 - */ - List getDeploymentList(Set ids); - - /** - * 获得 id 对应的 Deployment - * - * @param id 部署编号 - * @return 流程部署 - */ - Deployment getDeployment(String id); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java deleted file mode 100644 index fcfc805ce..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java +++ /dev/null @@ -1,202 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionInfoMapper; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.common.engine.impl.db.SuspensionState; -import org.flowable.engine.RepositoryService; -import org.flowable.engine.repository.Deployment; -import org.flowable.engine.repository.Model; -import org.flowable.engine.repository.ProcessDefinition; -import org.flowable.engine.repository.ProcessDefinitionQuery; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.addIfNotNull; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_KEY_NOT_MATCH; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_NAME_NOT_MATCH; -import static java.util.Collections.emptyList; - -/** - * 流程定义实现 - * 主要进行 Flowable {@link ProcessDefinition} 和 {@link Deployment} 的维护 - * - * @author yunlongn - * @author ZJQ - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionService { - - @Resource - private RepositoryService repositoryService; - - @Resource - private BpmProcessDefinitionInfoMapper processDefinitionMapper; - - @Override - public ProcessDefinition getProcessDefinition(String id) { - return repositoryService.getProcessDefinition(id); - } - - @Override - public List getProcessDefinitionList(Set ids) { - return repositoryService.createProcessDefinitionQuery().processDefinitionIds(ids).list(); - } - - @Override - public ProcessDefinition getProcessDefinitionByDeploymentId(String deploymentId) { - if (StrUtil.isEmpty(deploymentId)) { - return null; - } - return repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult(); - } - - @Override - public List getProcessDefinitionListByDeploymentIds(Set deploymentIds) { - if (CollUtil.isEmpty(deploymentIds)) { - return emptyList(); - } - return repositoryService.createProcessDefinitionQuery().deploymentIds(deploymentIds).list(); - } - - @Override - public ProcessDefinition getActiveProcessDefinition(String key) { - return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).active().singleResult(); - } - - @Override - public List getDeploymentList(Set ids) { - if (CollUtil.isEmpty(ids)) { - return emptyList(); - } - List list = new ArrayList<>(ids.size()); - for (String id : ids) { - addIfNotNull(list, getDeployment(id)); - } - return list; - } - - @Override - public Deployment getDeployment(String id) { - if (StrUtil.isEmpty(id)) { - return null; - } - return repositoryService.createDeploymentQuery().deploymentId(id).singleResult(); - } - - @Override - public String createProcessDefinition(Model model, BpmModelMetaInfoRespDTO modelMetaInfo, - byte[] bpmnBytes, BpmFormDO form) { - // 创建 Deployment 部署 - Deployment deploy = repositoryService.createDeployment() - .key(model.getKey()).name(model.getName()).category(model.getCategory()) - .addBytes(model.getKey() + BpmnModelConstants.BPMN_FILE_SUFFIX, bpmnBytes) - .tenantId(FlowableUtils.getTenantId()) - .disableSchemaValidation() // 禁用 XML Schema 验证,因为有自定义的属性 - .deploy(); - - // 设置 ProcessDefinition 的 category 分类 - ProcessDefinition definition = repositoryService.createProcessDefinitionQuery() - .deploymentId(deploy.getId()).singleResult(); - repositoryService.setProcessDefinitionCategory(definition.getId(), model.getCategory()); - // 注意 1,ProcessDefinition 的 key 和 name 是通过 BPMN 中的 的 id 和 name 决定 - // 注意 2,目前该项目的设计上,需要保证 Model、Deployment、ProcessDefinition 使用相同的 key,保证关联性。 - // 否则,会导致 ProcessDefinition 的分页无法查询到。 - if (!Objects.equals(definition.getKey(), model.getKey())) { - throw exception(PROCESS_DEFINITION_KEY_NOT_MATCH, model.getKey(), definition.getKey()); - } - if (!Objects.equals(definition.getName(), model.getName())) { - throw exception(PROCESS_DEFINITION_NAME_NOT_MATCH, model.getName(), definition.getName()); - } - - // 插入拓展表 - BpmProcessDefinitionInfoDO definitionDO = BeanUtils.toBean(modelMetaInfo, BpmProcessDefinitionInfoDO.class) - .setModelId(model.getId()).setProcessDefinitionId(definition.getId()); - if (form != null) { - definitionDO.setFormFields(form.getFields()).setFormConf(form.getConf()); - } - processDefinitionMapper.insert(definitionDO); - return definition.getId(); - } - - @Override - public void updateProcessDefinitionState(String id, Integer state) { - // 激活 - if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), state)) { - repositoryService.activateProcessDefinitionById(id, false, null); - return; - } - // 挂起 - if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), state)) { - // suspendProcessInstances = false,进行中的任务,不进行挂起。 - // 原因:只要新的流程不允许发起即可,老流程继续可以执行。 - repositoryService.suspendProcessDefinitionById(id, false, null); - return; - } - log.error("[updateProcessDefinitionState][流程定义({}) 修改未知状态({})]", id, state); - } - - @Override - public BpmnModel getProcessDefinitionBpmnModel(String id) { - return repositoryService.getBpmnModel(id); - } - - @Override - public BpmProcessDefinitionInfoDO getProcessDefinitionInfo(String id) { - return processDefinitionMapper.selectByProcessDefinitionId(id); - } - - @Override - public List getProcessDefinitionInfoList(Collection ids) { - return processDefinitionMapper.selectListByProcessDefinitionIds(ids); - } - - @Override - public PageResult getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageVO) { - ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery(); - if (StrUtil.isNotBlank(pageVO.getKey())) { - query.processDefinitionKey(pageVO.getKey()); - } - // 执行查询 - long count = query.count(); - if (count == 0) { - return PageResult.empty(count); - } - List list = query.orderByProcessDefinitionVersion().desc() - .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - return new PageResult<>(list, count); - } - - @Override - public List getProcessDefinitionListBySuspensionState(Integer suspensionState) { - // 拼接查询条件 - ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery(); - if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), suspensionState)) { - query.suspended(); - } else if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), suspensionState)) { - query.active(); - } - // 执行查询 - query.processDefinitionTenantId(FlowableUtils.getTenantId()); - return query.list(); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessExpressionService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessExpressionService.java deleted file mode 100644 index 0d8a99e07..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessExpressionService.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessExpressionDO; - -import javax.validation.Valid; - -/** - * BPM 流程表达式 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmProcessExpressionService { - - /** - * 创建流程表达式 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProcessExpression(@Valid BpmProcessExpressionSaveReqVO createReqVO); - - /** - * 更新流程表达式 - * - * @param updateReqVO 更新信息 - */ - void updateProcessExpression(@Valid BpmProcessExpressionSaveReqVO updateReqVO); - - /** - * 删除流程表达式 - * - * @param id 编号 - */ - void deleteProcessExpression(Long id); - - /** - * 获得流程表达式 - * - * @param id 编号 - * @return 流程表达式 - */ - BpmProcessExpressionDO getProcessExpression(Long id); - - /** - * 获得流程表达式分页 - * - * @param pageReqVO 分页查询 - * @return 流程表达式分页 - */ - PageResult getProcessExpressionPage(BpmProcessExpressionPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessExpressionServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessExpressionServiceImpl.java deleted file mode 100644 index f379bfdf7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessExpressionServiceImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessExpressionDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessExpressionMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_EXPRESSION_NOT_EXISTS; - -/** - * BPM 流程表达式 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BpmProcessExpressionServiceImpl implements BpmProcessExpressionService { - - @Resource - private BpmProcessExpressionMapper processExpressionMapper; - - @Override - public Long createProcessExpression(BpmProcessExpressionSaveReqVO createReqVO) { - // 插入 - BpmProcessExpressionDO processExpression = BeanUtils.toBean(createReqVO, BpmProcessExpressionDO.class); - processExpressionMapper.insert(processExpression); - // 返回 - return processExpression.getId(); - } - - @Override - public void updateProcessExpression(BpmProcessExpressionSaveReqVO updateReqVO) { - // 校验存在 - validateProcessExpressionExists(updateReqVO.getId()); - // 更新 - BpmProcessExpressionDO updateObj = BeanUtils.toBean(updateReqVO, BpmProcessExpressionDO.class); - processExpressionMapper.updateById(updateObj); - } - - @Override - public void deleteProcessExpression(Long id) { - // 校验存在 - validateProcessExpressionExists(id); - // 删除 - processExpressionMapper.deleteById(id); - } - - private void validateProcessExpressionExists(Long id) { - if (processExpressionMapper.selectById(id) == null) { - throw exception(PROCESS_EXPRESSION_NOT_EXISTS); - } - } - - @Override - public BpmProcessExpressionDO getProcessExpression(Long id) { - return processExpressionMapper.selectById(id); - } - - @Override - public PageResult getProcessExpressionPage(BpmProcessExpressionPageReqVO pageReqVO) { - return processExpressionMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessListenerService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessListenerService.java deleted file mode 100644 index f9f1020e0..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessListenerService.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessListenerDO; - -import javax.validation.Valid; - -/** - * BPM 流程监听器 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmProcessListenerService { - - /** - * 创建流程监听器 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProcessListener(@Valid BpmProcessListenerSaveReqVO createReqVO); - - /** - * 更新流程监听器 - * - * @param updateReqVO 更新信息 - */ - void updateProcessListener(@Valid BpmProcessListenerSaveReqVO updateReqVO); - - /** - * 删除流程监听器 - * - * @param id 编号 - */ - void deleteProcessListener(Long id); - - /** - * 获得流程监听器 - * - * @param id 编号 - * @return 流程监听器 - */ - BpmProcessListenerDO getProcessListener(Long id); - - /** - * 获得流程监听器分页 - * - * @param pageReqVO 分页查询 - * @return 流程监听器分页 - */ - PageResult getProcessListenerPage(BpmProcessListenerPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessListenerServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessListenerServiceImpl.java deleted file mode 100644 index e5f47b90b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessListenerServiceImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessListenerDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessListenerMapper; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmProcessListenerType; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmProcessListenerValueType; -import org.flowable.engine.delegate.JavaDelegate; -import org.flowable.engine.delegate.TaskListener; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * BPM 流程监听器 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BpmProcessListenerServiceImpl implements BpmProcessListenerService { - - @Resource - private BpmProcessListenerMapper processListenerMapper; - - @Override - public Long createProcessListener(BpmProcessListenerSaveReqVO createReqVO) { - // 校验 - validateCreateProcessListenerValue(createReqVO); - // 插入 - BpmProcessListenerDO processListener = BeanUtils.toBean(createReqVO, BpmProcessListenerDO.class); - processListenerMapper.insert(processListener); - return processListener.getId(); - } - - @Override - public void updateProcessListener(BpmProcessListenerSaveReqVO updateReqVO) { - // 校验存在 - validateProcessListenerExists(updateReqVO.getId()); - validateCreateProcessListenerValue(updateReqVO); - // 更新 - BpmProcessListenerDO updateObj = BeanUtils.toBean(updateReqVO, BpmProcessListenerDO.class); - processListenerMapper.updateById(updateObj); - } - - private void validateCreateProcessListenerValue(BpmProcessListenerSaveReqVO createReqVO) { - // class 类型 - if (createReqVO.getValueType().equals(BpmProcessListenerValueType.CLASS.getType())) { - try { - Class clazz = Class.forName(createReqVO.getValue()); - if (createReqVO.getType().equals(BpmProcessListenerType.EXECUTION.getType()) - && !JavaDelegate.class.isAssignableFrom(clazz)) { - throw exception(PROCESS_LISTENER_CLASS_IMPLEMENTS_ERROR, createReqVO.getValue(), - JavaDelegate.class.getName()); - } else if (createReqVO.getType().equals(BpmProcessListenerType.TASK.getType()) - && !TaskListener.class.isAssignableFrom(clazz)) { - throw exception(PROCESS_LISTENER_CLASS_IMPLEMENTS_ERROR, createReqVO.getValue(), - TaskListener.class.getName()); - } - } catch (ClassNotFoundException e) { - throw exception(PROCESS_LISTENER_CLASS_NOT_FOUND, createReqVO.getValue()); - } - return; - } - // 表达式 - if (!StrUtil.startWith(createReqVO.getValue(), "${") || !StrUtil.endWith(createReqVO.getValue(), "}")) { - throw exception(PROCESS_LISTENER_EXPRESSION_INVALID, createReqVO.getValue()); - } - } - - @Override - public void deleteProcessListener(Long id) { - // 校验存在 - validateProcessListenerExists(id); - // 删除 - processListenerMapper.deleteById(id); - } - - private void validateProcessListenerExists(Long id) { - if (processListenerMapper.selectById(id) == null) { - throw exception(PROCESS_LISTENER_NOT_EXISTS); - } - } - - @Override - public BpmProcessListenerDO getProcessListener(Long id) { - return processListenerMapper.selectById(id); - } - - @Override - public PageResult getProcessListenerPage(BpmProcessListenerPageReqVO pageReqVO) { - return processListenerMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupService.java deleted file mode 100644 index 967f6e104..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupService.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 用户组 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmUserGroupService { - - /** - * 创建用户组 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createUserGroup(@Valid BpmUserGroupSaveReqVO createReqVO); - - /** - * 更新用户组 - * - * @param updateReqVO 更新信息 - */ - void updateUserGroup(@Valid BpmUserGroupSaveReqVO updateReqVO); - - /** - * 删除用户组 - * - * @param id 编号 - */ - void deleteUserGroup(Long id); - - /** - * 获得用户组 - * - * @param id 编号 - * @return 用户组 - */ - BpmUserGroupDO getUserGroup(Long id); - - /** - * 获得用户组列表 - * - * @param ids 编号 - * @return 用户组列表 - */ - List getUserGroupList(Collection ids); - - /** - * 获得指定状态的用户组列表 - * - * @param status 状态 - * @return 用户组列表 - */ - List getUserGroupListByStatus(Integer status); - - /** - * 获得用户组分页 - * - * @param pageReqVO 分页查询 - * @return 用户组分页 - */ - PageResult getUserGroupPage(BpmUserGroupPageReqVO pageReqVO); - - /** - * 校验用户组们是否有效。如下情况,视为无效: - * 1. 用户组编号不存在 - * 2. 用户组被禁用 - * - * @param ids 用户组编号数组 - */ - void validUserGroups(Collection ids); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceImpl.java deleted file mode 100644 index 3d60dea7c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmUserGroupMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.USER_GROUP_IS_DISABLE; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.USER_GROUP_NOT_EXISTS; - -/** - * 用户组 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BpmUserGroupServiceImpl implements BpmUserGroupService { - - @Resource - private BpmUserGroupMapper userGroupMapper; - - @Override - public Long createUserGroup(BpmUserGroupSaveReqVO createReqVO) { - BpmUserGroupDO userGroup = BeanUtils.toBean(createReqVO, BpmUserGroupDO.class); - userGroupMapper.insert(userGroup); - return userGroup.getId(); - } - - @Override - public void updateUserGroup(BpmUserGroupSaveReqVO updateReqVO) { - // 校验存在 - validateUserGroupExists(updateReqVO.getId()); - // 更新 - BpmUserGroupDO updateObj = BeanUtils.toBean(updateReqVO, BpmUserGroupDO.class); - userGroupMapper.updateById(updateObj); - } - - @Override - public void deleteUserGroup(Long id) { - // 校验存在 - this.validateUserGroupExists(id); - // 删除 - userGroupMapper.deleteById(id); - } - - private void validateUserGroupExists(Long id) { - if (userGroupMapper.selectById(id) == null) { - throw exception(USER_GROUP_NOT_EXISTS); - } - } - - @Override - public BpmUserGroupDO getUserGroup(Long id) { - return userGroupMapper.selectById(id); - } - - @Override - public List getUserGroupList(Collection ids) { - return userGroupMapper.selectBatchIds(ids); - } - - - @Override - public List getUserGroupListByStatus(Integer status) { - return userGroupMapper.selectListByStatus(status); - } - - @Override - public PageResult getUserGroupPage(BpmUserGroupPageReqVO pageReqVO) { - return userGroupMapper.selectPage(pageReqVO); - } - - @Override - public void validUserGroups(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return; - } - // 获得用户组信息 - List userGroups = userGroupMapper.selectBatchIds(ids); - Map userGroupMap = convertMap(userGroups, BpmUserGroupDO::getId); - // 校验 - ids.forEach(id -> { - BpmUserGroupDO userGroup = userGroupMap.get(id); - if (userGroup == null) { - throw exception(USER_GROUP_NOT_EXISTS); - } - if (!CommonStatusEnum.ENABLE.getStatus().equals(userGroup.getStatus())) { - throw exception(USER_GROUP_IS_DISABLE, userGroup.getName()); - } - }); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmFormFieldRespDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmFormFieldRespDTO.java deleted file mode 100644 index 1606192ce..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmFormFieldRespDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -/** - * Bpm 表单的 Field 表单项 Response DTO - * 字段的定义,可见 https://github.com/JakHuang/form-generator/issues/46 文档 - * - * @author 芋道源码 - */ -@Data -public class BpmFormFieldRespDTO { - - /** - * 表单标题 - */ - private String label; - /** - * 表单字段的属性名,可自定义 - */ - @JsonProperty(value = "vModel") - private String vModel; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java deleted file mode 100644 index 8ec9dc64b..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition.dto; - -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import lombok.Data; - -/** - * BPM 流程 MetaInfo Response DTO - * 主要用于 { Model#setMetaInfo(String)} 的存储 - * - * 最终,它的字段和 {@link cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO} 是一致的 - * - * @author 芋道源码 - */ -@Data -public class BpmModelMetaInfoRespDTO { - - /** - * 流程图标 - */ - private String icon; - /** - * 流程描述 - */ - private String description; - - /** - * 表单类型 - */ - private Integer formType; - /** - * 表单编号 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private Long formId; - /** - * 自定义表单的提交路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomCreatePath; - /** - * 自定义表单的查看路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomViewPath; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java deleted file mode 100644 index e7b84c998..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition.dto; - -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 流程定义创建 Request DTO - */ -@Data -public class BpmProcessDefinitionCreateReqDTO { - - // ========== 模型相关 ========== - - /** - * 流程模型的编号 - */ - @NotEmpty(message = "流程模型编号不能为空") - private String modelId; - /** - * 流程标识 - */ - @NotEmpty(message = "流程标识不能为空") - private String key; - /** - * 流程名称 - */ - @NotEmpty(message = "流程名称不能为空") - private String name; - /** - * 流程描述 - */ - private String description; - /** - * 流程分类 - */ - @NotEmpty(message = "流程分类不能为空") - private String category; - /** - * BPMN XML - */ - @NotEmpty(message = "BPMN XML 不能为空") - private byte[] bpmnBytes; - - // ========== 表单相关 ========== - - /** - * 表单类型 - */ - @NotNull(message = "表单类型不能为空") - private Integer formType; - /** - * 动态表单编号 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private Long formId; - /** - * 表单的配置 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private String formConf; - /** - * 表单项的数组 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private List formFields; - /** - * 自定义表单的提交路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomCreatePath; - /** - * 自定义表单的查看路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomViewPath; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageService.java deleted file mode 100644 index ff51ae306..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageService.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message; - -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; - -import javax.validation.Valid; - -/** - * BPM 消息 Service 接口 - * - * TODO 芋艿:未来支持消息的可配置;不同的流程,在什么场景下,需要发送什么消息,消息的内容是什么; - * - * @author 芋道源码 - */ -public interface BpmMessageService { - - /** - * 发送流程实例被通过的消息 - * - * @param reqDTO 发送信息 - */ - void sendMessageWhenProcessInstanceApprove(@Valid BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO); - - /** - * 发送流程实例被不通过的消息 - * - * @param reqDTO 发送信息 - */ - void sendMessageWhenProcessInstanceReject(@Valid BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO); - - /** - * 发送任务被分配的消息 - * - * @param reqDTO 发送信息 - */ - void sendMessageWhenTaskAssigned(@Valid BpmMessageSendWhenTaskCreatedReqDTO reqDTO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java deleted file mode 100644 index 032370158..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message; - -import cn.iocoder.yudao.framework.web.config.WebProperties; -import cn.iocoder.yudao.module.bpm.convert.message.BpmMessageConvert; -import cn.iocoder.yudao.module.bpm.enums.message.BpmMessageEnum; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO; -import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; -import cn.iocoder.yudao.module.system.api.sms.SmsSendApi; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - -/** - * BPM 消息 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class BpmMessageServiceImpl implements BpmMessageService { - - @Resource - private SmsSendApi smsSendApi; - - @Resource - private WebProperties webProperties; - - @Override - public void sendMessageWhenProcessInstanceApprove(BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), - BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams)); - } - - @Override - public void sendMessageWhenProcessInstanceReject(BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("reason", reqDTO.getReason()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), - BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams)); - } - - @Override - public void sendMessageWhenTaskAssigned(BpmMessageSendWhenTaskCreatedReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("taskName", reqDTO.getTaskName()); - templateParams.put("startUserNickname", reqDTO.getStartUserNickname()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getAssigneeUserId(), - BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams)); - } - - private String getProcessInstanceDetailUrl(String taskId) { - return webProperties.getAdminUi().getUrl() + "/bpm/process-instance/detail?id=" + taskId; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceApproveReqDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceApproveReqDTO.java deleted file mode 100644 index 7c37734f9..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceApproveReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message.dto; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * BPM 发送流程实例被通过 Request DTO - */ -@Data -public class BpmMessageSendWhenProcessInstanceApproveReqDTO { - - /** - * 流程实例的编号 - */ - @NotEmpty(message = "流程实例的编号不能为空") - private String processInstanceId; - /** - * 流程实例的名字 - */ - @NotEmpty(message = "流程实例的名字不能为空") - private String processInstanceName; - @NotNull(message = "发起人的用户编号") - private Long startUserId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceRejectReqDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceRejectReqDTO.java deleted file mode 100644 index 69a266b68..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceRejectReqDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message.dto; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * BPM 发送流程实例被不通过 Request DTO - */ -@Data -public class BpmMessageSendWhenProcessInstanceRejectReqDTO { - - /** - * 流程实例的编号 - */ - @NotEmpty(message = "流程实例的编号不能为空") - private String processInstanceId; - /** - * 流程实例的名字 - */ - @NotEmpty(message = "流程实例的名字不能为空") - private String processInstanceName; - @NotNull(message = "发起人的用户编号") - private Long startUserId; - - /** - * 不通过理由 - */ - @NotEmpty(message = "不通过理由不能为空") - private String reason; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenTaskCreatedReqDTO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenTaskCreatedReqDTO.java deleted file mode 100644 index 7cb0e3d70..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenTaskCreatedReqDTO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message.dto; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * BPM 发送任务被分配 Request DTO - */ -@Data -public class BpmMessageSendWhenTaskCreatedReqDTO { - - /** - * 流程实例的编号 - */ - @NotEmpty(message = "流程实例的编号不能为空") - private String processInstanceId; - /** - * 流程实例的名字 - */ - @NotEmpty(message = "流程实例的名字不能为空") - private String processInstanceName; - @NotNull(message = "发起人的用户编号") - private Long startUserId; - @NotEmpty(message = "发起人的昵称") - private String startUserNickname; - - /** - * 流程任务的编号 - */ - @NotEmpty(message = "流程任务的编号不能为空") - private String taskId; - /** - * 流程任务的名字 - */ - @NotEmpty(message = "流程任务的名字不能为空") - private String taskName; - - /** - * 审批人的用户编号 - */ - @NotNull(message = "审批人的用户编号不能为空") - private Long assigneeUserId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveService.java deleted file mode 100644 index b255e0888..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveService.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.oa; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; - -import javax.validation.Valid; - -/** - * 请假申请 Service 接口 - * - * @author jason - * @author 芋道源码 - */ -public interface BpmOALeaveService { - - /** - * 创建请假申请 - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createLeave(Long userId, @Valid BpmOALeaveCreateReqVO createReqVO); - - /** - * 更新请假申请的状态 - * - * @param id 编号 - * @param status 结果 - */ - void updateLeaveStatus(Long id, Integer status); - - /** - * 获得请假申请 - * - * @param id 编号 - * @return 请假申请 - */ - BpmOALeaveDO getLeave(Long id); - - /** - * 获得请假申请分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页查询 - * @return 请假申请分页 - */ - PageResult getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveServiceImpl.java deleted file mode 100644 index a8601e546..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveServiceImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.oa; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOALeaveMapper; -import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_LEAVE_NOT_EXISTS; - -/** - * OA 请假申请 Service 实现类 - * - * @author jason - * @author 芋道源码 - */ -@Service -@Validated -public class BpmOALeaveServiceImpl implements BpmOALeaveService { - - /** - * OA 请假对应的流程定义 KEY - */ - public static final String PROCESS_KEY = "oa_leave"; - - @Resource - private BpmOALeaveMapper leaveMapper; - - @Resource - private BpmProcessInstanceApi processInstanceApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createLeave(Long userId, BpmOALeaveCreateReqVO createReqVO) { - // 插入 OA 请假单 - long day = LocalDateTimeUtil.between(createReqVO.getStartTime(), createReqVO.getEndTime()).toDays(); - BpmOALeaveDO leave = BeanUtils.toBean(createReqVO, BpmOALeaveDO.class) - .setUserId(userId).setDay(day).setStatus(BpmTaskStatusEnum.RUNNING.getStatus()); - leaveMapper.insert(leave); - - // 发起 BPM 流程 - Map processInstanceVariables = new HashMap<>(); - processInstanceVariables.put("day", day); - String processInstanceId = processInstanceApi.createProcessInstance(userId, - new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY) - .setVariables(processInstanceVariables).setBusinessKey(String.valueOf(leave.getId())) - .setStartUserSelectAssignees(createReqVO.getStartUserSelectAssignees())).getCheckedData(); - - // 将工作流的编号,更新到 OA 请假单中 - leaveMapper.updateById(new BpmOALeaveDO().setId(leave.getId()).setProcessInstanceId(processInstanceId)); - return leave.getId(); - } - - @Override - public void updateLeaveStatus(Long id, Integer status) { - validateLeaveExists(id); - leaveMapper.updateById(new BpmOALeaveDO().setId(id).setStatus(status)); - } - - private void validateLeaveExists(Long id) { - if (leaveMapper.selectById(id) == null) { - throw exception(OA_LEAVE_NOT_EXISTS); - } - } - - @Override - public BpmOALeaveDO getLeave(Long id) { - return leaveMapper.selectById(id); - } - - @Override - public PageResult getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO) { - return leaveMapper.selectPage(userId, pageReqVO); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/listener/BpmOALeaveStatusListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/listener/BpmOALeaveStatusListener.java deleted file mode 100644 index 912479aaf..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/listener/BpmOALeaveStatusListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.oa.listener; - -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent; -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener; -import cn.iocoder.yudao.module.bpm.service.oa.BpmOALeaveService; -import cn.iocoder.yudao.module.bpm.service.oa.BpmOALeaveServiceImpl; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * OA 请假单的结果的监听器实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmOALeaveStatusListener extends BpmProcessInstanceStatusEventListener { - - @Resource - private BpmOALeaveService leaveService; - - @Override - protected String getProcessDefinitionKey() { - return BpmOALeaveServiceImpl.PROCESS_KEY; - } - - @Override - protected void onEvent(BpmProcessInstanceStatusEvent event) { - leaveService.updateLeaveStatus(Long.parseLong(event.getBusinessKey()), event.getStatus()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java deleted file mode 100644 index 4bed16413..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import org.flowable.engine.history.HistoricActivityInstance; - -import java.util.List; - -/** - * BPM 活动实例 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmActivityService { - - /** - * 获得指定流程实例的活动实例列表 - * - * @param processInstanceId 流程实例的编号 - * @return 活动实例列表 - */ - List getActivityListByProcessInstanceId(String processInstanceId); - - /** - * 获得执行编号对应的活动实例 - * - * @param executionId 执行编号 - * @return 活动实例 - */ - List getHistoricActivityListByExecutionId(String executionId); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java deleted file mode 100644 index c06445efa..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import cn.iocoder.yudao.module.bpm.convert.task.BpmActivityConvert; -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.HistoryService; -import org.flowable.engine.history.HistoricActivityInstance; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - - -/** - * BPM 活动实例 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Slf4j -@Validated -public class BpmActivityServiceImpl implements BpmActivityService { - - @Resource - private HistoryService historyService; - - @Override - public List getActivityListByProcessInstanceId(String processInstanceId) { - List activityList = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(processInstanceId).list(); - return BpmActivityConvert.INSTANCE.convertList(activityList); - } - - @Override - public List getHistoricActivityListByExecutionId(String executionId) { - return historyService.createHistoricActivityInstanceQuery().executionId(executionId).list(); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyService.java deleted file mode 100644 index bd84490e8..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyService.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; - -import java.util.Collection; - -/** - * 流程抄送 Service 接口 - * - * 现在是在审批的时候进行流程抄送 - */ -public interface BpmProcessInstanceCopyService { - - /** - * 流程实例的抄送 - * - * @param userIds 抄送的用户编号 - * @param taskId 流程任务编号 - */ - void createProcessInstanceCopy(Collection userIds, String taskId); - - /** - * 获得抄送的流程的分页 - * - * @param userId 当前登录用户 - * @param pageReqVO 分页请求 - * @return 抄送的分页结果 - */ - PageResult getProcessInstanceCopyPage(Long userId, - BpmProcessInstanceCopyPageReqVO pageReqVO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyServiceImpl.java deleted file mode 100644 index 5d7347001..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyServiceImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmProcessInstanceCopyMapper; -import cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import lombok.extern.slf4j.Slf4j; -import org.flowable.engine.repository.ProcessDefinition; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.Task; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -/** - * 流程抄送 Service 实现类 - * - * @author kyle - */ -@Service -@Validated -@Slf4j -public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopyService { - - @Resource - private BpmProcessInstanceCopyMapper processInstanceCopyMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private BpmTaskService taskService; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private BpmProcessInstanceService processInstanceService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private BpmProcessDefinitionService processDefinitionService; - - @Override - public void createProcessInstanceCopy(Collection userIds, String taskId) { - // 1.1 校验任务存在 - Task task = taskService.getTask(taskId); - if (ObjectUtil.isNull(task)) { - throw exception(ErrorCodeConstants.TASK_NOT_EXISTS); - } - // 1.2 校验流程实例存在 - String processInstanceId = task.getProcessInstanceId(); - ProcessInstance processInstance = processInstanceService.getProcessInstance(processInstanceId); - if (processInstance == null) { - throw exception(ErrorCodeConstants.PROCESS_INSTANCE_NOT_EXISTS); - } - // 1.3 校验流程定义存在 - ProcessDefinition processDefinition = processDefinitionService.getProcessDefinition( - processInstance.getProcessDefinitionId()); - if (processDefinition == null) { - throw exception(ErrorCodeConstants.PROCESS_DEFINITION_NOT_EXISTS); - } - - // 2. 创建抄送流程 - List copyList = convertList(userIds, userId -> new BpmProcessInstanceCopyDO() - .setUserId(userId).setStartUserId(Long.valueOf(processInstance.getStartUserId())) - .setProcessInstanceId(processInstanceId).setProcessInstanceName(processInstance.getName()) - .setCategory(processDefinition.getCategory()).setTaskId(taskId).setTaskName(task.getName())); - processInstanceCopyMapper.insertBatch(copyList); - } - - @Override - public PageResult getProcessInstanceCopyPage(Long userId, - BpmProcessInstanceCopyPageReqVO pageReqVO) { - return processInstanceCopyMapper.selectPage(userId, pageReqVO); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java deleted file mode 100644 index 43e44aa5c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java +++ /dev/null @@ -1,144 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCancelReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCreateReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstancePageReqVO; -import org.flowable.engine.delegate.event.FlowableCancelledEvent; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.runtime.ProcessInstance; - -import javax.validation.Valid; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 流程实例 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmProcessInstanceService { - - /** - * 获得流程实例 - * - * @param id 流程实例的编号 - * @return 流程实例 - */ - ProcessInstance getProcessInstance(String id); - - /** - * 获得流程实例列表 - * - * @param ids 流程实例的编号集合 - * @return 流程实例列表 - */ - List getProcessInstances(Set ids); - - /** - * 获得流程实例 Map - * - * @param ids 流程实例的编号集合 - * @return 流程实例列表 Map - */ - default Map getProcessInstanceMap(Set ids) { - return convertMap(getProcessInstances(ids), ProcessInstance::getProcessInstanceId); - } - - /** - * 获得历史的流程实例 - * - * @param id 流程实例的编号 - * @return 历史的流程实例 - */ - HistoricProcessInstance getHistoricProcessInstance(String id); - - /** - * 获得历史的流程实例列表 - * - * @param ids 流程实例的编号集合 - * @return 历史的流程实例列表 - */ - List getHistoricProcessInstances(Set ids); - - /** - * 获得历史的流程实例 Map - * - * @param ids 流程实例的编号集合 - * @return 历史的流程实例列表 Map - */ - default Map getHistoricProcessInstanceMap(Set ids) { - return convertMap(getHistoricProcessInstances(ids), HistoricProcessInstance::getId); - } - - /** - * 获得流程实例的分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程实例的分页 - */ - PageResult getProcessInstancePage(Long userId, - @Valid BpmProcessInstancePageReqVO pageReqVO); - - /** - * 创建流程实例(提供给前端) - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 实例的编号 - */ - String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqVO createReqVO); - - /** - * 创建流程实例(提供给内部) - * - * @param userId 用户编号 - * @param createReqDTO 创建信息 - * @return 实例的编号 - */ - String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO createReqDTO); - - /** - * 发起人取消流程实例 - * - * @param userId 用户编号 - * @param cancelReqVO 取消信息 - */ - void cancelProcessInstanceByStartUser(Long userId, @Valid BpmProcessInstanceCancelReqVO cancelReqVO); - - /** - * 管理员取消流程实例 - * - * @param userId 用户编号 - * @param cancelReqVO 取消信息 - */ - void cancelProcessInstanceByAdmin(Long userId, BpmProcessInstanceCancelReqVO cancelReqVO); - - /** - * 更新 ProcessInstance 拓展记录为取消 - * - * @param event 流程取消事件 - */ - void updateProcessInstanceWhenCancel(FlowableCancelledEvent event); - - /** - * 更新 ProcessInstance 拓展记录为完成 - * - * @param instance 流程任务 - */ - void updateProcessInstanceWhenApprove(ProcessInstance instance); - - /** - * 更新 ProcessInstance 拓展记录为不通过 - * - * @param id 流程编号 - * @param reason 理由。例如说,审批不通过时,需要传递该值 - */ - void updateProcessInstanceReject(String id, String reason); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java deleted file mode 100644 index 443236c6a..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.date.DateUtils; import cn.iocoder.yudao.framework.common.util.object.PageUtils; import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCancelReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCreateReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstancePageReqVO; import cn.iocoder.yudao.module.bpm.convert.task.BpmProcessInstanceConvert; import cn.iocoder.yudao.module.bpm.enums.task.BpmDeleteReasonEnum; import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum; import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.BpmTaskCandidateStartUserSelectStrategy; import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants; import cn.iocoder.yudao.module.bpm.framework.flowable.core.event.BpmProcessInstanceEventPublisher; import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import lombok.extern.slf4j.Slf4j; import org.flowable.bpmn.model.BpmnModel; import org.flowable.bpmn.model.UserTask; import org.flowable.engine.HistoryService; import org.flowable.engine.RuntimeService; import org.flowable.engine.delegate.event.FlowableCancelledEvent; import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.history.HistoricProcessInstanceQuery; import org.flowable.engine.repository.ProcessDefinition; import org.flowable.engine.runtime.ProcessInstance; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import javax.validation.Valid; import java.util.*; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; /** * 流程实例 Service 实现类 * * ProcessDefinition & ProcessInstance & Execution & Task 的关系: * 1. * * HistoricProcessInstance & ProcessInstance 的关系: * 1. * * 简单来说,前者 = 历史 + 运行中的流程实例,后者仅是运行中的流程实例 * * @author 芋道源码 */ @Service @Validated @Slf4j public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService { @Resource private RuntimeService runtimeService; @Resource private HistoryService historyService; @Resource private BpmProcessDefinitionService processDefinitionService; @Resource private BpmMessageService messageService; @Resource private AdminUserApi adminUserApi; @Resource private BpmProcessInstanceEventPublisher processInstanceEventPublisher; @Override public ProcessInstance getProcessInstance(String id) { return runtimeService.createProcessInstanceQuery() .includeProcessVariables() .processInstanceId(id) .singleResult(); } @Override public List getProcessInstances(Set ids) { return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list(); } @Override public HistoricProcessInstance getHistoricProcessInstance(String id) { return historyService.createHistoricProcessInstanceQuery().processInstanceId(id).includeProcessVariables().singleResult(); } @Override public List getHistoricProcessInstances(Set ids) { return historyService.createHistoricProcessInstanceQuery().processInstanceIds(ids).list(); } @Override public PageResult getProcessInstancePage(Long userId, BpmProcessInstancePageReqVO pageReqVO) { // 通过 BpmProcessInstanceExtDO 表,先查询到对应的分页 HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery() .includeProcessVariables() .processInstanceTenantId(FlowableUtils.getTenantId()) .orderByProcessInstanceStartTime().desc(); if (userId != null) { // 【我的流程】菜单时,需要传递该字段 processInstanceQuery.startedBy(String.valueOf(userId)); } else if (pageReqVO.getStartUserId() != null) { // 【管理流程】菜单时,才会传递该字段 processInstanceQuery.startedBy(String.valueOf(pageReqVO.getStartUserId())); } if (StrUtil.isNotEmpty(pageReqVO.getName())) { processInstanceQuery.processInstanceNameLike("%" + pageReqVO.getName() + "%"); } if (StrUtil.isNotEmpty(pageReqVO.getProcessDefinitionId())) { processInstanceQuery.processDefinitionId("%" + pageReqVO.getProcessDefinitionId() + "%"); } if (StrUtil.isNotEmpty(pageReqVO.getCategory())) { processInstanceQuery.processDefinitionCategory(pageReqVO.getCategory()); } if (pageReqVO.getStatus() != null) { processInstanceQuery.variableValueEquals(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, pageReqVO.getStatus()); } if (ArrayUtil.isNotEmpty(pageReqVO.getCreateTime())) { processInstanceQuery.startedAfter(DateUtils.of(pageReqVO.getCreateTime()[0])); processInstanceQuery.startedBefore(DateUtils.of(pageReqVO.getCreateTime()[1])); } // 查询数量 long processInstanceCount = processInstanceQuery.count(); if (processInstanceCount == 0) { return PageResult.empty(processInstanceCount); } // 查询列表 List processInstanceList = processInstanceQuery.listPage(PageUtils.getStart(pageReqVO), pageReqVO.getPageSize()); return new PageResult<>(processInstanceList, processInstanceCount); } @Override @Transactional(rollbackFor = Exception.class) public String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqVO createReqVO) { // 获得流程定义 ProcessDefinition definition = processDefinitionService.getProcessDefinition(createReqVO.getProcessDefinitionId()); // 发起流程 return createProcessInstance0(userId, definition, createReqVO.getVariables(), null, createReqVO.getStartUserSelectAssignees()); } @Override public String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO createReqDTO) { // 获得流程定义 ProcessDefinition definition = processDefinitionService.getActiveProcessDefinition(createReqDTO.getProcessDefinitionKey()); // 发起流程 return createProcessInstance0(userId, definition, createReqDTO.getVariables(), createReqDTO.getBusinessKey(), createReqDTO.getStartUserSelectAssignees()); } private String createProcessInstance0(Long userId, ProcessDefinition definition, Map variables, String businessKey, Map> startUserSelectAssignees) { // 1.1 校验流程定义 if (definition == null) { throw exception(PROCESS_DEFINITION_NOT_EXISTS); } if (definition.isSuspended()) { throw exception(PROCESS_DEFINITION_IS_SUSPENDED); } // 1.2 校验发起人自选审批人 validateStartUserSelectAssignees(definition, startUserSelectAssignees); // 2. 创建流程实例 if (variables == null) { variables = new HashMap<>(); } FlowableUtils.filterProcessInstanceFormVariable(variables); // 过滤一下,避免 ProcessInstance 系统级的变量被占用 variables.put(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, // 流程实例状态:审批中 BpmProcessInstanceStatusEnum.RUNNING.getStatus()); if (CollUtil.isNotEmpty(startUserSelectAssignees)) { variables.put(BpmConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES, startUserSelectAssignees); } ProcessInstance instance = runtimeService.createProcessInstanceBuilder() .processDefinitionId(definition.getId()) .businessKey(businessKey) .name(definition.getName().trim()) .variables(variables) .start(); return instance.getId(); } private void validateStartUserSelectAssignees(ProcessDefinition definition, Map> startUserSelectAssignees) { // 1. 获得发起人自选审批人的 UserTask 列表 BpmnModel bpmnModel = processDefinitionService.getProcessDefinitionBpmnModel(definition.getId()); List userTaskList = BpmTaskCandidateStartUserSelectStrategy.getStartUserSelectUserTaskList(bpmnModel); if (CollUtil.isEmpty(userTaskList)) { return; } // 2. 校验发起人自选审批人的 UserTask 是否都配置了 userTaskList.forEach(userTask -> { List assignees = startUserSelectAssignees != null ? startUserSelectAssignees.get(userTask.getId()) : null; if (CollUtil.isEmpty(assignees)) { throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, userTask.getName()); } Map userMap = adminUserApi.getUserMap(assignees); assignees.forEach(assignee -> { if (userMap.get(assignee) == null) { throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_EXISTS, userTask.getName(), assignee); } }); }); } @Override public void cancelProcessInstanceByStartUser(Long userId, @Valid BpmProcessInstanceCancelReqVO cancelReqVO) { // 1.1 校验流程实例存在 ProcessInstance instance = getProcessInstance(cancelReqVO.getId()); if (instance == null) { throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS); } // 1.2 只能取消自己的 if (!Objects.equals(instance.getStartUserId(), String.valueOf(userId))) { throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF); } // 2. 通过删除流程实例,实现流程实例的取消, // 删除流程实例,正则执行任务 ACT_RU_TASK. 任务会被删除。 deleteProcessInstance(cancelReqVO.getId(), BpmDeleteReasonEnum.CANCEL_PROCESS_INSTANCE_BY_START_USER.format(cancelReqVO.getReason())); // 3. 进一步的处理,交给 updateProcessInstanceCancel 方法 } @Override public void cancelProcessInstanceByAdmin(Long userId, BpmProcessInstanceCancelReqVO cancelReqVO) { // 1.1 校验流程实例存在 ProcessInstance instance = getProcessInstance(cancelReqVO.getId()); if (instance == null) { throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS); } // 1.2 管理员取消,不用校验是否为自己的 AdminUserRespDTO user = adminUserApi.getUser(userId).getCheckedData(); // 2. 通过删除流程实例,实现流程实例的取消, // 删除流程实例,正则执行任务 ACT_RU_TASK. 任务会被删除。 deleteProcessInstance(cancelReqVO.getId(), BpmDeleteReasonEnum.CANCEL_PROCESS_INSTANCE_BY_ADMIN.format(user.getNickname(), cancelReqVO.getReason())); // 3. 进一步的处理,交给 updateProcessInstanceCancel 方法 } @Override public void updateProcessInstanceWhenCancel(FlowableCancelledEvent event) { // 1. 判断是否为 Reject 不通过。如果是,则不进行更新. // 因为,updateProcessInstanceReject 方法(审批不通过),已经进行更新了 if (BpmDeleteReasonEnum.isRejectReason((String) event.getCause())) { return; } // 2. 更新流程实例 status runtimeService.setVariable(event.getProcessInstanceId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, BpmProcessInstanceStatusEnum.CANCEL.getStatus()); // 3. 发送流程实例的状态事件 // 注意:此时如果去查询 ProcessInstance 的话,字段是不全的,所以去查询了 HistoricProcessInstance HistoricProcessInstance processInstance = getHistoricProcessInstance(event.getProcessInstanceId()); // 发送流程实例的状态事件 processInstanceEventPublisher.sendProcessInstanceResultEvent( BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceStatusEvent(this, processInstance, BpmProcessInstanceStatusEnum.CANCEL.getStatus())); } @Override public void updateProcessInstanceWhenApprove(ProcessInstance instance) { // 1. 更新流程实例 status runtimeService.setVariable(instance.getId(), BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, BpmProcessInstanceStatusEnum.APPROVE.getStatus()); // 2. 发送流程被【通过】的消息 messageService.sendMessageWhenProcessInstanceApprove(BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceApproveMessage(instance)); // 3. 发送流程实例的状态事件 // 注意:此时如果去查询 ProcessInstance 的话,字段是不全的,所以去查询了 HistoricProcessInstance HistoricProcessInstance processInstance = getHistoricProcessInstance(instance.getId()); processInstanceEventPublisher.sendProcessInstanceResultEvent( BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceStatusEvent(this, processInstance, BpmProcessInstanceStatusEnum.APPROVE.getStatus())); } @Override @Transactional(rollbackFor = Exception.class) public void updateProcessInstanceReject(String id, String reason) { // 1. 更新流程实例 status runtimeService.setVariable(id, BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS, BpmProcessInstanceStatusEnum.REJECT.getStatus()); // 2. 删除流程实例,以实现驳回任务时,取消整个审批流程 ProcessInstance processInstance = getProcessInstance(id); deleteProcessInstance(id, StrUtil.format(BpmDeleteReasonEnum.REJECT_TASK.format(reason))); // 3. 发送流程被【不通过】的消息 messageService.sendMessageWhenProcessInstanceReject(BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceRejectMessage(processInstance, reason)); // 4. 发送流程实例的状态事件 processInstanceEventPublisher.sendProcessInstanceResultEvent( BpmProcessInstanceConvert.INSTANCE.buildProcessInstanceStatusEvent(this, processInstance, BpmProcessInstanceStatusEnum.REJECT.getStatus())); } private void deleteProcessInstance(String id, String reason) { runtimeService.deleteProcessInstance(id, reason); } } \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java deleted file mode 100644 index e9a55c0ff..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java +++ /dev/null @@ -1,186 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import org.flowable.bpmn.model.UserTask; -import org.flowable.task.api.Task; -import org.flowable.task.api.history.HistoricTaskInstance; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 流程任务实例 Service 接口 - * - * @author jason - * @author 芋道源码 - */ -public interface BpmTaskService { - - /** - * 获得待办的流程任务分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程任务分页 - */ - PageResult getTaskTodoPage(Long userId, BpmTaskPageReqVO pageReqVO); - - /** - * 获得已办的流程任务分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程任务分页 - */ - PageResult getTaskDonePage(Long userId, BpmTaskPageReqVO pageReqVO); - - /** - * 获得全部的流程任务分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程任务分页 - */ - PageResult getTaskPage(Long userId, BpmTaskPageReqVO pageReqVO); - - /** - * 获得流程任务 Map - * - * @param processInstanceIds 流程实例的编号数组 - * @return 流程任务 Map - */ - default Map> getTaskMapByProcessInstanceIds(List processInstanceIds) { - return CollectionUtils.convertMultiMap(getTasksByProcessInstanceIds(processInstanceIds), - Task::getProcessInstanceId); - } - - /** - * 获得流程任务列表 - * - * @param processInstanceIds 流程实例的编号数组 - * @return 流程任务列表 - */ - List getTasksByProcessInstanceIds(List processInstanceIds); - - /** - * 获得指定流程实例的流程任务列表,包括所有状态的 - * - * @param processInstanceId 流程实例的编号 - * @return 流程任务列表 - */ - List getTaskListByProcessInstanceId(String processInstanceId); - - /** - * 通过任务 - * - * @param userId 用户编号 - * @param reqVO 通过请求 - */ - void approveTask(Long userId, @Valid BpmTaskApproveReqVO reqVO); - - /** - * 不通过任务 - * - * @param userId 用户编号 - * @param reqVO 不通过请求 - */ - void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO); - - /** - * 将流程任务分配给指定用户 - * - * @param userId 用户编号 - * @param reqVO 分配请求 - */ - void transferTask(Long userId, BpmTaskTransferReqVO reqVO); - - /** - * 更新 Task 状态,在创建时 - * - * @param task 任务实体 - */ - void updateTaskStatusWhenCreated(Task task); - - /** - * 更新 Task 状态,在取消时 - * - * @param taskId 任务的编号 - */ - void updateTaskStatusWhenCanceled(String taskId); - - /** - * 更新 Task 拓展记录,并发送通知 - * - * @param task 任务实体 - */ - void updateTaskExtAssign(Task task); - - /** - * 获取任务 - * - * @param id 任务编号 - * @return 任务 - */ - Task getTask(String id); - - /** - * 获取当前任务的可回退的 UserTask 集合 - * - * @param id 当前的任务 ID - * @return 可以回退的节点列表 - */ - List getUserTaskListByReturn(String id); - - /** - * 将任务回退到指定的 targetDefinitionKey 位置 - * - * @param userId 用户编号 - * @param reqVO 回退的任务key和当前所在的任务ID - */ - void returnTask(Long userId, BpmTaskReturnReqVO reqVO); - - /** - * 将指定任务委派给其他人处理,等接收人处理后再回到原审批人手中审批 - * - * @param userId 用户编号 - * @param reqVO 被委派人和被委派的任务编号理由参数 - */ - void delegateTask(Long userId, BpmTaskDelegateReqVO reqVO); - - /** - * 任务加签 - * - * @param userId 被加签的用户和任务 ID,加签类型 - * @param reqVO 当前用户 ID - */ - void createSignTask(Long userId, BpmTaskSignCreateReqVO reqVO); - - /** - * 任务减签 - * - * @param userId 当前用户ID - * @param reqVO 被减签的任务 ID,理由 - */ - void deleteSignTask(Long userId, BpmTaskSignDeleteReqVO reqVO); - - /** - * 获取指定任务的子任务列表 - * - * @param parentTaskId 父任务ID - * @return 子任务列表 - */ - List getTaskListByParentTaskId(String parentTaskId); - - /** - * 通过任务 ID,查询任务名 Map - * - * @param taskIds 任务 ID - * @return 任务 ID 与名字的 Map - */ - Map getTaskNameByTaskIds(Collection taskIds); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java deleted file mode 100644 index 411b7fa8e..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java +++ /dev/null @@ -1,822 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert; -import cn.iocoder.yudao.module.bpm.enums.task.BpmCommentTypeEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmDeleteReasonEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskSignTypeEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants; -import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; -import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.FlowElement; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.HistoryService; -import org.flowable.engine.ManagementService; -import org.flowable.engine.RuntimeService; -import org.flowable.engine.TaskService; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.DelegationState; -import org.flowable.task.api.Task; -import org.flowable.task.api.TaskQuery; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.task.api.history.HistoricTaskInstanceQuery; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; -import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.util.Assert; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.*; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * 流程任务实例 Service 实现类 - * - * @author 芋道源码 - * @author jason - */ -@Slf4j -@Service -public class BpmTaskServiceImpl implements BpmTaskService { - - @Resource - private TaskService taskService; - @Resource - private HistoryService historyService; - @Resource - private RuntimeService runtimeService; - @Resource - private ManagementService managementService; - - @Resource - private BpmProcessInstanceService processInstanceService; - @Resource - private BpmProcessInstanceCopyService processInstanceCopyService; - @Resource - private BpmModelService bpmModelService; - @Resource - private BpmMessageService messageService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - public PageResult getTaskTodoPage(Long userId, BpmTaskPageReqVO pageVO) { - TaskQuery taskQuery = taskService.createTaskQuery() - .taskAssignee(String.valueOf(userId)) // 分配给自己 - .active() - .includeProcessVariables() - .orderByTaskCreateTime().desc(); // 创建时间倒序 - if (StrUtil.isNotBlank(pageVO.getName())) { - taskQuery.taskNameLike("%" + pageVO.getName() + "%"); - } - if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) { - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0])); - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1])); - } - long count = taskQuery.count(); - if (count == 0) { - return PageResult.empty(); - } - List tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - return new PageResult<>(tasks, count); - } - - @Override - public PageResult getTaskDonePage(Long userId, BpmTaskPageReqVO pageVO) { - HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery() - .finished() // 已完成 - .taskAssignee(String.valueOf(userId)) // 分配给自己 - .includeTaskLocalVariables() - .orderByHistoricTaskInstanceEndTime().desc(); // 审批时间倒序 - if (StrUtil.isNotBlank(pageVO.getName())) { - taskQuery.taskNameLike("%" + pageVO.getName() + "%"); - } - if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) { - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0])); - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1])); - } - // 执行查询 - long count = taskQuery.count(); - if (count == 0) { - return PageResult.empty(); - } - List tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - return new PageResult<>(tasks, count); - } - - @Override - public PageResult getTaskPage(Long userId, BpmTaskPageReqVO pageVO) { - HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery() - .includeTaskLocalVariables() - .taskTenantId(FlowableUtils.getTenantId()) - .orderByHistoricTaskInstanceEndTime().desc(); // 审批时间倒序 - if (StrUtil.isNotBlank(pageVO.getName())) { - taskQuery.taskNameLike("%" + pageVO.getName() + "%"); - } - if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) { - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0])); - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1])); - } - // 执行查询 - long count = taskQuery.count(); - if (count == 0) { - return PageResult.empty(); - } - List tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - return new PageResult<>(tasks, count); - } - - @Override - public List getTasksByProcessInstanceIds(List processInstanceIds) { - if (CollUtil.isEmpty(processInstanceIds)) { - return Collections.emptyList(); - } - return taskService.createTaskQuery().processInstanceIdIn(processInstanceIds).list(); - } - - @Override - public List getTaskListByProcessInstanceId(String processInstanceId) { - List tasks = historyService.createHistoricTaskInstanceQuery() - .includeTaskLocalVariables() - .processInstanceId(processInstanceId) - .orderByHistoricTaskInstanceStartTime().desc() // 创建时间倒序 - .list(); - if (CollUtil.isEmpty(tasks)) { - return Collections.emptyList(); - } - return tasks; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void approveTask(Long userId, @Valid BpmTaskApproveReqVO reqVO) { - // 1.1 校验任务存在 - Task task = validateTask(userId, reqVO.getId()); - // 1.2 校验流程实例存在 - ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - if (instance == null) { - throw exception(PROCESS_INSTANCE_NOT_EXISTS); - } - - // 2. 抄送用户 - if (CollUtil.isNotEmpty(reqVO.getCopyUserIds())) { - processInstanceCopyService.createProcessInstanceCopy(reqVO.getCopyUserIds(), reqVO.getId()); - } - - // 情况一:被委派的任务,不调用 complete 去完成任务 - if (DelegationState.PENDING.equals(task.getDelegationState())) { - approveDelegateTask(reqVO, task); - return; - } - - // 情况二:审批有【后】加签的任务 - if (BpmTaskSignTypeEnum.AFTER.getType().equals(task.getScopeType())) { - approveAfterSignTask(task, reqVO); - return; - } - - // 情况三:审批普通的任务。大多数情况下,都是这样 - // 3.1 更新 task 状态、原因 - updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.APPROVE.getStatus(), reqVO.getReason()); - // 3.2 添加评论 - taskService.addComment(task.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.APPROVE.getType(), - BpmCommentTypeEnum.APPROVE.formatComment(reqVO.getReason())); - // 3.3 调用 BPM complete 去完成任务 - // 其中,variables 是存储动态表单到 local 任务级别。过滤一下,避免 ProcessInstance 系统级的变量被占用 - if (CollUtil.isNotEmpty(reqVO.getVariables())) { - Map variables = FlowableUtils.filterTaskFormVariable(reqVO.getVariables()); - taskService.complete(task.getId(), variables, true); - } else { - taskService.complete(task.getId()); - } - - // 【加签专属】处理加签任务 - handleParentTaskIfSign(task.getParentTaskId()); - } - - /** - * 审批通过存在“后加签”的任务。 - *

- * 注意:该任务不能马上完成,需要一个中间状态(APPROVING),并激活剩余所有子任务(PROCESS)为可审批处理 - * 如果马上完成,则会触发下一个任务,甚至如果没有下一个任务则流程实例就直接结束了! - * - * @param task 当前任务 - * @param reqVO 前端请求参数 - */ - private void approveAfterSignTask(Task task, BpmTaskApproveReqVO reqVO) { - // 更新父 task 状态 + 原因 - updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.APPROVING.getStatus(), reqVO.getReason()); - - // 2. 激活子任务 - List childrenTaskList = getTaskListByParentTaskId(task.getId()); - for (Task childrenTask : childrenTaskList) { - taskService.resolveTask(childrenTask.getId()); - // 更新子 task 状态 - updateTaskStatus(childrenTask.getId(), BpmTaskStatusEnum.RUNNING.getStatus()); - } - } - - /** - * 如果父任务是有前后【加签】的任务,如果它【加签】出来的子任务都被处理,需要处理父任务: - * - * 1. 如果是【向前】加签,则需要重新激活父任务,让它可以被审批 - * 2. 如果是【向后】加签,则需要完成父任务,让它完成审批 - * - * @param parentTaskId 父任务编号 - */ - private void handleParentTaskIfSign(String parentTaskId) { - if (StrUtil.isBlank(parentTaskId)) { - return; - } - // 1.1 判断是否还有子任务。如果没有,就不处理 - Long childrenTaskCount = getTaskCountByParentTaskId(parentTaskId); - if (childrenTaskCount > 0) { - return; - } - // 1.2 只处理加签的父任务 - Task parentTask = validateTaskExist(parentTaskId); - String scopeType = parentTask.getScopeType(); - if (BpmTaskSignTypeEnum.of(scopeType) == null) { - return; - } - - // 2. 子任务已处理完成,清空 scopeType 字段,修改 parentTask 信息,方便后续可以继续向前后向后加签 - TaskEntityImpl parentTaskImpl = (TaskEntityImpl) parentTask; - parentTaskImpl.setScopeType(null); - taskService.saveTask(parentTaskImpl); - - // 3.1 情况一:处理向【向前】加签 - if (BpmTaskSignTypeEnum.BEFORE.getType().equals(scopeType)) { - // 3.1.1 owner 重新赋值给父任务的 assignee,这样它就可以被审批 - taskService.resolveTask(parentTaskId); - // 3.1.2 更新流程任务 status - updateTaskStatus(parentTaskId, BpmTaskStatusEnum.RUNNING.getStatus()); - // 3.2 情况二:处理向【向后】加签 - } else if (BpmTaskSignTypeEnum.AFTER.getType().equals(scopeType)) { - // 只有 parentTask 处于 APPROVING 的情况下,才可以继续 complete 完成 - // 否则,一个未审批的 parentTask 任务,在加签出来的任务都被减签的情况下,就直接完成审批,这样会存在问题 - Integer status = (Integer) parentTask.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS); - if (ObjectUtil.notEqual(status, BpmTaskStatusEnum.APPROVING.getStatus())) { - return; - } - // 3.2.2 完成自己(因为它已经没有子任务,所以也可以完成) - updateTaskStatus(parentTaskId, BpmTaskStatusEnum.APPROVE.getStatus()); - taskService.complete(parentTaskId); - } - - // 4. 递归处理父任务 - handleParentTaskIfSign(parentTask.getParentTaskId()); - } - - /** - * 审批被委派的任务 - * - * @param reqVO 前端请求参数,包含当前任务ID,审批意见等 - * @param task 当前被审批的任务 - */ - private void approveDelegateTask(BpmTaskApproveReqVO reqVO, Task task) { - // 1. 添加审批意见 - AdminUserRespDTO currentUser = adminUserApi.getUser(WebFrameworkUtils.getLoginUserId()).getCheckedData(); - AdminUserRespDTO ownerUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())).getCheckedData(); // 发起委托的用户 - Assert.notNull(ownerUser, "委派任务找不到原审批人,需要检查数据"); - taskService.addComment(reqVO.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.DELEGATE_END.getType(), - BpmCommentTypeEnum.DELEGATE_END.formatComment(currentUser.getNickname(), ownerUser.getNickname(), reqVO.getReason())); - - // 2.1 调用 resolveTask 完成任务。 - // 底层调用 TaskHelper.changeTaskAssignee(task, task.getOwner()):将 owner 设置为 assignee - taskService.resolveTask(task.getId()); - // 2.2 更新 task 状态 + 原因 - updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.RUNNING.getStatus(), reqVO.getReason()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO) { - // 1.1 校验任务存在 - Task task = validateTask(userId, reqVO.getId()); - // 1.2 校验流程实例存在 - ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - if (instance == null) { - throw exception(PROCESS_INSTANCE_NOT_EXISTS); - } - - // 2.1 更新流程实例为不通过 - updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.REJECT.getStatus(), reqVO.getReason()); - // 2.2 添加评论 - taskService.addComment(task.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.REJECT.getType(), - BpmCommentTypeEnum.REJECT.formatComment(reqVO.getReason())); - - // 3. 更新流程实例,审批不通过! - processInstanceService.updateProcessInstanceReject(instance.getProcessInstanceId(), reqVO.getReason()); - } - - /** - * 更新流程任务的 status 状态 - * - * @param id 任务编号 - * @param status 状态 - */ - private void updateTaskStatus(String id, Integer status) { - taskService.setVariableLocal(id, BpmConstants.TASK_VARIABLE_STATUS, status); - } - - /** - * 更新流程任务的 status 状态、reason 理由 - * - * @param id 任务编号 - * @param status 状态 - * @param reason 理由(审批通过、审批不通过的理由) - */ - private void updateTaskStatusAndReason(String id, Integer status, String reason) { - updateTaskStatus(id, status); - taskService.setVariableLocal(id, BpmConstants.TASK_VARIABLE_REASON, reason); - } - - /** - * 校验任务是否存在,并且是否是分配给自己的任务 - * - * @param userId 用户 id - * @param taskId task id - */ - private Task validateTask(Long userId, String taskId) { - Task task = validateTaskExist(taskId); - if (!Objects.equals(userId, NumberUtils.parseLong(task.getAssignee()))) { - throw exception(TASK_OPERATE_FAIL_ASSIGN_NOT_SELF); - } - return task; - } - - @Override - public void updateTaskStatusWhenCreated(Task task) { - Integer status = (Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS); - if (status != null) { - log.error("[updateTaskStatusWhenCreated][taskId({}) 已经有状态({})]", task.getId(), status); - return; - } - updateTaskStatus(task.getId(), BpmTaskStatusEnum.RUNNING.getStatus()); - } - - @Override - public void updateTaskStatusWhenCanceled(String taskId) { - Task task = getTask(taskId); - // 1. 可能只是活动,不是任务,所以查询不到 - if (task == null) { - log.error("[updateTaskStatusWhenCanceled][taskId({}) 任务不存在]", taskId); - return; - } - - // 2. 更新 task 状态 + 原因 - Integer status = (Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS); - if (BpmTaskStatusEnum.isEndStatus(status)) { - log.error("[updateTaskStatusWhenCanceled][taskId({}) 处于结果({}),无需进行更新]", taskId, status); - return; - } - updateTaskStatusAndReason(taskId, BpmTaskStatusEnum.CANCEL.getStatus(), BpmDeleteReasonEnum.CANCEL_BY_SYSTEM.getReason()); - // 补充说明:由于 Task 被删除成 HistoricTask 后,无法通过 taskService.addComment 添加理由,所以无法存储具体的取消理由 - } - - @Override - public void updateTaskExtAssign(Task task) { - // 发送通知。在事务提交时,批量执行操作,所以直接查询会无法查询到 ProcessInstance,所以这里是通过监听事务的提交来实现。 - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - - @Override - public void afterCommit() { - if (StrUtil.isEmpty(task.getAssignee())) { - return; - } - ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())).getCheckedData(); - messageService.sendMessageWhenTaskAssigned(BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task)); - } - - }); - } - - private Task validateTaskExist(String id) { - Task task = getTask(id); - if (task == null) { - throw exception(TASK_NOT_EXISTS); - } - return task; - } - - @Override - public Task getTask(String id) { - return taskService.createTaskQuery().taskId(id).includeTaskLocalVariables().singleResult(); - } - - private HistoricTaskInstance getHistoricTask(String id) { - return historyService.createHistoricTaskInstanceQuery().taskId(id).includeTaskLocalVariables().singleResult(); - } - - @Override - public List getUserTaskListByReturn(String id) { - // 1.1 校验当前任务 task 存在 - Task task = validateTaskExist(id); - // 1.2 根据流程定义获取流程模型信息 - BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(task.getProcessDefinitionId()); - FlowElement source = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); - if (source == null) { - throw exception(TASK_NOT_EXISTS); - } - - // 2.1 查询该任务的前置任务节点的 key 集合 - List previousUserList = BpmnModelUtils.getPreviousUserTaskList(source, null, null); - if (CollUtil.isEmpty(previousUserList)) { - return Collections.emptyList(); - } - // 2.2 过滤:只有串行可到达的节点,才可以回退。类似非串行、子流程无法退回 - previousUserList.removeIf(userTask -> !BpmnModelUtils.isSequentialReachable(source, userTask, null)); - return previousUserList; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void returnTask(Long userId, BpmTaskReturnReqVO reqVO) { - // 1.1 当前任务 task - Task task = validateTask(userId, reqVO.getId()); - if (task.isSuspended()) { - throw exception(TASK_IS_PENDING); - } - // 1.2 校验源头和目标节点的关系,并返回目标元素 - FlowElement targetElement = validateTargetTaskCanReturn(task.getTaskDefinitionKey(), - reqVO.getTargetTaskDefinitionKey(), task.getProcessDefinitionId()); - - // 2. 调用 Flowable 框架的回退逻辑 - returnTask(task, targetElement, reqVO); - } - - /** - * 回退流程节点时,校验目标任务节点是否可回退 - * - * @param sourceKey 当前任务节点 Key - * @param targetKey 目标任务节点 key - * @param processDefinitionId 当前流程定义 ID - * @return 目标任务节点元素 - */ - private FlowElement validateTargetTaskCanReturn(String sourceKey, String targetKey, String processDefinitionId) { - // 1.1 获取流程模型信息 - BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(processDefinitionId); - // 1.3 获取当前任务节点元素 - FlowElement source = BpmnModelUtils.getFlowElementById(bpmnModel, sourceKey); - // 1.3 获取跳转的节点元素 - FlowElement target = BpmnModelUtils.getFlowElementById(bpmnModel, targetKey); - if (target == null) { - throw exception(TASK_TARGET_NODE_NOT_EXISTS); - } - - // 2.2 只有串行可到达的节点,才可以回退。类似非串行、子流程无法退回 - if (!BpmnModelUtils.isSequentialReachable(source, target, null)) { - throw exception(TASK_RETURN_FAIL_SOURCE_TARGET_ERROR); - } - return target; - } - - /** - * 执行回退逻辑 - * - * @param currentTask 当前回退的任务 - * @param targetElement 需要回退到的目标任务 - * @param reqVO 前端参数封装 - */ - public void returnTask(Task currentTask, FlowElement targetElement, BpmTaskReturnReqVO reqVO) { - // 1. 获得所有需要回撤的任务 taskDefinitionKey,用于稍后的 moveActivityIdsToSingleActivityId 回撤 - // 1.1 获取所有正常进行的任务节点 Key - List taskList = taskService.createTaskQuery().processInstanceId(currentTask.getProcessInstanceId()).list(); - List runTaskKeyList = convertList(taskList, Task::getTaskDefinitionKey); - // 1.2 通过 targetElement 的出口连线,计算在 runTaskKeyList 有哪些 key 需要被撤回 - // 为什么不直接使用 runTaskKeyList 呢?因为可能存在多个审批分支,例如说:A -> B -> C 和 D -> F,而只要 C 撤回到 A,需要排除掉 F - List returnUserTaskList = BpmnModelUtils.iteratorFindChildUserTasks(targetElement, runTaskKeyList, null, null); - List returnTaskKeyList = convertList(returnUserTaskList, UserTask::getId); - - // 2. 给当前要被回退的 task 数组,设置回退意见 - taskList.forEach(task -> { - // 需要排除掉,不需要设置回退意见的任务 - if (!returnTaskKeyList.contains(task.getTaskDefinitionKey())) { - return; - } - // 2.1 添加评论 - taskService.addComment(task.getId(), currentTask.getProcessInstanceId(), BpmCommentTypeEnum.RETURN.getType(), - BpmCommentTypeEnum.RETURN.formatComment(reqVO.getReason())); - // 2.2 更新 task 状态 + 原因 - updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.RETURN.getStatus(), reqVO.getReason()); - }); - - // 3. 执行驳回 - runtimeService.createChangeActivityStateBuilder() - .processInstanceId(currentTask.getProcessInstanceId()) - .moveActivityIdsToSingleActivityId(returnTaskKeyList, // 当前要跳转的节点列表( 1 或多) - reqVO.getTargetTaskDefinitionKey()) // targetKey 跳转到的节点(1) - .changeState(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delegateTask(Long userId, BpmTaskDelegateReqVO reqVO) { - String taskId = reqVO.getId(); - // 1.1 校验任务 - Task task = validateTask(userId, reqVO.getId()); - if (task.getAssignee().equals(reqVO.getDelegateUserId().toString())) { // 校验当前审批人和被委派人不是同一人 - throw exception(TASK_DELEGATE_FAIL_USER_REPEAT); - } - // 1.2 校验目标用户存在 - AdminUserRespDTO delegateUser = adminUserApi.getUser(reqVO.getDelegateUserId()).getCheckedData(); - if (delegateUser == null) { - throw exception(TASK_DELEGATE_FAIL_USER_NOT_EXISTS); - } - - // 2. 添加委托意见 - AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData(); - taskService.addComment(taskId, task.getProcessInstanceId(), BpmCommentTypeEnum.DELEGATE_START.getType(), - BpmCommentTypeEnum.DELEGATE_START.formatComment(currentUser.getNickname(), delegateUser.getNickname(), reqVO.getReason())); - - // 3.1 设置任务所有人 (owner) 为原任务的处理人 (assignee) - taskService.setOwner(taskId, task.getAssignee()); - // 3.2 执行委派,将任务委派给 delegateUser - taskService.delegateTask(taskId, reqVO.getDelegateUserId().toString()); - // 3.3 更新 task 状态。 - // 为什么不更新原因?因为原因目前主要给审批通过、不通过时使用 - updateTaskStatus(taskId, BpmTaskStatusEnum.DELEGATE.getStatus()); - } - - @Override - public void transferTask(Long userId, BpmTaskTransferReqVO reqVO) { - String taskId = reqVO.getId(); - // 1.1 校验任务 - Task task = validateTask(userId, reqVO.getId()); - if (task.getAssignee().equals(reqVO.getAssigneeUserId().toString())) { // 校验当前审批人和被转派人不是同一人 - throw exception(TASK_TRANSFER_FAIL_USER_REPEAT); - } - // 1.2 校验目标用户存在 - AdminUserRespDTO assigneeUser = adminUserApi.getUser(reqVO.getAssigneeUserId()).getCheckedData(); - if (assigneeUser == null) { - throw exception(TASK_TRANSFER_FAIL_USER_NOT_EXISTS); - } - - // 2. 添加委托意见 - AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData(); - taskService.addComment(taskId, task.getProcessInstanceId(), BpmCommentTypeEnum.TRANSFER.getType(), - BpmCommentTypeEnum.TRANSFER.formatComment(currentUser.getNickname(), assigneeUser.getNickname(), reqVO.getReason())); - - // 3.1 设置任务所有人 (owner) 为原任务的处理人 (assignee) - taskService.setOwner(taskId, task.getAssignee()); - // 3.2 执行转派(审批人),将任务转派给 assigneeUser - // 委托( delegate)和转派(transfer)的差别,就在这块的调用!!!! - taskService.setAssignee(taskId, reqVO.getAssigneeUserId().toString()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void createSignTask(Long userId, BpmTaskSignCreateReqVO reqVO) { - // 1. 获取和校验任务 - TaskEntityImpl taskEntity = validateTaskCanCreateSign(userId, reqVO); - List userList = adminUserApi.getUserList(reqVO.getUserIds()).getCheckedData(); - if (CollUtil.isEmpty(userList)) { - throw exception(TASK_SIGN_CREATE_USER_NOT_EXIST); - } - - // 2. 处理当前任务 - // 2.1 开启计数功能,主要用于为了让表 ACT_RU_TASK 中的 SUB_TASK_COUNT_ 字段记录下总共有多少子任务,后续可能有用 - taskEntity.setCountEnabled(true); - // 2.2 向前加签,设置 owner,置空 assign。等子任务都完成后,再调用 resolveTask 重新将 owner 设置为 assign - // 原因是:不能和向前加签的子任务一起审批,需要等前面的子任务都完成才能审批 - if (reqVO.getType().equals(BpmTaskSignTypeEnum.BEFORE.getType())) { - taskEntity.setOwner(taskEntity.getAssignee()); - taskEntity.setAssignee(null); - } - // 2.4 记录加签方式,完成任务时需要用到判断 - taskEntity.setScopeType(reqVO.getType()); - // 2.5 保存当前任务修改后的值 - taskService.saveTask(taskEntity); - // 2.6 更新 task 状态为 WAIT,只有在向前加签的时候 - if (reqVO.getType().equals(BpmTaskSignTypeEnum.BEFORE.getType())) { - updateTaskStatus(taskEntity.getId(), BpmTaskStatusEnum.WAIT.getStatus()); - } - - // 3. 创建加签任务 - createSignTaskList(convertList(reqVO.getUserIds(), String::valueOf), taskEntity); - - // 4. 记录加签的评论到 task 任务 - AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData(); - String comment = StrUtil.format(BpmCommentTypeEnum.ADD_SIGN.getComment(), - currentUser.getNickname(), BpmTaskSignTypeEnum.nameOfType(reqVO.getType()), - String.join(",", convertList(userList, AdminUserRespDTO::getNickname)), reqVO.getReason()); - taskService.addComment(reqVO.getId(), taskEntity.getProcessInstanceId(), BpmCommentTypeEnum.ADD_SIGN.getType(), comment); - } - - /** - * 校验任务是否可以加签,主要校验加签类型是否一致: - *

- * 1. 如果存在“向前加签”的任务,则不能“向后加签” - * 2. 如果存在“向后加签”的任务,则不能“向前加签” - * - * @param userId 当前用户 ID - * @param reqVO 请求参数,包含任务 ID 和加签类型 - * @return 当前任务 - */ - private TaskEntityImpl validateTaskCanCreateSign(Long userId, BpmTaskSignCreateReqVO reqVO) { - TaskEntityImpl taskEntity = (TaskEntityImpl) validateTask(userId, reqVO.getId()); - // 向前加签和向后加签不能同时存在 - if (taskEntity.getScopeType() != null - && ObjectUtil.notEqual(taskEntity.getScopeType(), reqVO.getType())) { - throw exception(TASK_SIGN_CREATE_TYPE_ERROR, - BpmTaskSignTypeEnum.nameOfType(taskEntity.getScopeType()), BpmTaskSignTypeEnum.nameOfType(reqVO.getType())); - } - - // 同一个 key 的任务,审批人不重复 - List taskList = taskService.createTaskQuery().processInstanceId(taskEntity.getProcessInstanceId()) - .taskDefinitionKey(taskEntity.getTaskDefinitionKey()).list(); - List currentAssigneeList = convertListByFlatMap(taskList, task -> // 需要考虑 owner 的情况,因为向后加签时,它暂时没 assignee 而是 owner - Stream.of(NumberUtils.parseLong(task.getAssignee()), NumberUtils.parseLong(task.getOwner()))); - if (CollUtil.containsAny(currentAssigneeList, reqVO.getUserIds())) { - List userList = adminUserApi.getUserList( CollUtil.intersection(currentAssigneeList, reqVO.getUserIds())).getCheckedData(); - throw exception(TASK_SIGN_CREATE_USER_REPEAT, String.join(",", convertList(userList, AdminUserRespDTO::getNickname))); - } - return taskEntity; - } - - /** - * 创建加签子任务 - * - * @param userIds 被加签的用户 ID - * @param taskEntity 被加签的任务 - */ - private void createSignTaskList(List userIds, TaskEntityImpl taskEntity) { - if (CollUtil.isEmpty(userIds)) { - return; - } - // 创建加签人的新任务,全部基于 taskEntity 为父任务来创建 - for (String addSignId : userIds) { - if (StrUtil.isBlank(addSignId)) { - continue; - } - createSignTask(taskEntity, addSignId); - } - } - - /** - * 创建加签子任务 - * - * @param parentTask 父任务 - * @param assignee 子任务的执行人 - */ - private void createSignTask(TaskEntityImpl parentTask, String assignee) { - // 1. 生成子任务 - TaskEntityImpl task = (TaskEntityImpl) taskService.newTask(IdUtil.fastSimpleUUID()); - BpmTaskConvert.INSTANCE.copyTo(parentTask, task); - - // 2.1 向前加签,设置审批人 - if (BpmTaskSignTypeEnum.BEFORE.getType().equals(parentTask.getScopeType())) { - task.setAssignee(assignee); - // 2.2 向后加签,设置 owner 不设置 assignee 是因为不能同时审批,需要等父任务完成 - } else { - task.setOwner(assignee); - } - // 2.3 保存子任务 - taskService.saveTask(task); - - // 3. 向后前签,设置子任务的状态为 WAIT,因为需要等父任务审批完 - if (BpmTaskSignTypeEnum.AFTER.getType().equals(parentTask.getScopeType())) { - updateTaskStatus(task.getId(), BpmTaskStatusEnum.WAIT.getStatus()); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSignTask(Long userId, BpmTaskSignDeleteReqVO reqVO) { - // 1.1 校验 task 可以被减签 - Task task = validateTaskCanSignDelete(reqVO.getId()); - // 1.2 校验取消人存在 - AdminUserRespDTO cancelUser = null; - if (StrUtil.isNotBlank(task.getAssignee())) { - cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getAssignee())).getCheckedData(); - } - if (cancelUser == null && StrUtil.isNotBlank(task.getOwner())) { - cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())).getCheckedData(); - } - Assert.notNull(cancelUser, "任务中没有所有者和审批人,数据错误"); - - // 2.1 获得子任务列表,包括子任务的子任务 - List childTaskList = getAllChildTaskList(task); - childTaskList.add(task); - // 2.2 更新子任务为已取消 - String cancelReason = StrUtil.format("任务被取消,原因:由于[{}]操作[减签],", cancelUser.getNickname()); - childTaskList.forEach(childTask -> updateTaskStatusAndReason(childTask.getId(), BpmTaskStatusEnum.CANCEL.getStatus(), cancelReason)); - // 2.3 删除任务和所有子任务 - taskService.deleteTasks(convertList(childTaskList, Task::getId)); - - // 3. 记录日志到父任务中。先记录日志是因为,通过 handleParentTask 方法之后,任务可能被完成了,并且不存在了,会报异常,所以先记录 - AdminUserRespDTO user = adminUserApi.getUser(userId).getCheckedData(); - taskService.addComment(task.getParentTaskId(), task.getProcessInstanceId(), BpmCommentTypeEnum.SUB_SIGN.getType(), - StrUtil.format(BpmCommentTypeEnum.SUB_SIGN.getComment(), user.getNickname(), cancelUser.getNickname())); - - // 4. 处理当前任务的父任务 - handleParentTaskIfSign(task.getParentTaskId()); - } - - /** - * 校验任务是否能被减签 - * - * @param id 任务编号 - * @return 任务信息 - */ - private Task validateTaskCanSignDelete(String id) { - Task task = validateTaskExist(id); - if (task.getParentTaskId() == null) { - throw exception(TASK_SIGN_DELETE_NO_PARENT); - } - Task parentTask = getTask(task.getParentTaskId()); - if (parentTask == null) { - throw exception(TASK_SIGN_DELETE_NO_PARENT); - } - if (BpmTaskSignTypeEnum.of(parentTask.getScopeType()) == null) { - throw exception(TASK_SIGN_DELETE_NO_PARENT); - } - return task; - } - - /** - * 获得所有子任务列表 - * - * @param parentTask 父任务 - * @return 所有子任务列表 - */ - private List getAllChildTaskList(Task parentTask) { - List result = new ArrayList<>(); - // 1. 递归获取子级 - Stack stack = new Stack<>(); - stack.push(parentTask); - // 2. 递归遍历 - for (int i = 0; i < Short.MAX_VALUE; i++) { - if (stack.isEmpty()) { - break; - } - // 2.1 获取子任务们 - Task task = stack.pop(); - List childTaskList = getTaskListByParentTaskId(task.getId()); - // 2.2 如果非空,则添加到 stack 进一步递归 - if (CollUtil.isNotEmpty(childTaskList)) { - stack.addAll(childTaskList); - result.addAll(childTaskList); - } - } - return result; - } - - @Override - public List getTaskListByParentTaskId(String parentTaskId) { - String tableName = managementService.getTableName(TaskEntity.class); - // taskService.createTaskQuery() 没有 parentId 参数,所以写 sql 查询 - String sql = "select ID_,NAME_,OWNER_,ASSIGNEE_ from " + tableName + " where PARENT_TASK_ID_=#{parentTaskId}"; - return taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).list(); - } - - /** - * 获取子任务个数 - * - * @param parentTaskId 父任务 ID - * @return 剩余子任务个数 - */ - private Long getTaskCountByParentTaskId(String parentTaskId) { - String tableName = managementService.getTableName(TaskEntity.class); - String sql = "SELECT COUNT(1) from " + tableName + " WHERE PARENT_TASK_ID_=#{parentTaskId}"; - return taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).count(); - } - - @Override - public Map getTaskNameByTaskIds(Collection taskIds) { - if (CollUtil.isEmpty(taskIds)) { - return Collections.emptyMap(); - } - List tasks = taskService.createTaskQuery().taskIds(taskIds).list(); - return convertMap(tasks, Task::getId, Task::getName); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application-dev.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index 0753ceeeb..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,101 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - demo: true # 开启演示模式 diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application-local.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 2d60cea66..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,127 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.bpm.dal.mysql: debug - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - captcha: - enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试 - security: - mock-enable: true - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application.yaml deleted file mode 100644 index bd377f272..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,123 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# 工作流 Flowable 配置 -flowable: - # 1. false: 默认值,Flowable 启动时,对比数据库表中保存的版本,如果不匹配。将抛出异常 - # 2. true: 启动时会对数据库中所有表进行更新操作,如果表存在,不做处理,反之,自动创建表 - # 3. create_drop: 启动时自动创建表,关闭时自动删除表 - # 4. drop_create: 启动时,删除旧表,再创建新表 - database-schema-update: true # 设置为 false,可通过 https://github.com/flowable/flowable-sql 初始化 - db-history-used: true # flowable6 默认 true 生成信息表,无需手动设置 - check-process-definitions: false # 设置为 false,禁用 /resources/processes 自动部署 BPMN XML 流程 - history-level: audit # full:保存历史数据的最高级别,可保存全部流程相关细节,包括流程流转各节点参数 - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.bpm - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - captcha: - timeout: 5m - width: 160 - height: 60 - tenant: # 多租户相关配置项 - enable: true - -debug: false diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/bootstrap.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 0f30e625a..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: bpm-server - - profiles: - active: local - -server: - port: 48083 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/logback-spring.xml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvokerTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvokerTest.java deleted file mode 100644 index 702dce3f1..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvokerTest.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.BpmTaskCandidateUserStrategy; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.delegate.DelegateExecution; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * {@link BpmTaskCandidateInvoker} 的单元测试 - * - * @author 芋道源码 - */ -public class BpmTaskCandidateInvokerTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateInvoker taskCandidateInvoker; - - @Mock - private AdminUserApi adminUserApi; - @Spy - private BpmTaskCandidateStrategy strategy = new BpmTaskCandidateUserStrategy(); - @Spy - private List strategyList = Collections.singletonList(strategy); - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "1,2"; - DelegateExecution execution = mock(DelegateExecution.class); - // mock 方法(DelegateExecution) - UserTask userTask = mock(UserTask.class); - when(execution.getCurrentFlowElement()).thenReturn(userTask); - when(userTask.getAttributeValue(eq(BpmnModelConstants.NAMESPACE), eq(BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY))) - .thenReturn(BpmTaskCandidateStrategyEnum.USER.getStrategy().toString()); - when(userTask.getAttributeValue(eq(BpmnModelConstants.NAMESPACE), eq(BpmnModelConstants.USER_TASK_CANDIDATE_PARAM))) - .thenReturn(param); - // mock 方法(adminUserApi) - AdminUserRespDTO user1 = randomPojo(AdminUserRespDTO.class, o -> o.setId(1L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - AdminUserRespDTO user2 = randomPojo(AdminUserRespDTO.class, o -> o.setId(2L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - Map userMap = MapUtil.builder(user1.getId(), user1) - .put(user2.getId(), user2).build(); - when(adminUserApi.getUserMap(eq(asSet(1L, 2L)))).thenReturn(userMap); - - // 调用 - Set results = taskCandidateInvoker.calculateUsers(execution); - // 断言 - assertEquals(asSet(1L, 2L), results); - } - - @Test - public void testRemoveDisableUsers() { - // 准备参数. 1L 可以找到;2L 是禁用的;3L 找不到 - Set assigneeUserIds = asSet(1L, 2L, 3L); - // mock 方法 - AdminUserRespDTO user1 = randomPojo(AdminUserRespDTO.class, o -> o.setId(1L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - AdminUserRespDTO user2 = randomPojo(AdminUserRespDTO.class, o -> o.setId(2L) - .setStatus(CommonStatusEnum.DISABLE.getStatus())); - Map userMap = MapUtil.builder(user1.getId(), user1) - .put(user2.getId(), user2).build(); - when(adminUserApi.getUserMap(eq(assigneeUserIds))).thenReturn(userMap); - - // 调用 - taskCandidateInvoker.removeDisableUsers(assigneeUserIds); - // 断言 - assertEquals(asSet(1L), assigneeUserIds); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpressionTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpressionTest.java deleted file mode 100644 index 251af1d9f..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpressionTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.expression; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmTaskAssignLeaderExpressionTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskAssignLeaderExpression expression; - - @Mock - private AdminUserApi adminUserApi; - @Mock - private DeptApi deptApi; - - @Mock - private BpmProcessInstanceService processInstanceService; - - @Test - public void testCalculateUsers_noDept() { - // 准备参数 - DelegateExecution execution = mockDelegateExecution(1L); - // mock 方法(startUser) - AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(success(startUser)); - // mock 方法(getStartUserDept)没有部门 - when(deptApi.getDept(eq(10L))).thenReturn(success(null)); - - // 调用 - Set result = expression.calculateUsers(execution, 1); - // 断言 - assertEquals(0, result.size()); - } - - @Test - public void testCalculateUsers_noParentDept() { - // 准备参数 - DelegateExecution execution = mockDelegateExecution(1L); - // mock 方法(startUser) - AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(success(startUser)); - DeptRespDTO startUserDept = randomPojo(DeptRespDTO.class, o -> o.setId(10L).setParentId(100L) - .setLeaderUserId(20L)); - // mock 方法(getDept) - when(deptApi.getDept(eq(10L))).thenReturn(success(startUserDept)); - when(deptApi.getDept(eq(100L))).thenReturn(success(null)); - - // 调用 - Set result = expression.calculateUsers(execution, 2); - // 断言 - assertEquals(asSet(20L), result); - } - - @Test - public void testCalculateUsers_existParentDept() { - // 准备参数 - DelegateExecution execution = mockDelegateExecution(1L); - // mock 方法(startUser) - AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(success(startUser)); - DeptRespDTO startUserDept = randomPojo(DeptRespDTO.class, o -> o.setId(10L).setParentId(100L) - .setLeaderUserId(20L)); - when(deptApi.getDept(eq(10L))).thenReturn(success(startUserDept)); - // mock 方法(父 dept) - DeptRespDTO parentDept = randomPojo(DeptRespDTO.class, o -> o.setId(100L).setParentId(1000L) - .setLeaderUserId(200L)); - when(deptApi.getDept(eq(100L))).thenReturn(success(parentDept)); - - // 调用 - Set result = expression.calculateUsers(execution, 2); - // 断言 - assertEquals(asSet(200L), result); - } - - @SuppressWarnings("SameParameterValue") - private DelegateExecution mockDelegateExecution(Long startUserId) { - ExecutionEntityImpl execution = new ExecutionEntityImpl(); - execution.setProcessInstanceId(randomString()); - // mock 返回 startUserId - ExecutionEntityImpl processInstance = new ExecutionEntityImpl(); - processInstance.setStartUserId(String.valueOf(startUserId)); - when(processInstanceService.getProcessInstance(eq(execution.getProcessInstanceId()))) - .thenReturn(processInstance); - return execution; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptLeaderStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptLeaderStrategyTest.java deleted file mode 100644 index ac74ec5b4..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptLeaderStrategyTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmTaskCandidateDeptLeaderStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateDeptLeaderStrategy strategy; - - @Mock - private DeptApi deptApi; - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "1,2"; - // mock 方法 - DeptRespDTO dept1 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(11L)); - DeptRespDTO dept2 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(22L)); - when(deptApi.getDeptList(eq(asSet(1L, 2L)))).thenReturn(success(asList(dept1, dept2))); - - // 调用 - Set results = strategy.calculateUsers(null, param); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptMemberStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptMemberStrategyTest.java deleted file mode 100644 index 68b0e985a..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateDeptMemberStrategyTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmTaskCandidateDeptMemberStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateDeptMemberStrategy strategy; - - @Mock - private AdminUserApi adminUserApi; - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "11,22"; - // mock 方法 - List users = convertList(asSet(11L, 22L), - id -> new AdminUserRespDTO().setId(id)); - when(adminUserApi.getUserListByDeptIds(eq(asSet(11L, 22L)))).thenReturn(success(users)); - - // 调用 - Set results = strategy.calculateUsers(null, param); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategyTest.java deleted file mode 100644 index eaa2ef7b5..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateExpressionStrategyTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import org.flowable.engine.delegate.DelegateExecution; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.MockedStatic; - -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -public class BpmTaskCandidateExpressionStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateExpressionStrategy strategy; - - @Test - public void testCalculateUsers() { - try (MockedStatic flowableUtilMockedStatic = mockStatic(FlowableUtils.class)) { - // 准备参数 - String param = "1,2"; - DelegateExecution execution = mock(DelegateExecution.class); - // mock 方法 - flowableUtilMockedStatic.when(() -> FlowableUtils.getExpressionValue(same(execution), eq(param))) - .thenReturn(asSet(1L, 2L)); - - // 调用 - Set results = strategy.calculateUsers(execution, param); - // 断言 - assertEquals(asSet(1L, 2L), results); - } - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategyTest.java deleted file mode 100644 index 8bd2c88af..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateGroupStrategyTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.Arrays; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmTaskCandidateGroupStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateGroupStrategy strategy; - - @Mock - private BpmUserGroupService userGroupService; - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "1,2"; - // mock 方法 - BpmUserGroupDO userGroup1 = randomPojo(BpmUserGroupDO.class, o -> o.setUserIds(asSet(11L, 12L))); - BpmUserGroupDO userGroup2 = randomPojo(BpmUserGroupDO.class, o -> o.setUserIds(asSet(21L, 22L))); - when(userGroupService.getUserGroupList(eq(asSet(1L, 2L)))).thenReturn(Arrays.asList(userGroup1, userGroup2)); - - // 调用 - Set results = strategy.calculateUsers(null, param); - // 断言 - assertEquals(asSet(11L, 12L, 21L, 22L), results); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidatePostStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidatePostStrategyTest.java deleted file mode 100644 index 5a476ae01..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidatePostStrategyTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.api.dept.PostApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmTaskCandidatePostStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidatePostStrategy strategy; - - @Mock - private PostApi postApi; - @Mock - private AdminUserApi adminUserApi; - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "1,2"; - // mock 方法 - List users = convertList(asSet(11L, 22L), - id -> new AdminUserRespDTO().setId(id)); - when(adminUserApi.getUserListByPostIds(eq(asSet(1L, 2L)))).thenReturn(success(users)); - - // 调用 - Set results = strategy.calculateUsers(null, param); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateRoleStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateRoleStrategyTest.java deleted file mode 100644 index 23625f5f4..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateRoleStrategyTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.permission.RoleApi; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmTaskCandidateRoleStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateRoleStrategy strategy; - - @Mock - private RoleApi roleApi; - @Mock - private PermissionApi permissionApi; - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "1,2"; - // mock 方法 - when(permissionApi.getUserRoleIdListByRoleIds(eq(asSet(1L, 2L)))) - .thenReturn(success(asSet(11L, 22L))); - - // 调用 - Set results = strategy.calculateUsers(null, param); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateUserStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateUserStrategyTest.java deleted file mode 100644 index d71ccebfd..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/BpmTaskCandidateUserStrategyTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; - -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class BpmTaskCandidateUserStrategyTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskCandidateUserStrategy strategy; - - @Test - public void testCalculateUsers() { - // 准备参数 - String param = "1,2"; - - // 调用 - Set results = strategy.calculateUsers(null, param); - // 断言 - assertEquals(asSet(1L, 2L), results); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/category/BpmCategoryServiceImplTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/category/BpmCategoryServiceImplTest.java deleted file mode 100644 index f5033d7c6..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/category/BpmCategoryServiceImplTest.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.category; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategorySaveReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.category.BpmCategoryMapper; -import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryServiceImpl; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.CATEGORY_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link BpmCategoryServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(BpmCategoryServiceImpl.class) -public class BpmCategoryServiceImplTest extends BaseDbUnitTest { - - @Resource - private BpmCategoryServiceImpl categoryService; - - @Resource - private BpmCategoryMapper categoryMapper; - - @Test - public void testCreateCategory_success() { - // 准备参数 - BpmCategorySaveReqVO createReqVO = randomPojo(BpmCategorySaveReqVO.class).setId(null) - .setStatus(randomCommonStatus()); - - // 调用 - Long categoryId = categoryService.createCategory(createReqVO); - // 断言 - assertNotNull(categoryId); - // 校验记录的属性是否正确 - BpmCategoryDO category = categoryMapper.selectById(categoryId); - assertPojoEquals(createReqVO, category, "id"); - } - - @Test - public void testUpdateCategory_success() { - // mock 数据 - BpmCategoryDO dbCategory = randomPojo(BpmCategoryDO.class); - categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - BpmCategorySaveReqVO updateReqVO = randomPojo(BpmCategorySaveReqVO.class, o -> { - o.setId(dbCategory.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - }); - - // 调用 - categoryService.updateCategory(updateReqVO); - // 校验是否更新正确 - BpmCategoryDO category = categoryMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, category); - } - - @Test - public void testUpdateCategory_notExists() { - // 准备参数 - BpmCategorySaveReqVO updateReqVO = randomPojo(BpmCategorySaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> categoryService.updateCategory(updateReqVO), CATEGORY_NOT_EXISTS); - } - - @Test - public void testDeleteCategory_success() { - // mock 数据 - BpmCategoryDO dbCategory = randomPojo(BpmCategoryDO.class); - categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbCategory.getId(); - - // 调用 - categoryService.deleteCategory(id); - // 校验数据不存在了 - assertNull(categoryMapper.selectById(id)); - } - - @Test - public void testDeleteCategory_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> categoryService.deleteCategory(id), CATEGORY_NOT_EXISTS); - } - - @Test - public void testGetCategoryPage() { - // mock 数据 - BpmCategoryDO dbCategory = randomPojo(BpmCategoryDO.class, o -> { // 等会查询到 - o.setName("芋头"); - o.setCode("xiaodun"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2023, 2, 2)); - }); - categoryMapper.insert(dbCategory); - // 测试 name 不匹配 - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName("小盾"))); - // 测试 code 不匹配 - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setCode("tudou"))); - // 测试 status 不匹配 - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setCreateTime(buildTime(2024, 2, 2)))); - // 准备参数 - BpmCategoryPageReqVO reqVO = new BpmCategoryPageReqVO(); - reqVO.setName("芋"); - reqVO.setCode("xiao"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = categoryService.getCategoryPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbCategory, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java deleted file mode 100644 index 3d5d508fd..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java +++ /dev/null @@ -1,144 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormSaveReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmFormMapper; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmFormFieldRespDTO; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.FORM_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link BpmFormServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(BpmFormServiceImpl.class) -public class BpmFormServiceTest extends BaseDbUnitTest { - - @Resource - private BpmFormServiceImpl formService; - - @Resource - private BpmFormMapper formMapper; - - @Test - public void testCreateForm_success() { - // 准备参数 - BpmFormSaveReqVO reqVO = randomPojo(BpmFormSaveReqVO.class, o -> { - o.setConf("{}"); - o.setFields(randomFields()); - }); - - // 调用 - Long formId = formService.createForm(reqVO); - // 断言 - assertNotNull(formId); - // 校验记录的属性是否正确 - BpmFormDO form = formMapper.selectById(formId); - assertPojoEquals(reqVO, form); - } - - @Test - public void testUpdateForm_success() { - // mock 数据 - BpmFormDO dbForm = randomPojo(BpmFormDO.class, o -> { - o.setConf("{}"); - o.setFields(randomFields()); - }); - formMapper.insert(dbForm);// @Sql: 先插入出一条存在的数据 - // 准备参数 - BpmFormSaveReqVO reqVO = randomPojo(BpmFormSaveReqVO.class, o -> { - o.setId(dbForm.getId()); // 设置更新的 ID - o.setConf("{'yudao': 'yuanma'}"); - o.setFields(randomFields()); - }); - - // 调用 - formService.updateForm(reqVO); - // 校验是否更新正确 - BpmFormDO form = formMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, form); - } - - @Test - public void testUpdateForm_notExists() { - // 准备参数 - BpmFormSaveReqVO reqVO = randomPojo(BpmFormSaveReqVO.class, o -> { - o.setConf("{'yudao': 'yuanma'}"); - o.setFields(randomFields()); - }); - - // 调用, 并断言异常 - assertServiceException(() -> formService.updateForm(reqVO), FORM_NOT_EXISTS); - } - - @Test - public void testDeleteForm_success() { - // mock 数据 - BpmFormDO dbForm = randomPojo(BpmFormDO.class); - formMapper.insert(dbForm);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbForm.getId(); - - // 调用 - formService.deleteForm(id); - // 校验数据不存在了 - assertNull(formMapper.selectById(id)); - } - - @Test - public void testDeleteForm_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> formService.deleteForm(id), FORM_NOT_EXISTS); - } - - @Test - public void testGetFormPage() { - // mock 数据 - BpmFormDO dbForm = randomPojo(BpmFormDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - }); - formMapper.insert(dbForm); - // 测试 name 不匹配 - formMapper.insert(cloneIgnoreId(dbForm, o -> o.setName("源码"))); - // 准备参数 - BpmFormPageReqVO reqVO = new BpmFormPageReqVO(); - reqVO.setName("芋道"); - - // 调用 - PageResult pageResult = formService.getFormPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbForm, pageResult.getList().get(0)); - } - - private List randomFields() { - int size = RandomUtil.randomInt(1, 3); - return Stream.iterate(0, i -> i).limit(size) - .map(i -> JsonUtils.toJsonString(randomPojo(BpmFormFieldRespDTO.class))) - .collect(Collectors.toList()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java b/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java deleted file mode 100644 index 759e0f143..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.framework.test.core.util.AssertUtils; -import cn.iocoder.yudao.framework.test.core.util.RandomUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmUserGroupMapper; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.USER_GROUP_NOT_EXISTS; - -/** - * {@link BpmUserGroupServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(BpmUserGroupServiceImpl.class) -public class BpmUserGroupServiceTest extends BaseDbUnitTest { - - @Resource - private BpmUserGroupServiceImpl userGroupService; - - @Resource - private BpmUserGroupMapper userGroupMapper; - - @Test - public void testCreateUserGroup_success() { - // 准备参数 - BpmUserGroupSaveReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupSaveReqVO.class); - - // 调用 - Long userGroupId = userGroupService.createUserGroup(reqVO); - // 断言 - Assertions.assertNotNull(userGroupId); - // 校验记录的属性是否正确 - BpmUserGroupDO userGroup = userGroupMapper.selectById(userGroupId); - AssertUtils.assertPojoEquals(reqVO, userGroup); - } - - @Test - public void testUpdateUserGroup_success() { - // mock 数据 - BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class); - userGroupMapper.insert(dbUserGroup);// @Sql: 先插入出一条存在的数据 - // 准备参数 - BpmUserGroupSaveReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupSaveReqVO.class, o -> { - o.setId(dbUserGroup.getId()); // 设置更新的 ID - }); - - // 调用 - userGroupService.updateUserGroup(reqVO); - // 校验是否更新正确 - BpmUserGroupDO userGroup = userGroupMapper.selectById(reqVO.getId()); // 获取最新的 - AssertUtils.assertPojoEquals(reqVO, userGroup); - } - - @Test - public void testUpdateUserGroup_notExists() { - // 准备参数 - BpmUserGroupSaveReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupSaveReqVO.class); - - // 调用, 并断言异常 - AssertUtils.assertServiceException(() -> userGroupService.updateUserGroup(reqVO), USER_GROUP_NOT_EXISTS); - } - - @Test - public void testDeleteUserGroup_success() { - // mock 数据 - BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class); - userGroupMapper.insert(dbUserGroup);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbUserGroup.getId(); - - // 调用 - userGroupService.deleteUserGroup(id); - // 校验数据不存在了 - Assertions.assertNull(userGroupMapper.selectById(id)); - } - - @Test - public void testDeleteUserGroup_notExists() { - // 准备参数 - Long id = RandomUtils.randomLongId(); - - // 调用, 并断言异常 - AssertUtils.assertServiceException(() -> userGroupService.deleteUserGroup(id), USER_GROUP_NOT_EXISTS); - } - - @Test - public void testGetUserGroupPage() { - // mock 数据 - BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2021, 11, 11)); - }); - userGroupMapper.insert(dbUserGroup); - // 测试 name 不匹配 - userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setName("芋道"))); - // 测试 status 不匹配 - userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setCreateTime(buildTime(2021, 12, 12)))); - // 准备参数 - BpmUserGroupPageReqVO reqVO = new BpmUserGroupPageReqVO(); - reqVO.setName("源码"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 11, 10),buildTime(2021, 11, 12)})); - - // 调用 - PageResult pageResult = userGroupService.getUserGroupPage(reqVO); - // 断言 - Assertions.assertEquals(1, pageResult.getTotal()); - Assertions.assertEquals(1, pageResult.getList().size()); - AssertUtils.assertPojoEquals(dbUserGroup, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 9d37b82c2..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,45 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - global-config: - db-config: - id-type: AUTO # H2 主键递增 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module.bpm diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/logback.xml b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/clean.sql b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index d4f93bbc2..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,3 +0,0 @@ -DELETE FROM "bpm_form"; -DELETE FROM "bpm_user_group"; -DELETE FROM "bpm_category"; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 1034962c7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TABLE IF NOT EXISTS "bpm_user_group" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "description" varchar(255) NOT NULL, - "status" tinyint NOT NULL, - "user_ids" varchar(255) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '用户组'; - -CREATE TABLE IF NOT EXISTS "bpm_category" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "code" varchar(63) NOT NULL, - "description" varchar(255) NOT NULL, - "status" tinyint NOT NULL, - "sort" int NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '分类'; - -CREATE TABLE IF NOT EXISTS "bpm_form" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "status" tinyint NOT NULL, - "fields" varchar(255) NOT NULL, - "conf" varchar(255) NOT NULL, - "remark" varchar(255), - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '动态表单'; diff --git a/yudao-module-crm/pom.xml b/yudao-module-crm/pom.xml deleted file mode 100644 index 56921c6fb..000000000 --- a/yudao-module-crm/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - cn.iocoder.cloud - yudao - ${revision} - - - yudao-module-crm-api - yudao-module-crm-biz - - 4.0.0 - yudao-module-crm - pom - - ${project.artifactId} - - crm 包下,客户关系管理(Customer Relationship Management)。 - 例如说:客户、联系人、商机、合同、回款等等 - 商业智能 BI 模块,包括:报表、图表、数据大屏等等 - - - diff --git a/yudao-module-crm/yudao-module-crm-api/pom.xml b/yudao-module-crm/yudao-module-crm-api/pom.xml deleted file mode 100644 index fc97b6759..000000000 --- a/yudao-module-crm/yudao-module-crm-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-crm - ${revision} - - 4.0.0 - yudao-module-crm-api - jar - - ${project.artifactId} - - crm 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java deleted file mode 100644 index c38bde7f5..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * crm API 包,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.crm.api; diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ApiConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ApiConstants.java deleted file mode 100644 index 544ebf9f4..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "crm-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/crm"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java deleted file mode 100644 index eee2b32d9..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums; - -/** - * CRM 字典类型的枚举类 - * - * @author 芋道源码 - */ -public interface DictTypeConstants { - - String CRM_CUSTOMER_INDUSTRY = "crm_customer_industry"; // CRM 客户所属行业 - String CRM_CUSTOMER_LEVEL = "crm_customer_level"; // CRM 客户等级 - String CRM_CUSTOMER_SOURCE = "crm_customer_source"; // CRM 客户来源 - String CRM_AUDIT_STATUS = "crm_audit_status"; // CRM 审批状态 - String CRM_PRODUCT_UNIT = "crm_product_unit"; // CRM 产品单位 - String CRM_PRODUCT_STATUS = "crm_product_status"; // CRM 产品状态 - String CRM_FOLLOW_UP_TYPE = "crm_follow_up_type"; // CRM 跟进方式 - String CRM_RECEIVABLE_RETURN_TYPE = "crm_receivable_return_type"; // CRM 回款方式 - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java deleted file mode 100644 index 07a6dad60..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * CRM 错误码枚举类 - *

- * crm 系统,使用 1-020-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 合同管理 1-020-000-000 ========== - ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在"); - ErrorCode CONTRACT_UPDATE_FAIL_NOT_DRAFT = new ErrorCode(1_020_000_001, "合同更新失败,原因:合同不是草稿状态"); - ErrorCode CONTRACT_SUBMIT_FAIL_NOT_DRAFT = new ErrorCode(1_020_000_002, "合同提交审核失败,原因:合同没处在未提交状态"); - ErrorCode CONTRACT_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS = new ErrorCode(1_020_000_003, "更新合同审核状态失败,原因:合同不是审核中状态"); - ErrorCode CONTRACT_NO_EXISTS = new ErrorCode(1_020_000_004, "生成合同序列号重复,请重试"); - ErrorCode CONTRACT_DELETE_FAIL = new ErrorCode(1_020_000_005, "删除合同失败,原因:有被回款所使用"); - - // ========== 线索管理 1-020-001-000 ========== - ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在"); - ErrorCode CLUE_TRANSFORM_FAIL_ALREADY = new ErrorCode(1_020_001_001, "线索已经转化过了,请勿重复转化"); - - // ========== 商机管理 1-020-002-000 ========== - ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); - ErrorCode BUSINESS_DELETE_FAIL_CONTRACT_EXISTS = new ErrorCode(1_020_002_001, "商机已关联合同,不能删除"); - ErrorCode BUSINESS_UPDATE_STATUS_FAIL_END_STATUS = new ErrorCode(1_020_002_002, "更新商机状态失败,原因:已经是结束状态"); - ErrorCode BUSINESS_UPDATE_STATUS_FAIL_STATUS_EQUALS = new ErrorCode(1_020_002_003, "更新商机状态失败,原因:已经是该状态"); - - // ========== 联系人管理 1-020-003-000 ========== - ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); - ErrorCode CONTACT_DELETE_FAIL_CONTRACT_LINK_EXISTS = new ErrorCode(1_020_003_002, "联系人已关联合同,不能删除"); - ErrorCode CONTACT_UPDATE_OWNER_USER_FAIL = new ErrorCode(1_020_003_003, "更新联系人负责人失败"); - - // ========== 回款 1-020-004-000 ========== - ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在"); - ErrorCode RECEIVABLE_UPDATE_FAIL_EDITING_PROHIBITED = new ErrorCode(1_020_004_001, "更新回款失败,原因:禁止编辑"); - ErrorCode RECEIVABLE_DELETE_FAIL = new ErrorCode(1_020_004_002, "删除回款失败,原因: 被回款计划所使用,不允许删除"); - ErrorCode RECEIVABLE_SUBMIT_FAIL_NOT_DRAFT = new ErrorCode(1_020_004_003, "回款提交审核失败,原因:回款没处在未提交状态"); - ErrorCode RECEIVABLE_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS = new ErrorCode(1_020_004_004, "更新回款审核状态失败,原因:回款不是审核中状态"); - ErrorCode RECEIVABLE_NO_EXISTS = new ErrorCode(1_020_004_005, "生成回款序列号重复,请重试"); - ErrorCode RECEIVABLE_CREATE_FAIL_CONTRACT_NOT_APPROVE = new ErrorCode(1_020_004_006, "创建回款失败,原因:合同不是审核通过状态"); - ErrorCode RECEIVABLE_CREATE_FAIL_PRICE_EXCEEDS_LIMIT = new ErrorCode(1_020_004_007, "创建回款失败,原因:回款金额超出合同金额,目前剩余可退:{} 元"); - ErrorCode RECEIVABLE_DELETE_FAIL_IS_APPROVE = new ErrorCode(1_020_004_008, "删除回款失败,原因:回款审批已通过"); - - // ========== 回款计划 1-020-005-000 ========== - ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_020_005_000, "回款计划不存在"); - ErrorCode RECEIVABLE_PLAN_UPDATE_FAIL = new ErrorCode(1_020_006_000, "更想回款计划失败,原因:已经有对应的还款"); - ErrorCode RECEIVABLE_PLAN_EXISTS_RECEIVABLE = new ErrorCode(1_020_006_001, "回款计划已经有对应的回款,不能使用"); - - // ========== 客户管理 1_020_006_000 ========== - ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_006_000, "客户不存在"); - ErrorCode CUSTOMER_OWNER_EXISTS = new ErrorCode(1_020_006_001, "客户【{}】已存在所属负责人"); - ErrorCode CUSTOMER_LOCKED = new ErrorCode(1_020_006_002, "客户【{}】状态已锁定"); - ErrorCode CUSTOMER_ALREADY_DEAL = new ErrorCode(1_020_006_003, "客户已交易"); - ErrorCode CUSTOMER_IN_POOL = new ErrorCode(1_020_006_004, "客户【{}】放入公海失败,原因:已经是公海客户"); - ErrorCode CUSTOMER_LOCKED_PUT_POOL_FAIL = new ErrorCode(1_020_006_005, "客户【{}】放入公海失败,原因:客户已锁定"); - ErrorCode CUSTOMER_UPDATE_OWNER_USER_FAIL = new ErrorCode(1_020_006_006, "更新客户【{}】负责人失败, 原因:系统异常"); - ErrorCode CUSTOMER_LOCK_FAIL_IS_LOCK = new ErrorCode(1_020_006_007, "锁定客户失败,它已经处于锁定状态"); - ErrorCode CUSTOMER_UNLOCK_FAIL_IS_UNLOCK = new ErrorCode(1_020_006_008, "解锁客户失败,它已经处于未锁定状态"); - ErrorCode CUSTOMER_LOCK_EXCEED_LIMIT = new ErrorCode(1_020_006_009, "锁定客户失败,超出锁定规则上限"); - ErrorCode CUSTOMER_OWNER_EXCEED_LIMIT = new ErrorCode(1_020_006_010, "操作失败,超出客户数拥有上限"); - ErrorCode CUSTOMER_DELETE_FAIL_HAVE_REFERENCE = new ErrorCode(1_020_006_011, "删除客户失败,有关联{}"); - ErrorCode CUSTOMER_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_020_006_012, "导入客户数据不能为空!"); - ErrorCode CUSTOMER_CREATE_NAME_NOT_NULL = new ErrorCode(1_020_006_013, "客户名称不能为空!"); - ErrorCode CUSTOMER_NAME_EXISTS = new ErrorCode(1_020_006_014, "已存在名为【{}】的客户!"); - ErrorCode CUSTOMER_UPDATE_DEAL_STATUS_FAIL = new ErrorCode(1_020_006_015, "更新客户的成交状态失败,原因:已经是该状态,无需更新"); - - // ========== 权限管理 1_020_007_000 ========== - ErrorCode CRM_PERMISSION_NOT_EXISTS = new ErrorCode(1_020_007_000, "数据权限不存在"); - ErrorCode CRM_PERMISSION_DENIED = new ErrorCode(1_020_007_001, "{}操作失败,原因:没有权限"); - ErrorCode CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS = new ErrorCode(1_020_007_003, "{}操作失败,原因:转移对象已经是该负责人"); - ErrorCode CRM_PERMISSION_DELETE_FAIL = new ErrorCode(1_020_007_004, "删除数据权限失败,原因:批量删除权限的时候,只能属于同一个 bizId 下"); - ErrorCode CRM_PERMISSION_DELETE_DENIED = new ErrorCode(1_020_007_006, "删除数据权限失败,原因:没有权限"); - ErrorCode CRM_PERMISSION_DELETE_SELF_PERMISSION_FAIL_EXIST_OWNER = new ErrorCode(1_020_007_007, "删除数据权限失败,原因:不能删除负责人"); - ErrorCode CRM_PERMISSION_CREATE_FAIL = new ErrorCode(1_020_007_008, "创建数据权限失败,原因:所加用户已有权限"); - ErrorCode CRM_PERMISSION_CREATE_FAIL_EXISTS = new ErrorCode(1_020_007_009, "同时添加数据权限失败,原因:用户【{}】已有模块【{}】数据【{}】的【{}】权限"); - - // ========== 产品 1_020_008_000 ========== - ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_020_008_000, "产品不存在"); - ErrorCode PRODUCT_NO_EXISTS = new ErrorCode(1_020_008_001, "产品编号已存在"); - ErrorCode PRODUCT_NOT_ENABLE = new ErrorCode(1_020_008_002, "产品【{}】已禁用"); - - // ========== 产品分类 1_020_009_000 ========== - ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_020_009_000, "产品分类不存在"); - ErrorCode PRODUCT_CATEGORY_EXISTS = new ErrorCode(1_020_009_001, "产品分类已存在"); - ErrorCode PRODUCT_CATEGORY_USED = new ErrorCode(1_020_009_002, "产品分类已关联产品"); - ErrorCode PRODUCT_CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1_020_009_003, "父分类不存在"); - ErrorCode PRODUCT_CATEGORY_PARENT_NOT_FIRST_LEVEL = new ErrorCode(1_020_009_004, "父分类不能是二级分类"); - ErrorCode PRODUCT_CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_020_009_005, "存在子分类,无法删除"); - - // ========== 商机状态 1_020_010_000 ========== - ErrorCode BUSINESS_STATUS_TYPE_NOT_EXISTS = new ErrorCode(1_020_010_000, "商机状态组不存在"); - ErrorCode BUSINESS_STATUS_TYPE_NAME_EXISTS = new ErrorCode(1_020_010_001, "商机状态组的名称已存在"); - ErrorCode BUSINESS_STATUS_UPDATE_FAIL_USED = new ErrorCode(1_020_010_002, "已经被使用的商机状态组,无法进行更新"); - ErrorCode BUSINESS_STATUS_DELETE_FAIL_USED = new ErrorCode(1_020_010_002, "已经被使用的商机状态组,无法进行删除"); - ErrorCode BUSINESS_STATUS_NOT_EXISTS = new ErrorCode(1_020_010_003, "商机状态不存在"); - - // ========== 客户公海规则设置 1_020_012_000 ========== - ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_012_001, "客户限制配置不存在"); - - // ========== 跟进记录 1_020_013_000 ========== - ErrorCode FOLLOW_UP_RECORD_NOT_EXISTS = new ErrorCode(1_020_013_000, "跟进记录不存在"); - ErrorCode FOLLOW_UP_RECORD_DELETE_DENIED = new ErrorCode(1_020_013_001, "删除跟进记录失败,原因:没有权限"); - - // ========== 数据统计 1_020_014_000 ========== - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java deleted file mode 100644 index aeeed316d..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java +++ /dev/null @@ -1,163 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums; - -/** - * CRM 操作日志枚举 - * 目的:统一管理,也减少 Service 里各种“复杂”字符串 - * - * @author HUIHUI - */ -public interface LogRecordConstants { - - // ======================= CRM_CLUE 线索 ======================= - - String CRM_CLUE_TYPE = "CRM 线索"; - String CRM_CLUE_CREATE_SUB_TYPE = "创建线索"; - String CRM_CLUE_CREATE_SUCCESS = "创建了线索{{#clue.name}}"; - String CRM_CLUE_UPDATE_SUB_TYPE = "更新线索"; - String CRM_CLUE_UPDATE_SUCCESS = "更新了线索【{{#clueName}}】: {_DIFF{#updateReq}}"; - String CRM_CLUE_DELETE_SUB_TYPE = "删除线索"; - String CRM_CLUE_DELETE_SUCCESS = "删除了线索【{{#clueName}}】"; - String CRM_CLUE_TRANSFER_SUB_TYPE = "转移线索"; - String CRM_CLUE_TRANSFER_SUCCESS = "将线索【{{#clue.name}}】的负责人从【{getAdminUserById{#clue.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; - String CRM_CLUE_TRANSLATE_SUB_TYPE = "线索转化为客户"; - String CRM_CLUE_TRANSLATE_SUCCESS = "将线索【{{#clueName}}】转化为客户"; - String CRM_CLUE_FOLLOW_UP_SUB_TYPE = "线索跟进"; - String CRM_CLUE_FOLLOW_UP_SUCCESS = "线索跟进【{{#clueName}}】"; - - // ======================= CRM_CUSTOMER 客户 ======================= - - String CRM_CUSTOMER_TYPE = "CRM 客户"; - String CRM_CUSTOMER_CREATE_SUB_TYPE = "创建客户"; - String CRM_CUSTOMER_CREATE_SUCCESS = "创建了客户{{#customer.name}}"; - String CRM_CUSTOMER_UPDATE_SUB_TYPE = "更新客户"; - String CRM_CUSTOMER_UPDATE_SUCCESS = "更新了客户【{{#customerName}}】: {_DIFF{#updateReqVO}}"; - String CRM_CUSTOMER_DELETE_SUB_TYPE = "删除客户"; - String CRM_CUSTOMER_DELETE_SUCCESS = "删除了客户【{{#customerName}}】"; - String CRM_CUSTOMER_TRANSFER_SUB_TYPE = "转移客户"; - String CRM_CUSTOMER_TRANSFER_SUCCESS = "将客户【{{#customer.name}}】的负责人从【{getAdminUserById{#customer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; - String CRM_CUSTOMER_LOCK_SUB_TYPE = "{{#customer.lockStatus ? '解锁客户' : '锁定客户'}}"; - String CRM_CUSTOMER_LOCK_SUCCESS = "{{#customer.lockStatus ? '将客户【' + #customer.name + '】解锁' : '将客户【' + #customer.name + '】锁定'}}"; - String CRM_CUSTOMER_POOL_SUB_TYPE = "客户放入公海"; - String CRM_CUSTOMER_POOL_SUCCESS = "将客户【{{#customerName}}】放入了公海"; - String CRM_CUSTOMER_RECEIVE_SUB_TYPE = "{{#ownerUserName != null ? '分配客户' : '领取客户'}}"; - String CRM_CUSTOMER_RECEIVE_SUCCESS = "{{#ownerUserName != null ? '将客户【' + #customer.name + '】分配给【' + #ownerUserName + '】' : '领取客户【' + #customer.name + '】'}}"; - String CRM_CUSTOMER_IMPORT_SUB_TYPE = "{{#isUpdate ? '导入并更新客户' : '导入客户'}}"; - String CRM_CUSTOMER_IMPORT_SUCCESS = "{{#isUpdate ? '导入并更新了客户【'+ #customer.name +'】' : '导入了客户【'+ #customer.name +'】'}}"; - String CRM_CUSTOMER_UPDATE_DEAL_STATUS_SUB_TYPE = "更新客户成交状态"; - String CRM_CUSTOMER_UPDATE_DEAL_STATUS_SUCCESS = "更新了客户【{{#customerName}}】的成交状态为【{{#dealStatus ? '已成交' : '未成交'}}】"; - String CRM_CUSTOMER_FOLLOW_UP_SUB_TYPE = "客户跟进"; - String CRM_CUSTOMER_FOLLOW_UP_SUCCESS = "客户跟进【{{#customerName}}】"; - - // ======================= CRM_CUSTOMER_LIMIT_CONFIG 客户限制配置 ======================= - - String CRM_CUSTOMER_LIMIT_CONFIG_TYPE = "CRM 客户限制配置"; - String CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE = "创建客户限制配置"; - String CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS = "创建了【{{#limitType}}】类型的客户限制配置"; - String CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE = "更新客户限制配置"; - String CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS = "更新了客户限制配置: {_DIFF{#updateReqVO}}"; - String CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE = "删除客户限制配置"; - String CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS = "删除了【{{#limitType}}】类型的客户限制配置"; - - // ======================= CRM_CUSTOMER_POOL_CONFIG 客户公海规则 ======================= - - String CRM_CUSTOMER_POOL_CONFIG_TYPE = "CRM 客户公海规则"; - String CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE = "{{#isPoolConfigUpdate ? '更新客户公海规则' : '创建客户公海规则'}}"; - String CRM_CUSTOMER_POOL_CONFIG_SUCCESS = "{{#isPoolConfigUpdate ? '更新了客户公海规则' : '创建了客户公海规则'}}"; - - // ======================= CRM_CONTACT 联系人 ======================= - - String CRM_CONTACT_TYPE = "CRM 联系人"; - String CRM_CONTACT_CREATE_SUB_TYPE = "创建联系人"; - String CRM_CONTACT_CREATE_SUCCESS = "创建了联系人{{#contact.name}}"; - String CRM_CONTACT_UPDATE_SUB_TYPE = "更新联系人"; - String CRM_CONTACT_UPDATE_SUCCESS = "更新了联系人【{{#contactName}}】: {_DIFF{#updateReqVO}}"; - String CRM_CONTACT_DELETE_SUB_TYPE = "删除联系人"; - String CRM_CONTACT_DELETE_SUCCESS = "删除了联系人【{{#contactName}}】"; - String CRM_CONTACT_TRANSFER_SUB_TYPE = "转移联系人"; - String CRM_CONTACT_TRANSFER_SUCCESS = "将联系人【{{#contact.name}}】的负责人从【{getAdminUserById{#contact.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; - String CRM_CONTACT_FOLLOW_UP_SUB_TYPE = "联系人跟进"; - String CRM_CONTACT_FOLLOW_UP_SUCCESS = "联系人跟进【{{#contactName}}】"; - String CRM_CONTACT_UPDATE_OWNER_USER_SUB_TYPE = "更新联系人负责人"; - String CRM_CONTACT_UPDATE_OWNER_USER_SUCCESS = "将联系人【{{#contact.name}}】的负责人从【{getAdminUserById{#contact.ownerUserId}}】变更为了【{getAdminUserById{#ownerUserId}}】"; - - // ======================= CRM_BUSINESS 商机 ======================= - - String CRM_BUSINESS_TYPE = "CRM 商机"; - String CRM_BUSINESS_CREATE_SUB_TYPE = "创建商机"; - String CRM_BUSINESS_CREATE_SUCCESS = "创建了商机{{#business.name}}"; - String CRM_BUSINESS_UPDATE_SUB_TYPE = "更新商机"; - String CRM_BUSINESS_UPDATE_SUCCESS = "更新了商机【{{#businessName}}】: {_DIFF{#updateReqVO}}"; - String CRM_BUSINESS_DELETE_SUB_TYPE = "删除商机"; - String CRM_BUSINESS_DELETE_SUCCESS = "删除了商机【{{#businessName}}】"; - String CRM_BUSINESS_TRANSFER_SUB_TYPE = "转移商机"; - String CRM_BUSINESS_TRANSFER_SUCCESS = "将商机【{{#business.name}}】的负责人从【{getAdminUserById{#business.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; - String CRM_BUSINESS_FOLLOW_UP_SUB_TYPE = "商机跟进"; - String CRM_BUSINESS_FOLLOW_UP_SUCCESS = "商机跟进【{{#businessName}}】"; - String CRM_BUSINESS_UPDATE_STATUS_SUB_TYPE = "更新商机状态"; - String CRM_BUSINESS_UPDATE_STATUS_SUCCESS = "更新了商机【{{#businessName}}】的状态从【{{#oldStatusName}}】变更为了【{{#newStatusName}}】"; - - // ======================= CRM_CONTRACT_CONFIG 合同配置 ======================= - - String CRM_CONTRACT_CONFIG_TYPE = "CRM 合同配置"; - String CRM_CONTRACT_CONFIG_SUB_TYPE = "{{#isPoolConfigUpdate ? '更新合同配置' : '创建合同配置'}}"; - String CRM_CONTRACT_CONFIG_SUCCESS = "{{#isPoolConfigUpdate ? '更新了合同配置' : '创建了合同配置'}}"; - - // ======================= CRM_CONTRACT 合同 ======================= - - String CRM_CONTRACT_TYPE = "CRM 合同"; - String CRM_CONTRACT_CREATE_SUB_TYPE = "创建合同"; - String CRM_CONTRACT_CREATE_SUCCESS = "创建了合同{{#contract.name}}"; - String CRM_CONTRACT_UPDATE_SUB_TYPE = "更新合同"; - String CRM_CONTRACT_UPDATE_SUCCESS = "更新了合同【{{#contractName}}】: {_DIFF{#updateReqVO}}"; - String CRM_CONTRACT_DELETE_SUB_TYPE = "删除合同"; - String CRM_CONTRACT_DELETE_SUCCESS = "删除了合同【{{#contractName}}】"; - String CRM_CONTRACT_TRANSFER_SUB_TYPE = "转移合同"; - String CRM_CONTRACT_TRANSFER_SUCCESS = "将合同【{{#contract.name}}】的负责人从【{getAdminUserById{#contract.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; - String CRM_CONTRACT_SUBMIT_SUB_TYPE = "提交合同审批"; - String CRM_CONTRACT_SUBMIT_SUCCESS = "提交合同【{{#contractName}}】审批成功"; - String CRM_CONTRACT_FOLLOW_UP_SUB_TYPE = "合同跟进"; - String CRM_CONTRACT_FOLLOW_UP_SUCCESS = "合同跟进【{{#contractName}}】"; - - // ======================= CRM_PRODUCT 产品 ======================= - - String CRM_PRODUCT_TYPE = "CRM 产品"; - String CRM_PRODUCT_CREATE_SUB_TYPE = "创建产品"; - String CRM_PRODUCT_CREATE_SUCCESS = "创建了产品【{{#createReqVO.name}}】"; - String CRM_PRODUCT_UPDATE_SUB_TYPE = "更新产品"; - String CRM_PRODUCT_UPDATE_SUCCESS = "更新了产品【{{#updateReqVO.name}}】: {_DIFF{#updateReqVO}}"; - String CRM_PRODUCT_DELETE_SUB_TYPE = "删除产品"; - String CRM_PRODUCT_DELETE_SUCCESS = "删除了产品【{{#product.name}}】"; - - // ======================= CRM_PRODUCT_CATEGORY 产品分类 ======================= - - String CRM_PRODUCT_CATEGORY_TYPE = "CRM 产品分类"; - String CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE = "创建产品分类"; - String CRM_PRODUCT_CATEGORY_CREATE_SUCCESS = "创建了产品分类【{{#createReqVO.name}}】"; - String CRM_PRODUCT_CATEGORY_UPDATE_SUB_TYPE = "更新产品分类"; - String CRM_PRODUCT_CATEGORY_UPDATE_SUCCESS = "更新了产品分类【{{#updateReqVO.name}}】: {_DIFF{#updateReqVO}}"; - String CRM_PRODUCT_CATEGORY_DELETE_SUB_TYPE = "删除产品分类"; - String CRM_PRODUCT_CATEGORY_DELETE_SUCCESS = "删除了产品分类【{{#productCategory.name}}】"; - - // ======================= CRM_RECEIVABLE 回款 ======================= - - String CRM_RECEIVABLE_TYPE = "CRM 回款"; - String CRM_RECEIVABLE_CREATE_SUB_TYPE = "创建回款"; - String CRM_RECEIVABLE_CREATE_SUCCESS = "创建了合同【{getContractById{#receivable.contractId}}】的{{#period != null ? '【第'+ #period +'期】' : '编号为【'+ #receivable.no +'】的'}}回款"; - String CRM_RECEIVABLE_UPDATE_SUB_TYPE = "更新回款"; - String CRM_RECEIVABLE_UPDATE_SUCCESS = "更新了合同【{getContractById{#receivable.contractId}}】的{{#period != null ? '【第'+ #period +'期】' : '编号为【'+ #receivable.no +'】的'}}回款: {_DIFF{#updateReqVO}}"; - String CRM_RECEIVABLE_DELETE_SUB_TYPE = "删除回款"; - String CRM_RECEIVABLE_DELETE_SUCCESS = "删除了合同【{getContractById{#receivable.contractId}}】的{{#period != null ? '【第'+ #period +'期】' : '编号为【'+ #receivable.no +'】的'}}回款"; - String CRM_RECEIVABLE_SUBMIT_SUB_TYPE = "提交回款审批"; - String CRM_RECEIVABLE_SUBMIT_SUCCESS = "提交编号为【{{#receivableNo}}】的回款审批成功"; - - // ======================= CRM_RECEIVABLE_PLAN 回款计划 ======================= - - String CRM_RECEIVABLE_PLAN_TYPE = "CRM 回款计划"; - String CRM_RECEIVABLE_PLAN_CREATE_SUB_TYPE = "创建回款计划"; - String CRM_RECEIVABLE_PLAN_CREATE_SUCCESS = "创建了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划"; - String CRM_RECEIVABLE_PLAN_UPDATE_SUB_TYPE = "更新回款计划"; - String CRM_RECEIVABLE_PLAN_UPDATE_SUCCESS = "更新了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划: {_DIFF{#updateReqVO}}"; - String CRM_RECEIVABLE_PLAN_DELETE_SUB_TYPE = "删除回款计划"; - String CRM_RECEIVABLE_PLAN_DELETE_SUCCESS = "删除了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划"; - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/business/CrmBusinessEndStatusEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/business/CrmBusinessEndStatusEnum.java deleted file mode 100644 index 4736c01b7..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/business/CrmBusinessEndStatusEnum.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.business; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 商机的结束状态枚举 - * - * @author lzxhqs - */ -@RequiredArgsConstructor -@Getter -public enum CrmBusinessEndStatusEnum implements IntArrayValuable { - - WIN(1, "赢单"), - LOSE(2, "输单"), - INVALID(3, "无效"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBusinessEndStatusEnum::getStatus).toArray(); - - /** - * 场景类型 - */ - private final Integer status; - /** - * 场景名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - public static CrmBusinessEndStatusEnum fromStatus(Integer status) { - return Arrays.stream(values()) - .filter(value -> value.getStatus().equals(status)) - .findFirst() - .orElse(null); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java deleted file mode 100644 index 67709e95b..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * CRM 的审批状态 - * - * @author 赤焰 - */ -@RequiredArgsConstructor -@Getter -public enum CrmAuditStatusEnum implements IntArrayValuable { - - DRAFT(0, "未提交"), - PROCESS(10, "审批中"), - APPROVE(20, "审核通过"), - REJECT(30, "审核不通过"), - CANCEL(40, "已取消"); - - private final Integer status; - private final String name; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmAuditStatusEnum::getStatus).toArray(); - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java deleted file mode 100644 index 8402ad288..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.common; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * CRM 业务类型枚举 - * - * @author HUIHUI - */ -@RequiredArgsConstructor -@Getter -public enum CrmBizTypeEnum implements IntArrayValuable { - - CRM_CLUE(1, "线索"), - CRM_CUSTOMER(2, "客户"), - CRM_CONTACT(3, "联系人"), - CRM_BUSINESS(4, "商机"), - CRM_CONTRACT(5, "合同"), - CRM_PRODUCT(6, "产品"), - CRM_RECEIVABLE(7, "回款"), - CRM_RECEIVABLE_PLAN(8, "回款计划") - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 名称 - */ - private final String name; - - public static String getNameByType(Integer type) { - CrmBizTypeEnum typeEnum = CollUtil.findOne(CollUtil.newArrayList(CrmBizTypeEnum.values()), - item -> ObjUtil.equal(item.type, type)); - return typeEnum == null ? null : typeEnum.getName(); - } - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmSceneTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmSceneTypeEnum.java deleted file mode 100644 index 945d7c6a3..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmSceneTypeEnum.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.common; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 列表检索场景 - * - * @author HUIHUI - */ -@Getter -@AllArgsConstructor -public enum CrmSceneTypeEnum implements IntArrayValuable { - - OWNER(1, "我负责的"), - INVOLVED(2, "我参与的"), - SUBORDINATE(3, "下属负责的"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneTypeEnum::getType).toArray(); - - /** - * 场景类型 - */ - private final Integer type; - /** - * 场景名称 - */ - private final String name; - - public static boolean isOwner(Integer type) { - return ObjUtil.equal(OWNER.getType(), type); - } - - public static boolean isInvolved(Integer type) { - return ObjUtil.equal(INVOLVED.getType(), type); - } - - public static boolean isSubordinate(Integer type) { - return ObjUtil.equal(SUBORDINATE.getType(), type); - } - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java deleted file mode 100644 index aa06b05eb..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.customer; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 客户等级 - * - * @author Wanwan - */ -@Getter -@AllArgsConstructor -public enum CrmCustomerLevelEnum implements IntArrayValuable { - - IMPORTANT(1, "A(重点客户)"), - GENERAL(2, "B(普通客户)"), - LOW_PRIORITY(3, "C(非优先客户)"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerLevelEnum::getLevel).toArray(); - - /** - * 状态 - */ - private final Integer level; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLimitConfigTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLimitConfigTypeEnum.java deleted file mode 100644 index 2cf8d7811..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLimitConfigTypeEnum.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.customer; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 客户限制配置规则类型 - * - * @author Wanwan - */ -@Getter -@AllArgsConstructor -public enum CrmCustomerLimitConfigTypeEnum implements IntArrayValuable { - - /** - * 拥有客户数限制 - */ - CUSTOMER_OWNER_LIMIT(1, "拥有客户数限制"), - /** - * 锁定客户数限制 - */ - CUSTOMER_LOCK_LIMIT(2, "锁定客户数限制"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerLimitConfigTypeEnum::getType).toArray(); - - /** - * 状态 - */ - private final Integer type; - /** - * 状态名 - */ - private final String name; - - public static String getNameByType(Integer type) { - CrmCustomerLimitConfigTypeEnum typeEnum = CollUtil.findOne(CollUtil.newArrayList(CrmCustomerLimitConfigTypeEnum.values()), - item -> ObjUtil.equal(item.type, type)); - return typeEnum == null ? null : typeEnum.getName(); - } - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/permission/CrmPermissionLevelEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/permission/CrmPermissionLevelEnum.java deleted file mode 100644 index f36e8cfff..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/permission/CrmPermissionLevelEnum.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.permission; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 数据权限级别枚举 - * - * OWNER > WRITE > READ - * - * @author HUIHUI - */ -@Getter -@AllArgsConstructor -public enum CrmPermissionLevelEnum implements IntArrayValuable { - - OWNER(1, "负责人"), - READ(2, "只读"), - WRITE(3, "读写"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmPermissionLevelEnum::getLevel).toArray(); - - /** - * 级别 - */ - private final Integer level; - /** - * 级别名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - public static boolean isOwner(Integer level) { - return ObjUtil.equal(OWNER.level, level); - } - - public static boolean isRead(Integer level) { - return ObjUtil.equal(READ.level, level); - } - - public static boolean isWrite(Integer level) { - return ObjUtil.equal(WRITE.level, level); - } - - public static String getNameByLevel(Integer level) { - CrmPermissionLevelEnum typeEnum = CollUtil.findOne(CollUtil.newArrayList(CrmPermissionLevelEnum.values()), - item -> ObjUtil.equal(item.level, level)); - return typeEnum == null ? null : typeEnum.getName(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/product/CrmProductStatusEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/product/CrmProductStatusEnum.java deleted file mode 100644 index 9516c35c6..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/product/CrmProductStatusEnum.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.product; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 商品状态 - * - * @author ZanGe丶 - * @since 2023-11-30 21:53 - */ -@Getter -@AllArgsConstructor -public enum CrmProductStatusEnum implements IntArrayValuable { - - DISABLE(0, "下架"), - ENABLE(1, "上架"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmProductStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - public static boolean isEnable(Integer status) { - return ObjUtil.equal(ENABLE.status, status); - } - - public static boolean isDisable(Integer status) { - return ObjUtil.equal(DISABLE.status, status); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/receivable/CrmReceivableReturnTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/receivable/CrmReceivableReturnTypeEnum.java deleted file mode 100644 index 3c01fe95c..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/receivable/CrmReceivableReturnTypeEnum.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums.receivable; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * CRM 回款方式枚举 - * - * @author HUIHUI - */ -@Getter -@AllArgsConstructor -public enum CrmReceivableReturnTypeEnum implements IntArrayValuable { - - CHECK(1, "支票"), - CASH(2, "现金"), - POSTAL_REMITTANCE(3, "邮政汇款"), - TELEGRAPHIC_TRANSFER(4, "电汇"), - ONLINE_TRANSFER(5, "网上转账"), - ALIPAY(6, "支付宝"), - WECHAT_PAY(7, "微信支付"), - OTHER(8, "其它"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmReceivableReturnTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/Dockerfile b/yudao-module-crm/yudao-module-crm-biz/Dockerfile deleted file mode 100644 index bdda8ac15..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-crm-biz -WORKDIR /yudao-module-crm-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-crm-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48089 端口 -EXPOSE 48089 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-crm/yudao-module-crm-biz/pom.xml b/yudao-module-crm/yudao-module-crm-biz/pom.xml deleted file mode 100644 index 93e4a8a5c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/pom.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-crm - ${revision} - - 4.0.0 - yudao-module-crm-biz - - ${project.artifactId} - - crm 包下,客户关系管理(Customer Relationship Management)。 - 例如说:客户、联系人、商机、合同、回款等等 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - cn.iocoder.cloud - yudao-module-crm-api - ${revision} - - - cn.iocoder.cloud - yudao-module-bpm-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-ip - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-job - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/CrmServerApplication.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/CrmServerApplication.java deleted file mode 100644 index 36bc7e8e3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/CrmServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - *

- * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class CrmServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(CrmServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java deleted file mode 100644 index 5c4e2493e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * crm API 实现类,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.crm.api; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java deleted file mode 100644 index f55bd8974..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java +++ /dev/null @@ -1,222 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.product.CrmProductService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; - -@Tag(name = "管理后台 - CRM 商机") -@RestController -@RequestMapping("/crm/business") -@Validated -public class CrmBusinessController { - - @Resource - private CrmBusinessService businessService; - @Resource - private CrmCustomerService customerService; - @Resource - private CrmBusinessStatusService businessStatusTypeService; - @Resource - private CrmBusinessStatusService businessStatusService; - @Resource - private CrmProductService productService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @PostMapping("/create") - @Operation(summary = "创建商机") - @PreAuthorize("@ss.hasPermission('crm:business:create')") - public CommonResult createBusiness(@Valid @RequestBody CrmBusinessSaveReqVO createReqVO) { - return success(businessService.createBusiness(createReqVO, getLoginUserId())); - } - - @PutMapping("/update") - @Operation(summary = "更新商机") - @PreAuthorize("@ss.hasPermission('crm:business:update')") - public CommonResult updateBusiness(@Valid @RequestBody CrmBusinessSaveReqVO updateReqVO) { - businessService.updateBusiness(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新商机状态") - @PreAuthorize("@ss.hasPermission('crm:business:update')") - public CommonResult updateBusinessStatus(@Valid @RequestBody CrmBusinessUpdateStatusReqVO updateStatusReqVO) { - businessService.updateBusinessStatus(updateStatusReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商机") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:business:delete')") - public CommonResult deleteBusiness(@RequestParam("id") Long id) { - businessService.deleteBusiness(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得商机") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:business:query')") - public CommonResult getBusiness(@RequestParam("id") Long id) { - CrmBusinessDO business = businessService.getBusiness(id); - return success(buildBusinessDetail(business)); - } - - private CrmBusinessRespVO buildBusinessDetail(CrmBusinessDO business) { - if (business == null) { - return null; - } - CrmBusinessRespVO businessVO = buildBusinessDetailList(Collections.singletonList(business)).get(0); - // 拼接产品项 - List businessProducts = businessService.getBusinessProductListByBusinessId(businessVO.getId()); - Map productMap = productService.getProductMap( - convertSet(businessProducts, CrmBusinessProductDO::getProductId)); - businessVO.setProducts(BeanUtils.toBean(businessProducts, CrmBusinessRespVO.Product.class, businessProductVO -> - MapUtils.findAndThen(productMap, businessProductVO.getProductId(), - product -> businessProductVO.setProductName(product.getName()) - .setProductNo(product.getNo()).setProductUnit(product.getUnit())))); - return businessVO; - } - - @GetMapping("/simple-all-list") - @Operation(summary = "获得联系人的精简列表") - @PreAuthorize("@ss.hasPermission('crm:contact:query')") - public CommonResult> getSimpleContactList() { - CrmBusinessPageReqVO reqVO = new CrmBusinessPageReqVO(); - reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 - PageResult pageResult = businessService.getBusinessPage(reqVO, getLoginUserId()); - return success(convertList(pageResult.getList(), business -> // 只返回 id、name 字段 - new CrmBusinessRespVO().setId(business.getId()).setName(business.getName()) - .setCustomerId(business.getCustomerId()))); - } - - @GetMapping("/page") - @Operation(summary = "获得商机分页") - @PreAuthorize("@ss.hasPermission('crm:business:query')") - public CommonResult> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) { - PageResult pageResult = businessService.getBusinessPage(pageVO, getLoginUserId()); - return success(new PageResult<>(buildBusinessDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得商机分页,基于指定客户") - public CommonResult> getBusinessPageByCustomer(@Valid CrmBusinessPageReqVO pageReqVO) { - if (pageReqVO.getCustomerId() == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - PageResult pageResult = businessService.getBusinessPageByCustomerId(pageReqVO); - return success(new PageResult<>(buildBusinessDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/page-by-contact") - @Operation(summary = "获得联系人的商机分页") - @PreAuthorize("@ss.hasPermission('crm:business:query')") - public CommonResult> getBusinessContactPage(@Valid CrmBusinessPageReqVO pageReqVO) { - PageResult pageResult = businessService.getBusinessPageByContact(pageReqVO); - return success(new PageResult<>(buildBusinessDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出商机 Excel") - @PreAuthorize("@ss.hasPermission('crm:business:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportBusinessExcel(@Valid CrmBusinessPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - exportReqVO.setPageSize(PAGE_SIZE_NONE); - List list = businessService.getBusinessPage(exportReqVO, getLoginUserId()).getList(); - // 导出 Excel - ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessRespVO.class, - buildBusinessDetailList(list)); - } - - public List buildBusinessDetailList(List list) { - if (CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - // 1.1 获取客户列表 - Map customerMap = customerService.getCustomerMap( - convertSet(list, CrmBusinessDO::getCustomerId)); - // 1.2 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(list, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 1.3 获得商机状态组 - Map statusTypeMap = businessStatusTypeService.getBusinessStatusTypeMap( - convertSet(list, CrmBusinessDO::getStatusTypeId)); - Map statusMap = businessStatusService.getBusinessStatusMap( - convertSet(list, CrmBusinessDO::getStatusId)); - // 2. 拼接数据 - return BeanUtils.toBean(list, CrmBusinessRespVO.class, businessVO -> { - // 2.1 设置客户名称 - MapUtils.findAndThen(customerMap, businessVO.getCustomerId(), customer -> businessVO.setCustomerName(customer.getName())); - // 2.2 设置创建人、负责人名称 - MapUtils.findAndThen(userMap, NumberUtils.parseLong(businessVO.getCreator()), - user -> businessVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, businessVO.getOwnerUserId(), user -> { - businessVO.setOwnerUserName(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> businessVO.setOwnerUserDeptName(dept.getName())); - }); - // 2.3 设置商机状态 - MapUtils.findAndThen(statusTypeMap, businessVO.getStatusTypeId(), statusType -> businessVO.setStatusTypeName(statusType.getName())); - MapUtils.findAndThen(statusMap, businessVO.getStatusId(), status -> businessVO.setStatusName( - businessService.getBusinessStatusName(businessVO.getEndStatus(), status))); - }); - } - - @PutMapping("/transfer") - @Operation(summary = "商机转移") - @PreAuthorize("@ss.hasPermission('crm:business:update')") - public CommonResult transferBusiness(@Valid @RequestBody CrmBusinessTransferReqVO reqVO) { - businessService.transferBusiness(reqVO, getLoginUserId()); - return success(true); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusController.java deleted file mode 100644 index 016670527..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusController.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - CRM 商机状态") -@RestController -@RequestMapping("/crm/business-status") -@Validated -public class CrmBusinessStatusController { - - @Resource - private CrmBusinessStatusService businessStatusTypeService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @PostMapping("/create") - @Operation(summary = "创建商机状态") - @PreAuthorize("@ss.hasPermission('crm:business-status:create')") - public CommonResult createBusinessStatus(@Valid @RequestBody CrmBusinessStatusSaveReqVO createReqVO) { - return success(businessStatusTypeService.createBusinessStatus(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新商机状态") - @PreAuthorize("@ss.hasPermission('crm:business-status:update')") - public CommonResult updateBusinessStatus(@Valid @RequestBody CrmBusinessStatusSaveReqVO updateReqVO) { - businessStatusTypeService.updateBusinessStatus(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商机状态") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:business-status:delete')") - public CommonResult deleteBusinessStatusType(@RequestParam("id") Long id) { - businessStatusTypeService.deleteBusinessStatusType(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得商机状态") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:business-status:query')") - public CommonResult getBusinessStatusType(@RequestParam("id") Long id) { - CrmBusinessStatusTypeDO statusType = businessStatusTypeService.getBusinessStatusType(id); - if (statusType == null) { - return success(null); - } - List statuses = businessStatusTypeService.getBusinessStatusListByTypeId(id); - return success(BeanUtils.toBean(statusType, CrmBusinessStatusRespVO.class, - statusTypeVO -> statusTypeVO.setStatuses(BeanUtils.toBean(statuses, CrmBusinessStatusRespVO.Status.class)))); - } - - @GetMapping("/page") - @Operation(summary = "获得商机状态分页") - @PreAuthorize("@ss.hasPermission('crm:business-status:query')") - public CommonResult> getBusinessStatusPage(@Valid PageParam pageReqVO) { - // 1. 查询数据 - PageResult pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - // 2. 拼接数据 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), statusType -> Long.parseLong(statusType.getCreator()))); - Map deptMap = deptApi.getDeptMap( - convertSetByFlatMap(pageResult.getList(), CrmBusinessStatusTypeDO::getDeptIds, Collection::stream)); - return success(BeanUtils.toBean(pageResult, CrmBusinessStatusRespVO.class, statusTypeVO -> { - statusTypeVO.setCreator(userMap.get(NumberUtils.parseLong(statusTypeVO.getCreator())).getNickname()); - statusTypeVO.setDeptNames(convertList(statusTypeVO.getDeptIds(), - deptId -> deptMap.containsKey(deptId) ? deptMap.get(deptId).getName() : null)); - })); - } - - @GetMapping("/type-simple-list") - @Operation(summary = "获得商机状态组列表") - public CommonResult> getBusinessStatusTypeSimpleList() { - List list = businessStatusTypeService.getBusinessStatusTypeList(); - // 过滤掉部门不匹配的 - Long deptId = adminUserApi.getUser(getLoginUserId()).getCheckedData().getDeptId(); - list.removeIf(statusType -> CollUtil.isNotEmpty(statusType.getDeptIds()) && !statusType.getDeptIds().contains(deptId)); - return success(BeanUtils.toBean(list, CrmBusinessStatusRespVO.class)); - } - - @GetMapping("/status-simple-list") - @Operation(summary = "获得商机状态列表") - @Parameter(name = "typeId", description = "商机状态组", required = true, example = "1024") - public CommonResult> getBusinessStatusSimpleList(@RequestParam("typeId") Long typeId) { - List list = businessStatusTypeService.getBusinessStatusListByTypeId(typeId); - return success(BeanUtils.toBean(list, CrmBusinessStatusRespVO.Status.class)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessPageReqVO.java deleted file mode 100644 index 0e47bf5be..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商机分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmBusinessPageReqVO extends PageParam { - - @Schema(description = "商机名称", example = "李四") - private String name; - - @Schema(description = "客户编号", example = "10795") - private Long customerId; - - @Schema(description = "联系人编号", example = "10795") - private Long contactId; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessRespVO.java deleted file mode 100644 index 49cdcb80b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessRespVO.java +++ /dev/null @@ -1,144 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - CRM 商机 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmBusinessRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "商机名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("商机名称") - private String name; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10299") - private Long customerId; - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example ="true") - @ExcelProperty("跟进状态") - private Boolean followUpStatus; - - @Schema(description = "最后跟进时间") - @ExcelProperty("最后跟进时间") - private LocalDateTime contactLastTime; - - @Schema(description = "下次联系时间") - @ExcelProperty("下次联系时间") - private LocalDateTime contactNextTime; - - @Schema(description = "负责人的用户编号", example = "25682") - @ExcelProperty("负责人的用户编号") - private Long ownerUserId; - @Schema(description = "负责人名字", example = "25682") - @ExcelProperty("负责人名字") - private String ownerUserName; - @Schema(description = "负责人部门") - @ExcelProperty("负责人部门") - private String ownerUserDeptName; - - @Schema(description = "商机状态组编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714") - private Long statusTypeId; - @Schema(description = "商机状组名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "进行中") - @ExcelProperty("商机状态组") - private String statusTypeName; - - @Schema(description = "商机状态编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") - private Long statusId; - @Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "跟进中") - @ExcelProperty("商机状态") - private String statusName; - - @Schema - @ExcelProperty("结束状态") - private Integer endStatus; - - @ExcelProperty("结束时的备注") - private String endRemark; - - @Schema(description = "预计成交日期") - @ExcelProperty("预计成交日期") - private LocalDateTime dealTime; - - @Schema(description = "产品总金额", example = "12025") - @ExcelProperty("产品总金额") - private BigDecimal totalProductPrice; - - @Schema(description = "整单折扣") - @ExcelProperty("整单折扣") - private BigDecimal discountPercent; - - @Schema(description = "商机总金额", example = "12371") - @ExcelProperty("商机总金额") - private BigDecimal totalPrice; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "1024") - @ExcelProperty("创建人") - private String creator; - @Schema(description = "创建人名字", example = "芋道源码") - @ExcelProperty("创建人名字") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - - @Schema(description = "产品列表") - private List products; - - @Schema(description = "产品列表") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Product { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") - private Long productId; - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") - private String productNo; - @Schema(description = "产品单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private Integer productUnit; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - private BigDecimal productPrice; - - @Schema(description = "商机价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - private BigDecimal businessPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - private BigDecimal count; - - @Schema(description = "总计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - private BigDecimal totalPrice; - - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessSaveReqVO.java deleted file mode 100644 index 86864dc0f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessSaveReqVO.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAdminUserParseFunction; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.springframework.format.annotation.DateTimeFormat; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 商机创建/更新 Request VO") -@Data -public class CrmBusinessSaveReqVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") - private Long id; - - @Schema(description = "商机名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @DiffLogField(name = "商机名称") - @NotNull(message = "商机名称不能为空") - private String name; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10299") - @DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME) - @NotNull(message = "客户不能为空") - private Long customerId; - - @Schema(description = "下次联系时间") - @DiffLogField(name = "下次联系时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactNextTime; - - @Schema(description = "负责人用户编号", example = "14334") - @NotNull(message = "负责人不能为空") - @DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME) - private Long ownerUserId; - - @Schema(description = "商机状态组编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714") - @DiffLogField(name = "商机状态组") - @NotNull(message = "商机状态组不能为空") - private Long statusTypeId; - - @Schema(description = "预计成交日期") - @DiffLogField(name = "预计成交日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime dealTime; - - @Schema(description = "整单折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "55.00") - @DiffLogField(name = "整单折扣") - @NotNull(message = "整单折扣不能为空") - private BigDecimal discountPercent; - - @Schema(description = "备注", example = "随便") - @DiffLogField(name = "备注") - private String remark; - - @Schema(description = "联系人编号", example = "110") - private Long contactId; // 使用场景,在【联系人详情】添加商机时,如果需要关联两者,需要传递 contactId 字段 - - @Schema(description = "产品列表") - private List products; - - @Schema(description = "产品列表") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class BusinessProduct { - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - @NotNull(message = "产品单价不能为空") - private BigDecimal productPrice; - - @Schema(description = "商机价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - @NotNull(message = "商机价格不能为空") - private BigDecimal businessPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - @NotNull(message = "产品数量不能为空") - private Integer count; - - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessTransferReqVO.java deleted file mode 100644 index da3a87fca..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessTransferReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商机转移 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CrmBusinessTransferReqVO { - - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "商机编号不能为空") - private Long id; - - /** - * 新负责人的用户编号 - */ - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - /** - * 老负责人加入团队后的权限级别。如果 null 说明移除 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer oldOwnerPermissionLevel; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessUpdateStatusReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessUpdateStatusReqVO.java deleted file mode 100644 index 3fe7d9f47..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessUpdateStatusReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 商机更新状态 Request VO") -@Data -public class CrmBusinessUpdateStatusReqVO { - - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") - @NotNull(message = "商机编号不能为空") - private Long id; - - @Schema(description = "状态编号", example = "1") - private Long statusId; - - @Schema(description = "结束状态", example = "1") - @InEnum(value = CrmBusinessEndStatusEnum.class) - private Integer endStatus; - - @AssertTrue(message = "变更状态不正确") - public boolean isStatusValid() { - return statusId != null || endStatus != null; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusRespVO.java deleted file mode 100644 index a2ee1dfe5..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusRespVO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 商机状态 Response VO") -@Data -public class CrmBusinessStatusRespVO { - - @Schema(description = "状态组编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934") - private Long id; - - @Schema(description = "状态组名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String name; - - @Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED) - private List deptIds; - @Schema(description = "使用的部门名称", requiredMode = Schema.RequiredMode.REQUIRED) - private List deptNames; - - @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED) - private String creator; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "状态集合", requiredMode = Schema.RequiredMode.REQUIRED) - private List statuses; - - @Data - public static class Status { - - @Schema(description = "状态编号", example = "23899") - private Long id; - - @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - @Schema(description = "赢单率", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private BigDecimal percent; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sort; - - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusSaveReqVO.java deleted file mode 100644 index 42d6620e9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/status/CrmBusinessStatusSaveReqVO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.math.BigDecimal; -import java.util.List; - -@Schema(description = "管理后台 - 商机状态组新增/修改 Request VO") -@Data -public class CrmBusinessStatusSaveReqVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934") - private Long id; - - @Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotEmpty(message = "状态类型名不能为空") - private String name; - - @Schema(description = "使用的部门编号") - private List deptIds; - - @Schema(description = "商机状态集合", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "商机状态集合不能为空") - @Valid - private List statuses; - - @Data - public static class Status { - - @Schema(description = "状态编号", example = "23899") - private Long id; - - @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotEmpty(message = "状态名不能为空") - private String name; - - @Schema(description = "赢单率", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - @NotNull(message = "赢单率不能为空") - private BigDecimal percent; - - @Schema(description = "排序", hidden = true, example = "1") - private Integer sort; - - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java deleted file mode 100644 index 166268c2b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java +++ /dev/null @@ -1,173 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.clue.CrmClueService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static java.util.Collections.singletonList; - -@Tag(name = "管理后台 - 线索") -@RestController -@RequestMapping("/crm/clue") -@Validated -public class CrmClueController { - - @Resource - private CrmClueService clueService; - @Resource - private CrmCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @PostMapping("/create") - @Operation(summary = "创建线索") - @PreAuthorize("@ss.hasPermission('crm:clue:create')") - public CommonResult createClue(@Valid @RequestBody CrmClueSaveReqVO createReqVO) { - return success(clueService.createClue(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新线索") - @PreAuthorize("@ss.hasPermission('crm:clue:update')") - public CommonResult updateClue(@Valid @RequestBody CrmClueSaveReqVO updateReqVO) { - clueService.updateClue(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除线索") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:clue:delete')") - public CommonResult deleteClue(@RequestParam("id") Long id) { - clueService.deleteClue(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得线索") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:clue:query')") - public CommonResult getClue(@RequestParam("id") Long id) { - CrmClueDO clue = clueService.getClue(id); - return success(buildClueDetail(clue)); - } - - private CrmClueRespVO buildClueDetail(CrmClueDO clue) { - if (clue == null) { - return null; - } - return buildClueDetailList(singletonList(clue)).get(0); - } - - @GetMapping("/page") - @Operation(summary = "获得线索分页") - @PreAuthorize("@ss.hasPermission('crm:clue:query')") - public CommonResult> getCluePage(@Valid CrmCluePageReqVO pageVO) { - PageResult pageResult = clueService.getCluePage(pageVO, getLoginUserId()); - return success(new PageResult<>(buildClueDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出线索 Excel") - @PreAuthorize("@ss.hasPermission('crm:clue:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportClueExcel(@Valid CrmCluePageReqVO pageReqVO, HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PAGE_SIZE_NONE); - List list = clueService.getCluePage(pageReqVO, getLoginUserId()).getList(); - // 导出 Excel - ExcelUtils.write(response, "线索.xls", "数据", CrmClueRespVO.class, buildClueDetailList(list)); - } - - private List buildClueDetailList(List list) { - if (CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - // 1.1 获取客户列表 - Map customerMap = customerService.getCustomerMap( - convertSet(list, CrmClueDO::getCustomerId)); - // 1.2 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(list, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 2. 转换成 VO - return BeanUtils.toBean(list, CrmClueRespVO.class, clueVO -> { - clueVO.setAreaName(AreaUtils.format(clueVO.getAreaId())); - // 2.1 设置客户名称 - MapUtils.findAndThen(customerMap, clueVO.getCustomerId(), customer -> clueVO.setCustomerName(customer.getName())); - // 2.2 设置创建人、负责人名称 - MapUtils.findAndThen(userMap, NumberUtils.parseLong(clueVO.getCreator()), - user -> clueVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, clueVO.getOwnerUserId(), user -> { - clueVO.setOwnerUserName(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> clueVO.setOwnerUserDeptName(dept.getName())); - }); - }); - } - - @PutMapping("/transfer") - @Operation(summary = "线索转移") - @PreAuthorize("@ss.hasPermission('crm:clue:update')") - public CommonResult transferClue(@Valid @RequestBody CrmClueTransferReqVO reqVO) { - clueService.transferClue(reqVO, getLoginUserId()); - return success(true); - } - - @PutMapping("/transform") - @Operation(summary = "线索转化为客户") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:clue:update')") - public CommonResult transformClue(@RequestParam("id") Long id) { - clueService.transformClue(id, getLoginUserId()); - return success(Boolean.TRUE); - } - - @GetMapping("/follow-count") - @Operation(summary = "获得分配给我的、待跟进的线索数量") - @PreAuthorize("@ss.hasPermission('crm:clue:query')") - public CommonResult getFollowClueCount() { - return success(clueService.getFollowClueCount(getLoginUserId())); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java deleted file mode 100644 index a63d946e9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 线索分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCluePageReqVO extends PageParam { - - @Schema(description = "线索名称", example = "线索xxx") - private String name; - - @Schema(description = "转化状态", example = "2048") - private Boolean transformStatus; - - @Schema(description = "电话", example = "18000000000") - private String telephone; - - @Schema(description = "手机号", example = "18000000000") - private String mobile; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - - @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean pool; // null 则表示为不是公海数据 - - @Schema(description = "所属行业", example = "1") - private Integer industryId; - - @Schema(description = "客户等级", example = "1") - private Integer level; - - @Schema(description = "客户来源", example = "1") - private Integer source; - - @Schema(description = "跟进状态", example = "true") - private Boolean followUpStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java deleted file mode 100644 index 56e5c2561..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 线索 Response VO") -@Data -@ToString(callSuper = true) -@ExcelIgnoreUnannotated -public class CrmClueRespVO { - - @Schema(description = "编号,主键自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx") - @ExcelProperty("线索名称") - private String name; - - @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "跟进状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean followUpStatus; - - @Schema(description = "最后跟进时间") - @ExcelProperty("最后跟进时间") - private LocalDateTime contactLastTime; - - @Schema(description = "最后跟进内容", example = "吃饭、睡觉、打逗逗") - @ExcelProperty("最后跟进内容") - private String contactLastContent; - - @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") - @ExcelProperty("下次联系时间") - private LocalDateTime contactNextTime; - - @Schema(description = "负责人编号") - private Long ownerUserId; - @Schema(description = "负责人名字", example = "25682") - @ExcelProperty("负责人名字") - private String ownerUserName; - @Schema(description = "负责人部门") - @ExcelProperty("负责人部门") - private String ownerUserDeptName; - - @Schema(description = "转化状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty(value = "转化状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean transformStatus; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "520") - private Long customerId; - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "客户名称") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "手机号", example = "18000000000") - @ExcelProperty("手机号") - private String mobile; - - @Schema(description = "电话", example = "18000000000") - @ExcelProperty("电话") - private String telephone; - - @Schema(description = "QQ", example = "25682") - @ExcelProperty("QQ") - private String qq; - - @Schema(description = "wechat", example = "25682") - @ExcelProperty("wechat") - private String wechat; - - @Schema(description = "email", example = "25682") - @ExcelProperty("email") - private String email; - - @Schema(description = "地区编号", example = "1024") - @ExcelProperty("地区编号") - private Integer areaId; - @Schema(description = "地区名称", example = "北京市") - @ExcelProperty("地区名称") - private String areaName; - @Schema(description = "详细地址", example = "北京市成华大道") - @ExcelProperty("详细地址") - private String detailAddress; - - @Schema(description = "所属行业", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "所属行业", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY) - private Integer industryId; - - @Schema(description = "客户等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "客户等级", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL) - private Integer level; - - @Schema(description = "客户来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "客户来源", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE) - private Integer source; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "1024") - @ExcelProperty("创建人") - private String creator; - @Schema(description = "创建人名字", example = "芋道源码") - @ExcelProperty("创建人名字") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueSaveReqVO.java deleted file mode 100644 index aff2ad1eb..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueSaveReqVO.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.framework.common.validation.Telephone; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerIndustryParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerLevelParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerSourceParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAreaParseFunction; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; - -@Schema(description = "管理后台 - CRM 线索创建/更新 Request VO") -@Data -public class CrmClueSaveReqVO { - - @Schema(description = "编号", example = "10969") - private Long id; - - @Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx") - @DiffLogField(name = "线索名称") - @NotEmpty(message = "线索名称不能为空") - private String name; - - @Schema(description = "最后跟进时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @DiffLogField(name = "最后跟进时间") - private LocalDateTime contactLastTime; - - @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") - @DiffLogField(name = "下次联系时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactNextTime; - - @Schema(description = "负责人编号", example = "2048") - @NotNull(message = "负责人编号不能为空") - private Long ownerUserId; - - @Schema(description = "手机号", example = "18000000000") - @DiffLogField(name = "手机号") - @Mobile - private String mobile; - - @Schema(description = "电话", example = "18000000000") - @DiffLogField(name = "电话") - @Telephone - private String telephone; - - @Schema(description = "QQ", example = "123456789") - @DiffLogField(name = "QQ") - @Size(max = 20, message = "QQ长度不能超过 20 个字符") - private String qq; - - @Schema(description = "微信", example = "123456789") - @DiffLogField(name = "微信") - @Size(max = 255, message = "微信长度不能超过 255 个字符") - private String wechat; - - @Schema(description = "邮箱", example = "123456789@qq.com") - @DiffLogField(name = "邮箱") - @Email(message = "邮箱格式不正确") - @Size(max = 255, message = "邮箱长度不能超过 255 个字符") - private String email; - - @Schema(description = "地区编号", example = "20158") - @DiffLogField(name = "地区编号", function = SysAreaParseFunction.NAME) - private Integer areaId; - - @Schema(description = "详细地址", example = "北京市海淀区") - @DiffLogField(name = "详细地址") - private String detailAddress; - - @Schema(description = "所属行业", example = "1") - @DiffLogField(name = "所属行业", function = CrmCustomerIndustryParseFunction.NAME) - @DictFormat(CRM_CUSTOMER_INDUSTRY) - private Integer industryId; - - @Schema(description = "客户等级", example = "2") - @DiffLogField(name = "客户等级", function = CrmCustomerLevelParseFunction.NAME) - @InEnum(CrmCustomerLevelEnum.class) - private Integer level; - - @Schema(description = "客户来源", example = "3") - @DiffLogField(name = "客户来源", function = CrmCustomerSourceParseFunction.NAME) - private Integer source; - - @Schema(description = "客户描述", example = "任意文字") - @DiffLogField(name = "客户描述") - @Size(max = 4096, message = "客户描述长度不能超过 4096 个字符") - private String description; - - @Schema(description = "备注", example = "随便") - @DiffLogField(name = "备注") - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueTransferReqVO.java deleted file mode 100644 index d1a28694d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueTransferReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -@Schema(description = "管理后台 - 线索转移 Request VO") -@Data -public class CrmClueTransferReqVO { - - @Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "线索编号不能为空") - private Long id; - - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(value = CrmPermissionLevelEnum.class) - private Integer oldOwnerPermissionLevel; // 老负责人加入团队后的权限级别。如果 null 说明移除 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java deleted file mode 100644 index a9d2b35ee..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java +++ /dev/null @@ -1,226 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static java.util.Collections.singletonList; - -@Tag(name = "管理后台 - CRM 联系人") -@RestController -@RequestMapping("/crm/contact") -@Validated -@Slf4j -public class CrmContactController { - - @Resource - private CrmContactService contactService; - @Resource - private CrmCustomerService customerService; - @Resource - private CrmContactBusinessService contactBusinessLinkService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @PostMapping("/create") - @Operation(summary = "创建联系人") - @PreAuthorize("@ss.hasPermission('crm:contact:create')") - public CommonResult createContact(@Valid @RequestBody CrmContactSaveReqVO createReqVO) { - return success(contactService.createContact(createReqVO, getLoginUserId())); - } - - @PutMapping("/update") - @Operation(summary = "更新联系人") - @PreAuthorize("@ss.hasPermission('crm:contact:update')") - public CommonResult updateContact(@Valid @RequestBody CrmContactSaveReqVO updateReqVO) { - contactService.updateContact(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除联系人") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:contact:delete')") - public CommonResult deleteContact(@RequestParam("id") Long id) { - contactService.deleteContact(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得联系人") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:contact:query')") - public CommonResult getContact(@RequestParam("id") Long id) { - CrmContactDO contact = contactService.getContact(id); - return success(buildContactDetail(contact)); - } - - private CrmContactRespVO buildContactDetail(CrmContactDO contact) { - if (contact == null) { - return null; - } - return buildContactDetailList(singletonList(contact)).get(0); - } - - @GetMapping("/simple-all-list") - @Operation(summary = "获得联系人的精简列表") - @PreAuthorize("@ss.hasPermission('crm:contact:query')") - public CommonResult> getSimpleContactList() { - List list = contactService.getContactList(getLoginUserId()); - return success(convertList(list, contact -> // 只返回 id、name 字段 - new CrmContactRespVO().setId(contact.getId()).setName(contact.getName()) - .setCustomerId(contact.getCustomerId()))); - } - - @GetMapping("/page") - @Operation(summary = "获得联系人分页") - @PreAuthorize("@ss.hasPermission('crm:contact:query')") - public CommonResult> getContactPage(@Valid CrmContactPageReqVO pageVO) { - PageResult pageResult = contactService.getContactPage(pageVO, getLoginUserId()); - return success(new PageResult<>(buildContactDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得联系人分页,基于指定客户") - public CommonResult> getContactPageByCustomer(@Valid CrmContactPageReqVO pageVO) { - Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); - PageResult pageResult = contactService.getContactPageByCustomerId(pageVO); - return success(new PageResult<>(buildContactDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/page-by-business") - @Operation(summary = "获得联系人分页,基于指定商机") - public CommonResult> getContactPageByBusiness(@Valid CrmContactPageReqVO pageVO) { - Assert.notNull(pageVO.getBusinessId(), "商机编号不能为空"); - PageResult pageResult = contactService.getContactPageByBusinessId(pageVO); - return success(new PageResult<>(buildContactDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出联系人 Excel") - @PreAuthorize("@ss.hasPermission('crm:contact:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportContactExcel(@Valid CrmContactPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - exportReqVO.setPageNo(PAGE_SIZE_NONE); - List list = contactService.getContactPage(exportReqVO, getLoginUserId()).getList(); - ExcelUtils.write(response, "联系人.xls", "数据", CrmContactRespVO.class, buildContactDetailList(list)); - } - - private List buildContactDetailList(List contactList) { - if (CollUtil.isEmpty(contactList)) { - return Collections.emptyList(); - } - // 1.1 获取客户列表 - Map customerMap = customerService.getCustomerMap( - convertSet(contactList, CrmContactDO::getCustomerId)); - // 1.2 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 1.3 直属上级 Map - Map parentContactMap = contactService.getContactMap( - convertSet(contactList, CrmContactDO::getParentId)); - // 2. 转换成 VO - return BeanUtils.toBean(contactList, CrmContactRespVO.class, contactVO -> { - contactVO.setAreaName(AreaUtils.format(contactVO.getAreaId())); - // 2.1 设置客户名称 - MapUtils.findAndThen(customerMap, contactVO.getCustomerId(), customer -> contactVO.setCustomerName(customer.getName())); - // 2.2 设置创建人、负责人名称 - MapUtils.findAndThen(userMap, NumberUtils.parseLong(contactVO.getCreator()), - user -> contactVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, contactVO.getOwnerUserId(), user -> { - contactVO.setOwnerUserName(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> contactVO.setOwnerUserDeptName(dept.getName())); - }); - // 2.3 设置直属上级名称 - findAndThen(parentContactMap, contactVO.getParentId(), contact -> contactVO.setParentName(contact.getName())); - }); - } - - @PutMapping("/transfer") - @Operation(summary = "联系人转移") - @PreAuthorize("@ss.hasPermission('crm:contact:update')") - public CommonResult transferContact(@Valid @RequestBody CrmContactTransferReqVO reqVO) { - contactService.transferContact(reqVO, getLoginUserId()); - return success(true); - } - - // ================== 关联/取关商机 =================== - - @PostMapping("/create-business-list") - @Operation(summary = "创建联系人与商机的关联") - @PreAuthorize("@ss.hasPermission('crm:contact:create-business')") - public CommonResult createContactBusinessList(@Valid @RequestBody CrmContactBusinessReqVO createReqVO) { - contactBusinessLinkService.createContactBusinessList(createReqVO); - return success(true); - } - - - @PostMapping("/create-business-list2") - @Operation(summary = "创建联系人与商机的关联") - @PreAuthorize("@ss.hasPermission('crm:contact:create-business')") - public CommonResult createContactBusinessList2(@Valid @RequestBody CrmContactBusiness2ReqVO createReqVO) { - contactBusinessLinkService.createContactBusinessList2(createReqVO); - return success(true); - } - - @DeleteMapping("/delete-business-list") - @Operation(summary = "删除联系人与联系人的关联") - @PreAuthorize("@ss.hasPermission('crm:contact:delete-business')") - public CommonResult deleteContactBusinessList(@Valid @RequestBody CrmContactBusinessReqVO deleteReqVO) { - contactBusinessLinkService.deleteContactBusinessList(deleteReqVO); - return success(true); - } - - @DeleteMapping("/delete-business-list2") - @Operation(summary = "删除联系人与联系人的关联") - @PreAuthorize("@ss.hasPermission('crm:contact:delete-business')") - public CommonResult deleteContactBusinessList(@Valid @RequestBody CrmContactBusiness2ReqVO deleteReqVO) { - contactBusinessLinkService.deleteContactBusinessList2(deleteReqVO); - return success(true); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusiness2ReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusiness2ReqVO.java deleted file mode 100644 index edc07bf96..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusiness2ReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - CRM 联系人商机 Request VO") // 【商机关联联系人】用于关联,取消关联的操作 -@Data -public class CrmContactBusiness2ReqVO { - - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638") - @NotNull(message="商机不能为空") - private Long businessId; - - @Schema(description = "联系人编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878") - @NotEmpty(message="联系人数组不能为空") - private List contactIds; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusinessReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusinessReqVO.java deleted file mode 100644 index c0be78698..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactBusinessReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - CRM 联系人商机 Request VO") // 【联系人关联商机】用于关联,取消关联的操作 -@Data -public class CrmContactBusinessReqVO { - - @Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878") - @NotNull(message="联系人不能为空") - private Long contactId; - - @Schema(description = "商机编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638") - @NotEmpty(message="商机不能为空") - private List businessIds; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactPageReqVO.java deleted file mode 100644 index 6698a3855..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactPageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 联系人分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmContactPageReqVO extends PageParam { - - @Schema(description = "姓名", example = "芋艿") - private String name; - - @Schema(description = "客户编号", example = "10795") - private Long customerId; - - @Schema(description = "手机号", example = "13898273941") - private String mobile; - - @Schema(description = "电话", example = "021-383773") - private String telephone; - - @Schema(description = "电子邮箱", example = "111@22.com") - private String email; - - @Schema(description = "QQ", example = "3882872") - private Long qq; - - @Schema(description = "微信", example = "zzZ98373") - private String wechat; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - - @Schema(description = "商机编号", example = "10430") - private Long businessId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactRespVO.java deleted file mode 100644 index b2b1e8384..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactRespVO.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 联系人 Response VO") -@Data -@ToString(callSuper = true) -@ExcelIgnoreUnannotated -public class CrmContactRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167") - private Long id; - - @Schema(description = "联系人姓名", example = "芋艿") - @ExcelProperty(value = "联系人姓名", order = 1) - private String name; - - @Schema(description = "客户编号", example = "10795") - private Long customerId; - @ExcelProperty(value = "客户名称", order = 2) - @Schema(description = "客户名字", example = "test") - private String customerName; - - @Schema(description = "最后跟进时间") - @ExcelProperty(value = "最后跟进时间", order = 6) - private LocalDateTime contactLastTime; - - @Schema(description = "最后跟进内容") - @ExcelProperty(value = "最后跟进内容", order = 6) - private String contactLastContent; - - @Schema(description = "下次联系时间") - @ExcelProperty(value = "下次联系时间", order = 6) - private LocalDateTime contactNextTime; - - @Schema(description = "负责人编号") - private Long ownerUserId; - @Schema(description = "负责人名字", example = "25682") - @ExcelProperty("负责人名字") - private String ownerUserName; - @Schema(description = "负责人部门") - @ExcelProperty("负责人部门") - private String ownerUserDeptName; - - @Schema(description = "手机号", example = "1387171766") - @ExcelProperty(value = "手机号", order = 4) - private String mobile; - - @Schema(description = "电话", example = "021-0029922") - @ExcelProperty(value = "电话", order = 4) - private String telephone; - - @Schema(description = "电子邮箱", example = "1111@22.com") - @ExcelProperty(value = "邮箱", order = 4) - private String email; - - @Schema(description = "QQ", example = "197272662") - @ExcelProperty(value = "QQ", order = 4) - private Long qq; - - @Schema(description = "微信", example = "zzz3883") - @ExcelProperty(value = "微信", order = 4) - private String wechat; - - @Schema(description = "地区编号", example = "20158") - private Integer areaId; - @Schema(description = "地区名", example = "上海上海市浦东新区") - @ExcelProperty(value = "地区", order = 5) - private String areaName; - - @Schema(description = "地址") - @ExcelProperty(value = "地址", order = 5) - private String detailAddress; - - @Schema(description = "性别") - @ExcelProperty(value = "性别", converter = DictConvert.class, order = 3) - @DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_SEX) - private Integer sex; - - @Schema(description = "是否关键决策人") - @ExcelProperty(value = "是否关键决策人", converter = DictConvert.class, order = 3) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean master; - - @Schema(description = "职位") - @ExcelProperty(value = "职位", order = 3) - private String post; - - @Schema(description = "直属上级", example = "23457") - private Long parentId; - @Schema(description = "直属上级名", example = "芋头") - @ExcelProperty(value = "直属上级", order = 4) - private String parentName; - - @Schema(description = "备注", example = "你说的对") - @ExcelProperty(value = "备注", order = 6) - private String remark; - - @Schema(description = "创建人", example = "25682") - private String creator; - @Schema(description = "创建人名字", example = "test") - @ExcelProperty(value = "创建人", order = 8) - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactSaveReqVO.java deleted file mode 100644 index dd5f9d86c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactSaveReqVO.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.framework.common.validation.Telephone; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.*; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotNull; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -@Schema(description = "管理后台 - CRM 联系人创建/更新 Request VO") -@Data -public class CrmContactSaveReqVO { - - @Schema(description = "主键", example = "3167") - private Long id; - - @Schema(description = "姓名", example = "芋艿") - @NotNull(message = "姓名不能为空") - @DiffLogField(name = "姓名") - private String name; - - @Schema(description = "客户编号", example = "10795") - @NotNull(message = "客户编号不能为空") - @DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME) - private Long customerId; - - @Schema(description = "下次联系时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) - @DiffLogField(name = "下次联系时间") - private LocalDateTime contactNextTime; - - @Schema(description = "负责人用户编号", example = "14334") - @NotNull(message = "负责人不能为空") - @DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME) - private Long ownerUserId; - - @Schema(description = "手机号", example = "1387171766") - @Mobile - @DiffLogField(name = "手机号") - private String mobile; - - @Schema(description = "电话", example = "021-0029922") - @Telephone - @DiffLogField(name = "电话") - private String telephone; - - @Schema(description = "QQ", example = "197272662") - @DiffLogField(name = "QQ") - private Long qq; - - @Schema(description = "微信", example = "zzz3883") - @DiffLogField(name = "微信") - private String wechat; - - @Schema(description = "电子邮箱", example = "1111@22.com") - @DiffLogField(name = "邮箱") - @Email - private String email; - - @Schema(description = "地区编号", example = "20158") - @DiffLogField(name = "所在地", function = SysAreaParseFunction.NAME) - private Integer areaId; - - @Schema(description = "地址") - @DiffLogField(name = "地址") - private String detailAddress; - - @Schema(description = "性别") - @DiffLogField(name = "性别", function = SysSexParseFunction.NAME) - private Integer sex; - - @Schema(description = "是否关键决策人") - @DiffLogField(name = "关键决策人", function = SysBooleanParseFunction.NAME) - private Boolean master; - - @Schema(description = "职位") - @DiffLogField(name = "职位") - private String post; - - @Schema(description = "直属上级", example = "23457") - @DiffLogField(name = "直属上级", function = CrmContactParseFunction.NAME) - private Long parentId; - - @Schema(description = "备注", example = "你说的对") - @DiffLogField(name = "备注") - private String remark; - - @Schema(description = "关联商机 ID", example = "122233") - private Long businessId; // 注意:该字段用于在【商机】详情界面「新建联系人」时,自动进行关联 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java deleted file mode 100644 index 4f94ee2ac..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; - -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 联系人转移 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CrmContactTransferReqVO { - - @Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "联系人编号不能为空") - private Long id; - - /** - * 新负责人的用户编号 - */ - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - /** - * 老负责人加入团队后的权限级别。如果 null 说明移除 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer oldOwnerPermissionLevel; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractConfigController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractConfigController.java deleted file mode 100644 index 369260fcb..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractConfigController.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config.CrmContractConfigRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config.CrmContractConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 合同配置") -@RestController -@RequestMapping("/crm/contract-config") -@Validated -public class CrmContractConfigController { - - @Resource - private CrmContractConfigService contractConfigService; - - @GetMapping("/get") - @Operation(summary = "获取合同配置") - @PreAuthorize("@ss.hasPermission('crm:contract-config:query')") - public CommonResult getCustomerPoolConfig() { - CrmContractConfigDO config = contractConfigService.getContractConfig(); - return success(BeanUtils.toBean(config, CrmContractConfigRespVO.class)); - } - - @PutMapping("/save") - @Operation(summary = "更新合同配置") - @PreAuthorize("@ss.hasPermission('crm:contract-config:update')") - public CommonResult saveCustomerPoolConfig(@Valid @RequestBody CrmContractConfigSaveReqVO updateReqVO) { - contractConfigService.saveContractConfig(updateReqVO); - return success(true); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java deleted file mode 100644 index 225ef13dc..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java +++ /dev/null @@ -1,256 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.product.CrmProductService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static java.util.Collections.singletonList; - -@Tag(name = "管理后台 - CRM 合同") -@RestController -@RequestMapping("/crm/contract") -@Validated -public class CrmContractController { - - @Resource - private CrmContractService contractService; - @Resource - private CrmCustomerService customerService; - @Resource - private CrmContactService contactService; - @Resource - private CrmBusinessService businessService; - @Resource - private CrmProductService productService; - @Resource - private CrmReceivableService receivableService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @PostMapping("/create") - @Operation(summary = "创建合同") - @PreAuthorize("@ss.hasPermission('crm:contract:create')") - public CommonResult createContract(@Valid @RequestBody CrmContractSaveReqVO createReqVO) { - return success(contractService.createContract(createReqVO, getLoginUserId())); - } - - @PutMapping("/update") - @Operation(summary = "更新合同") - @PreAuthorize("@ss.hasPermission('crm:contract:update')") - public CommonResult updateContract(@Valid @RequestBody CrmContractSaveReqVO updateReqVO) { - contractService.updateContract(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除合同") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:contract:delete')") - public CommonResult deleteContract(@RequestParam("id") Long id) { - contractService.deleteContract(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得合同") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult getContract(@RequestParam("id") Long id) { - CrmContractDO contract = contractService.getContract(id); - return success(buildContractDetail(contract)); - } - - private CrmContractRespVO buildContractDetail(CrmContractDO contract) { - if (contract == null) { - return null; - } - CrmContractRespVO contractVO = buildContractDetailList(singletonList(contract)).get(0); - // 拼接产品项 - List businessProducts = contractService.getContractProductListByContractId(contractVO.getId()); - Map productMap = productService.getProductMap( - convertSet(businessProducts, CrmContractProductDO::getProductId)); - contractVO.setProducts(BeanUtils.toBean(businessProducts, CrmContractRespVO.Product.class, businessProductVO -> - MapUtils.findAndThen(productMap, businessProductVO.getProductId(), - product -> businessProductVO.setProductName(product.getName()) - .setProductNo(product.getNo()).setProductUnit(product.getUnit())))); - return contractVO; - } - - @GetMapping("/page") - @Operation(summary = "获得合同分页") - @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult> getContractPage(@Valid CrmContractPageReqVO pageVO) { - PageResult pageResult = contractService.getContractPage(pageVO, getLoginUserId()); - return success(BeanUtils.toBean(pageResult, CrmContractRespVO.class).setList(buildContractDetailList(pageResult.getList()))); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得合同分页,基于指定客户") - public CommonResult> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) { - Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); - PageResult pageResult = contractService.getContractPageByCustomerId(pageVO); - return success(BeanUtils.toBean(pageResult, CrmContractRespVO.class).setList(buildContractDetailList(pageResult.getList()))); - } - - @GetMapping("/page-by-business") - @Operation(summary = "获得合同分页,基于指定商机") - public CommonResult> getContractPageByBusiness(@Valid CrmContractPageReqVO pageVO) { - Assert.notNull(pageVO.getBusinessId(), "商机编号不能为空"); - PageResult pageResult = contractService.getContractPageByBusinessId(pageVO); - return success(BeanUtils.toBean(pageResult, CrmContractRespVO.class).setList(buildContractDetailList(pageResult.getList()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出合同 Excel") - @PreAuthorize("@ss.hasPermission('crm:contract:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportContractExcel(@Valid CrmContractPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - PageResult pageResult = contractService.getContractPage(exportReqVO, getLoginUserId()); - // 导出 Excel - ExcelUtils.write(response, "合同.xls", "数据", CrmContractRespVO.class, - BeanUtils.toBean(pageResult.getList(), CrmContractRespVO.class)); - } - - @PutMapping("/transfer") - @Operation(summary = "合同转移") - @PreAuthorize("@ss.hasPermission('crm:contract:update')") - public CommonResult transferContract(@Valid @RequestBody CrmContractTransferReqVO reqVO) { - contractService.transferContract(reqVO, getLoginUserId()); - return success(true); - } - - @PutMapping("/submit") - @Operation(summary = "提交合同审批") - @PreAuthorize("@ss.hasPermission('crm:contract:update')") - public CommonResult submitContract(@RequestParam("id") Long id) { - contractService.submitContract(id, getLoginUserId()); - return success(true); - } - - private List buildContractDetailList(List contractList) { - if (CollUtil.isEmpty(contractList)) { - return Collections.emptyList(); - } - // 1.1 获取客户列表 - Map customerMap = customerService.getCustomerMap( - convertSet(contractList, CrmContractDO::getCustomerId)); - // 1.2 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(contractList, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 1.3 获取联系人 - Map contactMap = convertMap(contactService.getContactList(convertSet(contractList, - CrmContractDO::getSignContactId)), CrmContactDO::getId); - // 1.4 获取商机 - Map businessMap = businessService.getBusinessMap( - convertSet(contractList, CrmContractDO::getBusinessId)); - // 1.5 获得已回款金额 - Map receivablePriceMap = receivableService.getReceivablePriceMapByContractId( - convertSet(contractList, CrmContractDO::getId)); - // 2. 拼接数据 - return BeanUtils.toBean(contractList, CrmContractRespVO.class, contractVO -> { - // 2.1 设置客户信息 - findAndThen(customerMap, contractVO.getCustomerId(), customer -> contractVO.setCustomerName(customer.getName())); - // 2.2 设置用户信息 - findAndThen(userMap, Long.parseLong(contractVO.getCreator()), user -> contractVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, contractVO.getOwnerUserId(), user -> { - contractVO.setOwnerUserName(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> contractVO.setOwnerUserDeptName(dept.getName())); - }); - findAndThen(userMap, contractVO.getSignUserId(), user -> contractVO.setSignUserName(user.getNickname())); - // 2.3 设置联系人信息 - findAndThen(contactMap, contractVO.getSignContactId(), contact -> contractVO.setSignContactName(contact.getName())); - // 2.4 设置商机信息 - findAndThen(businessMap, contractVO.getBusinessId(), business -> contractVO.setBusinessName(business.getName())); - // 2.5 设置已回款金额 - contractVO.setTotalReceivablePrice(receivablePriceMap.getOrDefault(contractVO.getId(), BigDecimal.ZERO)); - }); - } - - @GetMapping("/audit-count") - @Operation(summary = "获得待审核合同数量") - @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult getAuditContractCount() { - return success(contractService.getAuditContractCount(getLoginUserId())); - } - - @GetMapping("/remind-count") - @Operation(summary = "获得即将到期(提醒)的合同数量") - @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult getRemindContractCount() { - return success(contractService.getRemindContractCount(getLoginUserId())); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得合同精简列表", description = "只包含的合同,主要用于前端的下拉选项") - @Parameter(name = "customerId", description = "客户编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult> getContractSimpleList(@RequestParam("customerId") Long customerId) { - CrmContractPageReqVO pageReqVO = new CrmContractPageReqVO().setCustomerId(customerId); - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); // 不分页 - PageResult pageResult = contractService.getContractPageByCustomerId(pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(Collections.emptyList()); - } - // 拼接数据 - Map receivablePriceMap = receivableService.getReceivablePriceMapByContractId( - convertSet(pageResult.getList(), CrmContractDO::getId)); - return success(convertList(pageResult.getList(), contract -> new CrmContractRespVO() // 只返回 id、name 等精简字段 - .setId(contract.getId()).setName(contract.getName()).setAuditStatus(contract.getAuditStatus()) - .setTotalPrice(contract.getTotalPrice()) - .setTotalReceivablePrice(receivablePriceMap.getOrDefault(contract.getId(), BigDecimal.ZERO)))); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/config/CrmContractConfigRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/config/CrmContractConfigRespVO.java deleted file mode 100644 index c39cf9269..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/config/CrmContractConfigRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 合同配置 Response VO") -@Data -public class CrmContractConfigRespVO { - - @Schema(description = "是否开启提前提醒", example = "true") - private Boolean notifyEnabled; - - @Schema(description = "提前提醒天数", example = "2") - private Integer notifyDays; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/config/CrmContractConfigSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/config/CrmContractConfigSaveReqVO.java deleted file mode 100644 index 2eb79d8e0..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/config/CrmContractConfigSaveReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config; - -import cn.hutool.core.util.BooleanUtil; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.AssertTrue; -import java.util.Objects; - -@Schema(description = "管理后台 - CRM 合同配置 Request VO") -@Data -public class CrmContractConfigSaveReqVO { - - @Schema(description = "是否开启提前提醒", example = "true") - @DiffLogField(name = "是否开启提前提醒") - private Boolean notifyEnabled; - - @Schema(description = "提前提醒天数", example = "2") - @DiffLogField(name = "提前提醒天数") - private Integer notifyDays; - - @AssertTrue(message = "提前提醒天数不能为空") - @JsonIgnore - public boolean isNotifyDaysValid() { - if (!BooleanUtil.isTrue(getNotifyEnabled())) { - return true; - } - return Objects.nonNull(getNotifyDays()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractPageReqVO.java deleted file mode 100644 index 74f8008b8..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractPageReqVO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 合同分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmContractPageReqVO extends PageParam { - - /** - * 过期类型 - 即将过期 - */ - public static final Integer EXPIRY_TYPE_ABOUT_TO_EXPIRE = 1; - /** - * 过期类型 - 已过期 - */ - public static final Integer EXPIRY_TYPE_EXPIRED = 2; - - @Schema(description = "合同编号", example = "XYZ008") - private String no; - - @Schema(description = "合同名称", example = "王五") - private String name; - - @Schema(description = "客户编号", example = "18336") - private Long customerId; - - @Schema(description = "商机编号", example = "10864") - private Long businessId; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - - @Schema(description = "审批状态", example = "20") - @InEnum(CrmAuditStatusEnum.class) - private Integer auditStatus; - - @Schema(description = "过期类型", example = "1") - private Integer expiryType; // 过期类型,为 null 时则表示全部 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractRespVO.java deleted file mode 100644 index a01bc110b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractRespVO.java +++ /dev/null @@ -1,162 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - CRM 合同 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmContractRespVO { - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @ExcelProperty("合同编号") - private Long id; - - @Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @ExcelProperty("合同名称") - private String name; - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20230101") - @ExcelProperty("合同编号") - private String no; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18336") - @ExcelProperty("客户编号") - private Long customerId; - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "18336") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "商机编号", example = "10864") - @ExcelProperty("商机编号") - private Long businessId; - @Schema(description = "商机名称", example = "10864") - @ExcelProperty("商机名称") - private String businessName; - - @Schema(description = "最后跟进时间") - @ExcelProperty("最后跟进时间") - private LocalDateTime contactLastTime; - - @Schema(description = "负责人的用户编号", example = "25682") - @ExcelProperty("负责人的用户编号") - private Long ownerUserId; - @Schema(description = "负责人名字", example = "25682") - @ExcelProperty("负责人名字") - private String ownerUserName; - @Schema(description = "负责人部门") - @ExcelProperty("负责人部门") - private String ownerUserDeptName; - - @Schema(description = "工作流编号", example = "1043") - @ExcelProperty("工作流编号") - private String processInstanceId; - - @Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @ExcelProperty("审批状态") - private Integer auditStatus; - - @Schema(description = "下单日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("下单日期") - private LocalDateTime orderDate; - - @Schema(description = "开始时间") - @ExcelProperty("开始时间") - private LocalDateTime startTime; - - @Schema(description = "结束时间") - @ExcelProperty("结束时间") - private LocalDateTime endTime; - - @Schema(description = "产品总金额", example = "19510") - @ExcelProperty("产品总金额") - private BigDecimal totalProductPrice; - - @Schema(description = "整单折扣") - @ExcelProperty("整单折扣") - private BigDecimal discountPercent; - - @Schema(description = "合同金额", example = "5617") - @ExcelProperty("合同金额") - private BigDecimal totalPrice; - - @Schema(description = "已回款金额", example = "5617") - @ExcelProperty("已回款金额") - private BigDecimal totalReceivablePrice; - - @Schema(description = "客户签约人编号", example = "18546") - private Long signContactId; - @Schema(description = "客户签约人", example = "小豆") - @ExcelProperty("客户签约人") - private String signContactName; - - @Schema(description = "公司签约人", example = "14036") - private Long signUserId; - @Schema(description = "公司签约人", example = "小明") - @ExcelProperty("公司签约人") - private String signUserName; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "创建人", example = "25682") - @ExcelProperty("创建人") - private String creator; - - @Schema(description = "创建人名字", example = "test") - @ExcelProperty("创建人名字") - private String creatorName; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - - @Schema(description = "产品列表") - private List products; - - @Schema(description = "产品列表") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Product { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") - private Long productId; - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") - private String productNo; - @Schema(description = "产品单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private Integer productUnit; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - private BigDecimal productPrice; - - @Schema(description = "合同价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - private BigDecimal contractPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - private BigDecimal count; - - @Schema(description = "总计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - private BigDecimal totalPrice; - - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractSaveReqVO.java deleted file mode 100644 index 2f5e8447c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractSaveReqVO.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract; - -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmBusinessParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmContactParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAdminUserParseFunction; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.springframework.format.annotation.DateTimeFormat; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 合同创建/更新 Request VO") -@Data -public class CrmContractSaveReqVO { - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - private Long id; - - @Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @DiffLogField(name = "合同名称") - @NotNull(message = "合同名称不能为空") - private String name; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18336") - @DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME) - @NotNull(message = "客户编号不能为空") - private Long customerId; - - @Schema(description = "商机编号", example = "10864") - @DiffLogField(name = "商机", function = CrmBusinessParseFunction.NAME) - private Long businessId; - - @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17144") - @DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME) - @NotNull(message = "负责人不能为空") - private Long ownerUserId; - - @Schema(description = "下单日期", requiredMode = Schema.RequiredMode.REQUIRED) - @DiffLogField(name = "下单日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @NotNull(message = "下单日期不能为空") - private LocalDateTime orderDate; - - @Schema(description = "开始时间") - @DiffLogField(name = "开始时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间") - @DiffLogField(name = "结束时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "整单折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "55.00") - @DiffLogField(name = "整单折扣") - @NotNull(message = "整单折扣不能为空") - private BigDecimal discountPercent; - - @Schema(description = "合同金额", example = "5617") - @DiffLogField(name = "合同金额") - private BigDecimal totalPrice; - - @Schema(description = "客户签约人编号", example = "18546") - @DiffLogField(name = "客户签约人", function = CrmContactParseFunction.NAME) - private Long signContactId; - - @Schema(description = "公司签约人", example = "14036") - @DiffLogField(name = "公司签约人", function = SysAdminUserParseFunction.NAME) - private Long signUserId; - - @Schema(description = "备注", example = "你猜") - @DiffLogField(name = "备注") - private String remark; - - @Schema(description = "产品列表") - private List products; - - @Schema(description = "产品列表") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Product { - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - @NotNull(message = "产品单价不能为空") - private BigDecimal productPrice; - - @Schema(description = "合同价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") - @NotNull(message = "合同价格不能为空") - private BigDecimal contractPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - @NotNull(message = "产品数量不能为空") - private Integer count; - - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractTransferReqVO.java deleted file mode 100644 index e234a0230..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractTransferReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 合同转移 Request VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CrmContractTransferReqVO { - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "联系人编号不能为空") - private Long id; - - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(value = CrmPermissionLevelEnum.class) - private Integer oldOwnerPermissionLevel; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java deleted file mode 100644 index 68e7a48c1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java +++ /dev/null @@ -1,316 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static java.util.Collections.singletonList; - -@Tag(name = "管理后台 - CRM 客户") -@RestController -@RequestMapping("/crm/customer") -@Validated -public class CrmCustomerController { - - @Resource - private CrmCustomerService customerService; - @Resource - private CrmCustomerPoolConfigService customerPoolConfigService; - - @Resource - private DeptApi deptApi; - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建客户") - @PreAuthorize("@ss.hasPermission('crm:customer:create')") - public CommonResult createCustomer(@Valid @RequestBody CrmCustomerSaveReqVO createReqVO) { - return success(customerService.createCustomer(createReqVO, getLoginUserId())); - } - - @PutMapping("/update") - @Operation(summary = "更新客户") - @PreAuthorize("@ss.hasPermission('crm:customer:update')") - public CommonResult updateCustomer(@Valid @RequestBody CrmCustomerSaveReqVO updateReqVO) { - customerService.updateCustomer(updateReqVO); - return success(true); - } - - @PutMapping("/update-deal-status") - @Operation(summary = "更新客户的成交状态") - @Parameters({ - @Parameter(name = "id", description = "客户编号", required = true), - @Parameter(name = "dealStatus", description = "成交状态", required = true) - }) - public CommonResult updateCustomerDealStatus(@RequestParam("id") Long id, - @RequestParam("dealStatus") Boolean dealStatus) { - customerService.updateCustomerDealStatus(id, dealStatus); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除客户") - @Parameter(name = "id", description = "客户编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:customer:delete')") - public CommonResult deleteCustomer(@RequestParam("id") Long id) { - customerService.deleteCustomer(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得客户") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult getCustomer(@RequestParam("id") Long id) { - // 1. 获取客户 - CrmCustomerDO customer = customerService.getCustomer(id); - // 2. 拼接数据 - return success(buildCustomerDetail(customer)); - } - - public CrmCustomerRespVO buildCustomerDetail(CrmCustomerDO customer) { - if (customer == null) { - return null; - } - return buildCustomerDetailList(singletonList(customer)).get(0); - } - - @GetMapping("/page") - @Operation(summary = "获得客户分页") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { - // 1. 查询客户分页 - PageResult pageResult = customerService.getCustomerPage(pageVO, getLoginUserId()); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - // 2. 拼接数据 - return success(new PageResult<>(buildCustomerDetailList(pageResult.getList()), pageResult.getTotal())); - } - - public List buildCustomerDetailList(List list) { - if (CollUtil.isEmpty(list)) { - return java.util.Collections.emptyList(); - } - // 1.1 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertSetByFlatMap(list, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 1.2 获取距离进入公海的时间 - Map poolDayMap = getPoolDayMap(list); - // 2. 转换成 VO - return BeanUtils.toBean(list, CrmCustomerRespVO.class, customerVO -> { - customerVO.setAreaName(AreaUtils.format(customerVO.getAreaId())); - // 2.1 设置创建人、负责人名称 - MapUtils.findAndThen(userMap, NumberUtils.parseLong(customerVO.getCreator()), - user -> customerVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, customerVO.getOwnerUserId(), user -> { - customerVO.setOwnerUserName(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> customerVO.setOwnerUserDeptName(dept.getName())); - }); - // 2.2 设置距离进入公海的时间 - if (customerVO.getOwnerUserId() != null) { - customerVO.setPoolDay(poolDayMap.get(customerVO.getId())); - } - }); - } - - @GetMapping("/put-pool-remind-page") - @Operation(summary = "获得待进入公海客户分页") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult> getPutPoolRemindCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { - // 1. 查询客户分页 - PageResult pageResult = customerService.getPutPoolRemindCustomerPage(pageVO, getLoginUserId()); - // 2. 拼接数据 - return success(new PageResult<>(buildCustomerDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/put-pool-remind-count") - @Operation(summary = "获得待进入公海客户数量") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult getPutPoolRemindCustomerCount() { - return success(customerService.getPutPoolRemindCustomerCount(getLoginUserId())); - } - - @GetMapping("/today-contact-count") - @Operation(summary = "获得今日需联系客户数量") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult getTodayContactCustomerCount() { - return success(customerService.getTodayContactCustomerCount(getLoginUserId())); - } - - @GetMapping("/follow-count") - @Operation(summary = "获得分配给我、待跟进的线索数量的客户数量") - @PreAuthorize("@ss.hasPermission('crm:customer:query')") - public CommonResult getFollowCustomerCount() { - return success(customerService.getFollowCustomerCount(getLoginUserId())); - } - - /** - * 获取距离进入公海的时间 Map - * - * @param list 客户列表 - * @return key 客户编号, value 距离进入公海的时间 - */ - private Map getPoolDayMap(List list) { - CrmCustomerPoolConfigDO poolConfig = customerPoolConfigService.getCustomerPoolConfig(); - if (poolConfig == null || !poolConfig.getEnabled()) { - return MapUtil.empty(); - } - list = CollectionUtils.filterList(list, customer -> { - // 特殊:如果没负责人,则说明已经在公海,不用计算 - if (customer.getOwnerUserId() == null) { - return false; - } - // 已成交 or 已锁定,不进入公海 - return !customer.getDealStatus() && !customer.getLockStatus(); - }); - return convertMap(list, CrmCustomerDO::getId, customer -> { - // 1.1 未成交放入公海天数 - long dealExpireDay = poolConfig.getDealExpireDays() - LocalDateTimeUtils.between(customer.getOwnerTime()); - // 1.2 未跟进放入公海天数 - LocalDateTime lastTime = customer.getOwnerTime(); - if (customer.getContactLastTime() != null && customer.getContactLastTime().isAfter(lastTime)) { - lastTime = customer.getContactLastTime(); - } - long contactExpireDay = poolConfig.getContactExpireDays() - LocalDateTimeUtils.between(lastTime); - // 2. 返回最小的天数 - long poolDay = Math.min(dealExpireDay, contactExpireDay); - return poolDay > 0 ? poolDay : 0; - }); - } - - @GetMapping(value = "/simple-list") - @Operation(summary = "获取客户精简信息列表", description = "只包含有读权限的客户,主要用于前端的下拉选项") - public CommonResult> getCustomerSimpleList() { - CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO(); - reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 - List list = customerService.getCustomerPage(reqVO, getLoginUserId()).getList(); - return success(convertList(list, customer -> // 只返回 id、name 精简字段 - new CrmCustomerRespVO().setId(customer.getId()).setName(customer.getName()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出客户 Excel") - @PreAuthorize("@ss.hasPermission('crm:customer:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportCustomerExcel(@Valid CrmCustomerPageReqVO pageVO, - HttpServletResponse response) throws IOException { - pageVO.setPageSize(PAGE_SIZE_NONE); // 不分页 - List list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList(); - // 导出 Excel - ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerRespVO.class, - buildCustomerDetailList(list)); - } - - @GetMapping("/get-import-template") - @Operation(summary = "获得导入客户模板") - public void importTemplate(HttpServletResponse response) throws IOException { - // 手动创建导出 demo - List list = Arrays.asList( - CrmCustomerImportExcelVO.builder().name("芋道").industryId(1).level(1).source(1) - .mobile("15601691300").telephone("").qq("").wechat("").email("yunai@iocoder.cn") - .areaId(null).detailAddress("").remark("").build(), - CrmCustomerImportExcelVO.builder().name("源码").industryId(1).level(1).source(1) - .mobile("15601691300").telephone("").qq("").wechat("").email("yunai@iocoder.cn") - .areaId(null).detailAddress("").remark("").build() - ); - // 输出 - ExcelUtils.write(response, "客户导入模板.xls", "客户列表", CrmCustomerImportExcelVO.class, list); - } - - @PostMapping("/import") - @Operation(summary = "导入客户") - @PreAuthorize("@ss.hasPermission('crm:customer:import')") - public CommonResult importExcel(@Valid CrmCustomerImportReqVO importReqVO) - throws Exception { - List list = ExcelUtils.read(importReqVO.getFile(), CrmCustomerImportExcelVO.class); - return success(customerService.importCustomerList(list, importReqVO)); - } - - @PutMapping("/transfer") - @Operation(summary = "转移客户") - @PreAuthorize("@ss.hasPermission('crm:customer:update')") - public CommonResult transferCustomer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) { - customerService.transferCustomer(reqVO, getLoginUserId()); - return success(true); - } - - @PutMapping("/lock") - @Operation(summary = "锁定/解锁客户") - @PreAuthorize("@ss.hasPermission('crm:customer:update')") - public CommonResult lockCustomer(@Valid @RequestBody CrmCustomerLockReqVO lockReqVO) { - customerService.lockCustomer(lockReqVO, getLoginUserId()); - return success(true); - } - - // ==================== 公海相关操作 ==================== - - @PutMapping("/put-pool") - @Operation(summary = "数据放入公海") - @Parameter(name = "id", description = "客户编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:customer:update')") - public CommonResult putCustomerPool(@RequestParam("id") Long id) { - customerService.putCustomerPool(id); - return success(true); - } - - @PutMapping("/receive") - @Operation(summary = "领取公海客户") - @Parameter(name = "ids", description = "编号数组", required = true, example = "1,2,3") - @PreAuthorize("@ss.hasPermission('crm:customer:receive')") - public CommonResult receiveCustomer(@RequestParam(value = "ids") List ids) { - customerService.receiveCustomer(ids, getLoginUserId(), Boolean.TRUE); - return success(true); - } - - @PutMapping("/distribute") - @Operation(summary = "分配公海给对应负责人") - @PreAuthorize("@ss.hasPermission('crm:customer:distribute')") - public CommonResult distributeCustomer(@Valid @RequestBody CrmCustomerDistributeReqVO distributeReqVO) { - customerService.receiveCustomer(distributeReqVO.getIds(), distributeReqVO.getOwnerUserId(), Boolean.FALSE); - return success(true); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java deleted file mode 100644 index 82a326c05..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; - -@Tag(name = "管理后台 - CRM 客户限制配置") -@RestController -@RequestMapping("/crm/customer-limit-config") -@Validated -public class CrmCustomerLimitConfigController { - - @Resource - private CrmCustomerLimitConfigService customerLimitConfigService; - - @Resource - private DeptApi deptApi; - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建客户限制配置") - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:create')") - public CommonResult createCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigSaveReqVO createReqVO) { - return success(customerLimitConfigService.createCustomerLimitConfig(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新客户限制配置") - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:update')") - public CommonResult updateCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigSaveReqVO updateReqVO) { - customerLimitConfigService.updateCustomerLimitConfig(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除客户限制配置") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:delete')") - public CommonResult deleteCustomerLimitConfig(@RequestParam("id") Long id) { - customerLimitConfigService.deleteCustomerLimitConfig(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得客户限制配置") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:query')") - public CommonResult getCustomerLimitConfig(@RequestParam("id") Long id) { - CrmCustomerLimitConfigDO limitConfig = customerLimitConfigService.getCustomerLimitConfig(id); - // 拼接数据 - Map userMap = adminUserApi.getUserMap(limitConfig.getUserIds()); - Map deptMap = deptApi.getDeptMap(limitConfig.getDeptIds()); - return success(BeanUtils.toBean(limitConfig, CrmCustomerLimitConfigRespVO.class, configVO -> { - configVO.setUsers(CollectionUtils.convertList(configVO.getUserIds(), userMap::get)); - configVO.setDepts(CollectionUtils.convertList(configVO.getDeptIds(), deptMap::get)); - })); - } - - @GetMapping("/page") - @Operation(summary = "获得客户限制配置分页") - @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:query')") - public CommonResult> getCustomerLimitConfigPage(@Valid CrmCustomerLimitConfigPageReqVO pageVO) { - PageResult pageResult = customerLimitConfigService.getCustomerLimitConfigPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - // 拼接数据 - Map userMap = adminUserApi.getUserMap( - convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getUserIds, Collection::stream)); - Map deptMap = deptApi.getDeptMap( - convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getDeptIds, Collection::stream)); - return success(BeanUtils.toBean(pageResult, CrmCustomerLimitConfigRespVO.class, configVO -> { - configVO.setUsers(CollectionUtils.convertList(configVO.getUserIds(), userMap::get)); - configVO.setDepts(CollectionUtils.convertList(configVO.getDeptIds(), deptMap::get)); - })); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerPoolConfigController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerPoolConfigController.java deleted file mode 100644 index 5c566359f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerPoolConfigController.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 客户公海配置") -@RestController -@RequestMapping("/crm/customer-pool-config") -@Validated -public class CrmCustomerPoolConfigController { - - @Resource - private CrmCustomerPoolConfigService customerPoolConfigService; - - @GetMapping("/get") - @Operation(summary = "获取客户公海规则设置") - @PreAuthorize("@ss.hasPermission('crm:customer-pool-config:query')") - public CommonResult getCustomerPoolConfig() { - CrmCustomerPoolConfigDO poolConfig = customerPoolConfigService.getCustomerPoolConfig(); - return success(BeanUtils.toBean(poolConfig, CrmCustomerPoolConfigRespVO.class)); - } - - @PutMapping("/save") - @Operation(summary = "更新客户公海规则设置") - @PreAuthorize("@ss.hasPermission('crm:customer-pool-config:update')") - public CommonResult saveCustomerPoolConfig(@Valid @RequestBody CrmCustomerPoolConfigSaveReqVO updateReqVO) { - customerPoolConfigService.saveCustomerPoolConfig(updateReqVO); - return success(true); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerDistributeReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerDistributeReqVO.java deleted file mode 100644 index fd47f6782..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerDistributeReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - CRM 客户分配公海给对应负责人 Request VO") -@Data -public class CrmCustomerDistributeReqVO { - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024]") - @NotEmpty(message = "客户编号不能为空") - private List ids; - - @Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "负责人不能为空") - private Long ownerUserId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportExcelVO.java deleted file mode 100644 index a45e9115f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportExcelVO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect; -import cn.iocoder.yudao.framework.excel.core.convert.AreaConvert; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.crm.framework.excel.core.AreaExcelColumnSelectFunction; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.*; - -/** - * 客户 Excel 导入 VO - */ -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题 -public class CrmCustomerImportExcelVO { - - @ExcelProperty("客户名称") - private String name; - - @ExcelProperty("手机") - private String mobile; - - @ExcelProperty("电话") - private String telephone; - - @ExcelProperty("QQ") - private String qq; - - @ExcelProperty("微信") - private String wechat; - - @ExcelProperty("邮箱") - private String email; - - @ExcelProperty(value = "地区", converter = AreaConvert.class) - @ExcelColumnSelect(functionName = AreaExcelColumnSelectFunction.NAME) - private Integer areaId; - - @ExcelProperty("详细地址") - private String detailAddress; - - @ExcelProperty(value = "所属行业", converter = DictConvert.class) - @DictFormat(CRM_CUSTOMER_INDUSTRY) - @ExcelColumnSelect(dictType = CRM_CUSTOMER_INDUSTRY) - private Integer industryId; - - @ExcelProperty(value = "客户等级", converter = DictConvert.class) - @DictFormat(CRM_CUSTOMER_LEVEL) - @ExcelColumnSelect(dictType = CRM_CUSTOMER_LEVEL) - private Integer level; - - @ExcelProperty(value = "客户来源", converter = DictConvert.class) - @DictFormat(CRM_CUSTOMER_SOURCE) - @ExcelColumnSelect(dictType = CRM_CUSTOMER_SOURCE) - private Integer source; - - @ExcelProperty("备注") - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportReqVO.java deleted file mode 100644 index 362bad882..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Builder; -import lombok.Data; -import org.springframework.web.multipart.MultipartFile; - -@Schema(description = "管理后台 - 客户导入 Request VO") -@Data -@Builder -public class CrmCustomerImportReqVO { - - @Schema(description = "Excel 文件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "Excel 文件不能为空") - private MultipartFile file; - - @Schema(description = "是否支持更新", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否支持更新不能为空") - private Boolean updateSupport; - - @Schema(description = "负责人", example = "1") - private Long ownerUserId; // 为 null 则客户进入公海 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportRespVO.java deleted file mode 100644 index dda5bc5d1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Builder; -import lombok.Data; - -import java.util.List; -import java.util.Map; - -@Schema(description = "管理后台 - 客户导入 Response VO") -@Data -@Builder -public class CrmCustomerImportRespVO { - - @Schema(description = "创建成功的客户名数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List createCustomerNames; - - @Schema(description = "更新成功的客户名数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List updateCustomerNames; - - @Schema(description = "导入失败的客户集合,key 为客户名,value 为失败原因", requiredMode = Schema.RequiredMode.REQUIRED) - private Map failureCustomerNames; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerLockReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerLockReqVO.java deleted file mode 100644 index 10bf2e10a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerLockReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户锁定/解锁 Request VO") -@Data -public class CrmCustomerLockReqVO { - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private Long id; - - @Schema(description = "客户锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Boolean lockStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerPageReqVO.java deleted file mode 100644 index 73af5d6b1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerPageReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 客户分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerPageReqVO extends PageParam { - - /** - * 联系状态 - 今日需联系 - */ - public static final int CONTACT_TODAY = 1; - /** - * 联系状态 - 已逾期 - */ - public static final int CONTACT_EXPIRED = 2; - /** - * 联系状态 - 已联系 - */ - public static final int CONTACT_ALREADY = 3; - - @Schema(description = "客户名称", example = "赵六") - private String name; - - @Schema(description = "手机", example = "18000000000") - private String mobile; - - @Schema(description = "所属行业", example = "1") - private Integer industryId; - - @Schema(description = "客户等级", example = "1") - private Integer level; - - @Schema(description = "客户来源", example = "1") - private Integer source; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - - @Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean pool; // null 则表示为不是公海数据 - - @Schema(description = "联系状态", example = "1") - private Integer contactStatus; // backlog 查询条件 - - @Schema(description = "跟进状态", example = "true") - private Boolean followUpStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerRespVO.java deleted file mode 100644 index 236129918..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerRespVO.java +++ /dev/null @@ -1,130 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 客户 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmCustomerRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty("客户名称") - private String name; - - @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "跟进状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean followUpStatus; - - @Schema(description = "最后跟进时间") - @ExcelProperty("最后跟进时间") - private LocalDateTime contactLastTime; - - @Schema(description = "最后跟进内容", example = "吃饭、睡觉、打逗逗") - @ExcelProperty("最后跟进内容") - private String contactLastContent; - - @Schema(description = "下次联系时间") - @ExcelProperty("下次联系时间") - private LocalDateTime contactNextTime; - - @Schema(description = "负责人的用户编号", example = "25682") - @ExcelProperty("负责人的用户编号") - private Long ownerUserId; - @Schema(description = "负责人名字", example = "25682") - @ExcelProperty("负责人名字") - private String ownerUserName; - @Schema(description = "负责人部门") - @ExcelProperty("负责人部门") - private String ownerUserDeptName; - - @Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "锁定状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean lockStatus; - - @Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "成交状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.BOOLEAN_STRING) - private Boolean dealStatus; - - @Schema(description = "手机", example = "25682") - @ExcelProperty("手机") - private String mobile; - - @Schema(description = "电话", example = "25682") - @ExcelProperty("电话") - private String telephone; - - @Schema(description = "QQ", example = "25682") - @ExcelProperty("QQ") - private String qq; - - @Schema(description = "wechat", example = "25682") - @ExcelProperty("wechat") - private String wechat; - - @Schema(description = "email", example = "25682") - @ExcelProperty("email") - private String email; - - @Schema(description = "地区编号", example = "1024") - @ExcelProperty("地区编号") - private Integer areaId; - @Schema(description = "地区名称", example = "北京市") - @ExcelProperty("地区名称") - private String areaName; - @Schema(description = "详细地址", example = "北京市成华大道") - @ExcelProperty("详细地址") - private String detailAddress; - - @Schema(description = "所属行业", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "所属行业", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY) - private Integer industryId; - - @Schema(description = "客户等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "客户等级", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL) - private Integer level; - - @Schema(description = "客户来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @ExcelProperty(value = "客户来源", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE) - private Integer source; - - @Schema(description = "负责人的用户编号", example = "25682") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - - @Schema(description = "创建人", example = "1024") - @ExcelProperty("创建人") - private String creator; - @Schema(description = "创建人名字", example = "芋道源码") - @ExcelProperty("创建人名字") - private String creatorName; - - @Schema(description = "距离加入公海时间", example = "1") - private Long poolDay; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerSaveReqVO.java deleted file mode 100644 index daedb7830..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerSaveReqVO.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.framework.common.validation.Telephone; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerIndustryParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerLevelParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerSourceParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAreaParseFunction; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; - -@Schema(description = "管理后台 - CRM 客户新增/修改 Request VO") -@Data -public class CrmCustomerSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private Long id; - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - @DiffLogField(name = "客户名称") - @NotEmpty(message = "客户名称不能为空") - private String name; - - @Schema(description = "下次联系时间") - @DiffLogField(name = "下次联系时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactNextTime; - - @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - @NotNull(message = "负责人的用户编号不能为空") - private Long ownerUserId; - - @Schema(description = "手机", example = "18000000000") - @DiffLogField(name = "手机") - @Mobile - private String mobile; - - @Schema(description = "电话", example = "18000000000") - @DiffLogField(name = "电话") - @Telephone - private String telephone; - - @Schema(description = "QQ", example = "123456789") - @DiffLogField(name = "QQ") - @Size(max = 20, message = "QQ长度不能超过 20 个字符") - private String qq; - - @Schema(description = "微信", example = "123456789") - @DiffLogField(name = "微信") - @Size(max = 255, message = "微信长度不能超过 255 个字符") - private String wechat; - - @Schema(description = "邮箱", example = "123456789@qq.com") - @DiffLogField(name = "邮箱") - @Email(message = "邮箱格式不正确") - @Size(max = 255, message = "邮箱长度不能超过 255 个字符") - private String email; - - @Schema(description = "地区编号", example = "20158") - @DiffLogField(name = "地区编号", function = SysAreaParseFunction.NAME) - private Integer areaId; - - @Schema(description = "详细地址", example = "北京市海淀区") - @DiffLogField(name = "详细地址") - private String detailAddress; - - @Schema(description = "所属行业", example = "1") - @DiffLogField(name = "所属行业", function = CrmCustomerIndustryParseFunction.NAME) - @DictFormat(CRM_CUSTOMER_INDUSTRY) - private Integer industryId; - - @Schema(description = "客户等级", example = "2") - @DiffLogField(name = "客户等级", function = CrmCustomerLevelParseFunction.NAME) - @InEnum(CrmCustomerLevelEnum.class) - private Integer level; - - @Schema(description = "客户来源", example = "3") - @DiffLogField(name = "客户来源", function = CrmCustomerSourceParseFunction.NAME) - private Integer source; - - @Schema(description = "备注", example = "随便") - @DiffLogField(name = "备注") - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerTransferReqVO.java deleted file mode 100644 index 467ac8ad4..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerTransferReqVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; - -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - CRM 客户转移 Request VO") -@Data -public class CrmCustomerTransferReqVO { - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "客户编号不能为空") - private Long id; - - /** - * 新负责人的用户编号 - */ - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - /** - * 老负责人加入团队后的权限级别。如果 null 说明移除 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer oldOwnerPermissionLevel; - - /** - * 转移客户时,需要额外有【联系人】【商机】【合同】的 checkbox 选择。选中时,也一起转移 - */ - @Schema(description = "同时转移", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - private List toBizTypes; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigPageReqVO.java deleted file mode 100644 index 37ce11009..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 客户限制配置分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmCustomerLimitConfigPageReqVO extends PageParam { - - @Schema(description = "规则类型", example = "1") - private Integer type; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java deleted file mode 100644 index 8ff03ad66..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; - -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 客户限制配置 Response VO") -@Data -public class CrmCustomerLimitConfigRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930") - private Long id; - - @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer type; - - @Schema(description = "规则适用人群") - private List userIds; - - @Schema(description = "规则适用部门") - private List deptIds; - - @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") - private Integer maxCount; - - @Schema(description = "成交客户是否占有拥有客户数") - private Boolean dealCountEnabled; - - @Schema(description = "规则适用人群名称") - private List users; - - @Schema(description = "规则适用部门名称") - private List depts; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigSaveReqVO.java deleted file mode 100644 index 9a4f25861..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigSaveReqVO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; - -import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAdminUserParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysDeptParseFunction; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - 客户限制配置创建/更新 Request VO") -@Data -public class CrmCustomerLimitConfigSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930") - private Long id; - - @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "规则类型不能为空") - @DiffLogField(name = "规则类型") - private Integer type; - - @Schema(description = "规则适用人群") - @DiffLogField(name = "规则适用人群", function = SysAdminUserParseFunction.NAME) - private List userIds; - - @Schema(description = "规则适用部门") - @DiffLogField(name = "规则适用部门", function = SysDeptParseFunction.NAME) - private List deptIds; - - @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") - @NotNull(message = "数量上限不能为空") - @DiffLogField(name = "数量上限") - private Integer maxCount; - - @Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)") - @DiffLogField(name = "成交客户是否占有拥有客户数") - private Boolean dealCountEnabled; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigRespVO.java deleted file mode 100644 index 4a5b6b8c0..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户公海规则 Response VO") -@Data -public class CrmCustomerPoolConfigRespVO { - - @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否启用客户公海不能为空") - private Boolean enabled; - - @Schema(description = "未跟进放入公海天数", example = "2") - private Integer contactExpireDays; - - @Schema(description = "未成交放入公海天数", example = "2") - private Integer dealExpireDays; - - @Schema(description = "是否开启提前提醒", example = "true") - private Boolean notifyEnabled; - - @Schema(description = "提前提醒天数", example = "2") - private Integer notifyDays; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java deleted file mode 100644 index 6fa1301c6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; - -import cn.hutool.core.util.BooleanUtil; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.util.Objects; - -@Schema(description = "管理后台 - CRM 客户公海配置的创建/更新 Request VO") -@Data -public class CrmCustomerPoolConfigSaveReqVO { - - @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @DiffLogField(name = "是否启用客户公海") - @NotNull(message = "是否启用客户公海不能为空") - private Boolean enabled; - - @Schema(description = "未跟进放入公海天数", example = "2") - @DiffLogField(name = "未跟进放入公海天数") - private Integer contactExpireDays; - - @Schema(description = "未成交放入公海天数", example = "2") - @DiffLogField(name = "未成交放入公海天数") - private Integer dealExpireDays; - - @Schema(description = "是否开启提前提醒", example = "true") - @DiffLogField(name = "是否开启提前提醒") - private Boolean notifyEnabled; - - @Schema(description = "提前提醒天数", example = "2") - @DiffLogField(name = "提前提醒天数") - private Integer notifyDays; - - @AssertTrue(message = "未成交放入公海天数不能为空") - @JsonIgnore - public boolean isDealExpireDaysValid() { - if (!BooleanUtil.isTrue(getEnabled())) { - return true; - } - return Objects.nonNull(getDealExpireDays()); - } - - @AssertTrue(message = "未跟进放入公海天数不能为空") - @JsonIgnore - public boolean isContactExpireDaysValid() { - if (!BooleanUtil.isTrue(getEnabled())) { - return true; - } - return Objects.nonNull(getContactExpireDays()); - } - - @AssertTrue(message = "提前提醒天数不能为空") - @JsonIgnore - public boolean isNotifyDaysValid() { - if (!BooleanUtil.isTrue(getNotifyEnabled())) { - return true; - } - return Objects.nonNull(getNotifyDays()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java deleted file mode 100644 index 867c4e730..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.followup; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.followup.CrmFollowUpRecordService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.ArrayList; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - - -@Tag(name = "管理后台 - 跟进记录") -@RestController -@RequestMapping("/crm/follow-up-record") -@Validated -public class CrmFollowUpRecordController { - - @Resource - private CrmFollowUpRecordService followUpRecordService; - @Resource - private CrmContactService contactService; - @Resource - private CrmBusinessService businessService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建跟进记录") - public CommonResult createFollowUpRecord(@Valid @RequestBody CrmFollowUpRecordSaveReqVO createReqVO) { - return success(followUpRecordService.createFollowUpRecord(createReqVO)); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除跟进记录") - @Parameter(name = "id", description = "编号", required = true) - public CommonResult deleteFollowUpRecord(@RequestParam("id") Long id) { - followUpRecordService.deleteFollowUpRecord(id, getLoginUserId()); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得跟进记录") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getFollowUpRecord(@RequestParam("id") Long id) { - CrmFollowUpRecordDO followUpRecord = followUpRecordService.getFollowUpRecord(id); - return success(BeanUtils.toBean(followUpRecord, CrmFollowUpRecordRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得跟进记录分页") - public CommonResult> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) { - PageResult pageResult = followUpRecordService.getFollowUpRecordPage(pageReqVO); - // 1.1 查询联系人和商机 - Map contactMap = contactService.getContactMap( - convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream())); - Map businessMap = businessService.getBusinessMap( - convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream())); - // 1.2 查询用户 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), item -> Long.valueOf(item.getCreator()))); - // 2. 拼接数据 - PageResult voPageResult = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class, record -> { - // 2.1 设置联系人和商机信息 - record.setBusinesses(new ArrayList<>()).setContacts(new ArrayList<>()); - record.getContactIds().forEach(id -> MapUtils.findAndThen(contactMap, id, contact -> - record.getContacts().add(new CrmBusinessRespVO().setId(contact.getId()).setName(contact.getName())))); - record.getBusinessIds().forEach(id -> MapUtils.findAndThen(businessMap, id, business -> - record.getBusinesses().add(new CrmBusinessRespVO().setId(business.getId()).setName(business.getName())))); - // 2.2 设置用户信息 - MapUtils.findAndThen(userMap, Long.valueOf(record.getCreator()), user -> record.setCreatorName(user.getNickname())); - }); - return success(voPageResult); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordPageReqVO.java deleted file mode 100644 index 78c28a08f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.followup.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 跟进记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmFollowUpRecordPageReqVO extends PageParam { - - @Schema(description = "数据类型", example = "2") - private Integer bizType; - - @Schema(description = "数据编号", example = "5564") - private Long bizId; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordRespVO.java deleted file mode 100644 index 1ce10b73e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordRespVO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.followup.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_FOLLOW_UP_TYPE; - -@Schema(description = "管理后台 - 跟进记录 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmFollowUpRecordRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28800") - private Long id; - - @Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer bizType; - - @Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5564") - private Long bizId; - - @Schema(description = "跟进类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @DictFormat(CRM_FOLLOW_UP_TYPE) - private Integer type; - - @Schema(description = "跟进内容", requiredMode = Schema.RequiredMode.REQUIRED) - private String content; - - @Schema(description = "下次联系时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime nextTime; - - @Schema(description = "关联的商机编号数组") - private List businessIds; - @Schema(description = "关联的商机数组") - private List businesses; - - @Schema(description = "关联的联系人编号数组") - private List contactIds; - @Schema(description = "关联的联系人名称数组") - private List contacts; - - @Schema(description = "图片") - private List picUrls; - @Schema(description = "附件") - private List fileUrls; - - @Schema(description = "创建人", example = "1024") - @ExcelProperty("创建人") - private String creator; - @Schema(description = "创建人名字", example = "芋道源码") - @ExcelProperty("创建人名字") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordSaveReqVO.java deleted file mode 100644 index 0b6291a0e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordSaveReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.followup.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 跟进记录新增/修改 Request VO") -@Data -public class CrmFollowUpRecordSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28800") - private Long id; - - @Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "数据类型不能为空") - private Integer bizType; - - @Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5564") - @NotNull(message = "数据编号不能为空") - private Long bizId; - - @Schema(description = "跟进类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "跟进类型不能为空") - private Integer type; - - @Schema(description = "跟进内容", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "跟进内容不能为空") - private String content; - - @Schema(description = "下次联系时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "下次联系时间不能为空") - private LocalDateTime nextTime; - - @Schema(description = "关联的商机编号数组") - private List businessIds; - @Schema(description = "关联的联系人编号数组") - private List contactIds; - - @Schema(description = "图片") - private List picUrls; - @Schema(description = "附件") - private List fileUrls; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/CrmOperateLogController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/CrmOperateLogController.java deleted file mode 100644 index 4aa48bd57..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/CrmOperateLogController.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.operatelog; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.operatelog.vo.CrmOperateLogPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.operatelog.vo.CrmOperateLogRespVO; -import cn.iocoder.yudao.module.crm.enums.LogRecordConstants; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.system.api.logger.OperateLogApi; -import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogPageReqDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.HashMap; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -@Tag(name = "管理后台 - CRM 操作日志") -@RestController -@RequestMapping("/crm/operate-log") -@Validated -public class CrmOperateLogController { - - @Resource - private OperateLogApi operateLogApi; - - /** - * {@link CrmBizTypeEnum} 与 {@link LogRecordConstants} 的映射关系 - */ - private static final Map BIZ_TYPE_MAP = new HashMap<>(); - - static { - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_CLUE.getType(), CRM_CLUE_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_CUSTOMER.getType(), CRM_CUSTOMER_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_CONTACT.getType(), CRM_CONTACT_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_BUSINESS.getType(), CRM_BUSINESS_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_CONTRACT.getType(), CRM_CONTRACT_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_PRODUCT.getType(), CRM_PRODUCT_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_RECEIVABLE.getType(), CRM_RECEIVABLE_TYPE); - BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), CRM_RECEIVABLE_PLAN_TYPE); - } - - @GetMapping("/page") - @Operation(summary = "获得操作日志") - public CommonResult> getCustomerOperateLog(@Valid CrmOperateLogPageReqVO pageReqVO) { - OperateLogPageReqDTO reqDTO = new OperateLogPageReqDTO(); - reqDTO.setPageSize(PAGE_SIZE_NONE); // 默认不分页,需要分页需注释 - reqDTO.setType(BIZ_TYPE_MAP.get(pageReqVO.getBizType())).setBizId(pageReqVO.getBizId()); - return success(BeanUtils.toBean(operateLogApi.getOperateLogPage(reqDTO).getCheckedData(), CrmOperateLogRespVO.class)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogPageReqVO.java deleted file mode 100644 index de3af64b3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.operatelog.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 操作日志 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmOperateLogPageReqVO extends PageParam { - - @Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmBizTypeEnum.class) - @NotNull(message = "数据类型不能为空") - private Integer bizType; - - @Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "数据编号不能为空") - private Long bizId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogRespVO.java deleted file mode 100644 index 8e458a8a0..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogRespVO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.operatelog.vo; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 操作日志 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmOperateLogRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private Long id; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userId; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String userName; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer userType; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private String type; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "修改客户") - private String subType; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private Long bizId; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "将什么从什么改为了什么") - private String action; - - @Schema(description = "编号", example = "{orderId: 1}") - private String extra; - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-01-01") - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.http b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.http deleted file mode 100644 index 1ef2bc1a1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.http +++ /dev/null @@ -1,32 +0,0 @@ -### 请求 /add -POST {{baseUrl}}/crm/permission/create -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "userId": 1, - "bizType": 2, - "bizId": 2, - "level": 1 -} - -### 请求 /update -PUT {{baseUrl}}/crm/permission/update -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "userId": 1, - "bizType": 2, - "bizId": 2, - "level": 1, - "id": 1 -} - -### 请求 /delete -DELETE {{baseUrl}}/crm/permission/delete?bizType=2&bizId=1&id=1 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java deleted file mode 100644 index 1a829ad2f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.permission; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.PostApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.google.common.collect.Multimaps; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - CRM 数据权限") -@RestController -@RequestMapping("/crm/permission") -@Validated -public class CrmPermissionController { - - @Resource - private CrmPermissionService permissionService; - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - @Resource - private PostApi postApi; - - @PostMapping("/create") - @Operation(summary = "创建数据权限") - public CommonResult create(@Valid @RequestBody CrmPermissionSaveReqVO reqVO) { - permissionService.createPermission(reqVO, getLoginUserId()); - return success(true); - } - - @PutMapping("/update") - @Operation(summary = "编辑数据权限") - @CrmPermission(bizTypeValue = "#updateReqVO.bizType", bizId = "#updateReqVO.bizId" - , level = CrmPermissionLevelEnum.OWNER) - public CommonResult updatePermission(@Valid @RequestBody CrmPermissionUpdateReqVO updateReqVO) { - permissionService.updatePermission(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除数据权限") - @Parameter(name = "ids", description = "数据权限编号", required = true, example = "1024") - public CommonResult deletePermission(@RequestParam("ids") Collection ids) { - permissionService.deletePermissionBatch(ids, getLoginUserId()); - return success(true); - } - - @DeleteMapping("/delete-self") - @Operation(summary = "删除自己的数据权限") - @Parameter(name = "id", description = "数据权限编号", required = true, example = "1024") - public CommonResult deleteSelfPermission(@RequestParam("id") Long id) { - permissionService.deleteSelfPermission(id, getLoginUserId()); - return success(true); - } - - @GetMapping("/list") - @Operation(summary = "获得数据权限列表") - @Parameters({ - @Parameter(name = "bizType", description = "CRM 类型", required = true, example = "2"), - @Parameter(name = "bizId", description = "CRM 类型数据编号", required = true, example = "1024") - }) - public CommonResult> getPermissionList(@RequestParam("bizType") Integer bizType, - @RequestParam("bizId") Long bizId) { - List permissions = permissionService.getPermissionListByBiz(bizType, bizId); - if (CollUtil.isEmpty(permissions)) { - return success(Collections.emptyList()); - } - - // 查询相关数据 - Map userMap = adminUserApi.getUserMap( - convertSet(permissions, CrmPermissionDO::getUserId)); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - Map postMap = postApi.getPostMap( - convertSetByFlatMap(userMap.values(), AdminUserRespDTO::getPostIds, - item -> item != null ? item.stream() : Stream.empty())); - // 拼接数据 - return success(CollectionUtils.convertList(BeanUtils.toBean(permissions, CrmPermissionRespVO.class), item -> { - findAndThen(userMap, item.getUserId(), user -> { - item.setNickname(user.getNickname()); - findAndThen(deptMap, user.getDeptId(), deptRespDTO -> item.setDeptName(deptRespDTO.getName())); - if (CollUtil.isEmpty(user.getPostIds())) { - item.setPostNames(Collections.emptySet()); - return; - } - List postList = MapUtils.getList(Multimaps.forMap(postMap), user.getPostIds()); - item.setPostNames(CollectionUtils.convertSet(postList, PostRespDTO::getName)); - }); - return item; - })); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionRespVO.java deleted file mode 100644 index 28985aef6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionRespVO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.Set; - -@Schema(description = "管理后台 - CRM 数据权限 Response VO") -@Data -public class CrmPermissionRespVO { - - @Schema(description = "数据权限编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "CRM 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmBizTypeEnum.class) - @NotNull(message = "CRM 类型不能为空") - private Integer bizType; - - @Schema(description = "CRM 类型数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "CRM 类型数据编号不能为空") - private Long bizId; - - @Schema(description = "权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmPermissionLevelEnum.class) - @NotNull(message = "权限级别不能为空") - private Integer level; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String nickname; - - @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "研发部") - private String deptName; - - @Schema(description = "岗位名称数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[BOOS,经理]") - private Set postNames; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-01-01 00:00:00") - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionSaveReqVO.java deleted file mode 100644 index c4d7e9c20..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionSaveReqVO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - CRM 数据权限创建/更新 Request VO") -@Data -public class CrmPermissionSaveReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "CRM 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmBizTypeEnum.class) - @NotNull(message = "CRM 类型不能为空") - private Integer bizType; - - @Schema(description = "CRM 类型数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "CRM 类型数据编号不能为空") - private Long bizId; - - @Schema(description = "权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmPermissionLevelEnum.class) - @NotNull(message = "权限级别不能为空") - private Integer level; - - /** - * 添加客户团队成员时,需要额外有【联系人】【商机】【合同】的 checkbox 选择。 - * 选中时,同时添加对应的权限 - */ - @Schema(description = "同时添加", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - private List toBizTypes; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionUpdateReqVO.java deleted file mode 100644 index d49f5662f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionUpdateReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - CRM 数据权限更新 Request VO") -@Data -public class CrmPermissionUpdateReqVO { - - @Schema(description = "数据权限编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,2]") - @NotNull(message = "数据权限编号列表不能为空") - private List ids; - - @Schema(description = "Crm 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmBizTypeEnum.class) - @NotNull(message = "Crm 类型不能为空") - private Integer bizType; - - @Schema(description = "Crm 类型数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "Crm 类型数据编号不能为空") - private Long bizId; - - @Schema(description = "权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @InEnum(CrmPermissionLevelEnum.class) - @NotNull(message = "权限级别不能为空") - private Integer level; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductCategoryController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductCategoryController.java deleted file mode 100644 index dec0d6241..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductCategoryController.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryRespVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import cn.iocoder.yudao.module.crm.service.product.CrmProductCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 产品分类") -@RestController -@RequestMapping("/crm/product-category") -@Validated -public class CrmProductCategoryController { - - @Resource - private CrmProductCategoryService productCategoryService; - - @PostMapping("/create") - @Operation(summary = "创建产品分类") - @PreAuthorize("@ss.hasPermission('crm:product-category:create')") - public CommonResult createProductCategory(@Valid @RequestBody CrmProductCategoryCreateReqVO createReqVO) { - return success(productCategoryService.createProductCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新产品分类") - @PreAuthorize("@ss.hasPermission('crm:product-category:update')") - public CommonResult updateProductCategory(@Valid @RequestBody CrmProductCategoryCreateReqVO updateReqVO) { - productCategoryService.updateProductCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除产品分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:product-category:delete')") - public CommonResult deleteProductCategory(@RequestParam("id") Long id) { - productCategoryService.deleteProductCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得产品分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:product-category:query')") - public CommonResult getProductCategory(@RequestParam("id") Long id) { - CrmProductCategoryDO category = productCategoryService.getProductCategory(id); - return success(BeanUtils.toBean(category, CrmProductCategoryRespVO.class)); - } - - @GetMapping("/list") - @Operation(summary = "获得产品分类列表") - @PreAuthorize("@ss.hasPermission('crm:product-category:query')") - public CommonResult> getProductCategoryList(@Valid CrmProductCategoryListReqVO listReqVO) { - List list = productCategoryService.getProductCategoryList(listReqVO); - return success(BeanUtils.toBean(list, CrmProductCategoryRespVO.class)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java deleted file mode 100644 index 555993b86..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.translate.core.TranslateUtils; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import cn.iocoder.yudao.module.crm.enums.product.CrmProductStatusEnum; -import cn.iocoder.yudao.module.crm.service.product.CrmProductService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - CRM 产品") -@RestController -@RequestMapping("/crm/product") -@Validated -public class CrmProductController { - - @Resource - private CrmProductService productService; - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建产品") - @PreAuthorize("@ss.hasPermission('crm:product:create')") - public CommonResult createProduct(@Valid @RequestBody CrmProductSaveReqVO createReqVO) { - return success(productService.createProduct(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新产品") - @PreAuthorize("@ss.hasPermission('crm:product:update')") - public CommonResult updateProduct(@Valid @RequestBody CrmProductSaveReqVO updateReqVO) { - productService.updateProduct(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除产品") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:product:delete')") - public CommonResult deleteProduct(@RequestParam("id") Long id) { - productService.deleteProduct(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得产品") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:product:query')") - public CommonResult getProduct(@RequestParam("id") Long id) { - CrmProductDO product = productService.getProduct(id); - return success(BeanUtils.toBean(product, CrmProductRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得产品精简列表", description = "只包含被开启的产品,主要用于前端的下拉选项") - public CommonResult> getProductSimpleList() { - List list = productService.getProductListByStatus(CrmProductStatusEnum.ENABLE.getStatus()); - return success(convertList(list, product -> new CrmProductRespVO().setId(product.getId()).setName(product.getName()) - .setUnit(product.getUnit()).setNo(product.getNo()).setPrice(product.getPrice()))); - } - - @GetMapping("/page") - @Operation(summary = "获得产品分页") - @PreAuthorize("@ss.hasPermission('crm:product:query')") - public CommonResult> getProductPage(@Valid CrmProductPageReqVO pageVO) { - PageResult pageResult = productService.getProductPage(pageVO); - return success(BeanUtils.toBean(pageResult, CrmProductRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出产品 Excel") - @PreAuthorize("@ss.hasPermission('crm:product:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportProductExcel(@Valid CrmProductPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = productService.getProductPage(exportReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "产品.xls", "数据", CrmProductRespVO.class, - TranslateUtils.translate(BeanUtils.toBean(list, CrmProductRespVO.class))); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java deleted file mode 100644 index e1b249c15..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.category; - -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - CRM 产品分类创建/更新 Request VO") -@Data -public class CrmProductCategoryCreateReqVO{ - - @Schema(description = "分类编号", example = "23902") - private Long id; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - @NotNull(message = "分类名称不能为空") - @DiffLogField(name = "分类名称") - private String name; - - @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4680") - @NotNull(message = "父级编号不能为空") - private Long parentId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryListReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryListReqVO.java deleted file mode 100644 index 6144c95c4..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryListReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.category; - -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 产品分类列表 Request VO") -@Data -public class CrmProductCategoryListReqVO { - - @ExcelProperty("名称") - private String name; - - @ExcelProperty("父级 id") - private Long parentId; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryRespVO.java deleted file mode 100644 index 657a32c5b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 产品分类 Response VO") -@Data -public class CrmProductCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23902") - private Long id; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private String name; - - @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4680") - private Long parentId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductPageReqVO.java deleted file mode 100644 index 39b1090f8..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 产品分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmProductPageReqVO extends PageParam { - - @Schema(description = "产品名称", example = "李四") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductRespVO.java deleted file mode 100644 index 08625b8ca..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductRespVO.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import com.fhs.core.trans.anno.Trans; -import com.fhs.core.trans.constant.TransType; -import com.fhs.core.trans.vo.VO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 产品 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmProductRespVO implements VO { - - @Schema(description = "产品编号", example = "20529") - @ExcelProperty("产品编号") - private Long id; - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "好产品") - @ExcelProperty("产品名称") - private String name; - - @Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "12306") - @ExcelProperty("产品编码") - private String no; - - @Schema(description = "单位", example = "2") - @ExcelProperty(value = "单位", converter = DictConvert.class) - @DictFormat(DictTypeConstants.CRM_PRODUCT_UNIT) - private Integer unit; - - @Schema(description = "价格, 单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - @ExcelProperty("价格,单位:分") - private BigDecimal price; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "上架") - @ExcelProperty(value = "单位", converter = DictConvert.class) - @DictFormat(DictTypeConstants.CRM_PRODUCT_STATUS) - private Integer status; - - @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @Trans(type = TransType.SIMPLE, target = CrmProductCategoryDO.class, fields = "name", ref = "categoryName") - private Long categoryId; - @Schema(description = "产品分类名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "衣服") - @ExcelProperty("产品分类") - private String categoryName; - - @Schema(description = "产品描述", example = "你说的对") - @ExcelProperty("产品描述") - private String description; - - @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926") - @Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, - fields = "nickname", ref = "ownerUserName") - private Long ownerUserId; - @Schema(description = "负责人的用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @ExcelProperty("负责人") - private String ownerUserName; - - @Schema(description = "创建人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @Trans(type = TransType.AUTO_TRANS, key = AdminUserApi.PREFIX, - fields = "nickname", ref = "creatorName") - private String creator; - @Schema(description = "创建人名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @ExcelProperty("创建人") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java deleted file mode 100644 index 761242f4f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product; - -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmProductStatusParseFunction; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmProductUnitParseFunction; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - CRM 产品创建/修改 Request VO") -@Data -public class CrmProductSaveReqVO { - - @Schema(description = "产品编号", example = "20529") - private Long id; - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "好产品") - @NotNull(message = "产品名称不能为空") - @DiffLogField(name = "产品名称") - private String name; - - @Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "12306") - @NotNull(message = "产品编码不能为空") - @DiffLogField(name = "产品编码") - private String no; - - @Schema(description = "单位", example = "2") - @DiffLogField(name = "单位", function = CrmProductUnitParseFunction.NAME) - private Integer unit; - - @Schema(description = "价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") - @NotNull(message = "价格不能为空") - @DiffLogField(name = "价格") - private BigDecimal price; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "上架") - @NotNull(message = "状态不能为空") - @DiffLogField(name = "状态", function = CrmProductStatusParseFunction.NAME) - private Integer status; - - @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "产品分类编号不能为空") - @DiffLogField(name = "产品分类编号") - private Long categoryId; - - @Schema(description = "产品描述", example = "你说的对") - @DiffLogField(name = "产品描述") - private String description; - - @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926") - @NotNull(message = "负责人的用户编号不能为空") - private Long ownerUserId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java deleted file mode 100644 index 1b7dfa361..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java +++ /dev/null @@ -1,183 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - CRM 回款") -@RestController -@RequestMapping("/crm/receivable") -@Validated -public class CrmReceivableController { - - @Resource - private CrmReceivableService receivableService; - @Resource - private CrmContractService contractService; - @Resource - private CrmCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @PostMapping("/create") - @Operation(summary = "创建回款") - @PreAuthorize("@ss.hasPermission('crm:receivable:create')") - public CommonResult createReceivable(@Valid @RequestBody CrmReceivableSaveReqVO createReqVO) { - return success(receivableService.createReceivable(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新回款") - @PreAuthorize("@ss.hasPermission('crm:receivable:update')") - public CommonResult updateReceivable(@Valid @RequestBody CrmReceivableSaveReqVO updateReqVO) { - receivableService.updateReceivable(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除回款") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:receivable:delete')") - public CommonResult deleteReceivable(@RequestParam("id") Long id) { - receivableService.deleteReceivable(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得回款") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:receivable:query')") - public CommonResult getReceivable(@RequestParam("id") Long id) { - CrmReceivableDO receivable = receivableService.getReceivable(id); - return success(buildReceivableDetail(receivable)); - } - - private CrmReceivableRespVO buildReceivableDetail(CrmReceivableDO receivable) { - if (receivable == null) { - return null; - } - return buildReceivableDetailList(Collections.singletonList(receivable)).get(0); - } - - @GetMapping("/page") - @Operation(summary = "获得回款分页") - @PreAuthorize("@ss.hasPermission('crm:receivable:query')") - public CommonResult> getReceivablePage(@Valid CrmReceivablePageReqVO pageReqVO) { - PageResult pageResult = receivableService.getReceivablePage(pageReqVO, getLoginUserId()); - return success(new PageResult<>(buildReceivableDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得回款分页,基于指定客户") - public CommonResult> getReceivablePageByCustomer(@Valid CrmReceivablePageReqVO pageReqVO) { - Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); - PageResult pageResult = receivableService.getReceivablePageByCustomerId(pageReqVO); - return success(new PageResult<>(buildReceivableDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出回款 Excel") - @PreAuthorize("@ss.hasPermission('crm:receivable:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportReceivableExcel(@Valid CrmReceivablePageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - exportReqVO.setPageSize(PAGE_SIZE_NONE); - List list = receivableService.getReceivablePage(exportReqVO, getLoginUserId()).getList(); - // 导出 Excel - ExcelUtils.write(response, "回款.xls", "数据", CrmReceivableRespVO.class, - buildReceivableDetailList(list)); - } - - private List buildReceivableDetailList(List receivableList) { - if (CollUtil.isEmpty(receivableList)) { - return Collections.emptyList(); - } - // 1.1 获取客户列表 - Map customerMap = customerService.getCustomerMap( - convertSet(receivableList, CrmReceivableDO::getCustomerId)); - // 1.2 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(receivableList, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - // 1.3 获得合同列表 - Map contractMap = contractService.getContractMap( - convertSet(receivableList, CrmReceivableDO::getContractId)); - // 2. 拼接结果 - return BeanUtils.toBean(receivableList, CrmReceivableRespVO.class, (receivableVO) -> { - // 2.1 拼接客户名称 - findAndThen(customerMap, receivableVO.getCustomerId(), customer -> receivableVO.setCustomerName(customer.getName())); - // 2.2 拼接负责人、创建人名称 - MapUtils.findAndThen(userMap, NumberUtils.parseLong(receivableVO.getCreator()), - user -> receivableVO.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, receivableVO.getOwnerUserId(), user -> { - receivableVO.setOwnerUserName(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> receivableVO.setOwnerUserDeptName(dept.getName())); - }); - // 2.3 拼接合同信息 - findAndThen(contractMap, receivableVO.getContractId(), contract -> - receivableVO.setContract(BeanUtils.toBean(contract, CrmContractRespVO.class))); - }); - } - - @PutMapping("/submit") - @Operation(summary = "提交回款审批") - @PreAuthorize("@ss.hasPermission('crm:receivable:update')") - public CommonResult submitContract(@RequestParam("id") Long id) { - receivableService.submitReceivable(id, getLoginUserId()); - return success(true); - } - - @GetMapping("/audit-count") - @Operation(summary = "获得待审核回款数量") - @PreAuthorize("@ss.hasPermission('crm:receivable:query')") - public CommonResult getAuditReceivableCount() { - return success(receivableService.getAuditReceivableCount(getLoginUserId())); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java deleted file mode 100644 index 74ba2e0e1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java +++ /dev/null @@ -1,190 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivablePlanService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - CRM 回款计划") -@RestController -@RequestMapping("/crm/receivable-plan") -@Validated -public class CrmReceivablePlanController { - - @Resource - private CrmReceivablePlanService receivablePlanService; - @Resource - private CrmReceivableService receivableService; - @Resource - private CrmContractService contractService; - @Resource - private CrmCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建回款计划") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:create')") - public CommonResult createReceivablePlan(@Valid @RequestBody CrmReceivablePlanSaveReqVO createReqVO) { - return success(receivablePlanService.createReceivablePlan(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新回款计划") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:update')") - public CommonResult updateReceivablePlan(@Valid @RequestBody CrmReceivablePlanSaveReqVO updateReqVO) { - receivablePlanService.updateReceivablePlan(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除回款计划") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:delete')") - public CommonResult deleteReceivablePlan(@RequestParam("id") Long id) { - receivablePlanService.deleteReceivablePlan(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得回款计划") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult getReceivablePlan(@RequestParam("id") Long id) { - CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(id); - return success(buildReceivablePlanDetail(receivablePlan)); - } - - private CrmReceivablePlanRespVO buildReceivablePlanDetail(CrmReceivablePlanDO receivablePlan) { - if (receivablePlan == null) { - return null; - } - return buildReceivableDetailList(Collections.singletonList(receivablePlan)).get(0); - } - - @GetMapping("/page") - @Operation(summary = "获得回款计划分页") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult> getReceivablePlanPage(@Valid CrmReceivablePlanPageReqVO pageReqVO) { - PageResult pageResult = receivablePlanService.getReceivablePlanPage(pageReqVO, getLoginUserId()); - return success(new PageResult<>(buildReceivableDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/page-by-customer") - @Operation(summary = "获得回款计划分页,基于指定客户") - public CommonResult> getReceivablePlanPageByCustomer(@Valid CrmReceivablePlanPageReqVO pageReqVO) { - Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); - PageResult pageResult = receivablePlanService.getReceivablePlanPageByCustomerId(pageReqVO); - return success(new PageResult<>(buildReceivableDetailList(pageResult.getList()), pageResult.getTotal())); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出回款计划 Excel") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportReceivablePlanExcel(@Valid CrmReceivablePlanPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { - exportReqVO.setPageSize(PAGE_SIZE_NONE); - List list = receivablePlanService.getReceivablePlanPage(exportReqVO, getLoginUserId()).getList(); - // 导出 Excel - ExcelUtils.write(response, "回款计划.xls", "数据", CrmReceivablePlanRespVO.class, - buildReceivableDetailList(list)); - } - - private List buildReceivableDetailList(List receivablePlanList) { - if (CollUtil.isEmpty(receivablePlanList)) { - return Collections.emptyList(); - } - // 1.1 获取客户 Map - Map customerMap = customerService.getCustomerMap( - convertSet(receivablePlanList, CrmReceivablePlanDO::getCustomerId)); - // 1.2 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(receivablePlanList, - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); - // 1.3 获得合同 Map - Map contractMap = contractService.getContractMap( - convertSet(receivablePlanList, CrmReceivablePlanDO::getContractId)); - // 1.4 获得回款 Map - Map receivableMap = receivableService.getReceivableMap( - convertSet(receivablePlanList, CrmReceivablePlanDO::getReceivableId)); - // 2. 拼接数据 - return BeanUtils.toBean(receivablePlanList, CrmReceivablePlanRespVO.class, (receivablePlanVO) -> { - // 2.1 拼接客户信息 - findAndThen(customerMap, receivablePlanVO.getCustomerId(), customer -> receivablePlanVO.setCustomerName(customer.getName())); - // 2.2 拼接用户信息 - findAndThen(userMap, receivablePlanVO.getOwnerUserId(), user -> receivablePlanVO.setOwnerUserName(user.getNickname())); - findAndThen(userMap, Long.parseLong(receivablePlanVO.getCreator()), user -> receivablePlanVO.setCreatorName(user.getNickname())); - // 2.3 拼接合同信息 - findAndThen(contractMap, receivablePlanVO.getContractId(), contract -> receivablePlanVO.setContractNo(contract.getNo())); - // 2.4 拼接回款信息 - receivablePlanVO.setReceivable(BeanUtils.toBean(receivableMap.get(receivablePlanVO.getReceivableId()), CrmReceivableRespVO.class)); - }); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得回款计划精简列表", description = "获得回款计划精简列表,主要用于前端的下拉选项") - @Parameters({ - @Parameter(name = "customerId", description = "客户编号", required = true), - @Parameter(name = "contractId", description = "合同编号", required = true) - }) - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult> getReceivablePlanSimpleList(@RequestParam("customerId") Long customerId, - @RequestParam("contractId") Long contractId) { - CrmReceivablePlanPageReqVO pageReqVO = new CrmReceivablePlanPageReqVO().setCustomerId(customerId).setContractId(contractId); - pageReqVO.setPageNo(PAGE_SIZE_NONE); - PageResult pageResult = receivablePlanService.getReceivablePlanPageByCustomerId(pageReqVO); - return success(convertList(pageResult.getList(), receivablePlan -> new CrmReceivablePlanRespVO() // 只返回 id、period 等信息 - .setId(receivablePlan.getId()).setPeriod(receivablePlan.getPeriod()).setReceivableId(receivablePlan.getReceivableId()) - .setPrice(receivablePlan.getPrice()).setReturnType(receivablePlan.getReturnType()))); - } - - @GetMapping("/remind-count") - @Operation(summary = "获得待回款提醒数量") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult getReceivablePlanRemindCount() { - return success(receivablePlanService.getReceivablePlanRemindCount(getLoginUserId())); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java deleted file mode 100644 index b730128ce..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 回款计划分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivablePlanPageReqVO extends PageParam { - - /** - * 提醒类型 - 待回款 - */ - public final static Integer REMIND_TYPE_NEEDED = 1; - /** - * 提醒类型 - 已逾期 - */ - public final static Integer REMIND_TYPE_EXPIRED = 2; - /** - * 提醒类型 - 已回款 - */ - public final static Integer REMIND_TYPE_RECEIVED = 3; - - @Schema(description = "客户编号", example = "18026") - private Long customerId; - - @Schema(description = "合同编号", example = "H3473") - private String contractNo; - - @Schema(description = "合同编号", example = "3473") - private Long contractId; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - - @Schema(description = "提醒类型", example = "1") - private Integer remindType; // 提醒类型,为 null 时则表示全部 - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java deleted file mode 100644 index ad1ce3a7b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; - -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 回款计划 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmReceivablePlanRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "期数", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("期数") - private Integer period; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("客户编号") - private Long customerId; - @Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") - @ExcelProperty("客户名字") - private String customerName; - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("合同编号") - private Long contractId; - @Schema(description = "合同编号", example = "Q110") - @ExcelProperty("合同编号") - private String contractNo; - - @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("负责人编号") - private Long ownerUserId; - @Schema(description = "负责人", example = "test") - @ExcelProperty("负责人") - private String ownerUserName; - - @Schema(description = "计划回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") - @ExcelProperty("计划回款日期") - private LocalDateTime returnTime; - - @Schema(description = "计划回款方式", example = "1") - @ExcelProperty("计划回款方式") - private Integer returnType; - - @Schema(description = "计划回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") - @ExcelProperty("计划回款金额") - private BigDecimal price; - - @Schema(description = "回款编号", example = "19852") - @ExcelProperty("回款编号") - private Long receivableId; - @Schema(description = "回款信息") - @ExcelProperty("回款信息") - private CrmReceivableRespVO receivable; - - @Schema(description = "提前几天提醒", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("提前几天提醒") - private Integer remindDays; - - @Schema(description = "提醒日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") - @ExcelProperty("提醒日期") - private LocalDateTime remindTime; - - @Schema(description = "备注", example = "备注") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - - @Schema(description = "创建人", example = "1024") - @ExcelProperty("创建人") - private String creator; - @Schema(description = "创建人名字", example = "芋道源码") - @ExcelProperty("创建人名字") - private String creatorName; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanSaveReqVO.java deleted file mode 100644 index cefb02a9e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanSaveReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 回款计划新增/修改 Request VO") -@Data -public class CrmReceivablePlanSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Long id; - - @Schema(description = "客户编号", hidden = true, example = "2") - private Long customerId; // 该字段不通过前端传递,而是 contractId 查询出来设置进去 - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "合同编号不能为空") - private Long contractId; - - @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "负责人编号不能为空") - private Long ownerUserId; - - @Schema(description = "计划回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") - @NotNull(message = "计划回款日期不能为空") - private LocalDateTime returnTime; - - @Schema(description = "回款方式", example = "1") - private Integer returnType; - - @Schema(description = "计划回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") - @NotNull(message = "计划回款金额不能为空") - private BigDecimal price; - - @Schema(description = "提前几天提醒", example = "1") - private Integer remindDays; - - @Schema(description = "备注", example = "备注") - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java deleted file mode 100644 index 415816c5d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - CRM 回款分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivablePageReqVO extends PageParam { - - @Schema(description = "回款编号") - private String no; - - @Schema(description = "回款计划编号", example = "31177") - private Long planId; - - @Schema(description = "客户编号", example = "4963") - private Long customerId; - - @Schema(description = "合同编号", example = "4963") - private Long contractId; - - @Schema(description = "场景类型", example = "1") - @InEnum(CrmSceneTypeEnum.class) - private Integer sceneType; // 场景类型,为 null 时则表示全部 - - @Schema(description = "审批状态", example = "20") - @InEnum(CrmAuditStatusEnum.class) - private Integer auditStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java deleted file mode 100644 index 12dcbaa02..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; - -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractRespVO; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 回款 Response VO") -@Data -@ExcelIgnoreUnannotated -public class CrmReceivableRespVO { - - @Schema(description = "编号", example = "25787") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "回款编号", example = "31177") - @ExcelProperty("回款编号") - private String no; - - @Schema(description = "回款计划编号", example = "1024") - @ExcelProperty("回款计划编号") - private Long planId; - - @Schema(description = "回款方式", example = "2") - @ExcelProperty("回款方式") - private Integer returnType; - - @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") - @ExcelProperty("回款金额") - private BigDecimal price; - - @Schema(description = "计划回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") - @ExcelProperty("计划回款日期") - private LocalDateTime returnTime; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("客户编号") - private Long customerId; - @Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") - @ExcelProperty("客户名字") - private String customerName; - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("合同编号") - private Long contractId; - @Schema(description = "合同信息") - @ExcelProperty("合同信息") - private CrmContractRespVO contract; - - @Schema(description = "负责人的用户编号", example = "25682") - @ExcelProperty("负责人的用户编号") - private Long ownerUserId; - @Schema(description = "负责人名字", example = "25682") - @ExcelProperty("负责人名字") - private String ownerUserName; - @Schema(description = "负责人部门") - @ExcelProperty("负责人部门") - private String ownerUserDeptName; - - @Schema(description = "工作流编号", example = "1043") - @ExcelProperty("工作流编号") - private String processInstanceId; - - @Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @ExcelProperty("审批状态") - private Integer auditStatus; - - @Schema(description = "工作流编号", example = "备注") - @ExcelProperty("工作流编号") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("更新时间") - private LocalDateTime updateTime; - - @Schema(description = "创建人", example = "25682") - @ExcelProperty("创建人") - private String creator; - @Schema(description = "创建人名字", example = "test") - @ExcelProperty("创建人名字") - private String creatorName; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableSaveReqVO.java deleted file mode 100644 index 1064fc924..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableSaveReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.receivable.CrmReceivableReturnTypeEnum; -import cn.iocoder.yudao.module.crm.framework.operatelog.core.*; -import com.mzt.logapi.starter.annotation.DiffLogField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 回款新增/修改 Request VO") -@Data -public class CrmReceivableSaveReqVO { - - @Schema(description = "编号", example = "25787") - private Long id; - - @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME) - @NotNull(message = "负责人编号不能为空") - private Long ownerUserId; - - @Schema(description = "客户编号", example = "2") - @DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME) - private Long customerId; // 该字段不通过前端传递,而是 contractId 查询出来设置进去 - - @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @DiffLogField(name = "合同", function = CrmContractParseFunction.NAME) - @NotNull(message = "合同编号不能为空") - private Long contractId; - - @Schema(description = "回款计划编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @DiffLogField(name = "合同", function = CrmReceivablePlanParseFunction.NAME) - private Long planId; - - @Schema(description = "回款方式", example = "2") - @DiffLogField(name = "回款方式", function = CrmReceivableReturnTypeParseFunction.NAME) - @InEnum(CrmReceivableReturnTypeEnum.class) - private Integer returnType; - - @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") - @DiffLogField(name = "回款金额") - @NotNull(message = "回款金额不能为空") - private BigDecimal price; - - @Schema(description = "回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") - @NotNull(message = "回款日期不能为空") - @DiffLogField(name = "回款日期") - private LocalDateTime returnTime; - - @Schema(description = "备注", example = "备注") - @DiffLogField(name = "备注") - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http deleted file mode 100644 index 6b960512d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http +++ /dev/null @@ -1,65 +0,0 @@ -# == 1. 客户总量分析 == -### 1.1 客户总量分析(按日期) -GET {{baseUrl}}/crm/statistics-customer/get-customer-summary-by-date?deptId=100&interval=2×[0]=2024-01-01 00:00:00×[1]=2024-01-29 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 1.2 客户总量统计(按用户) -GET {{baseUrl}}/crm/statistics-customer/get-customer-summary-by-user?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -# == 2. 客户跟进次数分析 == -### 2.1 客户跟进次数分析(按日期) -GET {{baseUrl}}/crm/statistics-customer/get-follow-up-summary-by-date?deptId=100&interval=2×[0]=2024-01-01 00:00:00×[1]=2024-01-29 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 2.2 客户总量统计(按用户) -GET {{baseUrl}}/crm/statistics-customer/get-follow-up-summary-by-user?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -# == 3. 客户跟进方式分析 == -### 3.1 客户跟进方式分析 -GET {{baseUrl}}/crm/statistics-customer/get-follow-up-summary-by-type?deptId=100&interval=2×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -# == 4. 客户成交周期 == -### 4.1 合同摘要信息(客户转化率页面) -GET {{baseUrl}}/crm/statistics-customer/get-contract-summary?deptId=100&interval=2×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -# == 5. 客户成交周期 == -### 5.1 获取客户公海分析(按日期) -GET {{baseUrl}}/crm/statistics-customer/get-pool-summary-by-date?deptId=100&interval=2×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 5.2 获取客户公海分析(按用户) -GET {{baseUrl}}/crm/statistics-customer/get-pool-summary-by-user?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -# == 6. 客户成交周期 == -### 6.1 客户成交周期(按日期) -GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-date?deptId=100&interval=2×[0]=2024-01-01 00:00:00×[1]=2024-01-29 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 6.2 获取客户成交周期(按用户) -GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-user?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 6.3 获取客户成交周期(按区域) -GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-area?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 6.4 获取客户成交周期(按产品) -GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-product?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java deleted file mode 100644 index f9586e51a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java +++ /dev/null @@ -1,113 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; -import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsCustomerService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 客户统计") -@RestController -@RequestMapping("/crm/statistics-customer") -@Validated -public class CrmStatisticsCustomerController { - - @Resource - private CrmStatisticsCustomerService customerService; - - @GetMapping("/get-customer-summary-by-date") - @Operation(summary = "获取客户总量分析(按日期)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getCustomerSummaryByDate(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getCustomerSummaryByDate(reqVO)); - } - - @GetMapping("/get-customer-summary-by-user") - @Operation(summary = "获取客户总量分析(按用户)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getCustomerSummaryByUser(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getCustomerSummaryByUser(reqVO)); - } - - @GetMapping("/get-follow-up-summary-by-date") - @Operation(summary = "获取客户跟进次数分析(按日期)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getFollowupSummaryByDate(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getFollowUpSummaryByDate(reqVO)); - } - - @GetMapping("/get-follow-up-summary-by-user") - @Operation(summary = "获取客户跟进次数分析(按用户)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getFollowUpSummaryByUser(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getFollowUpSummaryByUser(reqVO)); - } - - @GetMapping("/get-follow-up-summary-by-type") - @Operation(summary = "获取客户跟进次数分析(按类型)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getFollowUpSummaryByType(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getFollowUpSummaryByType(reqVO)); - } - - @GetMapping("/get-contract-summary") - @Operation(summary = "获取客户的首次合同、回款信息列表", description = "用于【客户转化率】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getContractSummary(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getContractSummary(reqVO)); - } - - @GetMapping("/get-pool-summary-by-date") - @Operation(summary = "获取公海客户分析(按日期)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getPoolSummaryByDate(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getPoolSummaryByDate(reqVO)); - } - - @GetMapping("/get-pool-summary-by-user") - @Operation(summary = "获取公海客户分析(按用户)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getPoolSummaryByUser(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getPoolSummaryByUser(reqVO)); - } - - @GetMapping("/get-customer-deal-cycle-by-date") - @Operation(summary = "获取客户成交周期(按日期)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getCustomerDealCycleByDate(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getCustomerDealCycleByDate(reqVO)); - } - - @GetMapping("/get-customer-deal-cycle-by-user") - @Operation(summary = "获取客户成交周期(按用户)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getCustomerDealCycleByUser(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getCustomerDealCycleByUser(reqVO)); - } - - @GetMapping("/get-customer-deal-cycle-by-area") - @Operation(summary = "获取客户成交周期(按用户)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getCustomerDealCycleByArea(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getCustomerDealCycleByArea(reqVO)); - } - - @GetMapping("/get-customer-deal-cycle-by-product") - @Operation(summary = "获取客户成交周期(按用户)") - @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") - public CommonResult> getCustomerDealCycleByProduct(@Valid CrmStatisticsCustomerReqVO reqVO) { - return success(customerService.getCustomerDealCycleByProduct(reqVO)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java deleted file mode 100644 index 17451e768..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.CrmBusinessController; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsFunnelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 销售漏斗") -@RestController -@RequestMapping("/crm/statistics-funnel") -@Validated -public class CrmStatisticsFunnelController { - - @Resource - private CrmStatisticsFunnelService funnelService; - - @GetMapping("/get-funnel-summary") - @Operation(summary = "获取销售漏斗统计数据", description = "用于【销售漏斗】页面的【销售漏斗分析】") - @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") - public CommonResult getFunnelSummary(@Valid CrmStatisticsFunnelReqVO reqVO) { - return success(funnelService.getFunnelSummary(reqVO)); - } - - @GetMapping("/get-business-summary-by-end-status") - @Operation(summary = "获取商机结束状态统计", description = "用于【销售漏斗】页面的【销售漏斗分析】") - @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") - public CommonResult> getBusinessSummaryByEndStatus(@Valid CrmStatisticsFunnelReqVO reqVO) { - return success(funnelService.getBusinessSummaryByEndStatus(reqVO)); - } - - @GetMapping("/get-business-summary-by-date") - @Operation(summary = "获取新增商机分析(按日期)", description = "用于【销售漏斗】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") - public CommonResult> getBusinessSummaryByDate(@Valid CrmStatisticsFunnelReqVO reqVO) { - return success(funnelService.getBusinessSummaryByDate(reqVO)); - } - - @GetMapping("/get-business-inversion-rate-summary-by-date") - @Operation(summary = "获取商机转化率分析(按日期)", description = "用于【销售漏斗】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") - public CommonResult> getBusinessInversionRateSummaryByDate(@Valid CrmStatisticsFunnelReqVO reqVO) { - return success(funnelService.getBusinessInversionRateSummaryByDate(reqVO)); - } - - @GetMapping("/get-business-page-by-date") - @Operation(summary = "获得商机分页(按日期)", description = "用于【销售漏斗】页面的【新增商机分析】") - @PreAuthorize("@ss.hasPermission('crm:business:query')") - public CommonResult> getBusinessPageByDate(@Valid CrmStatisticsFunnelReqVO pageVO) { - PageResult pageResult = funnelService.getBusinessPageByDate(pageVO); - return success(new PageResult<>(buildBusinessDetailList(pageResult.getList()), pageResult.getTotal())); - } - - private List buildBusinessDetailList(List list) { - return SpringUtil.getBean(CrmBusinessController.class).buildBusinessDetailList(list); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsPerformanceController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsPerformanceController.java deleted file mode 100644 index 6f705aa7a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsPerformanceController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO; -import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsPerformanceService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - - -@Tag(name = "管理后台 - CRM 员工业绩统计") -@RestController -@RequestMapping("/crm/statistics-performance") -@Validated -public class CrmStatisticsPerformanceController { - - @Resource - private CrmStatisticsPerformanceService performanceService; - - @GetMapping("/get-contract-count-performance") - @Operation(summary = "合同数量统计", description = "用于【合同数量分析】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-performance:query')") - public CommonResult> getContractCountPerformance(@Valid CrmStatisticsPerformanceReqVO performanceReqVO) { - return success(performanceService.getContractCountPerformance(performanceReqVO)); - } - - @GetMapping("/get-contract-price-performance") - @Operation(summary = "合同金额统计") - @PreAuthorize("@ss.hasPermission('crm:statistics-performance:query')") - public CommonResult> getContractPriceStaffPerformance(@Valid CrmStatisticsPerformanceReqVO performanceReqVO) { - return success(performanceService.getContractPricePerformance(performanceReqVO)); - } - - @GetMapping("/get-receivable-price-performance") - @Operation(summary = "回款金额统计") - @PreAuthorize("@ss.hasPermission('crm:statistics-performance:query')") - public CommonResult> getReceivablePriceStaffPerformance(@Valid CrmStatisticsPerformanceReqVO performanceReqVO) { - return success(performanceService.getReceivablePricePerformance(performanceReqVO)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsPortraitController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsPortraitController.java deleted file mode 100644 index 101b9c0c6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsPortraitController.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait.*; -import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsPortraitService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 客户画像") -@RestController -@RequestMapping("/crm/statistics-portrait") -@Validated -public class CrmStatisticsPortraitController { - - @Resource - private CrmStatisticsPortraitService statisticsPortraitService; - - @GetMapping("/get-customer-area-summary") - @Operation(summary = "获取客户地区统计数据", description = "用于【城市分布分析】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-portrait:query')") - public CommonResult> getCustomerAreaSummary(@Valid CrmStatisticsPortraitReqVO reqVO) { - return success(statisticsPortraitService.getCustomerSummaryByArea(reqVO)); - } - - @GetMapping("/get-customer-industry-summary") - @Operation(summary = "获取客户行业统计数据", description = "用于【客户行业分析】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-portrait:query')") - public CommonResult> getCustomerIndustrySummary(@Valid CrmStatisticsPortraitReqVO reqVO) { - return success(statisticsPortraitService.getCustomerSummaryByIndustry(reqVO)); - } - - @GetMapping("/get-customer-level-summary") - @Operation(summary = "获取客户级别统计数据", description = "用于【客户级别分析】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-portrait:query')") - public CommonResult> getCustomerLevelSummary(@Valid CrmStatisticsPortraitReqVO reqVO) { - return success(statisticsPortraitService.getCustomerSummaryByLevel(reqVO)); - } - - @GetMapping("/get-customer-source-summary") - @Operation(summary = "获取客户来源统计数据", description = "用于【客户来源分析】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-portrait:query')") - public CommonResult> getCustomerSourceSummary(@Valid CrmStatisticsPortraitReqVO reqVO) { - return success(statisticsPortraitService.getCustomerSummaryBySource(reqVO)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsRankController.http b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsRankController.http deleted file mode 100644 index e878ba1a9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsRankController.http +++ /dev/null @@ -1,9 +0,0 @@ -### 合同金额排行榜 -GET {{baseUrl}}/crm/statistics-rank/get-contract-price-rank?deptId=100×[0]=2022-12-12 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 回款金额排行榜 -GET {{baseUrl}}/crm/statistics-rank/get-receivable-price-rank?deptId=100×[0]=2022-12-12 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsRankController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsRankController.java deleted file mode 100644 index 627b5961d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsRankController.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO; -import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsRankService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 排行榜统计") -@RestController -@RequestMapping("/crm/statistics-rank") -@Validated -public class CrmStatisticsRankController { - - @Resource - private CrmStatisticsRankService rankService; - - @GetMapping("/get-contract-price-rank") - @Operation(summary = "获得合同金额排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getContractPriceRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getContractPriceRank(rankingReqVO)); - } - - @GetMapping("/get-receivable-price-rank") - @Operation(summary = "获得回款金额排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getReceivablePriceRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getReceivablePriceRank(rankingReqVO)); - } - - @GetMapping("/get-contract-count-rank") - @Operation(summary = "获得签约合同数量排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getContractCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getContractCountRank(rankingReqVO)); - } - - @GetMapping("/get-product-sales-rank") - @Operation(summary = "获得产品销量排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getProductSalesRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getProductSalesRank(rankingReqVO)); - } - - @GetMapping("/get-customer-count-rank") - @Operation(summary = "获得新增客户数排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getCustomerCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getCustomerCountRank(rankingReqVO)); - } - - @GetMapping("/get-contacts-count-rank") - @Operation(summary = "获得新增联系人数排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getContactsCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getContactsCountRank(rankingReqVO)); - } - - @GetMapping("/get-follow-count-rank") - @Operation(summary = "获得跟进次数排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getFollowCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getFollowCountRank(rankingReqVO)); - } - - @GetMapping("/get-follow-customer-count-rank") - @Operation(summary = "获得跟进客户数排行榜") - @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')") - public CommonResult> getFollowCustomerCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) { - return success(rankService.getFollowCustomerCountRank(rankingReqVO)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerByUserBaseRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerByUserBaseRespVO.java deleted file mode 100644 index bde0029c6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerByUserBaseRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 用户客户统计响应 Base Response VO - * - * 目的:可以统一拼接子 VO 的 ownerUserId、ownerUserName 属性 - */ -@Data -public class CrmStatisticsCustomerByUserBaseRespVO { - - @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long ownerUserId; - - @Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String ownerUserName; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerContractSummaryRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerContractSummaryRespVO.java deleted file mode 100644 index fa03d4609..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerContractSummaryRespVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - CRM 客户转化率分析 VO") -@Data -public class CrmStatisticsCustomerContractSummaryRespVO { - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String customerName; - - @Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "演示合同") - private String contractName; - - @Schema(description = "合同总金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1200.00") - private BigDecimal totalPrice; - - @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1200.00") - private BigDecimal receivablePrice; - - @Schema(description = "客户行业编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer industryId; - - @Schema(description = "客户来源编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer source; - - @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long ownerUserId; - @Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String ownerUserName; - - @Schema(description = "创建人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private String creator; - @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "源码") - private String creatorUserName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-01 13:24:26") - private LocalDateTime createTime; - - @Schema(description = "下单日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02 00:00:00") - private LocalDateTime orderDate; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java deleted file mode 100644 index 369837827..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户成交周期分析(按区域) VO") -@Data -public class CrmStatisticsCustomerDealCycleByAreaRespVO { - - @Schema(description = "省份编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @JsonIgnore - private Integer areaId; - - @Schema(description = "省份名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "浙江省") - private String areaName; - - @Schema(description = "成交周期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0") - private Double customerDealCycle; - - @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerDealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByDateRespVO.java deleted file mode 100644 index 62facb053..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByDateRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户成交周期分析(按日期) VO") -@Data -public class CrmStatisticsCustomerDealCycleByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "成交周期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0") - private Double customerDealCycle; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java deleted file mode 100644 index 442c195aa..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户成交周期分析(按产品) VO") -@Data -public class CrmStatisticsCustomerDealCycleByProductRespVO { - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "演示产品") - private String productName; - - @Schema(description = "成交周期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0") - private Double customerDealCycle; - - @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerDealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByUserRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByUserRespVO.java deleted file mode 100644 index 1c394b8b4..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByUserRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 成交周期分析(按用户) VO") -@Data -public class CrmStatisticsCustomerDealCycleByUserRespVO extends CrmStatisticsCustomerByUserBaseRespVO { - - @Schema(description = "成交周期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0") - private Double customerDealCycle; - - @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerDealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerReqVO.java deleted file mode 100644 index 620a00848..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerReqVO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import cn.iocoder.yudao.framework.common.enums.DateIntervalEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 数据统计的员工客户分析 Request VO") -@Data -public class CrmStatisticsCustomerReqVO { - - @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "部门 id 不能为空") - private Long deptId; - - /** - * 负责人用户 id, 当用户为空, 则计算部门下用户 - */ - @Schema(description = "负责人用户 id", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1") - private Long userId; - - /** - * userIds 目前不用前端传递,目前是方便后端通过 deptId 读取编号后,设置回来 - * 后续,可能会支持选择部分用户进行查询 - */ - @Schema(description = "负责人用户 id 集合", hidden = true, example = "2") - private List userIds; - - @Schema(description = "时间间隔类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = DateIntervalEnum.class, message = "时间间隔类型,必须是 {value}") - private Integer interval; - - @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.NOT_REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Size(min = 2, max = 2, message = "请选择时间范围") - private LocalDateTime[] times; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByDateRespVO.java deleted file mode 100644 index 7ffcb20ff..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByDateRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户总量分析(按日期) VO") -@Data -public class CrmStatisticsCustomerSummaryByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "新建客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerCreateCount; - - @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerDealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByUserRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByUserRespVO.java deleted file mode 100644 index fa8372b8b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByUserRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - CRM 客户总量分析(按用户) VO") -@Data -public class CrmStatisticsCustomerSummaryByUserRespVO extends CrmStatisticsCustomerByUserBaseRespVO { - - @Schema(description = "新建客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerCreateCount; - - @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerDealCount; - - @Schema(description = "合同总金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal contractPrice; - - @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal receivablePrice; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByDateRespVO.java deleted file mode 100644 index 9040c1eab..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByDateRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 跟进次数分析(按日期) VO") -@Data -public class CrmStatisticsFollowUpSummaryByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "跟进次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer followUpRecordCount; - - @Schema(description = "跟进客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer followUpCustomerCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByTypeRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByTypeRespVO.java deleted file mode 100644 index d39f1cc0d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByTypeRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 跟进次数分析(按类型) VO") -@Data -public class CrmStatisticsFollowUpSummaryByTypeRespVO { - - @Schema(description = "跟进类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer followUpType; - - @Schema(description = "跟进次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer followUpRecordCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByUserRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByUserRespVO.java deleted file mode 100644 index 065135626..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsFollowUpSummaryByUserRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 跟进次数分析(按用户) VO") -@Data -public class CrmStatisticsFollowUpSummaryByUserRespVO extends CrmStatisticsCustomerByUserBaseRespVO { - - @Schema(description = "跟进次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer followUpRecordCount; - - @Schema(description = "跟进客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer followUpCustomerCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByDateRespVO.java deleted file mode 100644 index ce09a9933..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByDateRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 公海客户分析(按日期) VO") -@Data -public class CrmStatisticsPoolSummaryByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "进入公海客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerPutCount; - - @Schema(description = "公海领取客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerTakeCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByUserRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByUserRespVO.java deleted file mode 100644 index fb59e8477..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByUserRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 公海客户分析(按用户) VO") -@Data -public class CrmStatisticsPoolSummaryByUserRespVO extends CrmStatisticsCustomerByUserBaseRespVO { - - @Schema(description = "进入公海客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerPutCount; - - @Schema(description = "公海领取客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerTakeCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelSummaryRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelSummaryRespVO.java deleted file mode 100644 index 38d1c118f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelSummaryRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - CRM 销售漏斗 Response VO") -@NoArgsConstructor -@AllArgsConstructor -@Data -public class CrmStatisticFunnelSummaryRespVO { - - @Schema(description = "客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long customerCount; - - @Schema(description = "商机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessCount; - - @Schema(description = "赢单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessWinCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java deleted file mode 100644 index 5e2ff5b2e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 商机转化率分析(按日期) VO") -@Data -public class CrmStatisticsBusinessInversionRateSummaryByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "商机数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessCount; - - @Schema(description = "赢单商机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessWinCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java deleted file mode 100644 index 1f8056c46..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - CRM 新增商机分析(按日期) VO") -@Data -public class CrmStatisticsBusinessSummaryByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "新增商机数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessCreateCount; - - @Schema(description = "新增商机金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private BigDecimal totalPrice; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByEndStatusRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByEndStatusRespVO.java deleted file mode 100644 index 023fdb846..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByEndStatusRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - CRM 商机结束状态统计 Response VO") -@NoArgsConstructor -@AllArgsConstructor -@Data -public class CrmStatisticsBusinessSummaryByEndStatusRespVO { - - @Schema(description = "结束状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer endStatus; - - @Schema(description = "商机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessCount; - - @Schema(description = "商机总金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private BigDecimal totalPrice; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java deleted file mode 100644 index 85ba52e17..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import cn.iocoder.yudao.framework.common.enums.DateIntervalEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 销售漏斗 Request VO") -@Data -public class CrmStatisticsFunnelReqVO extends PageParam { - - @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "部门 id 不能为空") - private Long deptId; - - /** - * 负责人用户 id, 当用户为空, 则计算部门下用户 - */ - @Schema(description = "负责人用户 id", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1") - private Long userId; - - /** - * userIds 目前不用前端传递,目前是方便后端通过 deptId 读取编号后,设置回来 - * 后续,可能会支持选择部分用户进行查询 - */ - @Schema(description = "负责人用户 id 集合", hidden = true, example = "2") - private List userIds; - - @Schema(description = "时间间隔类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = DateIntervalEnum.class, message = "时间间隔类型,必须是 {value}") - private Integer interval; - - @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.NOT_REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Size(min = 2, max = 2, message = "请选择时间范围") - private LocalDateTime[] times; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceReqVO.java deleted file mode 100644 index 58b539914..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceReqVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 员工业绩统计 Request VO") -@Data -public class CrmStatisticsPerformanceReqVO { - - @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "部门 id 不能为空") - private Long deptId; - - /** - * 负责人用户 id, 当用户为空, 则计算部门下用户 - */ - @Schema(description = "负责人用户 id", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1") - private Long userId; - - /** - * userIds 目前不用前端传递,目前是方便后端通过 deptId 读取编号后,设置回来 - *

- * 后续,可能会支持选择部分用户进行查询 - */ - @Schema(description = "负责人用户 id 集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2") - private List userIds; - - // TODO @scholar:应该传递的是 int year;年份 - @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @NotEmpty(message = "时间范围不能为空") - private LocalDateTime[] times; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceRespVO.java deleted file mode 100644 index f2cb9be60..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - - -@Schema(description = "管理后台 - CRM 员工业绩统计 Response VO") -@Data -public class CrmStatisticsPerformanceRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "当月统计结果", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private BigDecimal currentMonthCount; - - @Schema(description = "上月统计结果", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private BigDecimal lastMonthCount; - - @Schema(description = "去年同期统计结果", requiredMode = Schema.RequiredMode.REQUIRED, example = "3") - private BigDecimal lastYearCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerAreaRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerAreaRespVO.java deleted file mode 100644 index 3420e7e5b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerAreaRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户省份分析 VO") -@Data -public class CrmStatisticCustomerAreaRespVO { - - @Schema(description = "省份编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer areaId; - @Schema(description = "省份名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "浙江省") - private String areaName; - - @Schema(description = "客户个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerCount; - - @Schema(description = "成交个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer dealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerIndustryRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerIndustryRespVO.java deleted file mode 100644 index 84b8de70f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerIndustryRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户行业分析 VO") -@Data -public class CrmStatisticCustomerIndustryRespVO { - - @Schema(description = "客户行业ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer industryId; - - @Schema(description = "客户个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerCount; - - @Schema(description = "成交个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer dealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerLevelRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerLevelRespVO.java deleted file mode 100644 index dea4eeb0c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerLevelRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户级别分析 VO") -@Data -public class CrmStatisticCustomerLevelRespVO { - - @Schema(description = "客户级别编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer level; - - @Schema(description = "客户个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerCount; - - @Schema(description = "成交个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer dealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerSourceRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerSourceRespVO.java deleted file mode 100644 index 61b9688ff..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticCustomerSourceRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户来源分析 VO") -@Data -public class CrmStatisticCustomerSourceRespVO { - - @Schema(description = "客户来源编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer source; - - @Schema(description = "客户个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerCount; - - @Schema(description = "成交个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer dealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticsPortraitReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticsPortraitReqVO.java deleted file mode 100644 index eb65cb3c9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/portrait/CrmStatisticsPortraitReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 客户画像 Request VO") -@Data -public class CrmStatisticsPortraitReqVO { - - @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "部门 id 不能为空") - private Long deptId; - - /** - * 负责人用户 id, 当用户为空, 则计算部门下用户 - */ - @Schema(description = "负责人用户 id", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1") - private Long userId; - - /** - * userIds 目前不用前端传递,目前是方便后端通过 deptId 读取编号后,设置回来 - * 后续,可能会支持选择部分用户进行查询 - */ - @Schema(description = "负责人用户 id 集合", hidden = true, example = "2") - private List userIds; - - @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.NOT_REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Size(min = 2, max = 2, message = "请选择时间范围") - private LocalDateTime[] times; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/rank/CrmStatisticsRankReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/rank/CrmStatisticsRankReqVO.java deleted file mode 100644 index c4a16ef55..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/rank/CrmStatisticsRankReqVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 排行榜统计 Request VO") -@Data -public class CrmStatisticsRankReqVO { - - @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "部门 id 不能为空") - private Long deptId; - - /** - * userIds 目前不用前端传递,目前是方便后端通过 deptId 读取编号后,设置回来 - *

- * 后续,可能会支持选择部分用户进行查询 - */ - @Schema(description = "负责人用户 id 集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2") - private List userIds; - - @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @NotEmpty(message = "时间范围不能为空") - private LocalDateTime[] times; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/rank/CrmStatisticsRankRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/rank/CrmStatisticsRankRespVO.java deleted file mode 100644 index feb2f3f2e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/rank/CrmStatisticsRankRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - - -@Schema(description = "管理后台 - CRM 排行榜统计 Response VO") -@Data -public class CrmStatisticsRankRespVO { - - @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long ownerUserId; - - @Schema(description = "姓名", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String nickname; - - @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String deptName; - - /** - * 数量是个特别“抽象”的概念,在不同排行下,代表不同含义 - * - * 1. 金额:合同金额排行、回款金额排行 - * 2. 个数:签约合同排行、产品销量排行、产品销量排行、新增客户数排行、新增联系人排行、跟进次数排行、跟进客户数排行 - * - * 为什么使用 BigDecimal 的原因: - */ - @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private BigDecimal count; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/app/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/app/package-info.java deleted file mode 100644 index 78d85635c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/app/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.crm.controller.app; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java deleted file mode 100644 index 8354b3176..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.crm.controller; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/package-info.java deleted file mode 100644 index 6fbc52508..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 POJO 类的实体转换 - * - * 目前使用 MapStruct 框架 - */ -package cn.iocoder.yudao.module.crm.convert; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md deleted file mode 100644 index 8153487b7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java deleted file mode 100644 index a30ece21f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.business; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * CRM 商机 DO - * - * @author ljlleo - */ -@TableName("crm_business") -@KeySequence("crm_business_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmBusinessDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 商机名称 - */ - private String name; - /** - * 客户编号 - * - * 关联 {@link CrmCustomerDO#getId()} - */ - private Long customerId; - - /** - * 跟进状态 - */ - private Boolean followUpStatus; - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - /** - * 下次联系时间 - */ - private LocalDateTime contactNextTime; - - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - - /** - * 商机状态组编号 - * - * 关联 {@link CrmBusinessStatusTypeDO#getId()} - */ - private Long statusTypeId; - /** - * 商机状态编号 - * - * 关联 {@link CrmBusinessStatusDO#getId()} - */ - private Long statusId; - /** - * 结束状态 - * - * 枚举 {@link CrmBusinessEndStatusEnum} - */ - private Integer endStatus; - /** - * 结束时的备注 - */ - private String endRemark; - - /** - * 预计成交日期 - */ - private LocalDateTime dealTime; - /** - * 产品总金额,单位:元 - * - * productPrice = ∑({@link CrmBusinessProductDO#getTotalPrice()}) - */ - private BigDecimal totalProductPrice; - /** - * 整单折扣,百分比 - */ - private BigDecimal discountPercent; - /** - * 商机总金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessProductDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessProductDO.java deleted file mode 100644 index 2f66fc34d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessProductDO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.business; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * CRM 商机产品关联表 DO - * - * CrmBusinessDO : CrmBusinessProductDO = 1 : N - * - * @author lzxhqs - */ -@TableName("crm_business_product") -@KeySequence("crm_business_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmBusinessProductDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 商机编号 - * - * 关联 {@link CrmBusinessDO#getId()} - */ - private Long businessId; - /** - * 产品编号 - * - * 关联 {@link CrmProductDO#getId()} - */ - private Long productId; - /** - * 产品单价,单位:元 - * - * 冗余 {@link CrmProductDO#getPrice()} - */ - private BigDecimal productPrice; - /** - * 商机价格, 单位:元 - */ - private BigDecimal businessPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总计价格,单位:元 - * - * totalPrice = businessPrice * count - */ - private BigDecimal totalPrice; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java deleted file mode 100644 index 5d7b8bd13..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.business; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * CRM 商机状态 DO - * - * 注意,它是个配置表 - * - * @author ljlleo - */ -@TableName("crm_business_status") -@KeySequence("crm_business_status_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmBusinessStatusDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 状态类型编号 - * - * 关联 {@link CrmBusinessStatusTypeDO#getId()} - */ - private Long typeId; - /** - * 状态名 - */ - private String name; - /** - * 赢单率,百分比 - */ - private Integer percent; - /** - * 排序 - */ - private Integer sort; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java deleted file mode 100644 index 95b7a1f26..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.business; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.util.List; - -/** - * CRM 商机状态组 DO - * - * 注意,它是个配置表 - * - * @author ljlleo - */ -@TableName(value = "crm_business_status_type", autoResultMap = true) -@KeySequence("crm_business_status_type_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmBusinessStatusTypeDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 状态类型名 - */ - private String name; - - /** - * 使用的部门编号 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List deptIds; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java deleted file mode 100644 index 3af6feec4..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java +++ /dev/null @@ -1,128 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.clue; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * CRM 线索 DO - * - * @author Wanwan - */ -@TableName("crm_clue") -@KeySequence("crm_clue_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmClueDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - /** - * 线索名称 - */ - private String name; - - /** - * 跟进状态 - */ - private Boolean followUpStatus; - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - /** - * 最后跟进内容 - */ - private String contactLastContent; - /** - * 下次联系时间 - */ - private LocalDateTime contactNextTime; - - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - - /** - * 转化状态 - * - * true 表示已转换,会更新 {@link #customerId} 字段 - */ - private Boolean transformStatus; - /** - * 客户编号 - * - * 关联 {@link CrmCustomerDO#getId()} - */ - private Long customerId; - - /** - * 手机号 - */ - private String mobile; - /** - * 电话 - */ - private String telephone; - /** - * QQ - */ - private String qq; - /** - * wechat - */ - private String wechat; - /** - * email - */ - private String email; - /** - * 所在地 - * - * 关联 {@link cn.iocoder.yudao.framework.ip.core.Area#getId()} 字段 - */ - private Integer areaId; - /** - * 详细地址 - */ - private String detailAddress; - /** - * 所属行业 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_INDUSTRY} - */ - private Integer industryId; - /** - * 客户等级 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_LEVEL} - */ - private Integer level; - /** - * 客户来源 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_SOURCE} - */ - private Integer source; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/package-info.java deleted file mode 100644 index 929b9b6fe..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 线索 - */ -package cn.iocoder.yudao.module.crm.dal.dataobject.clue; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactBusinessDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactBusinessDO.java deleted file mode 100644 index 46185a5ac..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactBusinessDO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.contact; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * CRM 联系人与商机的关联 DO - * - * @author 芋道源码 - */ -@TableName("crm_contact_business") -@KeySequence("crm_contact_business_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmContactBusinessDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 联系人编号 - * - * 关联 {@link CrmContactDO#getId()} 字段 - */ - private Long contactId; - /** - * 商机编号 - * - * 关联 {@link CrmBusinessDO#getId()} 字段 - */ - private Long businessId; - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactDO.java deleted file mode 100644 index 5a891eb9c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/CrmContactDO.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.contact; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * CRM 联系人 DO - * - * @author 芋道源码 - */ -@TableName("crm_contact") -@KeySequence("crm_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmContactDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 联系人姓名 - */ - private String name; - /** - * 客户编号 - * - * 关联 {@link CrmCustomerDO#getId()} - */ - private Long customerId; - - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - /** - * 最后跟进内容 - */ - private String contactLastContent; - /** - * 下次联系时间 - */ - private LocalDateTime contactNextTime; - - /** - * 负责人用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - - /** - * 手机号 - */ - private String mobile; - /** - * 电话 - */ - private String telephone; - /** - * 电子邮箱 - */ - private String email; - /** - * QQ - */ - private Long qq; - /** - * 微信 - */ - private String wechat; - /** - * 所在地 - * - * 关联 {@link cn.iocoder.yudao.framework.ip.core.Area#getId()} 字段 - */ - private Integer areaId; - /** - * 详细地址 - */ - private String detailAddress; - /** - * 性别 - * - * 枚举 {@link cn.iocoder.yudao.module.system.enums.common.SexEnum} - */ - private Integer sex; - /** - * 是否关键决策人 - */ - private Boolean master; - /** - * 职位 - */ - private String post; - /** - * 直属上级 - * - * 关联 {@link CrmContactDO#id} - */ - private Long parentId; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/package-info.java deleted file mode 100644 index dfe0898e3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 联系人 - */ -package cn.iocoder.yudao.module.crm.dal.dataobject.contact; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractConfigDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractConfigDO.java deleted file mode 100644 index ab0c2d28e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractConfigDO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.contract; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.*; -import lombok.*; - -@TableName("crm_contract_config") -@KeySequence("crm_contract_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmContractConfigDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 是否开启提前提醒 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Boolean notifyEnabled; - /** - * 提前提醒天数 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Integer notifyDays; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractDO.java deleted file mode 100644 index 89f4fd98a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractDO.java +++ /dev/null @@ -1,123 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.contract; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * CRM 合同 DO - * - * @author dhb52 - */ -@TableName("crm_contract") -@KeySequence("crm_contract_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmContractDO extends BaseDO { - - /** - * 合同编号 - */ - @TableId - private Long id; - /** - * 合同名称 - */ - private String name; - /** - * 合同编号 - */ - private String no; - /** - * 客户编号 - * - * 关联 {@link CrmCustomerDO#getId()} - */ - private Long customerId; - /** - * 商机编号,非必须 - * - * 关联 {@link CrmBusinessDO#getId()} - */ - private Long businessId; - - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - - /** - * 工作流编号 - * - * 关联 ProcessInstance 的 id 属性 - */ - private String processInstanceId; - /** - * 审批状态 - * - * 枚举 {@link CrmAuditStatusEnum} - */ - private Integer auditStatus; - - /** - * 下单日期 - */ - private LocalDateTime orderDate; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 产品总金额,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 整单折扣 - */ - private BigDecimal discountPercent; - /** - * 合同总金额,单位:分 - */ - private BigDecimal totalPrice; - /** - * 客户签约人,非必须 - * - * 关联 {@link CrmContactDO#getId()} - */ - private Long signContactId; - /** - * 公司签约人,非必须 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long signUserId; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractProductDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractProductDO.java deleted file mode 100644 index 6bb3e6bf0..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractProductDO.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.contract; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * CRM 合同产品关联表 DO - * - * @author HUIHUI - */ -@TableName("crm_contract_product") -@KeySequence("crm_contract_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmContractProductDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 合同编号 - * - * 关联 {@link CrmContractDO#getId()} - */ - private Long contractId; - /** - * 产品编号 - * - * 关联 {@link CrmProductDO#getId()} - */ - private Long productId; - /** - * 产品单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 合同价格, 单位:元 - */ - private BigDecimal contractPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总计价格,单位:元 - * - * totalPrice = businessPrice * count - */ - private BigDecimal totalPrice; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java deleted file mode 100644 index 76d511115..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.customer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * CRM 客户 DO - * - * @author Wanwan - */ -@TableName(value = "crm_customer") -@KeySequence("crm_customer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmCustomerDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 客户名称 - */ - private String name; - - /** - * 跟进状态 - */ - private Boolean followUpStatus; - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - /** - * 最后跟进内容 - */ - private String contactLastContent; - /** - * 下次联系时间 - */ - private LocalDateTime contactNextTime; - - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - /** - * 成为负责人的时间 - */ - private LocalDateTime ownerTime; - - /** - * 锁定状态 - */ - private Boolean lockStatus; - /** - * 成交状态 - */ - private Boolean dealStatus; - - /** - * 手机 - */ - private String mobile; - /** - * 电话 - */ - private String telephone; - /** - * QQ - */ - private String qq; - /** - * wechat - */ - private String wechat; - /** - * email - */ - private String email; - /** - * 所在地 - * - * 关联 {@link cn.iocoder.yudao.framework.ip.core.Area#getId()} 字段 - */ - private Integer areaId; - /** - * 详细地址 - */ - private String detailAddress; - /** - * 所属行业 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_INDUSTRY} - */ - private Integer industryId; - /** - * 客户等级 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_LEVEL} - */ - private Integer level; - /** - * 客户来源 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_SOURCE} - */ - private Integer source; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerLimitConfigDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerLimitConfigDO.java deleted file mode 100644 index df3d3be6f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerLimitConfigDO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.customer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.util.List; - -/** - * 客户限制配置 DO - * - * @author Wanwan - */ -@TableName(value = "crm_customer_limit_config", autoResultMap = true) -@KeySequence("crm_customer_limit_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmCustomerLimitConfigDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 规则类型 - *

- * 枚举 {@link CrmCustomerLimitConfigTypeEnum} - */ - private Integer type; - /** - * 规则适用人群 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List userIds; - /** - * 规则适用部门 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List deptIds; - /** - * 数量上限 - */ - private Integer maxCount; - /** - * 成交客户是否占有拥有客户数 - * - * 当且仅当 {@link #type} 为 1 时,进行使用 - */ - private Boolean dealCountEnabled; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerPoolConfigDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerPoolConfigDO.java deleted file mode 100644 index 76f20dc3b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerPoolConfigDO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.customer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.*; -import lombok.*; - -/** - * 客户公海配置 DO - * - * @author Wanwan - */ -@TableName(value = "crm_customer_pool_config") -@KeySequence("crm_customer_pool_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmCustomerPoolConfigDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 是否启用客户公海 - */ - private Boolean enabled; - /** - * 未跟进放入公海天数 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Integer contactExpireDays; - /** - * 未成交放入公海天数 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Integer dealExpireDays; - /** - * 是否开启提前提醒 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Boolean notifyEnabled; - /** - * 提前提醒天数 - */ - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private Integer notifyDays; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java deleted file mode 100644 index a01d47af9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.followup; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.framework.mybatis.core.type.StringListTypeHandler; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 跟进记录 DO - * - * 用于记录客户、联系人的每一次跟进 - * - * @author 芋道源码 - */ -@TableName(value = "crm_follow_up_record", autoResultMap = true) -@KeySequence("crm_follow_up_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmFollowUpRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 数据类型 - * - * 枚举 {@link CrmBizTypeEnum} - */ - private Integer bizType; - /** - * 数据编号 - * - * 关联 {@link CrmBizTypeEnum} 对应模块 DO 的 id 字段 - */ - private Long bizId; - - /** - * 跟进类型 - * - * 关联 {@link DictTypeConstants#CRM_FOLLOW_UP_TYPE} 字典 - */ - private Integer type; - /** - * 跟进内容 - */ - private String content; - /** - * 下次联系时间 - */ - private LocalDateTime nextTime; - - /** - * 图片 - */ - @TableField(typeHandler = StringListTypeHandler.class) - private List picUrls; - /** - * 附件 - */ - @TableField(typeHandler = StringListTypeHandler.class) - private List fileUrls; - - /** - * 关联的商机编号数组 - * - * 关联 {@link CrmBusinessDO#getId()} - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List businessIds; - /** - * 关联的联系人编号数组 - * - * 关联 {@link CrmContactDO#getId()} - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List contactIds; - - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java deleted file mode 100644 index 59e47a5a8..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.permission; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * CRM 数据权限 DO - * - * @author HUIHUI - */ -@TableName("crm_permission") -@KeySequence("crm_permission_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmPermissionDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 数据类型 - * - * 枚举 {@link CrmBizTypeEnum} - */ - private Integer bizType; - /** - * 数据编号 - * - * 关联 {@link CrmBizTypeEnum} 对应模块 DO 的 id 字段 - */ - private Long bizId; - - /** - * 用户编号 - * - * 关联 AdminUser 的 id 字段 - */ - private Long userId; - - /** - * 权限级别 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - private Integer level; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductCategoryDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductCategoryDO.java deleted file mode 100644 index e0f4d6245..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductCategoryDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 产品分类 DO - * - * @author ZanGe丶 - */ -@TableName("crm_product_category") -@KeySequence("crm_product_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmProductCategoryDO extends BaseDO { - - /** - * 父分类编号 - 根分类 - */ - public static final Long PARENT_ID_NULL = 0L; - /** - * 限定分类层级 - */ - public static final int CATEGORY_LEVEL = 2; - - /** - * 分类编号 - */ - @TableId - private Long id; - /** - * 分类名称 - */ - private String name; - /** - * 父级编号 - * - * 关联 {@link CrmProductCategoryDO#getId()} - */ - private Long parentId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductDO.java deleted file mode 100644 index caeeb53d2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/CrmProductDO.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import cn.iocoder.yudao.module.crm.enums.product.CrmProductStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * CRM 产品 DO - * - * @author ZanGe丶 - */ -@TableName("crm_product") -@KeySequence("crm_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmProductDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 产品名称 - */ - private String name; - /** - * 产品编码 - */ - private String no; - /** - * 单位 - * - * 字典 {@link DictTypeConstants#CRM_PRODUCT_UNIT} - */ - private Integer unit; - /** - * 价格,单位:元 - */ - private BigDecimal price; - /** - * 状态 - * - * 关联 {@link CrmProductStatusEnum} - */ - private Integer status; - /** - * 产品分类 ID - * - * 关联 {@link CrmProductCategoryDO#getId()} 字段 - */ - private Long categoryId; - /** - * 产品描述 - */ - private String description; - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/package-info.java deleted file mode 100644 index 4c7282d73..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 产品表 - */ -package cn.iocoder.yudao.module.crm.dal.dataobject.product; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java deleted file mode 100644 index 269cac6cc..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.receivable.CrmReceivableReturnTypeEnum; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * 回款 DO - * - * @author 赤焰 - */ -@TableName("crm_receivable") -@KeySequence("crm_receivable_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmReceivableDO extends BaseDO { - - /** - * ID - */ - @TableId - private Long id; - /** - * 回款编号 - */ - private String no; - /** - * 回款计划编号 - * - * 关联 {@link CrmReceivablePlanDO#getId()},非必须 - */ - private Long planId; - /** - * 客户编号 - * - * 关联 {@link CrmCustomerDO#getId()} - */ - private Long customerId; - /** - * 合同编号 - * - * 关联 {@link CrmContractDO#getId()} - */ - private Long contractId; - /** - * 负责人编号,关联 {@link AdminUserRespDTO#getId()} - */ - private Long ownerUserId; - - /** - * 回款日期 - */ - private LocalDateTime returnTime; - /** - * 回款方式,关联枚举{@link CrmReceivableReturnTypeEnum} - */ - private Integer returnType; - /** - * 计划回款金额,单位:元 - */ - private BigDecimal price; - /** - * 备注 - */ - private String remark; - - /** - * 工作流编号 - * - * 关联 ProcessInstance 的 id 属性 - */ - private String processInstanceId; - /** - * 审批状态 - * - * 枚举 {@link CrmAuditStatusEnum} - */ - private Integer auditStatus; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java deleted file mode 100644 index 5ddefc559..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.receivable.CrmReceivableReturnTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * CRM 回款计划 DO - * - * @author 芋道源码 - */ -@TableName("crm_receivable_plan") -@KeySequence("crm_receivable_plan_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CrmReceivablePlanDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 期数 - */ - private Integer period; - /** - * 客户编号 - * - * 关联 {@link CrmCustomerDO#getId()} - */ - private Long customerId; - /** - * 合同编号 - * - * 关联 {@link CrmContractDO#getId()} - */ - private Long contractId; - - /** - * 负责人编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - - /** - * 计划回款日期 - */ - private LocalDateTime returnTime; - /** - * 计划回款类型 - * - * 枚举 {@link CrmReceivableReturnTypeEnum} - */ - private Integer returnType; - /** - * 计划回款金额,单位:元 - */ - private BigDecimal price; - - /** - * 回款编号,关联 {@link CrmReceivableDO#getId()} - */ - private Long receivableId; - - /** - * 提前几天提醒 - */ - private Integer remindDays; - /** - * 提醒日期 - */ - private LocalDateTime remindTime; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java deleted file mode 100644 index ba347bcf6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.business; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 商机 Mapper - * - * @author ljlleo - */ -@Mapper -public interface CrmBusinessMapper extends BaseMapperX { - - default int updateOwnerUserIdById(Long id, Long ownerUserId) { - return update(new LambdaUpdateWrapper() - .eq(CrmBusinessDO::getId, id) - .set(CrmBusinessDO::getOwnerUserId, ownerUserId)); - } - - default PageResult selectPageByCustomerId(CrmBusinessPageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eq(CrmBusinessDO::getCustomerId, pageReqVO.getCustomerId()) // 指定客户编号 - .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) - .orderByDesc(CrmBusinessDO::getId)); - } - - default PageResult selectPageByContactId(CrmBusinessPageReqVO pageReqVO, Collection businessIds) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .in(CrmBusinessDO::getId, businessIds) // 指定商机编号 - .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) - .orderByDesc(CrmBusinessDO::getId)); - } - - default PageResult selectPage(CrmBusinessPageReqVO pageReqVO, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_BUSINESS.getType(), - CrmBusinessDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE); - // 拼接自身的查询条件 - query.selectAll(CrmBusinessDO.class) - .likeIfPresent(CrmBusinessDO::getName, pageReqVO.getName()) - .orderByDesc(CrmBusinessDO::getId); - return selectJoinPage(pageReqVO, CrmBusinessDO.class, query); - } - - default Long selectCountByStatusTypeId(Long statusTypeId) { - return selectCount(CrmBusinessDO::getStatusTypeId, statusTypeId); - } - - default List selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmBusinessDO::getCustomerId, customerId) - .eq(CrmBusinessDO::getOwnerUserId, ownerUserId)); - } - - default PageResult selectPage(CrmStatisticsFunnelReqVO pageVO) { - return selectPage(pageVO, new LambdaQueryWrapperX() - .in(CrmBusinessDO::getOwnerUserId, pageVO.getUserIds()) - .betweenIfPresent(CrmBusinessDO::getCreateTime, pageVO.getTimes())); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java deleted file mode 100644 index a91a0fd14..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.business; - - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 商机产品 Mapper - * - * @author lzxhqs - */ -@Mapper -public interface CrmBusinessProductMapper extends BaseMapperX { - - default List selectListByBusinessId(Long businessId) { - return selectList(CrmBusinessProductDO::getBusinessId, businessId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java deleted file mode 100644 index dfe7afcc3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.business; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 商机状态 Mapper - * - * @author ljlleo - */ -@Mapper -public interface CrmBusinessStatusMapper extends BaseMapperX { - - default int deleteByTypeId(Long typeId) { - return delete(CrmBusinessStatusDO::getTypeId, typeId); - } - - default List selectListByTypeId(Long typeId) { - return selectList(CrmBusinessStatusDO::getTypeId, typeId); - } - - default CrmBusinessStatusDO selectByTypeIdAndId(Long statusTypeId, Long statusId) { - return selectOne(CrmBusinessStatusDO::getTypeId, statusTypeId, - CrmBusinessStatusDO::getId, statusId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java deleted file mode 100644 index 3444e58a7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusTypeMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.business; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 商机状态组 Mapper - * - * @author ljlleo - */ -@Mapper -public interface CrmBusinessStatusTypeMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .orderByDesc(CrmBusinessStatusTypeDO::getId)); - } - - default CrmBusinessStatusTypeDO selectByName(String name) { - return selectOne(CrmBusinessStatusTypeDO::getName, name); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java deleted file mode 100644 index d0665c604..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.clue; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 线索 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmClueMapper extends BaseMapperX { - - default PageResult selectPage(CrmCluePageReqVO pageReqVO, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CLUE.getType(), - CrmClueDO::getId, userId, pageReqVO.getSceneType(), pageReqVO.getPool()); - // 拼接自身的查询条件 - query.selectAll(CrmClueDO.class) - .likeIfPresent(CrmClueDO::getName, pageReqVO.getName()) - .eqIfPresent(CrmClueDO::getTransformStatus, pageReqVO.getTransformStatus()) - .likeIfPresent(CrmClueDO::getTelephone, pageReqVO.getTelephone()) - .likeIfPresent(CrmClueDO::getMobile, pageReqVO.getMobile()) - .eqIfPresent(CrmClueDO::getIndustryId, pageReqVO.getIndustryId()) - .eqIfPresent(CrmClueDO::getLevel, pageReqVO.getLevel()) - .eqIfPresent(CrmClueDO::getSource, pageReqVO.getSource()) - .eqIfPresent(CrmClueDO::getFollowUpStatus, pageReqVO.getFollowUpStatus()) - .orderByDesc(CrmClueDO::getId); - return selectJoinPage(pageReqVO, CrmClueDO.class, query); - } - - default List selectBatchIds(Collection ids, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CLUE.getType(), ids, userId); - query.selectAll(CrmClueDO.class).in(CrmClueDO::getId, ids).orderByDesc(CrmClueDO::getId); - // 拼接自身的查询条件 - return selectJoinList(CrmClueDO.class, query); - } - - default Long selectCountByFollow(Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CLUE.getType(), - CrmClueDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 未跟进 + 未转化 - query.eq(CrmClueDO::getFollowUpStatus, false) - .eq(CrmClueDO::getTransformStatus, false); - return selectCount(query); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/package-info.java deleted file mode 100644 index f9978e868..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 线索 - */ -package cn.iocoder.yudao.module.crm.dal.mysql.clue; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactBusinessMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactBusinessMapper.java deleted file mode 100644 index 7bff0c204..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactBusinessMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contact; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * CRM 联系人商机关联 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CrmContactBusinessMapper extends BaseMapperX { - - default CrmContactBusinessDO selectByContactIdAndBusinessId(Long contactId, Long businessId) { - return selectOne(CrmContactBusinessDO::getContactId, contactId, - CrmContactBusinessDO::getBusinessId, businessId); - } - - default void deleteByContactIdAndBusinessId(Long contactId, Collection businessIds) { - delete(new LambdaQueryWrapper() - .eq(CrmContactBusinessDO::getContactId, contactId) - .in(CrmContactBusinessDO::getBusinessId, businessIds)); - } - - default void deleteByBusinessIdAndContactId(Long businessId, List contactIds) { - delete(new LambdaQueryWrapper() - .eq(CrmContactBusinessDO::getBusinessId, businessId) - .in(CrmContactBusinessDO::getContactId, contactIds)); - } - - default List selectListByContactId(Long contactId) { - return selectList(CrmContactBusinessDO::getContactId, contactId); - } - - default List selectListByBusinessId(Long businessId) { - return selectList(CrmContactBusinessDO::getBusinessId, businessId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java deleted file mode 100644 index 75f2a750e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contact; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * CRM 联系人 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CrmContactMapper extends BaseMapperX { - - default int updateOwnerUserIdByCustomerId(Long customerId, Long ownerUserId) { - return update(new LambdaUpdateWrapper() - .eq(CrmContactDO::getCustomerId, customerId) - .set(CrmContactDO::getOwnerUserId, ownerUserId)); - } - - default PageResult selectPageByCustomerId(CrmContactPageReqVO pageVO) { - return selectPage(pageVO, new LambdaQueryWrapperX() - .eq(CrmContactDO::getCustomerId, pageVO.getCustomerId()) // 指定客户编号 - .likeIfPresent(CrmContactDO::getName, pageVO.getName()) - .eqIfPresent(CrmContactDO::getMobile, pageVO.getMobile()) - .eqIfPresent(CrmContactDO::getTelephone, pageVO.getTelephone()) - .eqIfPresent(CrmContactDO::getEmail, pageVO.getEmail()) - .eqIfPresent(CrmContactDO::getQq, pageVO.getQq()) - .eqIfPresent(CrmContactDO::getWechat, pageVO.getWechat()) - .orderByDesc(CrmContactDO::getId)); - } - - default PageResult selectPageByBusinessId(CrmContactPageReqVO pageVO, Collection ids) { - return selectPage(pageVO, new LambdaQueryWrapperX() - .in(CrmContactDO::getId, ids) // 指定联系人编号 - .likeIfPresent(CrmContactDO::getName, pageVO.getName()) - .eqIfPresent(CrmContactDO::getMobile, pageVO.getMobile()) - .eqIfPresent(CrmContactDO::getTelephone, pageVO.getTelephone()) - .eqIfPresent(CrmContactDO::getEmail, pageVO.getEmail()) - .eqIfPresent(CrmContactDO::getQq, pageVO.getQq()) - .eqIfPresent(CrmContactDO::getWechat, pageVO.getWechat()) - .orderByDesc(CrmContactDO::getId)); - } - - default PageResult selectPage(CrmContactPageReqVO pageReqVO, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTACT.getType(), - CrmContactDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE); - // 拼接自身的查询条件 - query.selectAll(CrmContactDO.class) - .likeIfPresent(CrmContactDO::getName, pageReqVO.getName()) - .eqIfPresent(CrmContactDO::getMobile, pageReqVO.getMobile()) - .eqIfPresent(CrmContactDO::getTelephone, pageReqVO.getTelephone()) - .eqIfPresent(CrmContactDO::getEmail, pageReqVO.getEmail()) - .eqIfPresent(CrmContactDO::getQq, pageReqVO.getQq()) - .eqIfPresent(CrmContactDO::getWechat, pageReqVO.getWechat()) - .orderByDesc(CrmContactDO::getId); - return selectJoinPage(pageReqVO, CrmContactDO.class, query); - } - - default List selectListByCustomerId(Long customerId) { - return selectList(CrmContactDO::getCustomerId, customerId); - } - - default List selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { - return selectList(CrmContactDO::getCustomerId, customerId, - CrmContactDO::getOwnerUserId, ownerUserId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractConfigMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractConfigMapper.java deleted file mode 100644 index 64e6f918b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractConfigMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contract; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 合同配置 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmContractConfigMapper extends BaseMapperX { - - default CrmContractConfigDO selectOne() { - return selectOne(new QueryWrapperX().limitN(1)); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java deleted file mode 100644 index 14d743291..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contract; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * CRM 合同 Mapper - * - * @author dhb52 - */ -@Mapper -public interface CrmContractMapper extends BaseMapperX { - - default CrmContractDO selectByNo(String no) { - return selectOne(CrmContractDO::getNo, no); - } - - default PageResult selectPageByCustomerId(CrmContractPageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eq(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) - .likeIfPresent(CrmContractDO::getNo, pageReqVO.getNo()) - .likeIfPresent(CrmContractDO::getName, pageReqVO.getName()) - .eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) - .eqIfPresent(CrmContractDO::getBusinessId, pageReqVO.getBusinessId()) - .orderByDesc(CrmContractDO::getId)); - } - - default PageResult selectPageByBusinessId(CrmContractPageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eq(CrmContractDO::getBusinessId, pageReqVO.getBusinessId()) - .likeIfPresent(CrmContractDO::getNo, pageReqVO.getNo()) - .likeIfPresent(CrmContractDO::getName, pageReqVO.getName()) - .eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) - .eqIfPresent(CrmContractDO::getBusinessId, pageReqVO.getBusinessId()) - .orderByDesc(CrmContractDO::getId)); - } - - default PageResult selectPage(CrmContractPageReqVO pageReqVO, Long userId, CrmContractConfigDO config) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(), - CrmContractDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE); - // 拼接自身的查询条件 - query.selectAll(CrmContractDO.class) - .likeIfPresent(CrmContractDO::getNo, pageReqVO.getNo()) - .likeIfPresent(CrmContractDO::getName, pageReqVO.getName()) - .eqIfPresent(CrmContractDO::getCustomerId, pageReqVO.getCustomerId()) - .eqIfPresent(CrmContractDO::getBusinessId, pageReqVO.getBusinessId()) - .eqIfPresent(CrmContractDO::getAuditStatus, pageReqVO.getAuditStatus()) - .orderByDesc(CrmContractDO::getId); - - // Backlog: 即将到期的合同 - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now()); - if (CrmContractPageReqVO.EXPIRY_TYPE_ABOUT_TO_EXPIRE.equals(pageReqVO.getExpiryType())) { // 即将到期 - query.eq(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.APPROVE.getStatus()) - .between(CrmContractDO::getEndTime, beginOfToday, endOfToday.plusDays(config.getNotifyDays())); - } else if (CrmContractPageReqVO.EXPIRY_TYPE_EXPIRED.equals(pageReqVO.getExpiryType())) { // 已到期 - query.eq(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.APPROVE.getStatus()) - .lt(CrmContractDO::getEndTime, endOfToday); - } - return selectJoinPage(pageReqVO, CrmContractDO.class, query); - } - - default List selectBatchIds(Collection ids, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 构建数据权限连表条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(), ids, userId); - // 拼接自身的查询条件 - query.selectAll(CrmContractDO.class).in(CrmContractDO::getId, ids).orderByDesc(CrmContractDO::getId); - return selectJoinList(CrmContractDO.class, query); - } - - default Long selectCountByContactId(Long contactId) { - return selectCount(CrmContractDO::getSignContactId, contactId); - } - - default Long selectCountByBusinessId(Long businessId) { - return selectCount(CrmContractDO::getBusinessId, businessId); - } - - default Long selectCountByAudit(Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(), - CrmContractDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 未审核 - query.eq(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.PROCESS.getStatus()); - return selectCount(query); - } - - default Long selectCountByRemind(Long userId, CrmContractConfigDO config) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(), - CrmContractDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 即将到期 - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now()); - query.eq(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.APPROVE.getStatus()) // 必须审批通过! - .between(CrmContractDO::getEndTime, beginOfToday, endOfToday.plusDays(config.getNotifyDays())); - return selectCount(query); - } - - default List selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmContractDO::getCustomerId, customerId) - .eq(CrmContractDO::getOwnerUserId, ownerUserId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractProductMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractProductMapper.java deleted file mode 100644 index feafbc444..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractProductMapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contract; - - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 合同产品 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CrmContractProductMapper extends BaseMapperX { - - default List selectListByContractId(Long contractId) { - return selectList(new LambdaQueryWrapperX().eq(CrmContractProductDO::getContractId, contractId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerLimitConfigMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerLimitConfigMapper.java deleted file mode 100644 index 08beaf808..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerLimitConfigMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 客户限制配置 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmCustomerLimitConfigMapper extends BaseMapperX { - - default PageResult selectPage(CrmCustomerLimitConfigPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CrmCustomerLimitConfigDO::getType, reqVO.getType()) - .orderByDesc(CrmCustomerLimitConfigDO::getId)); - } - - default List selectListByTypeAndUserIdAndDeptId( - Integer type, Long userId, Long deptId) { - LambdaQueryWrapperX query = new LambdaQueryWrapperX() - .eq(CrmCustomerLimitConfigDO::getType, type); - query.apply("FIND_IN_SET({0}, user_ids) > 0", userId); - if (deptId != null) { - query.apply("FIND_IN_SET({0}, dept_ids) > 0", deptId); - } - return selectList(query); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java deleted file mode 100644 index 503445388..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java +++ /dev/null @@ -1,189 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.customer; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.CrmCustomerPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.springframework.lang.Nullable; -import org.springframework.util.Assert; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 客户 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmCustomerMapper extends BaseMapperX { - - default Long selectCountByLockStatusAndOwnerUserId(Boolean lockStatus, Long ownerUserId) { - return selectCount(new LambdaUpdateWrapper() - .eq(CrmCustomerDO::getLockStatus, lockStatus) - .eq(CrmCustomerDO::getOwnerUserId, ownerUserId)); - } - - default Long selectCountByDealStatusAndOwnerUserId(@Nullable Boolean dealStatus, Long ownerUserId) { - return selectCount(new LambdaQueryWrapperX() - .eqIfPresent(CrmCustomerDO::getDealStatus, dealStatus) - .eq(CrmCustomerDO::getOwnerUserId, ownerUserId)); - } - - default int updateOwnerUserIdById(Long id, Long ownerUserId) { - return update(new LambdaUpdateWrapper() - .eq(CrmCustomerDO::getId, id) - .set(CrmCustomerDO::getOwnerUserId, ownerUserId)); - } - - default PageResult selectPage(CrmCustomerPageReqVO pageReqVO, Long ownerUserId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), - CrmCustomerDO::getId, ownerUserId, pageReqVO.getSceneType(), pageReqVO.getPool()); - // 拼接自身的查询条件 - query.selectAll(CrmCustomerDO.class) - .likeIfPresent(CrmCustomerDO::getName, pageReqVO.getName()) - .eqIfPresent(CrmCustomerDO::getMobile, pageReqVO.getMobile()) - .eqIfPresent(CrmCustomerDO::getIndustryId, pageReqVO.getIndustryId()) - .eqIfPresent(CrmCustomerDO::getLevel, pageReqVO.getLevel()) - .eqIfPresent(CrmCustomerDO::getSource, pageReqVO.getSource()) - .eqIfPresent(CrmCustomerDO::getFollowUpStatus, pageReqVO.getFollowUpStatus()); - - // backlog 查询 - if (ObjUtil.isNotNull(pageReqVO.getContactStatus())) { - Assert.isNull(pageReqVO.getPool(), "pool 必须是 null"); - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now()); - if (pageReqVO.getContactStatus().equals(CrmCustomerPageReqVO.CONTACT_TODAY)) { // 今天需联系 - query.between(CrmCustomerDO::getContactNextTime, beginOfToday, endOfToday); - } else if (pageReqVO.getContactStatus().equals(CrmCustomerPageReqVO.CONTACT_EXPIRED)) { // 已逾期 - query.lt(CrmCustomerDO::getContactNextTime, beginOfToday); - } else if (pageReqVO.getContactStatus().equals(CrmCustomerPageReqVO.CONTACT_ALREADY)) { // 已联系 - query.between(CrmCustomerDO::getContactLastTime, beginOfToday, endOfToday); - } else { - throw new IllegalArgumentException("未知联系状态:" + pageReqVO.getContactStatus()); - } - } - return selectJoinPage(pageReqVO, CrmCustomerDO.class, query); - } - - default List selectBatchIds(Collection ids, Long ownerUserId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, ownerUserId); - // 拼接自身的查询条件 - query.selectAll(CrmCustomerDO.class).in(CrmCustomerDO::getId, ids).orderByDesc(CrmCustomerDO::getId); - return selectJoinList(CrmCustomerDO.class, query); - } - - default CrmCustomerDO selectByCustomerName(String name) { - return selectOne(CrmCustomerDO::getName, name); - } - - default PageResult selectPutPoolRemindCustomerPage(CrmCustomerPageReqVO pageReqVO, - CrmCustomerPoolConfigDO poolConfig, - Long ownerUserId) { - final MPJLambdaWrapperX query = buildPutPoolRemindCustomerQuery(pageReqVO, poolConfig, ownerUserId); - return selectJoinPage(pageReqVO, CrmCustomerDO.class, query.selectAll(CrmCustomerDO.class)); - } - - default Long selectPutPoolRemindCustomerCount(CrmCustomerPageReqVO pageReqVO, - CrmCustomerPoolConfigDO poolConfigDO, - Long userId) { - final MPJLambdaWrapperX query = buildPutPoolRemindCustomerQuery(pageReqVO, poolConfigDO, userId); - return selectCount(query); - } - - static MPJLambdaWrapperX buildPutPoolRemindCustomerQuery(CrmCustomerPageReqVO pageReqVO, - CrmCustomerPoolConfigDO poolConfig, - Long ownerUserId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), - CrmCustomerDO::getId, ownerUserId, pageReqVO.getSceneType(), null); - - // 未锁定 + 未成交 - query.eq(CrmCustomerDO::getLockStatus, false).eq(CrmCustomerDO::getDealStatus, false); - - // 情况一:未成交提醒日期区间 - Integer dealExpireDays = poolConfig.getDealExpireDays(); - LocalDateTime startDealRemindTime = LocalDateTime.now().minusDays(dealExpireDays); - LocalDateTime endDealRemindTime = LocalDateTime.now() - .minusDays(Math.max(dealExpireDays - poolConfig.getNotifyDays(), 0)); - // 情况二:未跟进提醒日期区间 - Integer contactExpireDays = poolConfig.getContactExpireDays(); - LocalDateTime startContactRemindTime = LocalDateTime.now().minusDays(contactExpireDays); - LocalDateTime endContactRemindTime = LocalDateTime.now() - .minusDays(Math.max(contactExpireDays - poolConfig.getNotifyDays(), 0)); - query.and(q -> { - // 情况一:成交超时提醒 - q.between(CrmCustomerDO::getOwnerTime, startDealRemindTime, endDealRemindTime) - // 情况二:跟进超时提醒 - .or(w -> w.between(CrmCustomerDO::getOwnerTime, startContactRemindTime, endContactRemindTime) - .and(p -> p.between(CrmCustomerDO::getContactLastTime, startContactRemindTime, endContactRemindTime) - .or().isNull(CrmCustomerDO::getContactLastTime))); - }); - return query; - } - - /** - * 获得需要过期到公海的客户列表 - * - * @return 客户列表 - */ - default List selectListByAutoPool(CrmCustomerPoolConfigDO poolConfig) { - LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.gt(CrmCustomerDO::getOwnerUserId, 0); - // 未锁定 + 未成交 - query.eq(CrmCustomerDO::getLockStatus, false).eq(CrmCustomerDO::getDealStatus, false); - // 已经超时 - LocalDateTime dealExpireTime = LocalDateTime.now().minusDays(poolConfig.getDealExpireDays()); - LocalDateTime contactExpireTime = LocalDateTime.now().minusDays(poolConfig.getContactExpireDays()); - query.and(q -> { - // 情况一:成交超时 - q.lt(CrmCustomerDO::getOwnerTime, dealExpireTime) - // 情况二:跟进超时 - .or(w -> w.lt(CrmCustomerDO::getOwnerTime, contactExpireTime) - .and(p -> p.lt(CrmCustomerDO::getContactLastTime, contactExpireTime) - .or().isNull(CrmCustomerDO::getContactLastTime))); - }); - return selectList(query); - } - - default Long selectCountByTodayContact(Long ownerUserId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), - CrmCustomerDO::getId, ownerUserId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 今天需联系 - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now()); - query.between(CrmCustomerDO::getContactNextTime, beginOfToday, endOfToday); - return selectCount(query); - } - - default Long selectCountByFollow(Long ownerUserId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), - CrmCustomerDO::getId, ownerUserId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 未跟进 - query.eq(CrmClueDO::getFollowUpStatus, false); - return selectCount(query); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerPoolConfigMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerPoolConfigMapper.java deleted file mode 100644 index 06cf44e4f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerPoolConfigMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.customer; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 客户公海配置 Mapper - * - * @author Wanwan - */ -@Mapper -public interface CrmCustomerPoolConfigMapper extends BaseMapperX { - - default CrmCustomerPoolConfigDO selectOne() { - return selectOne(new LambdaQueryWrapperX().last("LIMIT 1")); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java deleted file mode 100644 index 45e2b412e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.followup; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 跟进记录 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CrmFollowUpRecordMapper extends BaseMapperX { - - default PageResult selectPage(CrmFollowUpRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CrmFollowUpRecordDO::getBizType, reqVO.getBizType()) - .eqIfPresent(CrmFollowUpRecordDO::getBizId, reqVO.getBizId()) - .orderByDesc(CrmFollowUpRecordDO::getId)); - } - - default void deleteByBiz(Integer bizType, Long bizId) { - delete(new LambdaQueryWrapperX() - .eq(CrmFollowUpRecordDO::getBizType, bizType) - .eq(CrmFollowUpRecordDO::getBizId, bizId)); - } - - default List selectListByBiz(Integer bizType, Collection bizIds) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmFollowUpRecordDO::getBizType, bizType) - .in(CrmFollowUpRecordDO::getBizId, bizIds)); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java deleted file mode 100644 index 07b7b6b1f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.permission; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * crm 数据权限 mapper - * - * @author HUIHUI - */ -@Mapper -public interface CrmPermissionMapper extends BaseMapperX { - - default CrmPermissionDO selectByBizTypeAndBizIdByUserId(Integer bizType, Long bizId, Long userId) { - return selectOne(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId) - .eq(CrmPermissionDO::getUserId, userId)); - } - - default List selectByBizTypeAndBizId(Integer bizType, Long bizId) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId)); - } - - default List selectByBizTypeAndBizIds(Integer bizType, Collection bizIds) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .in(CrmPermissionDO::getBizId, bizIds)); - } - - default List selectListByBizTypeAndUserId(Integer bizType, Long userId) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getUserId, userId)); - } - - default List selectListByBizTypeAndBizIdAndLevel(Integer bizType, Long bizId, Integer level) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId) - .eq(CrmPermissionDO::getLevel, level)); - } - - default CrmPermissionDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(CrmPermissionDO::getId, id, - CrmPermissionDO::getUserId, userId); - } - - default CrmPermissionDO selectByBizAndUserId(Integer bizType, Long bizId, Long userId) { - return selectOne(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId) - .eq(CrmPermissionDO::getUserId, userId)); - } - - default int deletePermission(Integer bizType, Long bizId) { - return delete(new LambdaQueryWrapperX() - .eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId)); - } - - default Long selectListByBiz(Collection bizTypes, Collection bizIds, Collection userIds) { - return selectCount(new LambdaQueryWrapperX() - .in(CrmPermissionDO::getBizType, bizTypes) - .in(CrmPermissionDO::getBizId, bizIds) - .in(CrmPermissionDO::getUserId, userIds)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/package-info.java deleted file mode 100644 index ff0e16b90..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.permission; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductCategoryMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductCategoryMapper.java deleted file mode 100644 index 3cced7356..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductCategoryMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.product; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * CRM 产品分类 Mapper - * - * @author ZanGe丶 - */ -@Mapper -public interface CrmProductCategoryMapper extends BaseMapperX { - - default List selectList(CrmProductCategoryListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(CrmProductCategoryDO::getName, reqVO.getName()) - .eqIfPresent(CrmProductCategoryDO::getParentId, reqVO.getParentId()) - .orderByDesc(CrmProductCategoryDO::getId)); - } - - default CrmProductCategoryDO selectByParentIdAndName(Long parentId, String name) { - return selectOne(CrmProductCategoryDO::getParentId, parentId, CrmProductCategoryDO::getName, name); - } - - default Long selectCountByParentId(Long parentId) { - return selectCount(CrmProductCategoryDO::getParentId, parentId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductMapper.java deleted file mode 100644 index 4d1d61809..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * CRM 产品 Mapper - * - * @author ZanGe丶 - */ -@Mapper -public interface CrmProductMapper extends BaseMapperX { - - default PageResult selectPage(CrmProductPageReqVO reqVO) { - return selectPage(reqVO, new MPJLambdaWrapperX() - .likeIfPresent(CrmProductDO::getName, reqVO.getName()) - .eqIfPresent(CrmProductDO::getStatus, reqVO.getStatus()) - .orderByDesc(CrmProductDO::getId)); - } - - default CrmProductDO selectByNo(String no) { - return selectOne(CrmProductDO::getNo, no); - } - - default Long selectCountByCategoryId(Long categoryId) { - return selectCount(CrmProductDO::getCategoryId, categoryId); - } - - default List selectListByStatus(Integer status) { - return selectList(CrmProductDO::getStatus, status); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java deleted file mode 100644 index 0c821c8c2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 回款 Mapper - * - * @author 赤焰 - */ -@Mapper -public interface CrmReceivableMapper extends BaseMapperX { - - default CrmReceivableDO selectByNo(String no) { - return selectOne(CrmReceivableDO::getNo, no); - } - - default PageResult selectPageByCustomerId(CrmReceivablePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 - .eqIfPresent(CrmReceivableDO::getNo, reqVO.getNo()) - .eqIfPresent(CrmReceivableDO::getContractId, reqVO.getContractId()) - .eqIfPresent(CrmReceivableDO::getPlanId, reqVO.getPlanId()) - .orderByDesc(CrmReceivableDO::getId)); - } - - default PageResult selectPage(CrmReceivablePageReqVO pageReqVO, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), - CrmReceivableDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE); - // 拼接自身的查询条件 - query.selectAll(CrmReceivableDO.class) - .eqIfPresent(CrmReceivableDO::getNo, pageReqVO.getNo()) - .eqIfPresent(CrmReceivableDO::getPlanId, pageReqVO.getPlanId()) - .eqIfPresent(CrmReceivableDO::getContractId, pageReqVO.getContractId()) - .eqIfPresent(CrmReceivableDO::getAuditStatus, pageReqVO.getAuditStatus()) - .orderByDesc(CrmReceivableDO::getId); - return selectJoinPage(pageReqVO, CrmReceivableDO.class, query); - } - - default List selectBatchIds(Collection ids, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), ids, userId); - // 拼接自身的查询条件 - query.selectAll(CrmReceivableDO.class).in(CrmReceivableDO::getId, ids).orderByDesc(CrmReceivableDO::getId); - return selectJoinList(CrmReceivableDO.class, query); - } - - default Long selectCountByAudit(Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), - CrmReceivableDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 未审核 - query.eq(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.PROCESS.getStatus()); - return selectCount(query); - } - - default List selectListByContractIdAndStatus(Long contractId, Collection auditStatuses) { - return selectList(new LambdaQueryWrapperX() - .eq(CrmReceivableDO::getContractId, contractId) - .in(CrmReceivableDO::getAuditStatus, auditStatuses)); - } - - default Map selectReceivablePriceMapByContractId(Collection contractIds) { - if (CollUtil.isEmpty(contractIds)) { - return Collections.emptyMap(); - } - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("contract_id, SUM(price) AS total_price") - .in("audit_status", CrmAuditStatusEnum.DRAFT.getStatus(), // 草稿 + 审批中 + 审批通过 - CrmAuditStatusEnum.PROCESS, CrmAuditStatusEnum.APPROVE.getStatus()) - .groupBy("contract_id") - .in("contract_id", contractIds)); - // 获得金额 - return convertMap(result, obj -> (Long) obj.get("contract_id"), obj -> (BigDecimal) obj.get("total_price")); - } - - default Long selectCountByContractId(Long contractId) { - return selectCount(CrmReceivableDO::getContractId, contractId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java deleted file mode 100644 index 4d5389793..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.receivable; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -/** - * 回款计划 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CrmReceivablePlanMapper extends BaseMapperX { - - default CrmReceivablePlanDO selectMaxPeriodByContractId(Long contractId) { - return selectOne(new MPJLambdaWrapperX() - .eq(CrmReceivablePlanDO::getContractId, contractId) - .orderByDesc(CrmReceivablePlanDO::getPeriod) - .last("LIMIT 1")); - } - - default PageResult selectPageByCustomerId(CrmReceivablePlanPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - if (Objects.nonNull(reqVO.getContractNo())) { // 根据合同编号检索 - query.innerJoin(CrmContractDO.class, on -> on.like(CrmContractDO::getNo, reqVO.getContractNo()) - .eq(CrmContractDO::getId, CrmReceivablePlanDO::getContractId)); - } - query.eq(CrmReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 - .eqIfPresent(CrmReceivablePlanDO::getContractId, reqVO.getContractId()) - .orderByDesc(CrmReceivablePlanDO::getPeriod); - return selectJoinPage(reqVO, CrmReceivablePlanDO.class, query); - } - - default PageResult selectPage(CrmReceivablePlanPageReqVO pageReqVO, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), - CrmReceivablePlanDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE); - // 拼接自身的查询条件 - query.selectAll(CrmReceivablePlanDO.class) - .eqIfPresent(CrmReceivablePlanDO::getCustomerId, pageReqVO.getCustomerId()) - .eqIfPresent(CrmReceivablePlanDO::getContractId, pageReqVO.getContractId()) - .orderByDesc(CrmReceivablePlanDO::getPeriod); - if (Objects.nonNull(pageReqVO.getContractNo())) { // 根据合同编号检索 - query.innerJoin(CrmContractDO.class, on -> on.like(CrmContractDO::getNo, pageReqVO.getContractNo()) - .eq(CrmContractDO::getId, CrmReceivablePlanDO::getContractId)); - } - - // Backlog: 回款提醒类型 - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - if (CrmReceivablePlanPageReqVO.REMIND_TYPE_NEEDED.equals(pageReqVO.getRemindType())) { // 待回款 - query.isNull(CrmReceivablePlanDO::getReceivableId) // 未回款 - .lt(CrmReceivablePlanDO::getReturnTime, beginOfToday) // 已逾期 - .lt(CrmReceivablePlanDO::getRemindTime, beginOfToday); // 今天开始提醒 - } else if (CrmReceivablePlanPageReqVO.REMIND_TYPE_EXPIRED.equals(pageReqVO.getRemindType())) { // 已逾期 - query.isNull(CrmReceivablePlanDO::getReceivableId) // 未回款 - .ge(CrmReceivablePlanDO::getReturnTime, beginOfToday); // 已逾期 - } else if (CrmReceivablePlanPageReqVO.REMIND_TYPE_RECEIVED.equals(pageReqVO.getRemindType())) { // 已回款 - query.isNotNull(CrmReceivablePlanDO::getReceivableId); - } - return selectJoinPage(pageReqVO, CrmReceivablePlanDO.class, query); - } - - default List selectBatchIds(Collection ids, Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 拼接数据权限的查询条件 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), ids, userId); - // 拼接自身的查询条件 - query.selectAll(CrmReceivablePlanDO.class).in(CrmReceivablePlanDO::getId, ids).orderByDesc(CrmReceivablePlanDO::getId); - return selectJoinList(CrmReceivablePlanDO.class, query); - } - - default Long selectReceivablePlanCountByRemind(Long userId) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX<>(); - // 我负责的 + 非公海 - CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), - CrmReceivablePlanDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); - // 未回款 + 已逾期 + 今天开始提醒 - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - query.isNull(CrmReceivablePlanDO::getReceivableId) // 未回款 - .lt(CrmReceivablePlanDO::getReturnTime, beginOfToday) // 已逾期 - .lt(CrmReceivablePlanDO::getRemindTime, beginOfToday); // 今天开始提醒 - return selectCount(query); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java deleted file mode 100644 index ca9a08252..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java +++ /dev/null @@ -1,211 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.statistics; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -/** - * CRM 客户分析 Mapper - * - * @author dhb52 - */ -@Mapper -public interface CrmStatisticsCustomerMapper { - - /** - * 新建客户数(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerCreateCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 成交客户数(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerDealCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 新建客户数(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerCreateCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 成交客户数(按用户) - * - * @param reqVO 请求参数@param reqVO 请求参数@param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerDealCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 合同总金额(按用户) - * - * @return 统计数据@return 统计数据@param reqVO 请求参数 - * @return 统计数据 - */ - List selectContractPriceGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 合同回款金额(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectReceivablePriceGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进次数(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectFollowUpRecordCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进客户数(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectFollowUpCustomerCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进次数(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectFollowUpRecordCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进客户数(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectFollowUpCustomerCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - - /** - * 首次合同、回款信息(用于【客户转化率】页面) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectContractSummary(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进次数(按类型) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectFollowUpRecordCountGroupByType(CrmStatisticsCustomerReqVO reqVO); - - - /** - * 进入公海客户数(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 - default List selectPoolCustomerPutCountByDate(CrmStatisticsCustomerReqVO reqVO) { - LocalDateTime currrentDate = LocalDateTimeUtil.beginOfDay(reqVO.getTimes()[0]); - LocalDateTime endDate = LocalDateTimeUtil.endOfDay(reqVO.getTimes()[1]); - List voList = new ArrayList<>(); - while (currrentDate.isBefore(endDate)) { - voList.add(new CrmStatisticsPoolSummaryByDateRespVO() - .setTime(LocalDateTimeUtil.format(currrentDate, "yyyy-MM-dd")) - .setCustomerPutCount(RandomUtil.randomInt(0, 10)) - .setCustomerTakeCount(RandomUtil.randomInt(0, 10))); - currrentDate = currrentDate.plusDays(1); - } - - return voList; - } - - /** - * 公海领取客户数(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 - default List selectPoolCustomerTakeCountByDate(CrmStatisticsCustomerReqVO reqVO) { - return selectPoolCustomerPutCountByDate(reqVO); - } - - /** - * 进入公海客户数(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 - default List selectPoolCustomerPutCountByUser(CrmStatisticsCustomerReqVO reqVO) { - return convertList(reqVO.getUserIds(), userId -> - (CrmStatisticsPoolSummaryByUserRespVO) new CrmStatisticsPoolSummaryByUserRespVO() - .setCustomerPutCount(RandomUtil.randomInt(0, 10)) - .setCustomerTakeCount(RandomUtil.randomInt(0, 10)) - .setOwnerUserId(userId)); - } - - /** - * 公海领取客户数(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 - default List selectPoolCustomerTakeCountByUser(CrmStatisticsCustomerReqVO reqVO) { - return selectPoolCustomerPutCountByUser(reqVO); - } - - /** - * 客户成交周期(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerDealCycleGroupByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerDealCycleGroupByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按区域) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerDealCycleGroupByAreaId(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按产品) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List selectCustomerDealCycleGroupByProductId(CrmStatisticsCustomerReqVO reqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java deleted file mode 100644 index d69fa6290..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessInversionRateSummaryByDateRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByDateRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByEndStatusRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * CRM 销售漏斗 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CrmStatisticsFunnelMapper { - - Long selectCustomerCountByDate(CrmStatisticsFunnelReqVO reqVO); - - Long selectBusinessCountByDateAndEndStatus(@Param("reqVO") CrmStatisticsFunnelReqVO reqVO, @Param("status") Integer status); - - List selectBusinessSummaryListGroupByEndStatus(CrmStatisticsFunnelReqVO reqVO); - - List selectBusinessSummaryGroupByDate(CrmStatisticsFunnelReqVO reqVO); - - List selectBusinessInversionRateSummaryByDate(CrmStatisticsFunnelReqVO reqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsPerformanceMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsPerformanceMapper.java deleted file mode 100644 index 6467a098d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsPerformanceMapper.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * CRM 员工业绩分析 Mapper - * - * @author scholar - */ -@Mapper -public interface CrmStatisticsPerformanceMapper { - - /** - * 员工签约合同数量 - * - * @param performanceReqVO 参数 - * @return 员工签约合同数量 - */ - List selectContractCountPerformance(CrmStatisticsPerformanceReqVO performanceReqVO); - - /** - * 员工签约合同金额 - * - * @param performanceReqVO 参数 - * @return 员工签约合同金额 - */ - List selectContractPricePerformance(CrmStatisticsPerformanceReqVO performanceReqVO); - - /** - * 员工回款金额 - * - * @param performanceReqVO 参数 - * @return 员工回款金额 - */ - List selectReceivablePricePerformance(CrmStatisticsPerformanceReqVO performanceReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsPortraitMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsPortraitMapper.java deleted file mode 100644 index a7c942752..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsPortraitMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait.*; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * CRM 数据画像 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CrmStatisticsPortraitMapper { - - List selectSummaryListGroupByAreaId(CrmStatisticsPortraitReqVO reqVO); - - List selectCustomerIndustryListGroupByIndustryId(CrmStatisticsPortraitReqVO reqVO); - - List selectCustomerSourceListGroupBySource(CrmStatisticsPortraitReqVO reqVO); - - List selectCustomerLevelListGroupByLevel(CrmStatisticsPortraitReqVO reqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsRankMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsRankMapper.java deleted file mode 100644 index 55062f57a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsRankMapper.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * CRM 排行榜统计 Mapper - * - * @author anhaohao - */ -@Mapper -public interface CrmStatisticsRankMapper { - - /** - * 查询合同金额排行榜 - * - * @param rankReqVO 参数 - * @return 合同金额排行榜 - */ - List selectContractPriceRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询回款金额排行榜 - * - * @param rankReqVO 参数 - * @return 回款金额排行榜 - */ - List selectReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询签约合同数量排行榜 - * - * @param rankReqVO 参数 - * @return 签约合同数量排行榜 - */ - List selectContractCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询产品销量排行榜 - * - * @param rankReqVO 参数 - * @return 产品销量排行榜 - */ - List selectProductSalesRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询新增客户数排行榜 - * - * @param rankReqVO 参数 - * @return 新增客户数排行榜 - */ - List selectCustomerCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询联系人数量排行榜 - * - * @param rankReqVO 参数 - * @return 联系人数量排行榜 - */ - List selectContactsCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询跟进次数排行榜 - * - * @param rankReqVO 参数 - * @return 跟进次数排行榜 - */ - List selectFollowCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 查询跟进客户数排行榜 - * - * @param rankReqVO 参数 - * @return 跟进客户数排行榜 - */ - List selectFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/redis/RedisKeyConstants.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/redis/RedisKeyConstants.java deleted file mode 100644 index 2932c1db1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/redis/RedisKeyConstants.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.redis; - -/** - * CRM Redis Key 枚举类 - * - * @author 芋道源码 - */ -public interface RedisKeyConstants { - - /** - * 序号的缓存 - * - * KEY 格式:trade_no:{prefix} - * VALUE 数据格式:编号自增 - */ - String NO = "crm:seq_no:"; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/redis/no/CrmNoRedisDAO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/redis/no/CrmNoRedisDAO.java deleted file mode 100644 index 68f0835ec..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/redis/no/CrmNoRedisDAO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.redis.no; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.module.crm.dal.redis.RedisKeyConstants; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Repository; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; - - -/** - * Crm 订单序号的 Redis DAO - * - * @author HUIHUI - */ -@Repository -public class CrmNoRedisDAO { - - /** - * 合同 {@link cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO} - */ - public static final String CONTRACT_NO_PREFIX = "HT"; - - /** - * 回款 {@link cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO} - */ - public static final String RECEIVABLE_PREFIX = "HK"; - - @Resource - private StringRedisTemplate stringRedisTemplate; - - /** - * 生成序号,使用当前日期,格式为 {PREFIX} + yyyyMMdd + 6 位自增 - * 例如说:QTRK 202109 000001 (没有中间空格) - * - * @param prefix 前缀 - * @return 序号 - */ - public String generate(String prefix) { - // 递增序号 - String noPrefix = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATE_PATTERN); - String key = RedisKeyConstants.NO + noPrefix; - Long no = stringRedisTemplate.opsForValue().increment(key); - // 设置过期时间 - stringRedisTemplate.expire(key, Duration.ofDays(1L)); - return noPrefix + String.format("%06d", no); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/core/AreaExcelColumnSelectFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/core/AreaExcelColumnSelectFunction.java deleted file mode 100644 index 8f0a88905..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/core/AreaExcelColumnSelectFunction.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.excel.core; - -import cn.iocoder.yudao.framework.excel.core.function.ExcelColumnSelectFunction; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * 地区下拉框数据源的 {@link ExcelColumnSelectFunction} 实现类 - * - * @author HUIHUI - */ -@Service -public class AreaExcelColumnSelectFunction implements ExcelColumnSelectFunction { - - public static final String NAME = "getCrmAreaNameList"; // 防止和别的模块重名 - - @Override - public String getName() { - return NAME; - } - - @Override - public List getOptions() { - // 获取地区下拉数据 - // TODO @puhui999:嘿嘿,这里改成省份、城市、区域,三个选项,难度大么? - Area area = AreaUtils.getArea(Area.ID_CHINA); - return AreaUtils.getAreaNodePathList(area.getChildren()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/package-info.java deleted file mode 100644 index c2deef8b8..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * crm 模块的 excel 拓展封装 - */ -package cn.iocoder.yudao.module.crm.framework.excel; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmBusinessParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmBusinessParseFunction.java deleted file mode 100644 index 0c8baa334..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmBusinessParseFunction.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import com.mzt.logapi.service.IParseFunction; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * CRM 商机的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmBusinessParseFunction implements IParseFunction { - - public static final String NAME = "getBusinessById"; - - @Resource - private CrmBusinessService businessService; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - CrmBusinessDO businessDO = businessService.getBusiness(Long.parseLong(value.toString())); - return businessDO == null ? "" : businessDO.getName(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmContactParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmContactParseFunction.java deleted file mode 100644 index 4d4705acc..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmContactParseFunction.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import com.mzt.logapi.service.IParseFunction; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * CRM 联系人的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmContactParseFunction implements IParseFunction { - - public static final String NAME = "getContactById"; - - @Resource - private CrmContactService contactService; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - CrmContactDO contactDO = contactService.getContact(Long.parseLong(value.toString())); - return contactDO == null ? "" : contactDO.getName(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmContractParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmContractParseFunction.java deleted file mode 100644 index 07e2b6ec4..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmContractParseFunction.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import com.mzt.logapi.service.IParseFunction; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * CRM 合同的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmContractParseFunction implements IParseFunction { - - public static final String NAME = "getContractById"; - - @Resource - private CrmContractService contractService; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - CrmContractDO contract = contractService.getContract(Long.parseLong(value.toString())); - return contract == null ? "" : contract.getName(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerIndustryParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerIndustryParseFunction.java deleted file mode 100644 index dd0b1c781..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerIndustryParseFunction.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; - -/** - * 行业的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmCustomerIndustryParseFunction implements IParseFunction { - - public static final String NAME = "getCustomerIndustry"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(CRM_CUSTOMER_INDUSTRY, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerLevelParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerLevelParseFunction.java deleted file mode 100644 index eedd1d945..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerLevelParseFunction.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL; - -/** - * 客户等级的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmCustomerLevelParseFunction implements IParseFunction { - - public static final String NAME = "getCustomerLevel"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(CRM_CUSTOMER_LEVEL, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerParseFunction.java deleted file mode 100644 index ba81ccc0f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerParseFunction.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import com.mzt.logapi.service.IParseFunction; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * CRM 客户的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmCustomerParseFunction implements IParseFunction { - - public static final String NAME = "getCustomerById"; - - @Resource - private CrmCustomerService customerService; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - CrmCustomerDO crmCustomerDO = customerService.getCustomer(Long.parseLong(value.toString())); - return crmCustomerDO == null ? "" : crmCustomerDO.getName(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerSourceParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerSourceParseFunction.java deleted file mode 100644 index d1a023331..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmCustomerSourceParseFunction.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE; - -/** - * CRM 客户来源的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmCustomerSourceParseFunction implements IParseFunction { - - public static final String NAME = "getCustomerSource"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(CRM_CUSTOMER_SOURCE, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductStatusParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductStatusParseFunction.java deleted file mode 100644 index 446de1043..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductStatusParseFunction.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 产品状态的 {@link IParseFunction} 实现类 - * - * @author anhaohao - */ -@Component -@Slf4j -public class CrmProductStatusParseFunction implements IParseFunction { - - public static final String NAME = "getProductStatusName"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.CRM_PRODUCT_STATUS, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductUnitParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductUnitParseFunction.java deleted file mode 100644 index cec152e6d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductUnitParseFunction.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 产品单位的 {@link IParseFunction} 实现类 - * - * @author anhaohao - */ -@Component -@Slf4j -public class CrmProductUnitParseFunction implements IParseFunction { - - public static final String NAME = "getProductUnitName"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.CRM_PRODUCT_UNIT, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmReceivablePlanParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmReceivablePlanParseFunction.java deleted file mode 100644 index e9943eb67..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmReceivablePlanParseFunction.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivablePlanService; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * CRM 回款计划的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class CrmReceivablePlanParseFunction implements IParseFunction { - - public static final String NAME = "getReceivablePlanServiceById"; - - @Resource - private CrmReceivablePlanService receivablePlanService; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(Long.parseLong(value.toString())); - return receivablePlan == null ? "" : receivablePlan.getPeriod().toString(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmReceivableReturnTypeParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmReceivableReturnTypeParseFunction.java deleted file mode 100644 index 3da7fe42f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmReceivableReturnTypeParseFunction.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_RECEIVABLE_RETURN_TYPE; - -/** - * CRM 回款方式的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Slf4j -@Component -public class CrmReceivableReturnTypeParseFunction implements IParseFunction { - - public static final String NAME = "getReceivableReturnType"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(CRM_RECEIVABLE_RETURN_TYPE, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAdminUserParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAdminUserParseFunction.java deleted file mode 100644 index ff2e77bfa..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAdminUserParseFunction.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 管理员名字的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Slf4j -@Component -public class SysAdminUserParseFunction implements IParseFunction { - - public static final String NAME = "getAdminUserById"; - - @Resource - private AdminUserApi adminUserApi; - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - - // 获取用户信息 - AdminUserRespDTO user = adminUserApi.getUser(Long.parseLong(value.toString())).getCheckedData(); - if (user == null) { - log.warn("[apply][获取用户{{}}为空", value); - return ""; - } - // 返回格式 芋道源码(13888888888) - String nickname = user.getNickname(); - if (StrUtil.isEmpty(user.getMobile())) { - return nickname; - } - return StrUtil.format("{}({})", nickname, user.getMobile()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAreaParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAreaParseFunction.java deleted file mode 100644 index 3ccc76912..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAreaParseFunction.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 地名的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Slf4j -@Component -public class SysAreaParseFunction implements IParseFunction { - - public static final String NAME = "getArea"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return AreaUtils.format(Integer.parseInt(value.toString())); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysBooleanParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysBooleanParseFunction.java deleted file mode 100644 index 0e722a6f3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysBooleanParseFunction.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 是否类型的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class SysBooleanParseFunction implements IParseFunction { - - public static final String NAME = "getBoolean"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BOOLEAN_STRING, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysDeptParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysDeptParseFunction.java deleted file mode 100644 index efd672a7d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysDeptParseFunction.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import com.mzt.logapi.service.IParseFunction; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 管理员名字的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Slf4j -@Component -public class SysDeptParseFunction implements IParseFunction { - - public static final String NAME = "getDeptById"; - - @Resource - private DeptApi deptApi; - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - - // 获取部门信息 - DeptRespDTO dept = deptApi.getDept(Long.parseLong(value.toString())).getCheckedData(); - if (dept == null) { - log.warn("[apply][获取部门{{}}为空", value); - return ""; - } - return dept.getName(); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysSexParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysSexParseFunction.java deleted file mode 100644 index c8a9a9991..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysSexParseFunction.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.operatelog.core; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.mzt.logapi.service.IParseFunction; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * 行业的 {@link IParseFunction} 实现类 - * - * @author HUIHUI - */ -@Component -@Slf4j -public class SysSexParseFunction implements IParseFunction { - - public static final String NAME = "getSex"; - - @Override - public boolean executeBefore() { - return true; // 先转换值后对比 - } - - @Override - public String functionName() { - return NAME; - } - - @Override - public String apply(Object value) { - if (StrUtil.isEmptyIfStr(value)) { - return ""; - } - return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.USER_SEX, value.toString()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/package-info.java deleted file mode 100644 index 413b652c1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * crm 模块的 operatelog 拓展封装 - */ -package cn.iocoder.yudao.module.crm.framework.operatelog; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/package-info.java deleted file mode 100644 index 281e36c45..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 crm 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.crm.framework; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/annotations/CrmPermission.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/annotations/CrmPermission.java deleted file mode 100644 index 9ef6d4d02..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/annotations/CrmPermission.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.permission.core.annotations; - -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.METHOD; - -/** - * CRM 数据操作权限校验 AOP 注解 - * - * @author HUIHUI - */ -@Target({METHOD, ANNOTATION_TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface CrmPermission { - - /** - * CRM 类型 - */ - CrmBizTypeEnum[] bizType() default {}; - - /** - * CRM 类型扩展,通过 Spring EL 表达式获取到 {@link #bizType()} - * - * 目的:用于 CrmPermissionController 团队权限校验 - */ - String bizTypeValue() default ""; - - /** - * 数据编号,通过 Spring EL 表达式获取 - */ - String bizId(); - - /** - * 操作所需权限级别 - */ - CrmPermissionLevelEnum level(); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java deleted file mode 100644 index 35d99b414..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java +++ /dev/null @@ -1,130 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.permission.core.aop; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.spring.SpringExpressionUtils; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSION_DENIED; - -/** - * Crm 数据权限校验 AOP 切面 - * - * @author HUIHUI - */ -@Component -@Aspect -@Slf4j -public class CrmPermissionAspect { - - @Resource - private CrmPermissionService crmPermissionService; - - @Before("@annotation(crmPermission)") - public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) { - // 1.1 获取相关属性值 - Map expressionValues = parseExpressions(joinPoint, crmPermission); - Integer bizType = StrUtil.isEmpty(crmPermission.bizTypeValue()) ? - crmPermission.bizType()[0].getType() : (Integer) expressionValues.get(crmPermission.bizTypeValue()); // 模块类型 - // 1.2 处理兼容多个 bizId 的情况 - Object object = expressionValues.get(crmPermission.bizId()); // 模块数据编号 - Set bizIds = new HashSet<>(); - if (object instanceof Collection) { - bizIds.addAll(convertSet((Collection) object, item -> Long.parseLong(item.toString()))); - } else { - bizIds.add(Long.parseLong(object.toString())); - } - Integer permissionLevel = crmPermission.level().getLevel(); // 需要的权限级别 - - // 2. 逐个校验权限 - List permissionList = crmPermissionService.getPermissionListByBiz(bizType, bizIds); - Map> multiMap = convertMultiMap(permissionList, CrmPermissionDO::getBizId); - bizIds.forEach(bizId -> validatePermission(bizType, multiMap.get(bizId), permissionLevel)); - } - - private void validatePermission(Integer bizType, List bizPermissions, Integer permissionLevel) { - // 1. 如果是超级管理员则直接通过 - if (CrmPermissionUtils.isCrmAdmin()) { - return; - } - // 1.1 没有数据权限的情况 - if (CollUtil.isEmpty(bizPermissions)) { - // 公海数据如果没有团队成员大家也因该有读权限才对 - if (CrmPermissionLevelEnum.isRead(permissionLevel)) { - return; - } - // 没有数据权限的情况下超出了读权限直接报错,避免后面校验空指针 - throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType)); - } else { // 1.2 有数据权限但是没有负责人的情况 - if (!anyMatch(bizPermissions, item -> CrmPermissionLevelEnum.isOwner(item.getLevel()))) { - if (CrmPermissionLevelEnum.isRead(permissionLevel)) { - return; - } - } - } - - // 2.1 情况一:如果自己是负责人,则默认有所有权限 - CrmPermissionDO userPermission = CollUtil.findOne(bizPermissions, permission -> ObjUtil.equal(permission.getUserId(), getUserId())); - if (userPermission != null) { - if (CrmPermissionLevelEnum.isOwner(userPermission.getLevel())) { - return; - } - // 2.2 情况二:校验自己是否有读权限 - if (CrmPermissionLevelEnum.isRead(permissionLevel)) { - if (CrmPermissionLevelEnum.isRead(userPermission.getLevel()) // 校验当前用户是否有读权限 - || CrmPermissionLevelEnum.isWrite(userPermission.getLevel())) { // 校验当前用户是否有写权限 - return; - } - } - // 2.3 情况三:校验自己是否有写权限 - if (CrmPermissionLevelEnum.isWrite(permissionLevel)) { - if (CrmPermissionLevelEnum.isWrite(userPermission.getLevel())) { // 校验当前用户是否有写权限 - return; - } - } - } - // 2.4 没有权限,抛出异常 - log.info("[doBefore][userId({}) 要求权限({}) 实际权限({}) 数据校验错误]", // 打个 info 日志,方便后续排查问题、审计 - getUserId(), permissionLevel, toJsonString(userPermission)); - throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType)); - } - - /** - * 获得用户编号 - * - * @return 用户编号 - */ - private static Long getUserId() { - return WebFrameworkUtils.getLoginUserId(); - } - - private static Map parseExpressions(JoinPoint joinPoint, CrmPermission crmPermission) { - // 1. 需要解析的表达式 - List expressionStrings = new ArrayList<>(2); - expressionStrings.add(crmPermission.bizId()); - if (StrUtil.isNotEmpty(crmPermission.bizTypeValue())) { // 为空则表示 bizType 有值 - expressionStrings.add(crmPermission.bizTypeValue()); - } - // 2. 执行解析 - return SpringExpressionUtils.parseExpressions(joinPoint, expressionStrings); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/package-info.java deleted file mode 100644 index d895fe969..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.permission.core; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/package-info.java deleted file mode 100644 index 97f76dbe1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * crm 模块的 permission 拓展封装 - */ -package cn.iocoder.yudao.module.crm.framework.permission; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/rpc/config/RpcConfiguration.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index d36e50519..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.rpc.config; - -import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.PostApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {AdminUserApi.class, DeptApi.class, PostApi.class, - BpmProcessInstanceApi.class}) -public class RpcConfiguration { -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/rpc/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/rpc/package-info.java deleted file mode 100644 index 79ee21420..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.crm.framework.rpc; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/security/config/SecurityConfiguration.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 59a32206f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.crm.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Crm 模块的 Security 配置 - */ -@Configuration("crmSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("crmAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").permitAll() - .antMatchers("/actuator/**").permitAll(); - // Druid 监控 - registry.antMatchers("/druid/**").permitAll(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/security/core/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/security/core/package-info.java deleted file mode 100644 index 1e6b880ae..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.crm.framework.security.core; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/customer/CrmCustomerAutoPutPoolJob.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/customer/CrmCustomerAutoPutPoolJob.java deleted file mode 100644 index 032d18129..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/customer/CrmCustomerAutoPutPoolJob.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.crm.job.customer; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import com.xxl.job.core.handler.annotation.XxlJob; -import javax.annotation.Resource; -import org.springframework.stereotype.Component; - -/** - * 客户自动掉入公海 Job - * - * @author 芋道源码 - */ -@Component -public class CrmCustomerAutoPutPoolJob { - - @Resource - private CrmCustomerService customerService; - - @XxlJob("customerAutoPutPoolJob") - @TenantJob - public String execute() { - int count = customerService.autoPutCustomerPool(); - return String.format("掉入公海客户 %s 个", count); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/package-info.java deleted file mode 100644 index 144f64d02..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:临时占位,后续可删除 - */ -package cn.iocoder.yudao.module.crm.job; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/package-info.java deleted file mode 100644 index 2ea5f9f41..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * crm 包下,客户关系管理(Customer Relationship Management)。 - * 例如说:客户、联系人、商机、合同、回款等等 - * - * 1. Controller URL:以 /crm/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 crm_ 开头,方便在数据库中区分 - * - * 注意,由于 Crm 模块下,容易和其它模块重名,所以类名都加载 Crm 的前缀~ - */ -package cn.iocoder.yudao.module.crm; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java deleted file mode 100644 index d03da429f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java +++ /dev/null @@ -1,206 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateStatusReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 商机 Service 接口 - * - * @author ljlleo - */ -public interface CrmBusinessService { - - /** - * 创建商机 - * - * @param createReqVO 创建信息 - * @param userId 用户编号 - * @return 编号 - */ - Long createBusiness(@Valid CrmBusinessSaveReqVO createReqVO, Long userId); - - /** - * 更新商机 - * - * @param updateReqVO 更新信息 - */ - void updateBusiness(@Valid CrmBusinessSaveReqVO updateReqVO); - - /** - * 更新商机相关跟进信息 - * - * @param id 编号 - * @param contactNextTime 下次联系时间 - * @param contactLastContent 最后联系内容 - */ - void updateBusinessFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); - - /** - * 更新商机的下次联系时间 - * - * @param ids 编号数组 - * @param contactNextTime 下次联系时间 - */ - void updateBusinessContactNextTime(Collection ids, LocalDateTime contactNextTime); - - /** - * 更新商机的状态 - * - * @param reqVO 更新请求 - */ - void updateBusinessStatus(CrmBusinessUpdateStatusReqVO reqVO); - - /** - * 删除商机 - * - * @param id 编号 - */ - void deleteBusiness(Long id); - - /** - * 商机转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId); - - /** - * 获得商机 - * - * @param id 编号 - * @return 商机 - */ - CrmBusinessDO getBusiness(Long id); - - /** - * 校验商机是否有效 - * - * @param id 编号 - * @return 商机 - */ - CrmBusinessDO validateBusiness(Long id); - - /** - * 获得商机列表 - * - * @param ids 编号 - * @return 商机列表 - */ - List getBusinessList(Collection ids); - - /** - * 获得商机 Map - * - * @param ids 编号 - * @return 商机 Map - */ - default Map getBusinessMap(Collection ids) { - return convertMap(getBusinessList(ids), CrmBusinessDO::getId); - } - - /** - * 获得指定商机编号的产品列表 - * - * @param businessId 商机编号 - * @return 商机产品列表 - */ - List getBusinessProductListByBusinessId(Long businessId); - - /** - * 获得商机分页 - * - * 数据权限:基于 {@link CrmBusinessDO} - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 商机分页 - */ - PageResult getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId); - - /** - * 获得商机分页,基于指定客户 - * - * 数据权限:基于 {@link CrmCustomerDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 商机分页 - */ - PageResult getBusinessPageByCustomerId(CrmBusinessPageReqVO pageReqVO); - - /** - * 获得商机分页,基于指定联系人 - * - * 数据权限:基于 {@link CrmContactDO} 读取 - * - * @param pageReqVO 分页参数 - * @return 商机分页 - */ - PageResult getBusinessPageByContact(CrmBusinessPageReqVO pageReqVO); - - /** - * 获取关联客户的商机数量 - * - * @param customerId 客户编号 - * @return 数量 - */ - Long getBusinessCountByCustomerId(Long customerId); - - /** - * 获得使用指定商机状态组的商机数量 - * - * @param statusTypeId 商机状态组编号 - * @return 数量 - */ - Long getBusinessCountByStatusTypeId(Long statusTypeId); - - /** - * 获得商机状态名称 - * - * @param endStatus 结束状态 - * @param status 商机状态 - * @return 商机状态名称 - */ - default String getBusinessStatusName(Integer endStatus, CrmBusinessStatusDO status) { - if (endStatus != null) { - return CrmBusinessEndStatusEnum.fromStatus(endStatus).getName(); - } - return status.getName(); - } - - /** - * 获得商机列表 - * - * @param customerId 客户编号 - * @param ownerUserId 负责人编号 - * @return 商机列表 - */ - List getBusinessListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId); - - /** - * 获得商机分页,目前用于【数据统计】 - * - * @param pageVO 请求 - * @return 商机分页 - */ - PageResult getBusinessPageByDate(CrmStatisticsFunnelReqVO pageVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java deleted file mode 100644 index 3fad07b4d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java +++ /dev/null @@ -1,384 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateStatusReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessProductMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.crm.service.product.CrmProductService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -/** - * 商机 Service 实现类 - * - * @author ljlleo - */ -@Service -@Validated -public class CrmBusinessServiceImpl implements CrmBusinessService { - - @Resource - private CrmBusinessMapper businessMapper; - @Resource - private CrmBusinessProductMapper businessProductMapper; - - @Resource - private CrmBusinessStatusService businessStatusService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private CrmContractService contractService; - @Resource - private CrmCustomerService customerService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private CrmContactService contactService; - @Resource - private CrmPermissionService permissionService; - @Resource - private CrmContactBusinessService contactBusinessService; - @Resource - private CrmProductService productService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_CREATE_SUB_TYPE, bizNo = "{{#business.id}}", - success = CRM_BUSINESS_CREATE_SUCCESS) - public Long createBusiness(CrmBusinessSaveReqVO createReqVO, Long userId) { - // 1.1 校验产品项的有效性 - List businessProducts = validateBusinessProducts(createReqVO.getProducts()); - // 1.2 校验关联字段 - validateRelationDataExists(createReqVO); - - // 2.1 插入商机 - CrmBusinessDO business = BeanUtils.toBean(createReqVO, CrmBusinessDO.class); - business.setStatusId(businessStatusService.getBusinessStatusListByTypeId(createReqVO.getStatusTypeId()).get(0).getId()); // 默认状态 - calculateTotalPrice(business, businessProducts); - businessMapper.insert(business); - // 2.2 插入商机关联商品 - if (CollUtil.isNotEmpty(businessProducts)) { - businessProducts.forEach(item -> item.setBusinessId(business.getId())); - businessProductMapper.insertBatch(businessProducts); - } - - // 3. 创建数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(business.getOwnerUserId()) - .setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()).setBizId(business.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - - // 4. 在联系人的详情页,如果直接【新建商机】,则需要关联下 - if (createReqVO.getContactId() != null) { - contactBusinessService.createContactBusinessList(new CrmContactBusinessReqVO().setContactId(createReqVO.getContactId()) - .setBusinessIds(Collections.singletonList(business.getId()))); - } - - // 5. 记录操作日志上下文 - LogRecordContext.putVariable("business", business); - return business.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_BUSINESS_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateBusiness(CrmBusinessSaveReqVO updateReqVO) { - updateReqVO.setOwnerUserId(null).setStatusTypeId(null); // 不允许更新的字段 - // 1.1 校验存在 - CrmBusinessDO oldBusiness = validateBusinessExists(updateReqVO.getId()); - // 1.2 校验产品项的有效性 - List businessProducts = validateBusinessProducts(updateReqVO.getProducts()); - // 1.3 校验关联字段 - validateRelationDataExists(updateReqVO); - - // 2.1 更新商机 - CrmBusinessDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessDO.class); - calculateTotalPrice(updateObj, businessProducts); - businessMapper.updateById(updateObj); - // 2.2 更新商机关联商品 - updateBusinessProduct(updateObj.getId(), businessProducts); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldBusiness, CrmBusinessSaveReqVO.class)); - LogRecordContext.putVariable("businessName", oldBusiness.getName()); - } - - @Override - @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}", - success = CRM_BUSINESS_FOLLOW_UP_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void updateBusinessFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent) { - // 1. 校验存在 - CrmBusinessDO business = validateBusinessExists(id); - - // 2. 更新联系人的跟进信息 - businessMapper.updateById(new CrmBusinessDO().setId(id).setFollowUpStatus(true).setContactNextTime(contactNextTime) - .setContactLastTime(LocalDateTime.now())); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("businessName", business.getName()); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#ids", level = CrmPermissionLevelEnum.WRITE) - public void updateBusinessContactNextTime(Collection ids, LocalDateTime contactNextTime) { - businessMapper.updateBatch(convertList(ids, id -> new CrmBusinessDO().setId(id).setContactNextTime(contactNextTime))); - } - - private void updateBusinessProduct(Long id, List newList) { - List oldList = businessProductMapper.selectListByBusinessId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setBusinessId(id)); - businessProductMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - businessProductMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - businessProductMapper.deleteBatchIds(convertSet(diffList.get(2), CrmBusinessProductDO::getId)); - } - } - - private void validateRelationDataExists(CrmBusinessSaveReqVO saveReqVO) { - // 校验商机状态 - if (saveReqVO.getStatusTypeId() != null) { - businessStatusService.validateBusinessStatusType(saveReqVO.getStatusTypeId()); - } - // 校验客户 - if (saveReqVO.getCustomerId() != null) { - customerService.validateCustomer(saveReqVO.getCustomerId()); - } - // 校验联系人 - if (saveReqVO.getContactId() != null) { - contactService.validateContact(saveReqVO.getContactId()); - } - // 校验负责人 - if (saveReqVO.getOwnerUserId() != null) { - adminUserApi.validateUser(saveReqVO.getOwnerUserId()); - } - } - - private List validateBusinessProducts(List list) { - // 1. 校验产品存在 - productService.validProductList(convertSet(list, CrmBusinessSaveReqVO.BusinessProduct::getProductId)); - // 2. 转化为 CrmBusinessProductDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, CrmBusinessProductDO.class, - item -> item.setTotalPrice(MoneyUtils.priceMultiply(item.getBusinessPrice(), item.getCount())))); - } - - private void calculateTotalPrice(CrmBusinessDO business, List businessProducts) { - business.setTotalProductPrice(getSumValue(businessProducts, CrmBusinessProductDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - BigDecimal discountPrice = MoneyUtils.priceMultiplyPercent(business.getTotalProductPrice(), business.getDiscountPercent()); - business.setTotalPrice(business.getTotalProductPrice().subtract(discountPrice)); - } - - @Override - @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_UPDATE_STATUS_SUB_TYPE, bizNo = "{{#reqVO.id}}", - success = CRM_BUSINESS_UPDATE_STATUS_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateBusinessStatus(CrmBusinessUpdateStatusReqVO reqVO) { - // 1.1 校验存在 - CrmBusinessDO business = validateBusinessExists(reqVO.getId()); - // 1.2 校验商机未结束 - if (business.getEndStatus() != null) { - throw exception(BUSINESS_UPDATE_STATUS_FAIL_END_STATUS); - } - // 1.3 校验商机状态 - CrmBusinessStatusDO status = null; - if (reqVO.getStatusId() != null) { - status = businessStatusService.validateBusinessStatus(business.getStatusTypeId(), reqVO.getStatusId()); - } - // 1.4 校验是不是状态没变更 - if ((reqVO.getStatusId() != null && reqVO.getStatusId().equals(business.getStatusId())) - || (reqVO.getEndStatus() != null && reqVO.getEndStatus().equals(business.getEndStatus()))) { - throw exception(BUSINESS_UPDATE_STATUS_FAIL_STATUS_EQUALS); - } - - // 2. 更新商机状态 - businessMapper.updateById(new CrmBusinessDO().setId(reqVO.getId()).setStatusId(reqVO.getStatusId()) - .setEndStatus(reqVO.getEndStatus())); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("businessName", business.getName()); - LogRecordContext.putVariable("oldStatusName", getBusinessStatusName(business.getEndStatus(), - businessStatusService.getBusinessStatus(business.getStatusId()))); - LogRecordContext.putVariable("newStatusName", getBusinessStatusName(reqVO.getEndStatus(), status)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_BUSINESS_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteBusiness(Long id) { - // 1.1 校验存在 - CrmBusinessDO business = validateBusinessExists(id); - // 1.2 校验是否关联合同 - validateContractExists(id); - - // 删除商机 - businessMapper.deleteById(id); - // 删除数据权限 - permissionService.deletePermission(CrmBizTypeEnum.CRM_BUSINESS.getType(), id); - - // 记录操作日志上下文 - LogRecordContext.putVariable("businessName", business.getName()); - } - - /** - * 删除校验合同是关联合同 - * - * @param businessId 商机id - * @author lzxhqs - */ - private void validateContractExists(Long businessId) { - if (contractService.getContractCountByBusinessId(businessId) > 0) { - throw exception(BUSINESS_DELETE_FAIL_CONTRACT_EXISTS); - } - } - - private CrmBusinessDO validateBusinessExists(Long id) { - CrmBusinessDO crmBusiness = businessMapper.selectById(id); - if (crmBusiness == null) { - throw exception(BUSINESS_NOT_EXISTS); - } - return crmBusiness; - } - - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", - success = CRM_BUSINESS_TRANSFER_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) - public void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId) { - // 1 校验商机是否存在 - CrmBusinessDO business = validateBusinessExists(reqVO.getId()); - - // 2.1 数据权限转移 - permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_BUSINESS.getType(), - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); - // 2.2 设置新的负责人 - businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); - - // 记录操作日志上下文 - LogRecordContext.putVariable("business", business); - } - - //======================= 查询相关 ======================= - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmBusinessDO getBusiness(Long id) { - return businessMapper.selectById(id); - } - - @Override - public CrmBusinessDO validateBusiness(Long id) { - return validateBusinessExists(id); - } - - @Override - public List getBusinessList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return businessMapper.selectBatchIds(ids); - } - - @Override - public List getBusinessProductListByBusinessId(Long businessId) { - return businessProductMapper.selectListByBusinessId(businessId); - } - - @Override - public PageResult getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId) { - return businessMapper.selectPage(pageReqVO, userId); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getBusinessPageByCustomerId(CrmBusinessPageReqVO pageReqVO) { - return businessMapper.selectPageByCustomerId(pageReqVO); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#pageReqVO.contactId", level = CrmPermissionLevelEnum.READ) - public PageResult getBusinessPageByContact(CrmBusinessPageReqVO pageReqVO) { - // 1. 查询关联的商机编号 - List contactBusinessList = contactBusinessService.getContactBusinessListByContactId( - pageReqVO.getContactId()); - if (CollUtil.isEmpty(contactBusinessList)) { - return PageResult.empty(); - } - // 2. 查询商机分页 - return businessMapper.selectPageByContactId(pageReqVO, - convertSet(contactBusinessList, CrmContactBusinessDO::getBusinessId)); - } - - @Override - public Long getBusinessCountByCustomerId(Long customerId) { - return businessMapper.selectCount(CrmBusinessDO::getCustomerId, customerId); - } - - @Override - public Long getBusinessCountByStatusTypeId(Long statusTypeId) { - return businessMapper.selectCountByStatusTypeId(statusTypeId); - } - - @Override - public List getBusinessListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { - return businessMapper.selectListByCustomerIdOwnerUserId(customerId, ownerUserId); - } - - @Override - public PageResult getBusinessPageByDate(CrmStatisticsFunnelReqVO pageVO) { - return businessMapper.selectPage(pageVO); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java deleted file mode 100644 index 285e984d2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 商机状态 Service 接口 - * - * @author ljlleo - */ -public interface CrmBusinessStatusService { - - /** - * 创建商机状态 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBusinessStatus(@Valid CrmBusinessStatusSaveReqVO createReqVO); - - /** - * 更新商机状态 - * - * @param updateReqVO 更新信息 - */ - void updateBusinessStatus(@Valid CrmBusinessStatusSaveReqVO updateReqVO); - - /** - * 删除商机状态 - * - * @param id 编号 - */ - void deleteBusinessStatusType(Long id); - - /** - * 获得商机状态组 - * - * @param id 编号 - * @return 商机状态组 - */ - CrmBusinessStatusTypeDO getBusinessStatusType(Long id); - - /** - * 校验商机状态组 - * - * @param id 编号 - */ - void validateBusinessStatusType(Long id); - - /** - * 获得商机状态组列表 - * - * @return 商机状态组列表 - */ - List getBusinessStatusTypeList(); - - /** - * 获得商机状态组分页 - * - * @param pageReqVO 分页查询 - * @return 商机状态组分页 - */ - PageResult getBusinessStatusTypePage(PageParam pageReqVO); - - /** - * 获得商机状态组列表 - * - * @param ids 编号数组 - * @return 商机状态组列表 - */ - List getBusinessStatusTypeList(Collection ids); - - /** - * 获得商机状态组 Map - * - * @param ids 编号数组 - * @return 商机状态组 Map - */ - default Map getBusinessStatusTypeMap(Collection ids) { - return convertMap(getBusinessStatusTypeList(ids), CrmBusinessStatusTypeDO::getId); - } - - /** - * 获得指定类型的商机状态列表 - * - * @param typeId 商机状态组编号 - * @return 商机状态列表 - */ - List getBusinessStatusListByTypeId(Long typeId); - - /** - * 获得商机状态列表 - * - * @param ids 编号数组 - * @return 商机状态列表 - */ - List getBusinessStatusList(Collection ids); - - /** - * 获得商机状态 Map - * - * @param ids 编号数组 - * @return 商机状态 Map - */ - default Map getBusinessStatusMap(Collection ids) { - return convertMap(getBusinessStatusList(ids), CrmBusinessStatusDO::getId); - } - - /** - * 获得商机状态 - * - * @param id 编号 - * @return 商机状态 - */ - CrmBusinessStatusDO getBusinessStatus(Long id); - - /** - * 校验商机状态 - * - * @param statusTypeId 商机状态组编号 - * @param statusId 商机状态编号 - */ - CrmBusinessStatusDO validateBusinessStatus(Long statusTypeId, Long statusId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java deleted file mode 100644 index 3c2e0b664..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java +++ /dev/null @@ -1,195 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.business; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper; -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusTypeMapper; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; - -/** - * 商机状态 Service 实现类 - * - * @author ljlleo - */ -@Service -@Validated -public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService { - - @Resource - private CrmBusinessStatusTypeMapper businessStatusTypeMapper; - @Resource - private CrmBusinessStatusMapper businessStatusMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private CrmBusinessService businessService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createBusinessStatus(CrmBusinessStatusSaveReqVO createReqVO) { - // 1.1 检验名称是否存在 - validateBusinessStatusTypeNameUnique(createReqVO.getName(), null); - // 1.2 设置状态的排序 - int sort = 0; - for (CrmBusinessStatusSaveReqVO.Status status : createReqVO.getStatuses()) { - status.setSort(sort++); - } - - // 2.1 插入类型 - CrmBusinessStatusTypeDO statusType = BeanUtils.toBean(createReqVO, CrmBusinessStatusTypeDO.class); - businessStatusTypeMapper.insert(statusType); - // 2.2 插入状态 - List statuses = BeanUtils.toBean(createReqVO.getStatuses(), CrmBusinessStatusDO.class, - status -> status.setTypeId(statusType.getId())); - businessStatusMapper.insertBatch(statuses); - return statusType.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateBusinessStatus(CrmBusinessStatusSaveReqVO updateReqVO) { - // 1.1 校验存在 - validateBusinessStatusTypeExists(updateReqVO.getId()); - // 1.2 校验名称是否存在 - validateBusinessStatusTypeNameUnique(updateReqVO.getName(), updateReqVO.getId()); - // 1.3 设置状态的排序 - int sort = 0; - for (CrmBusinessStatusSaveReqVO.Status status : updateReqVO.getStatuses()) { - status.setSort(sort++); - } - // 1.4 已经使用,无法更新 - if (businessService.getBusinessCountByStatusTypeId(updateReqVO.getId()) > 0) { - throw exception(BUSINESS_STATUS_UPDATE_FAIL_USED); - } - - // 2.1 更新类型 - CrmBusinessStatusTypeDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessStatusTypeDO.class); - businessStatusTypeMapper.updateById(updateObj); - // 2.2 更新状态 - updateBusinessStatus(updateReqVO.getId(), BeanUtils.toBean(updateReqVO.getStatuses(), CrmBusinessStatusDO.class)); - } - - private void updateBusinessStatus(Long id, List newList) { - List oldList = businessStatusMapper.selectListByTypeId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setTypeId(id)); - businessStatusMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - businessStatusMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - businessStatusMapper.deleteBatchIds(convertSet(diffList.get(2), CrmBusinessStatusDO::getId)); - } - } - - private void validateBusinessStatusTypeExists(Long id) { - if (businessStatusTypeMapper.selectById(id) == null) { - throw exception(BUSINESS_STATUS_TYPE_NOT_EXISTS); - } - } - - private void validateBusinessStatusTypeNameUnique(String name, Long id) { - CrmBusinessStatusTypeDO statusType = businessStatusTypeMapper.selectByName(name); - if (statusType == null - || statusType.getId().equals(id)) { - return; - } - throw exception(BUSINESS_STATUS_TYPE_NAME_EXISTS); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteBusinessStatusType(Long id) { - // 1.1 校验存在 - validateBusinessStatusTypeExists(id); - // 1.2 已经使用,无法更新 - if (businessService.getBusinessCountByStatusTypeId(id) > 0) { - throw exception(BUSINESS_STATUS_DELETE_FAIL_USED); - } - - // 2.1 删除类型 - businessStatusTypeMapper.deleteById(id); - // 2.2 删除状态 - businessStatusMapper.deleteByTypeId(id); - } - - @Override - public CrmBusinessStatusTypeDO getBusinessStatusType(Long id) { - return businessStatusTypeMapper.selectById(id); - } - - @Override - public void validateBusinessStatusType(Long id) { - validateBusinessStatusTypeExists(id); - } - - @Override - public List getBusinessStatusTypeList() { - return businessStatusTypeMapper.selectList(); - } - - @Override - public PageResult getBusinessStatusTypePage(PageParam pageReqVO) { - return businessStatusTypeMapper.selectPage(pageReqVO); - } - - @Override - public List getBusinessStatusTypeList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return businessStatusTypeMapper.selectBatchIds(ids); - } - - @Override - public List getBusinessStatusListByTypeId(Long typeId) { - List list = businessStatusMapper.selectListByTypeId(typeId); - list.sort(Comparator.comparingInt(CrmBusinessStatusDO::getSort)); - return list; - } - - @Override - public List getBusinessStatusList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return businessStatusMapper.selectBatchIds(ids); - } - - @Override - public CrmBusinessStatusDO getBusinessStatus(Long id) { - return businessStatusMapper.selectById(id); - } - - @Override - public CrmBusinessStatusDO validateBusinessStatus(Long statusTypeId, Long statusId) { - CrmBusinessStatusDO status = businessStatusMapper.selectByTypeIdAndId(statusTypeId, statusId); - if (status == null) { - throw exception(BUSINESS_STATUS_NOT_EXISTS); - } - return status; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java deleted file mode 100644 index b325bfd25..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.clue; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 线索 Service 接口 - * - * @author Wanwan - */ -public interface CrmClueService { - - /** - * 创建线索 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createClue(@Valid CrmClueSaveReqVO createReqVO); - - /** - * 更新线索 - * - * @param updateReqVO 更新信息 - */ - void updateClue(@Valid CrmClueSaveReqVO updateReqVO); - - /** - * 更新线索相关的跟进信息 - * - * @param id 编号 - * @param contactNextTime 下次联系时间 - * @param contactLastContent 最后联系内容 - */ - void updateClueFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); - - /** - * 删除线索 - * - * @param id 编号 - */ - void deleteClue(Long id); - - /** - * 获得线索 - * - * @param id 编号 - * @return 线索 - */ - CrmClueDO getClue(Long id); - - /** - * 获得线索列表 - * - * @param ids 编号 - * @return 线索列表 - */ - List getClueList(Collection ids, Long userId); - - /** - * 获得线索分页 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 线索分页 - */ - PageResult getCluePage(CrmCluePageReqVO pageReqVO, Long userId); - - /** - * 线索转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferClue(CrmClueTransferReqVO reqVO, Long userId); - - /** - * 线索转化为客户 - * - * @param id 线索编号 - * @param userId 用户编号 - */ - void transformClue(Long id, Long userId); - - /** - * 获得分配给我的、待跟进的线索数量 - * - * @param userId 用户编号 - * @return 数量 - */ - Long getFollowClueCount(Long userId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java deleted file mode 100644 index 52c15547f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java +++ /dev/null @@ -1,241 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.clue; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.CrmCustomerSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; -import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.customer.bo.CrmCustomerCreateReqBO; -import cn.iocoder.yudao.module.crm.service.followup.CrmFollowUpRecordService; -import cn.iocoder.yudao.module.crm.service.followup.bo.CrmFollowUpCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.singleton; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_TRANSFORM_FAIL_ALREADY; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; - -/** - * 线索 Service 实现类 - * - * @author Wanwan - */ -@Service -@Validated -public class CrmClueServiceImpl implements CrmClueService { - - @Resource - private CrmClueMapper clueMapper; - - @Resource - private CrmCustomerService customerService; - @Resource - private CrmPermissionService crmPermissionService; - @Resource - private CrmFollowUpRecordService followUpRecordService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_CREATE_SUB_TYPE, bizNo = "{{#clue.id}}", - success = CRM_CLUE_CREATE_SUCCESS) - public Long createClue(CrmClueSaveReqVO createReqVO) { - // 1.1 校验关联数据 - validateRelationDataExists(createReqVO); - // 1.2 校验负责人是否存在 - adminUserApi.validateUser(createReqVO.getOwnerUserId()); - - // 2. 插入线索 - CrmClueDO clue = BeanUtils.toBean(createReqVO, CrmClueDO.class); - clueMapper.insert(clue); - - // 3. 创建数据权限 - CrmPermissionCreateReqBO createReqBO = new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CLUE.getType()) - .setBizId(clue.getId()).setUserId(clue.getOwnerUserId()).setLevel(CrmPermissionLevelEnum.OWNER.getLevel()); - crmPermissionService.createPermission(createReqBO); - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("clue", clue); - return clue.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_CLUE_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#updateReq.id", level = CrmPermissionLevelEnum.OWNER) - public void updateClue(CrmClueSaveReqVO updateReq) { - Assert.notNull(updateReq.getId(), "线索编号不能为空"); - // 1.1 校验线索是否存在 - CrmClueDO oldClue = validateClueExists(updateReq.getId()); - // 1.2 校验关联数据 - validateRelationDataExists(updateReq); - - // 2. 更新线索 - CrmClueDO updateObj = BeanUtils.toBean(updateReq, CrmClueDO.class); - clueMapper.updateById(updateObj); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldClue, CrmCustomerSaveReqVO.class)); - LogRecordContext.putVariable("clueName", oldClue.getName()); - } - - private void validateRelationDataExists(CrmClueSaveReqVO reqVO) { - // 校验负责人 - if (Objects.nonNull(reqVO.getOwnerUserId()) && - Objects.isNull(adminUserApi.getUser(reqVO.getOwnerUserId()))) { - throw exception(USER_NOT_EXISTS); - } - } - - @Override - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CLUE_FOLLOW_UP_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void updateClueFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent) { - // 校验线索是否存在 - CrmClueDO oldClue = validateClueExists(id); - - // 更新线索 - clueMapper.updateById(new CrmClueDO().setId(id).setFollowUpStatus(true).setContactNextTime(contactNextTime) - .setContactLastTime(LocalDateTime.now()).setContactLastContent(contactLastContent)); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("clueName", oldClue.getName()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CLUE_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteClue(Long id) { - // 1. 校验存在 - CrmClueDO clue = validateClueExists(id); - - // 2. 删除 - clueMapper.deleteById(id); - - // 3. 删除数据权限 - crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CLUE.getType(), id); - - // 4. 删除跟进 - followUpRecordService.deleteFollowUpRecordByBiz(CrmBizTypeEnum.CRM_CLUE.getType(), id); - - // 5. 记录操作日志上下文 - LogRecordContext.putVariable("clueName", clue.getName()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", - success = CRM_CLUE_TRANSFER_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) - public void transferClue(CrmClueTransferReqVO reqVO, Long userId) { - // 1 校验线索是否存在 - CrmClueDO clue = validateClueExists(reqVO.getId()); - - // 2.1 数据权限转移 - crmPermissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CLUE.getType(), - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); - // 2.2 设置新的负责人 - clueMapper.updateById(new CrmClueDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId())); - - // 3. 记录转移日志 - LogRecordContext.putVariable("clue", clue); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_TRANSLATE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CLUE_TRANSLATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void transformClue(Long id, Long userId) { - // 1.1 校验线索都存在 - CrmClueDO clue = validateClueExists(id); - // 1.2 存在已经转化的 - if (clue.getTransformStatus()) { - throw exception(CLUE_TRANSFORM_FAIL_ALREADY); - } - - // 2.1 遍历线索(未转化的线索),创建对应的客户 - Long customerId = customerService.createCustomer(BeanUtils.toBean(clue, CrmCustomerCreateReqBO.class), userId); - // 2.2 更新线索 - clueMapper.updateById(new CrmClueDO().setId(id).setTransformStatus(Boolean.TRUE).setCustomerId(customerId)); - // 2.3 复制跟进记录 - List followUpRecords = followUpRecordService.getFollowUpRecordByBiz( - CrmBizTypeEnum.CRM_CLUE.getType(), singleton(clue.getId())); - if (CollUtil.isNotEmpty(followUpRecords)) { - followUpRecordService.createFollowUpRecordBatch(convertList(followUpRecords, record -> - BeanUtils.toBean(record, CrmFollowUpCreateReqBO.class) - .setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()).setBizId(customerId))); - } - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("clueName", clue.getName()); - } - - private CrmClueDO validateClueExists(Long id) { - CrmClueDO crmClueDO = clueMapper.selectById(id); - if (crmClueDO == null) { - throw exception(CLUE_NOT_EXISTS); - } - return crmClueDO; - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmClueDO getClue(Long id) { - return clueMapper.selectById(id); - } - - @Override - public List getClueList(Collection ids, Long userId) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return clueMapper.selectBatchIds(ids, userId); - } - - @Override - public PageResult getCluePage(CrmCluePageReqVO pageReqVO, Long userId) { - return clueMapper.selectPage(pageReqVO, userId); - } - - @Override - public Long getFollowClueCount(Long userId) { - return clueMapper.selectCountByFollow(userId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessService.java deleted file mode 100644 index 7168fb9f5..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessService.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contact; - -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusiness2ReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; -import javax.validation.Valid; - -import java.util.List; - -/** - * CRM 联系人与商机的关联 Service 接口 - * - * @author 芋道源码 - */ -public interface CrmContactBusinessService { - - /** - * 创建联系人与商机的关联【通过联系人,关联商机】 - * - * @param createReqVO 创建信息 - */ - void createContactBusinessList(@Valid CrmContactBusinessReqVO createReqVO); - - /** - * 创建联系人与商机的关联【通过商机,关联联系人】 - * - * @param createReqVO 创建信息 - */ - void createContactBusinessList2(@Valid CrmContactBusiness2ReqVO createReqVO); - - /** - * 删除联系人与商机的关联【通过联系人,取关商机】 - * - * @param deleteReqVO 删除信息 - */ - void deleteContactBusinessList(@Valid CrmContactBusinessReqVO deleteReqVO); - - /** - * 删除联系人与商机的关联【通过商机,取关联系人】 - * - * @param deleteReqVO 删除信息 - */ - void deleteContactBusinessList2(@Valid CrmContactBusiness2ReqVO deleteReqVO); - - /** - * 删除联系人与商机的关联,基于联系人编号 - * - * @param contactId 联系人编号 - */ - void deleteContactBusinessByContactId(Long contactId); - - /** - * 获得联系人与商机的关联列表,基于联系人编号 - * - * @param contactId 联系人编号 - * @return 联系人商机关联 - */ - List getContactBusinessListByContactId(Long contactId); - - /** - * 获得联系人与商机的关联列表,基于商机编号 - * - * @param businessId 商机编号 - * @return 联系人商机关联 - */ - List getContactBusinessListByBusinessId(Long businessId); - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessServiceImpl.java deleted file mode 100644 index 99bbdd570..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessServiceImpl.java +++ /dev/null @@ -1,139 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contact; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusiness2ReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactBusinessMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.ArrayList; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_NOT_EXISTS; - -/** - * 联系人与商机的关联 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CrmContactBusinessServiceImpl implements CrmContactBusinessService { - - @Resource - private CrmContactBusinessMapper contactBusinessMapper; - - @Resource - @Lazy // 延迟加载,为了解决延迟加载 - private CrmBusinessService businessService; - @Resource - @Lazy // 延迟加载,为了解决延迟加载 - private CrmContactService contactService; - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#createReqVO.contactId", level = CrmPermissionLevelEnum.WRITE) - public void createContactBusinessList(CrmContactBusinessReqVO createReqVO) { - CrmContactDO contact = contactService.getContact(createReqVO.getContactId()); - if (contact == null) { - throw exception(CONTACT_NOT_EXISTS); - } - // 遍历处理,考虑到一般数量不会太多,代码处理简单 - List saveDOList = new ArrayList<>(); - createReqVO.getBusinessIds().forEach(businessId -> { - CrmBusinessDO business = businessService.getBusiness(businessId); - if (business == null) { - throw exception(BUSINESS_NOT_EXISTS); - } - // 关联判重 - if (contactBusinessMapper.selectByContactIdAndBusinessId(createReqVO.getContactId(), businessId) != null) { - return; - } - saveDOList.add(new CrmContactBusinessDO(null, createReqVO.getContactId(), businessId)); - }); - // 批量插入 - if (CollUtil.isNotEmpty(saveDOList)) { - contactBusinessMapper.insertBatch(saveDOList); - } - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#createReqVO.businessId", level = CrmPermissionLevelEnum.WRITE) - public void createContactBusinessList2(CrmContactBusiness2ReqVO createReqVO) { - CrmBusinessDO business = businessService.getBusiness(createReqVO.getBusinessId()); - if (business == null) { - throw exception(BUSINESS_NOT_EXISTS); - } - // 遍历处理,考虑到一般数量不会太多,代码处理简单 - List saveDOList = new ArrayList<>(); - createReqVO.getContactIds().forEach(contactId -> { - CrmContactDO contact = contactService.getContact(contactId); - if (contact == null) { - throw exception(CONTACT_NOT_EXISTS); - } - // 关联判重 - if (contactBusinessMapper.selectByContactIdAndBusinessId(contactId, createReqVO.getBusinessId()) != null) { - return; - } - saveDOList.add(new CrmContactBusinessDO(null, contactId, createReqVO.getBusinessId())); - }); - // 批量插入 - if (CollUtil.isNotEmpty(saveDOList)) { - contactBusinessMapper.insertBatch(saveDOList); - } - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#deleteReqVO.contactId", level = CrmPermissionLevelEnum.WRITE) - public void deleteContactBusinessList(CrmContactBusinessReqVO deleteReqVO) { - CrmContactDO contact = contactService.getContact(deleteReqVO.getContactId()); - if (contact == null) { - throw exception(CONTACT_NOT_EXISTS); - } - // 直接删除 - contactBusinessMapper.deleteByContactIdAndBusinessId( - deleteReqVO.getContactId(), deleteReqVO.getBusinessIds()); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#deleteReqVO.businessId", level = CrmPermissionLevelEnum.WRITE) - public void deleteContactBusinessList2(CrmContactBusiness2ReqVO deleteReqVO) { - CrmBusinessDO business = businessService.getBusiness(deleteReqVO.getBusinessId()); - if (business == null) { - throw exception(BUSINESS_NOT_EXISTS); - } - // 直接删除 - contactBusinessMapper.deleteByBusinessIdAndContactId( - deleteReqVO.getBusinessId(), deleteReqVO.getContactIds()); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#contactId", level = CrmPermissionLevelEnum.WRITE) - public void deleteContactBusinessByContactId(Long contactId) { - contactBusinessMapper.delete(CrmContactBusinessDO::getContactId, contactId); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#contactId", level = CrmPermissionLevelEnum.READ) - public List getContactBusinessListByContactId(Long contactId) { - return contactBusinessMapper.selectListByContactId(contactId); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#businessId", level = CrmPermissionLevelEnum.READ) - public List getContactBusinessListByBusinessId(Long businessId) { - return contactBusinessMapper.selectListByBusinessId(businessId); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java deleted file mode 100644 index 24273db2f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java +++ /dev/null @@ -1,172 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contact; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * CRM 联系人 Service 接口 - * - * @author 芋道源码 - */ -public interface CrmContactService { - - /** - * 创建联系人 - * - * @param createReqVO 创建信息 - * @param userId 用户编号 - * @return 编号 - */ - Long createContact(@Valid CrmContactSaveReqVO createReqVO, Long userId); - - /** - * 更新联系人 - * - * @param updateReqVO 更新信息 - */ - void updateContact(@Valid CrmContactSaveReqVO updateReqVO); - - /** - * 删除联系人 - * - * @param id 编号 - */ - void deleteContact(Long id); - - /** - * 联系人转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferContact(CrmContactTransferReqVO reqVO, Long userId); - - /** - * 更新指定客户的联系人的负责人 - * 数据权限基于 【客户】 - * - * @param customerId 客户编号 - * @param ownerUserId 用户编号 - */ - void updateOwnerUserIdByCustomerId(Long customerId, Long ownerUserId); - - /** - * 更新联系人相关跟进信息 - * - * @param id 编号 - * @param contactNextTime 下次联系时间 - * @param contactLastContent 最后联系内容 - */ - void updateContactFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); - - /** - * 更新联系人的下次联系时间 - * - * @param ids 编号数组 - * @param contactNextTime 下次联系时间 - */ - void updateContactContactNextTime(Collection ids, LocalDateTime contactNextTime); - - /** - * 获得联系人 - * - * @param id 编号 - * @return 联系人 - */ - CrmContactDO getContact(Long id); - - /** - * 校验联系人 - * - * @param id 编号 - */ - void validateContact(Long id); - - /** - * 获得联系人列表 - * - * @param ids 编号 - * @return 联系人列表 - */ - List getContactList(Collection ids); - - /** - * 获得联系人 Map - * - * @param ids 编号 - * @return 联系人 Map - */ - default Map getContactMap(Collection ids) { - return convertMap(getContactList(ids), CrmContactDO::getId); - } - - /** - * 获取联系人列表(校验权限) - * - * @param userId 用户编号 - * @return 联系人列表 - */ - List getContactList(Long userId); - - /** - * 获得联系人分页 - * - * 数据权限:基于 {@link CrmContactDO} - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 联系人分页 - */ - PageResult getContactPage(CrmContactPageReqVO pageReqVO, Long userId); - - /** - * 获得联系人分页 - * - * 数据权限:基于 {@link CrmCustomerDO} - * - * @param pageVO 分页查询 - * @return 联系人分页 - */ - PageResult getContactPageByCustomerId(CrmContactPageReqVO pageVO); - - /** - * 获得联系人分页 - * - * 数据权限:基于 {@link CrmBusinessDO} - * - * @param pageVO 分页查询 - * @return 联系人分页 - */ - PageResult getContactPageByBusinessId(CrmContactPageReqVO pageVO); - - /** - * 获取关联客户的联系人数量 - * - * @param customerId 客户编号 - * @return 数量 - */ - Long getContactCountByCustomerId(Long customerId); - - /** - * 获得联系人列表 - * - * @param customerId 客户编号 - * @param ownerUserId 负责人编号 - * @return 联系人列表 - */ - List getContactListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java deleted file mode 100644 index d6eb2a83c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java +++ /dev/null @@ -1,306 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contact; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; -import static java.util.Collections.singletonList; - -/** - * CRM 联系人 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CrmContactServiceImpl implements CrmContactService { - - @Resource - private CrmContactMapper contactMapper; - - @Resource - private CrmCustomerService customerService; - @Resource - private CrmPermissionService permissionService; - @Resource - @Lazy - private CrmContractService contractService; - @Resource - private CrmContactBusinessService contactBusinessService; - @Resource - private CrmBusinessService businessService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_CREATE_SUB_TYPE, bizNo = "{{#contact.id}}", - success = CRM_CONTACT_CREATE_SUCCESS) - public Long createContact(CrmContactSaveReqVO createReqVO, Long userId) { - createReqVO.setId(null); - // 1. 校验关联数据 - validateRelationDataExists(createReqVO); - - // 2. 插入联系人 - CrmContactDO contact = BeanUtils.toBean(createReqVO, CrmContactDO.class); - contactMapper.insert(contact); - - // 3. 创建数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(userId) - .setBizType(CrmBizTypeEnum.CRM_CONTACT.getType()).setBizId(contact.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - - // 4. 如果有关联商机,则需要创建关联 - if (createReqVO.getBusinessId() != null) { - contactBusinessService.createContactBusinessList(new CrmContactBusinessReqVO() - .setContactId(contact.getId()).setBusinessIds(singletonList(createReqVO.getBusinessId()))); - } - - // 5. 记录操作日志 - LogRecordContext.putVariable("contact", contact); - return contact.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_CONTACT_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateContact(CrmContactSaveReqVO updateReqVO) { - // 1.1 校验存在 - CrmContactDO oldContact = validateContactExists(updateReqVO.getId()); - // 1.2 校验关联数据 - validateRelationDataExists(updateReqVO); - - // 2. 更新联系人 - CrmContactDO updateObj = BeanUtils.toBean(updateReqVO, CrmContactDO.class); - contactMapper.updateById(updateObj); - - // 3. 记录操作日志 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldContact, CrmContactSaveReqVO.class)); - LogRecordContext.putVariable("contactName", oldContact.getName()); - } - - /** - * 校验关联的数据都存在 - * - * @param saveReqVO 新增/修改请求 VO - */ - private void validateRelationDataExists(CrmContactSaveReqVO saveReqVO) { - // 1. 校验客户 - if (saveReqVO.getCustomerId() != null && customerService.getCustomer(saveReqVO.getCustomerId()) == null) { - customerService.validateCustomer(saveReqVO.getCustomerId()); - } - // 2. 校验负责人 - if (saveReqVO.getOwnerUserId() != null) { - adminUserApi.validateUser(saveReqVO.getOwnerUserId()); - } - // 3. 直属上级 - if (saveReqVO.getParentId() != null) { - validateContactExists(saveReqVO.getParentId()); - } - // 4. 如果有关联商机,则需要校验存在 - if (saveReqVO.getBusinessId() != null && businessService.getBusiness(saveReqVO.getBusinessId()) == null) { - throw exception(BUSINESS_NOT_EXISTS); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CONTACT_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteContact(Long id) { - // 1.1 校验存在 - CrmContactDO contact = validateContactExists(id); - // 1.2 校验是否关联合同 - if (contractService.getContractCountByContactId(id) > 0) { - throw exception(CONTACT_DELETE_FAIL_CONTRACT_LINK_EXISTS); - } - - // 2. 删除联系人 - contactMapper.deleteById(id); - - // 4.1 删除数据权限 - permissionService.deletePermission(CrmBizTypeEnum.CRM_CONTACT.getType(), id); - // 4.2 删除商机关联 - contactBusinessService.deleteContactBusinessByContactId(id); - - // 记录操作日志上下文 - LogRecordContext.putVariable("contactName", contact.getName()); - } - - private CrmContactDO validateContactExists(Long id) { - CrmContactDO contact = contactMapper.selectById(id); - if (contact == null) { - throw exception(CONTACT_NOT_EXISTS); - } - return contact; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", - success = CRM_CONTACT_TRANSFER_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) - public void transferContact(CrmContactTransferReqVO reqVO, Long userId) { - // 1 校验联系人是否存在 - CrmContactDO contact = validateContactExists(reqVO.getId()); - - // 2.1 数据权限转移 - permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CONTACT.getType(), - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); - // 2.2 设置新的负责人 - contactMapper.updateById(new CrmContactDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId())); - - // 3. 记录转移日志 - LogRecordContext.putVariable("contact", contact); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#customerId", level = CrmPermissionLevelEnum.OWNER) - public void updateOwnerUserIdByCustomerId(Long customerId, Long ownerUserId) { - // 1. 校验存在 - List contacts = contactMapper.selectListByCustomerId(customerId); - if (CollUtil.isEmpty(contacts)) { - return; - } - int count = contactMapper.updateOwnerUserIdByCustomerId(customerId, ownerUserId); - if (count == 0) { - throw exception(CONTACT_UPDATE_OWNER_USER_FAIL); - } - - // 2. 记录操作日志 - for (CrmContactDO contact : contacts) { - receiveContactLog(contact, ownerUserId); - } - } - - @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_UPDATE_OWNER_USER_SUB_TYPE, bizNo = "{{#contact.id}", - success = CRM_CONTACT_UPDATE_OWNER_USER_SUCCESS) - public void receiveContactLog(CrmContactDO contact, Long ownerUserId) { - // 记录操作日志上下文 - LogRecordContext.putVariable("contact", contact); - LogRecordContext.putVariable("ownerUserId", ownerUserId); - } - - @Override - @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}", - success = CRM_CONTACT_FOLLOW_UP_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void updateContactFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent) { - // 1. 校验存在 - CrmContactDO contact = validateContactExists(id); - - // 2. 更新联系人的跟进信息 - contactMapper.updateById(new CrmContactDO().setId(id).setContactNextTime(contactNextTime) - .setContactLastTime(LocalDateTime.now()).setContactLastContent(contactLastContent)); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("contactName", contact.getName()); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#ids", level = CrmPermissionLevelEnum.WRITE) - public void updateContactContactNextTime(Collection ids, LocalDateTime contactNextTime) { - contactMapper.updateBatch(convertList(ids, id -> new CrmContactDO().setId(id).setContactNextTime(contactNextTime))); - } - - //======================= 查询相关 ======================= - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmContactDO getContact(Long id) { - return contactMapper.selectById(id); - } - - @Override - public void validateContact(Long id) { - validateContactExists(id); - } - - @Override - public List getContactList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return contactMapper.selectBatchIds(ids); - } - - @Override - public List getContactList(Long userId) { - CrmContactPageReqVO reqVO = new CrmContactPageReqVO(); - reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 - return contactMapper.selectPage(reqVO, userId).getList(); - } - - @Override - public PageResult getContactPage(CrmContactPageReqVO pageReqVO, Long userId) { - return contactMapper.selectPage(pageReqVO, userId); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getContactPageByCustomerId(CrmContactPageReqVO pageVO) { - return contactMapper.selectPageByCustomerId(pageVO); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#pageVO.businessId", level = CrmPermissionLevelEnum.READ) - public PageResult getContactPageByBusinessId(CrmContactPageReqVO pageVO) { - List contactBusinessList = contactBusinessService.getContactBusinessListByBusinessId(pageVO.getBusinessId()); - if (CollUtil.isEmpty(contactBusinessList)) { - return PageResult.empty(); - } - return contactMapper.selectPageByBusinessId(pageVO, convertSet(contactBusinessList, CrmContactBusinessDO::getContactId)); - } - - @Override - public Long getContactCountByCustomerId(Long customerId) { - return contactMapper.selectCount(CrmContactDO::getCustomerId, customerId); - } - - @Override - public List getContactListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { - return contactMapper.selectListByCustomerIdOwnerUserId(customerId, ownerUserId); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractConfigService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractConfigService.java deleted file mode 100644 index 39a06649a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractConfigService.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract; - -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config.CrmContractConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO; - -import javax.validation.Valid; - -/** - * 合同配置 Service 接口 - * - * @author 芋道源码 - */ -public interface CrmContractConfigService { - - /** - * 获得合同配置 - * - * @return 合同配置 - */ - CrmContractConfigDO getContractConfig(); - - /** - * 保存合同配置 - * - * @param saveReqVO 更新信息 - */ - void saveContractConfig(@Valid CrmContractConfigSaveReqVO saveReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractConfigServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractConfigServiceImpl.java deleted file mode 100644 index 2580cc30c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractConfigServiceImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract; - -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config.CrmContractConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractConfigMapper; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.starter.annotation.LogRecord; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Objects; - -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -/** - * 合同配置 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CrmContractConfigServiceImpl implements CrmContractConfigService { - - @Resource - private CrmContractConfigMapper contractConfigMapper; - - @Override - public CrmContractConfigDO getContractConfig() { - return contractConfigMapper.selectOne(); - } - - @Override - @LogRecord(type = CRM_CONTRACT_CONFIG_TYPE, subType = CRM_CONTRACT_CONFIG_SUB_TYPE, bizNo = "{{#configId}}", - success = CRM_CONTRACT_CONFIG_SUCCESS) - public void saveContractConfig(CrmContractConfigSaveReqVO saveReqVO) { - // 1. 存在,则进行更新 - CrmContractConfigDO dbConfig = getContractConfig(); - CrmContractConfigDO config = BeanUtils.toBean(saveReqVO, CrmContractConfigDO.class); - if (Objects.nonNull(dbConfig)) { - contractConfigMapper.updateById(config.setId(dbConfig.getId())); - // 记录操作日志上下文 - LogRecordContext.putVariable("isConfigUpdate", Boolean.TRUE); - LogRecordContext.putVariable("configId", config.getId()); - return; - } - - // 2. 不存在,则进行插入 - contractConfigMapper.insert(config); - // 记录操作日志上下文 - LogRecordContext.putVariable("isConfigUpdate", Boolean.FALSE); - LogRecordContext.putVariable("configId", config.getId()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java deleted file mode 100644 index f7a686759..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java +++ /dev/null @@ -1,205 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * CRM 合同 Service 接口 - * - * @author dhb52 - */ -public interface CrmContractService { - - /** - * 创建合同 - * - * @param createReqVO 创建信息 - * @param userId 用户编号 - * @return 编号 - */ - Long createContract(@Valid CrmContractSaveReqVO createReqVO, Long userId); - - /** - * 更新合同 - * - * @param updateReqVO 更新信息 - */ - void updateContract(@Valid CrmContractSaveReqVO updateReqVO); - - /** - * 删除合同 - * - * @param id 编号 - */ - void deleteContract(Long id); - - /** - * 合同转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferContract(CrmContractTransferReqVO reqVO, Long userId); - - /** - * 更新合同相关的更进信息 - * - * @param id 合同编号 - * @param contactNextTime 下次联系时间 - * @param contactLastContent 最后联系内容 - */ - void updateContractFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); - - /** - * 发起合同审批流程 - * - * @param id 合同编号 - * @param userId 用户编号 - */ - void submitContract(Long id, Long userId); - - /** - * 更新合同流程审批结果 - * - * @param id 合同编号 - * @param bpmResult BPM 审批结果 - */ - void updateContractAuditStatus(Long id, Integer bpmResult); - - /** - * 获得合同 - * - * @param id 编号 - * @return 合同 - */ - CrmContractDO getContract(Long id); - - /** - * 校验合同是否合法 - * - * @param id 编号 - * @return 合同 - */ - CrmContractDO validateContract(Long id); - - /** - * 获得合同列表 - * - * @param ids 编号 - * @return 合同列表 - */ - List getContractList(Collection ids); - - /** - * 获得合同 Map - * - * @param ids 编号 - * @return 合同 Map - */ - default Map getContractMap(Collection ids) { - return convertMap(getContractList(ids), CrmContractDO::getId); - } - - /** - * 获得合同分页 - * - * 数据权限:基于 {@link CrmContractDO} 读取 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 合同分页 - */ - PageResult getContractPage(CrmContractPageReqVO pageReqVO, Long userId); - - /** - * 获得合同分页,基于指定客户 - * - * 数据权限:基于 {@link CrmCustomerDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 合同分页 - */ - PageResult getContractPageByCustomerId(CrmContractPageReqVO pageReqVO); - - /** - * 获得合同分页,基于指定商机 - * - * 数据权限:基于 {@link CrmBusinessDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 合同分页 - */ - PageResult getContractPageByBusinessId(CrmContractPageReqVO pageReqVO); - - /** - * 查询属于某个联系人的合同数量 - * - * @param contactId 联系人ID - * @return 合同 - */ - Long getContractCountByContactId(Long contactId); - - /** - * 获取关联客户的合同数量 - * - * @param customerId 客户编号 - * @return 数量 - */ - Long getContractCountByCustomerId(Long customerId); - - /** - * 根据商机编号,获取关联客户的合同数量 - * - * @param businessId 商机编号 - * @return 数量 - */ - Long getContractCountByBusinessId(Long businessId); - - /** - * 根据合同编号,获得合同的产品列表 - * - * @param contactId 合同编号 - * @return 产品列表 - */ - List getContractProductListByContractId(Long contactId); - - /** - * 获得待审核合同数量 - * - * @param userId 用户编号 - * @return 提醒数量 - */ - Long getAuditContractCount(Long userId); - - /** - * 获得即将到期(提醒)的合同数量 - * - * @param userId 用户编号 - * @return 提醒数量 - */ - Long getRemindContractCount(Long userId); - - /** - * 获得合同列表 - * - * @param customerId 客户编号 - * @param ownerUserId 负责人编号 - * @return 合同列表 - */ - List getContractListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java deleted file mode 100644 index bcf5d9a9d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java +++ /dev/null @@ -1,415 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper; -import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractProductMapper; -import cn.iocoder.yudao.module.crm.dal.redis.no.CrmNoRedisDAO; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.crm.service.product.CrmProductService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; -import static cn.iocoder.yudao.module.crm.util.CrmAuditStatusUtils.convertBpmResultToAuditStatus; - -/** - * CRM 合同 Service 实现类 - * - * @author dhb52 - */ -@Service -@Validated -@Slf4j -public class CrmContractServiceImpl implements CrmContractService { - - /** - * BPM 合同审批流程标识 - */ - public static final String BPM_PROCESS_DEFINITION_KEY = "crm-contract-audit"; - - @Resource - private CrmContractMapper contractMapper; - @Resource - private CrmContractProductMapper contractProductMapper; - - @Resource - private CrmNoRedisDAO noRedisDAO; - - @Resource - private CrmPermissionService crmPermissionService; - @Resource - private CrmProductService productService; - @Resource - private CrmCustomerService customerService; - @Resource - private CrmBusinessService businessService; - @Resource - private CrmContactService contactService; - @Resource - private CrmContractConfigService contractConfigService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private CrmReceivableService receivableService; - @Resource - private AdminUserApi adminUserApi; - @Resource - private BpmProcessInstanceApi bpmProcessInstanceApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_CREATE_SUB_TYPE, bizNo = "{{#contract.id}}", - success = CRM_CONTRACT_CREATE_SUCCESS) - public Long createContract(CrmContractSaveReqVO createReqVO, Long userId) { - // 1.1 校验产品项的有效性 - List contractProducts = validateContractProducts(createReqVO.getProducts()); - // 1.2 校验关联字段 - validateRelationDataExists(createReqVO); - // 1.3 生成序号 - String no = noRedisDAO.generate(CrmNoRedisDAO.CONTRACT_NO_PREFIX); - if (contractMapper.selectByNo(no) != null) { - throw exception(CONTRACT_NO_EXISTS); - } - - // 2.1 插入合同 - CrmContractDO contract = BeanUtils.toBean(createReqVO, CrmContractDO.class).setNo(no); - calculateTotalPrice(contract, contractProducts); - contractMapper.insert(contract); - // 2.2 插入合同关联商品 - if (CollUtil.isNotEmpty(contractProducts)) { - contractProducts.forEach(item -> item.setContractId(contract.getId())); - contractProductMapper.insertBatch(contractProducts); - } - - // 3. 创建数据权限 - crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(contract.getOwnerUserId()) - .setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType()).setBizId(contract.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("contract", contract); - return contract.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_CONTRACT_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateContract(CrmContractSaveReqVO updateReqVO) { - Assert.notNull(updateReqVO.getId(), "合同编号不能为空"); - updateReqVO.setOwnerUserId(null); // 不允许更新的字段 - // 1.1 校验存在 - CrmContractDO contract = validateContractExists(updateReqVO.getId()); - // 1.2 只有草稿、审批中,可以编辑; - if (!ObjectUtils.equalsAny(contract.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus(), - CrmAuditStatusEnum.PROCESS.getStatus())) { - throw exception(CONTRACT_UPDATE_FAIL_NOT_DRAFT); - } - // 1.3 校验产品项的有效性 - List contractProducts = validateContractProducts(updateReqVO.getProducts()); - // 1.4 校验关联字段 - validateRelationDataExists(updateReqVO); - - // 2.1 更新合同 - CrmContractDO updateObj = BeanUtils.toBean(updateReqVO, CrmContractDO.class); - calculateTotalPrice(updateObj, contractProducts); - contractMapper.updateById(updateObj); - // 2.2 更新合同关联商品 - updateContractProduct(updateReqVO.getId(), contractProducts); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(contract, CrmContractSaveReqVO.class)); - LogRecordContext.putVariable("contractName", contract.getName()); - } - - private void updateContractProduct(Long id, List newList) { - List oldList = contractProductMapper.selectListByContractId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setContractId(id)); - contractProductMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - contractProductMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - contractProductMapper.deleteBatchIds(convertSet(diffList.get(2), CrmContractProductDO::getId)); - } - } - - /** - * 校验关联数据是否存在 - * - * @param reqVO 请求 - */ - private void validateRelationDataExists(CrmContractSaveReqVO reqVO) { - // 1. 校验客户 - if (reqVO.getCustomerId() != null) { - customerService.validateCustomer(reqVO.getCustomerId()); - } - // 2. 校验负责人 - if (reqVO.getOwnerUserId() != null) { - adminUserApi.validateUser(reqVO.getOwnerUserId()); - } - // 3. 如果有关联商机,则需要校验存在 - if (reqVO.getBusinessId() != null) { - businessService.validateBusiness(reqVO.getBusinessId()); - } - // 4. 校验签约相关字段 - if (reqVO.getSignContactId() != null) { - contactService.validateContact(reqVO.getSignContactId()); - } - if (reqVO.getSignUserId() != null) { - adminUserApi.validateUser(reqVO.getSignUserId()); - } - } - - private List validateContractProducts(List list) { - // 1. 校验产品存在 - productService.validProductList(convertSet(list, CrmContractSaveReqVO.Product::getProductId)); - // 2. 转化为 CrmContractProductDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, CrmContractProductDO.class, - item -> item.setTotalPrice(MoneyUtils.priceMultiply(item.getContractPrice(), item.getCount())))); - } - - private void calculateTotalPrice(CrmContractDO contract, List contractProducts) { - contract.setTotalProductPrice(getSumValue(contractProducts, CrmContractProductDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - BigDecimal discountPrice = MoneyUtils.priceMultiplyPercent(contract.getTotalProductPrice(), contract.getDiscountPercent()); - contract.setTotalPrice(contract.getTotalProductPrice().subtract(discountPrice)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CONTRACT_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteContract(Long id) { - // 1.1 校验存在 - CrmContractDO contract = validateContractExists(id); - // 1.2 如果被 CrmReceivableDO 所使用,则不允许删除 - if (receivableService.getReceivableCountByContractId(contract.getId()) > 0) { - throw exception(CONTRACT_DELETE_FAIL); - } - - // 2.1 删除合同 - contractMapper.deleteById(id); - // 2.2 删除数据权限 - crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CONTRACT.getType(), id); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("contractName", contract.getName()); - } - - private CrmContractDO validateContractExists(Long id) { - CrmContractDO contract = contractMapper.selectById(id); - if (contract == null) { - throw exception(CONTRACT_NOT_EXISTS); - } - return contract; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", - success = CRM_CONTRACT_TRANSFER_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) - public void transferContract(CrmContractTransferReqVO reqVO, Long userId) { - // 1. 校验合同是否存在 - CrmContractDO contract = validateContractExists(reqVO.getId()); - - // 2.1 数据权限转移 - crmPermissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CONTRACT.getType(), - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); - // 2.2 设置负责人 - contractMapper.updateById(new CrmContractDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId())); - - // 3. 记录转移日志 - LogRecordContext.putVariable("contract", contract); - } - - @Override - @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}", - success = CRM_CONTRACT_FOLLOW_UP_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void updateContractFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent) { - // 1. 校验存在 - CrmContractDO contract = validateContractExists(id); - - // 2. 更新联系人的跟进信息 - contractMapper.updateById(new CrmContractDO().setId(id).setContactLastTime(LocalDateTime.now())); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("contractName", contract.getName()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_SUBMIT_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CONTRACT_SUBMIT_SUCCESS) - public void submitContract(Long id, Long userId) { - // 1. 校验合同是否在审批 - CrmContractDO contract = validateContractExists(id); - if (ObjUtil.notEqual(contract.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus())) { - throw exception(CONTRACT_SUBMIT_FAIL_NOT_DRAFT); - } - - // 2. 创建合同审批流程实例 - String processInstanceId = bpmProcessInstanceApi.createProcessInstance(userId, new BpmProcessInstanceCreateReqDTO() - .setProcessDefinitionKey(BPM_PROCESS_DEFINITION_KEY).setBusinessKey(String.valueOf(id))).getCheckedData(); - - // 3. 更新合同工作流编号 - contractMapper.updateById(new CrmContractDO().setId(id).setProcessInstanceId(processInstanceId) - .setAuditStatus(CrmAuditStatusEnum.PROCESS.getStatus())); - - // 3. 记录日志 - LogRecordContext.putVariable("contractName", contract.getName()); - } - - @Override - public void updateContractAuditStatus(Long id, Integer bpmResult) { - // 1.1 校验合同是否存在 - CrmContractDO contract = validateContractExists(id); - // 1.2 只有审批中,可以更新审批结果 - if (ObjUtil.notEqual(contract.getAuditStatus(), CrmAuditStatusEnum.PROCESS.getStatus())) { - log.error("[updateContractAuditStatus][contract({}) 不处于审批中,无法更新审批结果({})]", - contract.getId(), bpmResult); - throw exception(CONTRACT_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS); - } - - // 2. 更新合同审批结果 - Integer auditStatus = convertBpmResultToAuditStatus(bpmResult); - contractMapper.updateById(new CrmContractDO().setId(id).setAuditStatus(auditStatus)); - } - - // ======================= 查询相关 ======================= - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmContractDO getContract(Long id) { - return contractMapper.selectById(id); - } - - @Override - public CrmContractDO validateContract(Long id) { - return validateContractExists(id); - } - - @Override - public List getContractList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return contractMapper.selectBatchIds(ids); - } - - @Override - public PageResult getContractPage(CrmContractPageReqVO pageReqVO, Long userId) { - // 1. 即将到期,需要查询合同配置 - CrmContractConfigDO config = null; - if (CrmContractPageReqVO.EXPIRY_TYPE_ABOUT_TO_EXPIRE.equals(pageReqVO.getExpiryType())) { - config = contractConfigService.getContractConfig(); - if (config != null && Boolean.FALSE.equals(config.getNotifyEnabled())) { - config = null; - } - if (config == null) { - return PageResult.empty(); - } - } - // 2. 查询分页 - return contractMapper.selectPage(pageReqVO, userId, config); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getContractPageByCustomerId(CrmContractPageReqVO pageReqVO) { - return contractMapper.selectPageByCustomerId(pageReqVO); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#pageReqVO.businessId", level = CrmPermissionLevelEnum.READ) - public PageResult getContractPageByBusinessId(CrmContractPageReqVO pageReqVO) { - return contractMapper.selectPageByBusinessId(pageReqVO); - } - - @Override - public Long getContractCountByContactId(Long contactId) { - return contractMapper.selectCountByContactId(contactId); - } - - @Override - public Long getContractCountByCustomerId(Long customerId) { - return contractMapper.selectCount(CrmContractDO::getCustomerId, customerId); - } - - @Override - public Long getContractCountByBusinessId(Long businessId) { - return contractMapper.selectCountByBusinessId(businessId); - } - - @Override - public List getContractProductListByContractId(Long contactId) { - return contractProductMapper.selectListByContractId(contactId); - } - - @Override - public Long getAuditContractCount(Long userId) { - return contractMapper.selectCountByAudit(userId); - } - - @Override - public Long getRemindContractCount(Long userId) { - CrmContractConfigDO config = contractConfigService.getContractConfig(); - if (config == null || Boolean.FALSE.equals(config.getNotifyEnabled())) { - return 0L; - } - return contractMapper.selectCountByRemind(userId, config); - } - - @Override - public List getContractListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { - return contractMapper.selectListByCustomerIdOwnerUserId(customerId, ownerUserId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/listener/CrmContractStatusListener.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/listener/CrmContractStatusListener.java deleted file mode 100644 index b3c07353a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/listener/CrmContractStatusListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract.listener; - -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent; -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractServiceImpl; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 合同审批的结果的监听器实现类 - * - * @author HUIHUI - */ -@Component -public class CrmContractStatusListener extends BpmProcessInstanceStatusEventListener { - - @Resource - private CrmContractService contractService; - - @Override - public String getProcessDefinitionKey() { - return CrmContractServiceImpl.BPM_PROCESS_DEFINITION_KEY; - } - - @Override - protected void onEvent(BpmProcessInstanceStatusEvent event) { - contractService.updateContractAuditStatus(Long.parseLong(event.getBusinessKey()), event.getStatus()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigService.java deleted file mode 100644 index 40a6f7015..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigService.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import javax.validation.Valid; - -import java.util.List; - -/** - * 客户限制配置 Service 接口 - * - * @author Wanwan - */ -public interface CrmCustomerLimitConfigService { - - /** - * 创建客户限制配置 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCustomerLimitConfig(@Valid CrmCustomerLimitConfigSaveReqVO createReqVO); - - /** - * 更新客户限制配置 - * - * @param updateReqVO 更新信息 - */ - void updateCustomerLimitConfig(@Valid CrmCustomerLimitConfigSaveReqVO updateReqVO); - - /** - * 删除客户限制配置 - * - * @param id 编号 - */ - void deleteCustomerLimitConfig(Long id); - - /** - * 获得客户限制配置 - * - * @param id 编号 - * @return 客户限制配置 - */ - CrmCustomerLimitConfigDO getCustomerLimitConfig(Long id); - - /** - * 获得客户限制配置分页 - * - * @param pageReqVO 分页查询 - * @return 客户限制配置分页 - */ - PageResult getCustomerLimitConfigPage(CrmCustomerLimitConfigPageReqVO pageReqVO); - - /** - * 查询用户对应的配置列表 - * - * @param type 类型 - * @param userId 用户类型 - */ - List getCustomerLimitConfigListByUserId(Integer type, Long userId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java deleted file mode 100644 index fa09fb5da..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java +++ /dev/null @@ -1,124 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; -import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_LIMIT_CONFIG_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -/** - * 客户限制配置 Service 实现类 - * - * @author Wanwan - */ -@Service -@Validated -public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfigService { - - @Resource - private CrmCustomerLimitConfigMapper customerLimitConfigMapper; - - @Resource - private DeptApi deptApi; - @Resource - private AdminUserApi adminUserApi; - - @Override - @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE, bizNo = "{{#limitId}}", - success = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS) - public Long createCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO createReqVO) { - validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds()); - // 插入 - CrmCustomerLimitConfigDO limitConfig = BeanUtils.toBean(createReqVO, CrmCustomerLimitConfigDO.class); - customerLimitConfigMapper.insert(limitConfig); - - // 记录操作日志上下文 - LogRecordContext.putVariable("limitType", CrmCustomerLimitConfigTypeEnum.getNameByType(limitConfig.getType())); - LogRecordContext.putVariable("limitId", limitConfig.getId()); - return limitConfig.getId(); - } - - @Override - @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS) - public void updateCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO updateReqVO) { - // 校验存在 - CrmCustomerLimitConfigDO oldLimitConfig = validateCustomerLimitConfigExists(updateReqVO.getId()); - validateUserAndDept(updateReqVO.getUserIds(), updateReqVO.getDeptIds()); - // 更新 - CrmCustomerLimitConfigDO updateObj = BeanUtils.toBean(updateReqVO, CrmCustomerLimitConfigDO.class); - customerLimitConfigMapper.updateById(updateObj); - - // 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldLimitConfig, CrmCustomerLimitConfigSaveReqVO.class)); - } - - @Override - @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS) - public void deleteCustomerLimitConfig(Long id) { - // 校验存在 - CrmCustomerLimitConfigDO limitConfig = validateCustomerLimitConfigExists(id); - // 删除 - customerLimitConfigMapper.deleteById(id); - - // 记录操作日志上下文 - LogRecordContext.putVariable("limitType", CrmCustomerLimitConfigTypeEnum.getNameByType(limitConfig.getType())); - } - - @Override - public CrmCustomerLimitConfigDO getCustomerLimitConfig(Long id) { - return customerLimitConfigMapper.selectById(id); - } - - @Override - public PageResult getCustomerLimitConfigPage(CrmCustomerLimitConfigPageReqVO pageReqVO) { - return customerLimitConfigMapper.selectPage(pageReqVO); - } - - private CrmCustomerLimitConfigDO validateCustomerLimitConfigExists(Long id) { - CrmCustomerLimitConfigDO limitConfigDO = customerLimitConfigMapper.selectById(id); - if (limitConfigDO == null) { - throw exception(CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); - } - return limitConfigDO; - } - - /** - * 校验入参的用户和部门 - * - * @param userIds 用户 ids - * @param deptIds 部门 ids - */ - private void validateUserAndDept(Collection userIds, Collection deptIds) { - deptApi.validateDeptList(deptIds); - adminUserApi.validateUserList(userIds); - } - - @Override - public List getCustomerLimitConfigListByUserId(Integer type, Long userId) { - AdminUserRespDTO user = adminUserApi.getUser(userId).getCheckedData(); - Assert.notNull(user, "用户({})不存在", userId); - return customerLimitConfigMapper.selectListByTypeAndUserIdAndDeptId(type, userId, user.getDeptId()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigService.java deleted file mode 100644 index 5a7c91842..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigService.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; - -import javax.validation.Valid; - -/** - * 客户公海配置 Service 接口 - * - * @author Wanwan - */ -public interface CrmCustomerPoolConfigService { - - /** - * 获得客户公海配置 - * - * @return 客户公海配置 - */ - CrmCustomerPoolConfigDO getCustomerPoolConfig(); - - /** - * 保存客户公海配置 - * - * @param saveReqVO 更新信息 - */ - void saveCustomerPoolConfig(@Valid CrmCustomerPoolConfigSaveReqVO saveReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java deleted file mode 100644 index d0984efa7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerPoolConfigMapper; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.starter.annotation.LogRecord; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.Objects; - -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -/** - * 客户公海配置 Service 实现类 - * - * @author Wanwan - */ -@Service -@Validated -public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigService { - - @Resource - private CrmCustomerPoolConfigMapper customerPoolConfigMapper; - - @Override - public CrmCustomerPoolConfigDO getCustomerPoolConfig() { - return customerPoolConfigMapper.selectOne(); - } - - @Override - @LogRecord(type = CRM_CUSTOMER_POOL_CONFIG_TYPE, subType = CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE, bizNo = "{{#poolConfigId}}", - success = CRM_CUSTOMER_POOL_CONFIG_SUCCESS) - public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) { - // 1. 存在,则进行更新 - CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig(); - CrmCustomerPoolConfigDO poolConfig = BeanUtils.toBean(saveReqVO, CrmCustomerPoolConfigDO.class); - if (Objects.nonNull(dbConfig)) { - customerPoolConfigMapper.updateById(poolConfig.setId(dbConfig.getId())); - // 记录操作日志上下文 - LogRecordContext.putVariable("isPoolConfigUpdate", Boolean.TRUE); - LogRecordContext.putVariable("poolConfigId", poolConfig.getId()); - return; - } - - // 2. 不存在,则进行插入 - customerPoolConfigMapper.insert(poolConfig); - // 记录操作日志上下文 - LogRecordContext.putVariable("isPoolConfigUpdate", Boolean.FALSE); - LogRecordContext.putVariable("poolConfigId", poolConfig.getId()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java deleted file mode 100644 index 3a133be96..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java +++ /dev/null @@ -1,198 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.service.customer.bo.CrmCustomerCreateReqBO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 客户 Service 接口 - * - * @author Wanwan - */ -public interface CrmCustomerService { - - /** - * 创建客户 - * - * @param createReqVO 创建信息 - * @param userId 用户编号 - * @return 编号 - */ - Long createCustomer(@Valid CrmCustomerSaveReqVO createReqVO, Long userId); - - /** - * 更新客户 - * - * @param updateReqVO 更新信息 - */ - void updateCustomer(@Valid CrmCustomerSaveReqVO updateReqVO); - - /** - * 更新客户的跟进状态 - * - * @param id 编号 - * @param dealStatus 跟进状态 - */ - void updateCustomerDealStatus(Long id, Boolean dealStatus); - - /** - * 更新客户相关的跟进信息 - * - * @param id 编号 - * @param contactNextTime 下次联系时间 - * @param contactLastContent 最后联系内容 - */ - void updateCustomerFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); - - /** - * 删除客户 - * - * @param id 编号 - */ - void deleteCustomer(Long id); - - /** - * 获得客户 - * - * @param id 编号 - * @return 客户 - */ - CrmCustomerDO getCustomer(Long id); - - /** - * 获得客户列表 - * - * @param ids 客户编号数组 - * @return 客户列表 - * @author ljlleo - */ - List getCustomerList(Collection ids); - - /** - * 获得客户 Map - * - * @param ids 客户编号数组 - * @return 客户 Map - */ - default Map getCustomerMap(Collection ids) { - return convertMap(getCustomerList(ids), CrmCustomerDO::getId); - } - - /** - * 获得客户分页 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 客户分页 - */ - PageResult getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId); - - /** - * 获得放入公海提醒的客户分页 - * - * @param pageVO 分页查询 - * @param userId 用户编号 - * @return 客户分页 - */ - PageResult getPutPoolRemindCustomerPage(CrmCustomerPageReqVO pageVO, Long userId); - - /** - * 获得待进入公海的客户数量 - * - * @param userId 用户编号 - * @return 提醒数量 - */ - Long getPutPoolRemindCustomerCount(Long userId); - - /** - * 获得今日需联系客户数量 - * - * @param userId 用户编号 - * @return 提醒数量 - */ - Long getTodayContactCustomerCount(Long userId); - - /** - * 获得分配给我的客户数量 - * - * @param userId 用户编号 - * @return 提醒数量 - */ - Long getFollowCustomerCount(Long userId); - - /** - * 校验客户是否存在 - * - * @param id 编号 - */ - void validateCustomer(Long id); - - /** - * 客户转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId); - - /** - * 锁定/解锁客户 - * - * @param lockReqVO 更新信息 - * @param userId 用户编号 - */ - void lockCustomer(@Valid CrmCustomerLockReqVO lockReqVO, Long userId); - - /** - * 创建客户 - * - * @param customerCreateReq 请求信息 - * @param userId 用户编号 - * @return 客户列表 - */ - Long createCustomer(CrmCustomerCreateReqBO customerCreateReq, Long userId); - - /** - * 批量导入客户 - * - * @param importCustomers 导入客户列表 - * @param importReqVO 请求 - * @return 导入结果 - */ - CrmCustomerImportRespVO importCustomerList(List importCustomers, CrmCustomerImportReqVO importReqVO); - - // ==================== 公海相关操作 ==================== - - /** - * 客户放入公海 - * - * @param id 客户编号 - */ - void putCustomerPool(Long id); - - /** - * 领取公海客户 - * - * @param ids 要领取的客户编号数组 - * @param ownerUserId 负责人 - * @param isReceive 是/否领取;true - 领取;false - 分配 - */ - void receiveCustomer(List ids, Long ownerUserId, Boolean isReceive); - - /** - * 【系统】客户自动掉入公海 - * - * @return 掉入公海数量 - */ - int autoPutCustomerPool(); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java deleted file mode 100644 index 2ca6c9cc2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ /dev/null @@ -1,662 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.bo.CrmCustomerCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; -import static cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum.CUSTOMER_LOCK_LIMIT; -import static cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum.CUSTOMER_OWNER_LIMIT; -import static java.util.Collections.singletonList; - -/** - * 客户 Service 实现类 - * - * @author Wanwan - */ -@Service -@Slf4j -@Validated -public class CrmCustomerServiceImpl implements CrmCustomerService { - - @Resource - private CrmCustomerMapper customerMapper; - - @Resource - private CrmPermissionService permissionService; - @Resource - private CrmCustomerLimitConfigService customerLimitConfigService; - @Resource - @Lazy - private CrmCustomerPoolConfigService customerPoolConfigService; - @Resource - @Lazy - private CrmContactService contactService; - @Resource - @Lazy - private CrmBusinessService businessService; - @Resource - @Lazy - private CrmContractService contractService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}", - success = CRM_CUSTOMER_CREATE_SUCCESS) - public Long createCustomer(CrmCustomerSaveReqVO createReqVO, Long userId) { - createReqVO.setId(null); - // 1. 校验拥有客户是否到达上限 - validateCustomerExceedOwnerLimit(createReqVO.getOwnerUserId(), 1); - - // 2. 插入客户 - CrmCustomerDO customer = initCustomer(createReqVO, userId); - customerMapper.insert(customer); - - // 3. 创建数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) - .setBizId(customer.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("customer", customer); - return customer.getId(); - } - - /** - * 初始化客户的通用字段 - * - * @param customer 客户信息 - * @param ownerUserId 负责人编号 - * @return 客户信息 DO - */ - private static CrmCustomerDO initCustomer(Object customer, Long ownerUserId) { - return BeanUtils.toBean(customer, CrmCustomerDO.class).setOwnerUserId(ownerUserId) - .setOwnerTime(LocalDateTime.now()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_CUSTOMER_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateCustomer(CrmCustomerSaveReqVO updateReqVO) { - Assert.notNull(updateReqVO.getId(), "客户编号不能为空"); - updateReqVO.setOwnerUserId(null); // 更新的时候,要把 updateReqVO 负责人设置为空,避免修改 - // 1. 校验存在 - CrmCustomerDO oldCustomer = validateCustomerExists(updateReqVO.getId()); - - // 2. 更新客户 - CrmCustomerDO updateObj = BeanUtils.toBean(updateReqVO, CrmCustomerDO.class); - customerMapper.updateById(updateObj); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldCustomer, CrmCustomerSaveReqVO.class)); - LogRecordContext.putVariable("customerName", oldCustomer.getName()); - } - - @Override - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_UPDATE_DEAL_STATUS_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CUSTOMER_UPDATE_DEAL_STATUS_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void updateCustomerDealStatus(Long id, Boolean dealStatus) { - // 1.1 校验存在 - CrmCustomerDO customer = validateCustomerExists(id); - // 1.2 校验是否重复操作 - if (Objects.equals(customer.getDealStatus(), dealStatus)) { - throw exception(CUSTOMER_UPDATE_DEAL_STATUS_FAIL); - } - - // 2. 更新客户的成交状态 - customerMapper.updateById(new CrmCustomerDO().setId(id).setDealStatus(dealStatus)); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("customerName", customer.getName()); - LogRecordContext.putVariable("dealStatus", dealStatus); - } - - @Override - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}", - success = CRM_CUSTOMER_FOLLOW_UP_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) - public void updateCustomerFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent) { - // 1.1 校验存在 - CrmCustomerDO customer = validateCustomerExists(id); - - // 2. 更新客户的跟进信息 - customerMapper.updateById(new CrmCustomerDO().setId(id).setFollowUpStatus(true).setContactNextTime(contactNextTime) - .setContactLastTime(LocalDateTime.now()).setContactLastContent(contactLastContent)); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("customerName", customer.getName()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CUSTOMER_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteCustomer(Long id) { - // 1.1 校验存在 - CrmCustomerDO customer = validateCustomerExists(id); - // 1.2 检查引用 - validateCustomerReference(id); - - // 2. 删除客户 - customerMapper.deleteById(id); - // 3. 删除数据权限 - permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), id); - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("customerName", customer.getName()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", - success = CRM_CUSTOMER_TRANSFER_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) - public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) { - // 1.1 校验客户是否存在 - CrmCustomerDO customer = validateCustomerExists(reqVO.getId()); - // 1.2 校验拥有客户是否到达上限 - validateCustomerExceedOwnerLimit(reqVO.getNewOwnerUserId(), 1); - // 2.1 数据权限转移 - permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CUSTOMER.getType(), - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); - // 2.2 转移后重新设置负责人 - customerMapper.updateById(new CrmCustomerDO().setId(reqVO.getId()) - .setOwnerUserId(reqVO.getNewOwnerUserId()).setOwnerTime(LocalDateTime.now())); - - // 2.3 同时转移 - if (CollUtil.isNotEmpty(reqVO.getToBizTypes())) { - transfer(reqVO, userId); - } - - // 3. 记录转移日志 - LogRecordContext.putVariable("customer", customer); - } - - /** - * 转移客户时,需要额外有【联系人】【商机】【合同】 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - private void transfer(CrmCustomerTransferReqVO reqVO, Long userId) { - if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTACT.getType())) { - List contactList = contactService.getContactListByCustomerIdOwnerUserId(reqVO.getId(), userId); - contactList.forEach(item -> { - contactService.transferContact(new CrmContactTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(), - reqVO.getOldOwnerPermissionLevel()), userId); - }); - } - if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_BUSINESS.getType())) { - List businessList = businessService.getBusinessListByCustomerIdOwnerUserId(reqVO.getId(), userId); - businessList.forEach(item -> { - businessService.transferBusiness(new CrmBusinessTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(), - reqVO.getOldOwnerPermissionLevel()), userId); - }); - } - if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTRACT.getType())) { - List contractList = contractService.getContractListByCustomerIdOwnerUserId(reqVO.getId(), userId); - contractList.forEach(item -> { - contractService.transferContract(new CrmContractTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(), - reqVO.getOldOwnerPermissionLevel()), userId); - }); - } - } - - @Override - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_LOCK_SUB_TYPE, bizNo = "{{#lockReqVO.id}}", - success = CRM_CUSTOMER_LOCK_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#lockReqVO.id", level = CrmPermissionLevelEnum.OWNER) - public void lockCustomer(CrmCustomerLockReqVO lockReqVO, Long userId) { - // 1.1 校验当前客户是否存在 - CrmCustomerDO customer = validateCustomerExists(lockReqVO.getId()); - // 1.2 校验当前是否重复操作锁定/解锁状态 - if (customer.getLockStatus().equals(lockReqVO.getLockStatus())) { - throw exception(customer.getLockStatus() ? CUSTOMER_LOCK_FAIL_IS_LOCK : CUSTOMER_UNLOCK_FAIL_IS_UNLOCK); - } - // 1.3 校验锁定上限 - if (lockReqVO.getLockStatus()) { - validateCustomerExceedLockLimit(userId); - } - - // 2. 更新锁定状态 - customerMapper.updateById(BeanUtils.toBean(lockReqVO, CrmCustomerDO.class)); - - // 3. 记录操作日志上下文 - // tips: 因为这里使用的是老的状态所以记录时反着记录,也就是 lockStatus 为 true 那么就是解锁反之为锁定 - LogRecordContext.putVariable("customer", customer); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}", - success = CRM_CUSTOMER_CREATE_SUCCESS) - public Long createCustomer(CrmCustomerCreateReqBO createReqBO, Long userId) { - // 1. 插入客户 - CrmCustomerDO customer = initCustomer(createReqBO, userId); - customerMapper.insert(customer); - - // 2. 创建数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) - .setBizId(customer.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("customer", customer); - return customer.getId(); - } - - @Override - public CrmCustomerImportRespVO importCustomerList(List importCustomers, - CrmCustomerImportReqVO importReqVO) { - // 校验非空 - importCustomers = filterList(importCustomers, item -> Objects.nonNull(item.getName())); - if (CollUtil.isEmpty(importCustomers)) { - throw exception(CUSTOMER_IMPORT_LIST_IS_EMPTY); - } - - // 逐条处理 - CrmCustomerImportRespVO respVO = CrmCustomerImportRespVO.builder().createCustomerNames(new ArrayList<>()) - .updateCustomerNames(new ArrayList<>()).failureCustomerNames(new LinkedHashMap<>()).build(); - importCustomers.forEach(importCustomer -> { - // 校验,判断是否有不符合的原因 - try { - validateCustomerForCreate(importCustomer); - } catch (ServiceException ex) { - respVO.getFailureCustomerNames().put(importCustomer.getName(), ex.getMessage()); - return; - } - // 情况一:判断如果不存在,在进行插入 - CrmCustomerDO existCustomer = customerMapper.selectByCustomerName(importCustomer.getName()); - if (existCustomer == null) { - // 1.1 插入客户信息 - CrmCustomerDO customer = initCustomer(importCustomer, importReqVO.getOwnerUserId()); - customerMapper.insert(customer); - respVO.getCreateCustomerNames().add(importCustomer.getName()); - // 1.2 创建数据权限 - if (importReqVO.getOwnerUserId() != null) { - permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) - .setBizId(customer.getId()).setUserId(importReqVO.getOwnerUserId()).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - } - // 1.3 记录操作日志 - getSelf().importCustomerLog(customer, false); - return; - } - - // 情况二:如果存在,判断是否允许更新 - if (!importReqVO.getUpdateSupport()) { - respVO.getFailureCustomerNames().put(importCustomer.getName(), - StrUtil.format(CUSTOMER_NAME_EXISTS.getMsg(), importCustomer.getName())); - return; - } - // 2.1 更新客户信息 - CrmCustomerDO updateCustomer = BeanUtils.toBean(importCustomer, CrmCustomerDO.class) - .setId(existCustomer.getId()); - customerMapper.updateById(updateCustomer); - respVO.getUpdateCustomerNames().add(importCustomer.getName()); - // 2.2 记录操作日志 - getSelf().importCustomerLog(updateCustomer, true); - }); - return respVO; - } - - /** - * 记录导入客户时的操作日志 - * - * @param customer 客户信息 - * @param isUpdate 是否更新;true - 更新,false - 新增 - */ - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_IMPORT_SUB_TYPE, bizNo = "{{#customer.id}}", - success = CRM_CUSTOMER_IMPORT_SUCCESS) - public void importCustomerLog(CrmCustomerDO customer, boolean isUpdate) { - LogRecordContext.putVariable("customer", customer); - LogRecordContext.putVariable("isUpdate", isUpdate); - } - - // ==================== 公海相关操作 ==================== - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_POOL_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_CUSTOMER_POOL_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void putCustomerPool(Long id) { - // 1. 校验存在 - CrmCustomerDO customer = customerMapper.selectById(id); - if (customer == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - // 1.2. 校验是否为公海数据 - validateCustomerOwnerExists(customer, true); - // 1.3. 校验客户是否锁定 - validateCustomerIsLocked(customer, true); - - // 2. 客户放入公海 - putCustomerPool(customer); - - // 记录操作日志上下文 - LogRecordContext.putVariable("customerName", customer.getName()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void receiveCustomer(List ids, Long ownerUserId, Boolean isReceive) { - // 1.1 校验存在 - List customers = customerMapper.selectBatchIds(ids); - if (customers.size() != ids.size()) { - throw exception(CUSTOMER_NOT_EXISTS); - } - // 1.2 校验负责人是否存在 - adminUserApi.validateUserList(singletonList(ownerUserId)); - // 1.3 校验状态 - customers.forEach(customer -> { - // 校验是否已有负责人 - validateCustomerOwnerExists(customer, false); - // 校验是否锁定 - validateCustomerIsLocked(customer, false); - // 校验成交状态 - validateCustomerDeal(customer); - }); - // 1.4 校验负责人是否到达上限 - validateCustomerExceedOwnerLimit(ownerUserId, customers.size()); - - // 2. 领取公海数据 - List updateCustomers = new ArrayList<>(); - List createPermissions = new ArrayList<>(); - customers.forEach(customer -> { - // 2.1. 设置负责人 - updateCustomers.add(new CrmCustomerDO().setId(customer.getId()) - .setOwnerUserId(ownerUserId).setOwnerTime(LocalDateTime.now())); - // 2.2. 创建负责人数据权限 - createPermissions.add(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) - .setBizId(customer.getId()).setUserId(ownerUserId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - }); - // 2.2 更新客户负责人 - customerMapper.updateBatch(updateCustomers); - // 2.3 创建负责人数据权限 - permissionService.createPermissionBatch(createPermissions); - // TODO @芋艿:要不要处理关联的联系人??? - - // 3. 记录操作日志 - AdminUserRespDTO user = null; - if (!isReceive) { - user = adminUserApi.getUser(ownerUserId).getCheckedData(); - } - for (CrmCustomerDO customer : customers) { - getSelf().receiveCustomerLog(customer, user == null ? null : user.getNickname()); - } - } - - @Override - public int autoPutCustomerPool() { - CrmCustomerPoolConfigDO poolConfig = customerPoolConfigService.getCustomerPoolConfig(); - if (poolConfig == null || !poolConfig.getEnabled()) { - return 0; - } - // 1. 获得需要放到的客户列表 - List customerList = customerMapper.selectListByAutoPool(poolConfig); - // 2. 逐个放入公海 - int count = 0; - for (CrmCustomerDO customer : customerList) { - try { - getSelf().putCustomerPool(customer); - count++; - } catch (Throwable e) { - log.error("[autoPutCustomerPool][客户({}) 放入公海异常]", customer.getId(), e); - } - } - return count; - } - - @Transactional(rollbackFor = Exception.class) // 需要 protected 修饰,因为需要在事务中调用 - protected void putCustomerPool(CrmCustomerDO customer) { - // 1. 设置负责人为 NULL - int updateOwnerUserIncr = customerMapper.updateOwnerUserIdById(customer.getId(), null); - if (updateOwnerUserIncr == 0) { - throw exception(CUSTOMER_UPDATE_OWNER_USER_FAIL); - } - - // 2. 联系人的负责人,也要设置为 null。因为:因为领取后,负责人也要关联过来,这块和 receiveCustomer 是对应的 - contactService.updateOwnerUserIdByCustomerId(customer.getId(), null); - - // 3. 删除负责人数据权限 - // 注意:需要放在 contactService 后面,不然【客户】数据权限已经被删除,无法操作! - permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(), - CrmPermissionLevelEnum.OWNER.getLevel()); - } - - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}", - success = CRM_CUSTOMER_RECEIVE_SUCCESS) - public void receiveCustomerLog(CrmCustomerDO customer, String ownerUserName) { - // 记录操作日志上下文 - LogRecordContext.putVariable("customer", customer); - LogRecordContext.putVariable("ownerUserName", ownerUserName); - } - - //======================= 查询相关 ======================= - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmCustomerDO getCustomer(Long id) { - return customerMapper.selectById(id); - } - - @Override - public List getCustomerList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return customerMapper.selectBatchIds(ids); - } - - @Override - public PageResult getCustomerPage(CrmCustomerPageReqVO pageReqVO, Long userId) { - return customerMapper.selectPage(pageReqVO, userId); - } - - @Override - public PageResult getPutPoolRemindCustomerPage(CrmCustomerPageReqVO pageVO, Long userId) { - CrmCustomerPoolConfigDO poolConfig = customerPoolConfigService.getCustomerPoolConfig(); - if (ObjUtil.isNull(poolConfig) - || Boolean.FALSE.equals(poolConfig.getEnabled()) - || Boolean.FALSE.equals(poolConfig.getNotifyEnabled())) { - return PageResult.empty(); - } - return customerMapper.selectPutPoolRemindCustomerPage(pageVO, poolConfig, userId); - } - - @Override - public Long getPutPoolRemindCustomerCount(Long userId) { - CrmCustomerPoolConfigDO poolConfig = customerPoolConfigService.getCustomerPoolConfig(); - if (ObjUtil.isNull(poolConfig) - || Boolean.FALSE.equals(poolConfig.getEnabled()) - || Boolean.FALSE.equals(poolConfig.getNotifyEnabled())) { - return 0L; - } - CrmCustomerPageReqVO pageVO = new CrmCustomerPageReqVO() - .setPool(null) - .setContactStatus(CrmCustomerPageReqVO.CONTACT_TODAY) - .setSceneType(CrmSceneTypeEnum.OWNER.getType()); - return customerMapper.selectPutPoolRemindCustomerCount(pageVO, poolConfig, userId); - } - - @Override - public Long getTodayContactCustomerCount(Long userId) { - return customerMapper.selectCountByTodayContact(userId); - } - - @Override - public Long getFollowCustomerCount(Long userId) { - return customerMapper.selectCountByFollow(userId); - } - - // ======================= 校验相关 ======================= - - private void validateCustomerForCreate(CrmCustomerImportExcelVO importCustomer) { - // 校验客户名称不能为空 - if (StrUtil.isEmptyIfStr(importCustomer.getName())) { - throw exception(CUSTOMER_CREATE_NAME_NOT_NULL); - } - } - - /** - * 校验客户是否被引用 - * - * @param id 客户编号 - */ - private void validateCustomerReference(Long id) { - if (contactService.getContactCountByCustomerId(id) > 0) { - throw exception(CUSTOMER_DELETE_FAIL_HAVE_REFERENCE, CrmBizTypeEnum.CRM_CONTACT.getName()); - } - if (businessService.getBusinessCountByCustomerId(id) > 0) { - throw exception(CUSTOMER_DELETE_FAIL_HAVE_REFERENCE, CrmBizTypeEnum.CRM_BUSINESS.getName()); - } - if (contractService.getContractCountByCustomerId(id) > 0) { - throw exception(CUSTOMER_DELETE_FAIL_HAVE_REFERENCE, CrmBizTypeEnum.CRM_CONTRACT.getName()); - } - } - - /** - * 校验客户是否存在 - * - * @param id 客户 id - */ - @Override - public void validateCustomer(Long id) { - validateCustomerExists(id); - } - - private void validateCustomerOwnerExists(CrmCustomerDO customer, Boolean pool) { - if (customer == null) { // 防御一下 - throw exception(CUSTOMER_NOT_EXISTS); - } - // 校验是否为公海数据 - if (pool && customer.getOwnerUserId() == null) { - throw exception(CUSTOMER_IN_POOL, customer.getName()); - } - // 负责人已存在 - if (!pool && customer.getOwnerUserId() != null) { - throw exception(CUSTOMER_OWNER_EXISTS, customer.getName()); - } - } - - private CrmCustomerDO validateCustomerExists(Long id) { - CrmCustomerDO customerDO = customerMapper.selectById(id); - if (customerDO == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - return customerDO; - } - - private void validateCustomerIsLocked(CrmCustomerDO customer, Boolean pool) { - if (customer.getLockStatus()) { - throw exception(pool ? CUSTOMER_LOCKED_PUT_POOL_FAIL : CUSTOMER_LOCKED, customer.getName()); - } - } - - private void validateCustomerDeal(CrmCustomerDO customer) { - if (customer.getDealStatus()) { - throw exception(CUSTOMER_ALREADY_DEAL); - } - } - - /** - * 校验用户拥有的客户数量,是否到达上限 - * - * @param userId 用户编号 - * @param newCount 附加数量 - */ - private void validateCustomerExceedOwnerLimit(Long userId, int newCount) { - List limitConfigs = customerLimitConfigService.getCustomerLimitConfigListByUserId( - CUSTOMER_OWNER_LIMIT.getType(), userId); - if (CollUtil.isEmpty(limitConfigs)) { - return; - } - Long ownerCount = customerMapper.selectCountByDealStatusAndOwnerUserId(null, userId); - Long dealOwnerCount = customerMapper.selectCountByDealStatusAndOwnerUserId(true, userId); - limitConfigs.forEach(limitConfig -> { - long nowCount = limitConfig.getDealCountEnabled() ? ownerCount : ownerCount - dealOwnerCount; - if (nowCount + newCount > limitConfig.getMaxCount()) { - throw exception(CUSTOMER_OWNER_EXCEED_LIMIT); - } - }); - } - - /** - * 校验用户锁定的客户数量,是否到达上限 - * - * @param userId 用户编号 - */ - private void validateCustomerExceedLockLimit(Long userId) { - List limitConfigs = customerLimitConfigService.getCustomerLimitConfigListByUserId( - CUSTOMER_LOCK_LIMIT.getType(), userId); - if (CollUtil.isEmpty(limitConfigs)) { - return; - } - Long lockCount = customerMapper.selectCountByLockStatusAndOwnerUserId(true, userId); - Integer maxCount = CollectionUtils.getMaxValue(limitConfigs, CrmCustomerLimitConfigDO::getMaxCount); - assert maxCount != null; - if (lockCount >= maxCount) { - throw exception(CUSTOMER_LOCK_EXCEED_LIMIT); - } - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private CrmCustomerServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/bo/CrmCustomerCreateReqBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/bo/CrmCustomerCreateReqBO.java deleted file mode 100644 index 87a6b3387..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/bo/CrmCustomerCreateReqBO.java +++ /dev/null @@ -1,121 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.customer.bo; - -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.framework.common.validation.Telephone; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Size; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 客户创建 Create Req BO - * - * @author HUIHUI - */ -@Data -public class CrmCustomerCreateReqBO { - - /** - * 客户名称 - */ - @NotEmpty(message = "客户名称不能为空") - private String name; - /** - * 跟进状态 - */ - private Boolean followUpStatus; - /** - * 锁定状态 - */ - private Boolean lockStatus; - /** - * 成交状态 - */ - private Boolean dealStatus; - /** - * 所属行业 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_INDUSTRY} - */ - private Integer industryId; - /** - * 客户等级 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_LEVEL} - */ - private Integer level; - /** - * 客户来源 - * - * 对应字典 {@link DictTypeConstants#CRM_CUSTOMER_SOURCE} - */ - private Integer source; - - /** - * 手机 - */ - @Mobile - private String mobile; - /** - * 电话 - */ - @Telephone - private String telephone; - /** - * QQ - */ - private String qq; - /** - * wechat - */ - private String wechat; - - /** - * 邮箱 - */ - @Email(message = "邮箱格式不正确") - private String email; - - /** - * 客户描述 - */ - @Size(max = 4096, message = "客户描述长度不能超过 4096 个字符") - private String description; - /** - * 备注 - */ - private String remark; - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; - /** - * 所在地 - * - * 关联 {@link cn.iocoder.yudao.framework.ip.core.Area#getId()} 字段 - */ - private Integer areaId; - /** - * 详细地址 - */ - private String detailAddress; - - /** - * 最后跟进时间 - */ - private LocalDateTime contactLastTime; - /** - * 最后跟进内容 - */ - private String contactLastContent; - /** - * 下次联系时间 - */ - private LocalDateTime contactNextTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordService.java deleted file mode 100644 index 3c043e386..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordService.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.followup; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; -import cn.iocoder.yudao.module.crm.service.followup.bo.CrmFollowUpCreateReqBO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * 跟进记录 Service 接口 - * - * @author 芋道源码 - */ -public interface CrmFollowUpRecordService { - - /** - * 创建跟进记录 (数据权限基于 bizType、 bizId) - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createFollowUpRecord(@Valid CrmFollowUpRecordSaveReqVO createReqVO); - - /** - * 创建更进 - * - * @param list 请求 - */ - void createFollowUpRecordBatch(List list); - - /** - * 删除跟进记录 (数据权限基于 bizType、 bizId) - * - * @param id 编号 - * @param userId 用户编号 - */ - void deleteFollowUpRecord(Long id, Long userId); - - /** - * 删除跟进 - * - * @param bizType 模块类型 - * @param bizId 模块数据编号 - */ - void deleteFollowUpRecordByBiz(Integer bizType, Long bizId); - - /** - * 获得跟进记录 - * - * @param id 编号 - * @return 跟进记录 - */ - CrmFollowUpRecordDO getFollowUpRecord(Long id); - - /** - * 获得跟进记录分页 (数据权限基于 bizType、 bizId) - * - * @param pageReqVO 分页查询 - * @return 跟进记录分页 - */ - PageResult getFollowUpRecordPage(CrmFollowUpRecordPageReqVO pageReqVO); - - /** - * 获取跟进记录 - * - * @param bizType 模块类型 - * @param bizIds 模块数据编号 - * @return 跟进列表 - */ - List getFollowUpRecordByBiz(Integer bizType, Collection bizIds); - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java deleted file mode 100644 index 0bc4480e3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java +++ /dev/null @@ -1,149 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.followup; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; -import cn.iocoder.yudao.module.crm.dal.mysql.followup.CrmFollowUpRecordMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.clue.CrmClueService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; -import cn.iocoder.yudao.module.crm.service.followup.bo.CrmFollowUpCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.FOLLOW_UP_RECORD_DELETE_DENIED; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.FOLLOW_UP_RECORD_NOT_EXISTS; - -/** - * 跟进记录 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { - - @Resource - private CrmFollowUpRecordMapper crmFollowUpRecordMapper; - - @Resource - @Lazy - private CrmPermissionService permissionService; - @Resource - @Lazy - private CrmBusinessService businessService; - @Resource - @Lazy - private CrmClueService clueService; - @Resource - @Lazy - private CrmContactService contactService; - @Resource - @Lazy - private CrmContractService contractService; - @Resource - @Lazy - private CrmCustomerService customerService; - - @Override - @CrmPermission(bizTypeValue = "#createReqVO.bizType", bizId = "#createReqVO.bizId", level = CrmPermissionLevelEnum.WRITE) - public Long createFollowUpRecord(CrmFollowUpRecordSaveReqVO createReqVO) { - // 1. 创建更进记录 - CrmFollowUpRecordDO record = BeanUtils.toBean(createReqVO, CrmFollowUpRecordDO.class); - crmFollowUpRecordMapper.insert(record); - - // 2. 更新 bizId 对应的记录 - if (ObjUtil.equal(CrmBizTypeEnum.CRM_CUSTOMER.getType(), record.getBizType())) { // 更新客户跟进信息 - customerService.updateCustomerFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); - } - if (ObjUtil.equal(CrmBizTypeEnum.CRM_BUSINESS.getType(), record.getBizType())) { // 更新商机跟进信息 - businessService.updateBusinessFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); - } - if (ObjUtil.equal(CrmBizTypeEnum.CRM_CLUE.getType(), record.getBizType())) { // 更新线索跟进信息 - clueService.updateClueFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); - } - if (ObjUtil.equal(CrmBizTypeEnum.CRM_CONTACT.getType(), record.getBizType())) { // 更新联系人跟进信息 - contactService.updateContactFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); - } - if (ObjUtil.equal(CrmBizTypeEnum.CRM_CONTRACT.getType(), record.getBizType())) { // 更新合同跟进信息 - contractService.updateContractFollowUp(record.getBizId(), record.getNextTime(), record.getContent()); - } - - // 3.1 更新 contactIds 对应的记录,只更新 nextTime - if (CollUtil.isNotEmpty(createReqVO.getContactIds())) { - contactService.updateContactContactNextTime(createReqVO.getContactIds(), createReqVO.getNextTime()); - } - // 3.2 需要更新 businessIds 对应的记录,只更新 nextTime - if (CollUtil.isNotEmpty(createReqVO.getBusinessIds())) { - businessService.updateBusinessContactNextTime(createReqVO.getBusinessIds(), createReqVO.getNextTime()); - } - return record.getId(); - } - - @Override - public void createFollowUpRecordBatch(List list) { - if (CollUtil.isEmpty(list)) { - return; - } - crmFollowUpRecordMapper.insertBatch(BeanUtils.toBean(list, CrmFollowUpRecordDO.class)); - } - - @Override - public void deleteFollowUpRecord(Long id, Long userId) { - // 校验存在 - CrmFollowUpRecordDO followUpRecord = validateFollowUpRecordExists(id); - // 校验权限 - if (!permissionService.hasPermission(followUpRecord.getBizType(), followUpRecord.getBizId(), userId, CrmPermissionLevelEnum.OWNER)) { - throw exception(FOLLOW_UP_RECORD_DELETE_DENIED); - } - - // 删除 - crmFollowUpRecordMapper.deleteById(id); - } - - @Override - public void deleteFollowUpRecordByBiz(Integer bizType, Long bizId) { - crmFollowUpRecordMapper.deleteByBiz(bizType, bizId); - } - - private CrmFollowUpRecordDO validateFollowUpRecordExists(Long id) { - CrmFollowUpRecordDO followUpRecord = crmFollowUpRecordMapper.selectById(id); - if (followUpRecord == null) { - throw exception(FOLLOW_UP_RECORD_NOT_EXISTS); - } - return followUpRecord; - } - - @Override - public CrmFollowUpRecordDO getFollowUpRecord(Long id) { - return crmFollowUpRecordMapper.selectById(id); - } - - @Override - @CrmPermission(bizTypeValue = "#pageReqVO.bizType", bizId = "#pageReqVO.bizId", level = CrmPermissionLevelEnum.READ) - public PageResult getFollowUpRecordPage(CrmFollowUpRecordPageReqVO pageReqVO) { - return crmFollowUpRecordMapper.selectPage(pageReqVO); - } - - @Override - public List getFollowUpRecordByBiz(Integer bizType, Collection bizIds) { - return crmFollowUpRecordMapper.selectListByBiz(bizType, bizIds); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/bo/CrmFollowUpCreateReqBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/bo/CrmFollowUpCreateReqBO.java deleted file mode 100644 index f718957c7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/bo/CrmFollowUpCreateReqBO.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.followup.bo; - -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 跟进信息 Create Req BO - * - * @author HUIHUI - */ -@Data -public class CrmFollowUpCreateReqBO { - - /** - * 数据类型 - * - * 枚举 {@link CrmBizTypeEnum} - */ - @NotNull(message = "数据类型不能为空") - private Integer bizType; - /** - * 数据编号 - * - * 关联 {@link CrmBizTypeEnum} 对应模块 DO 的 id 字段 - */ - @NotNull(message = "数据编号不能为空") - private Long bizId; - - /** - * 跟进类型 - * - * 关联 {@link DictTypeConstants#CRM_FOLLOW_UP_TYPE} 字典 - */ - @NotNull(message = "跟进类型不能为空") - private Integer type; - /** - * 跟进内容 - */ - @NotEmpty(message = "跟进内容不能为空") - private String content; - /** - * 下次联系时间 - */ - @NotNull(message = "下次联系时间不能为空") - private LocalDateTime nextTime; - - /** - * 图片 - */ - private List picUrls; - /** - * 附件 - */ - private List fileUrls; - - /** - * 关联的商机编号数组 - * - * 关联 {@link CrmBusinessDO#getId()} - */ - private List businessIds; - - /** - * 关联的联系人编号数组 - * - * 关联 {@link CrmContactDO#getId()} - */ - private List contactIds; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java deleted file mode 100644 index c5a6b854c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java +++ /dev/null @@ -1,131 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.permission; - - -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * crm 数据权限 Service 接口 - * - * @author HUIHUI - */ -public interface CrmPermissionService { - - /** - * 创建数据权限 - * - * @param reqVO 创建信息 - * @param userId 用户编号 - */ - void createPermission(CrmPermissionSaveReqVO reqVO, Long userId); - - /** - * 创建数据权限 - * - * @param createReqBO 创建信息 - * @return 编号 - */ - Long createPermission(@Valid CrmPermissionCreateReqBO createReqBO); - - /** - * 创建数据权限 - * - * @param createReqBOs 创建信息 - */ - void createPermissionBatch(@Valid List createReqBOs); - - /** - * 更新数据权限 - * - * @param updateReqVO 更新信息 - */ - void updatePermission(CrmPermissionUpdateReqVO updateReqVO); - - /** - * 数据权限转移 - * - * @param crmPermissionTransferReqBO 数据权限转移请求 - */ - void transferPermission(@Valid CrmPermissionTransferReqBO crmPermissionTransferReqBO); - - /** - * 删除数据权限 - * - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} - * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() - * @param level 数据权限级别,关联 {@link CrmPermissionLevelEnum} - */ - void deletePermission(Integer bizType, Long bizId, Integer level); - - /** - * 删除数据权限 - * - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} - * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() - */ - void deletePermission(Integer bizType, Long bizId); - - /** - * 批量删除数据权限 - * - * @param ids 权限编号 - * @param userId 用户编号 - */ - void deletePermissionBatch(Collection ids, Long userId); - - /** - * 删除指定用户数据权限 - * - * @param id 权限编号 - * @param userId 用户编号 - */ - void deleteSelfPermission(Long id, Long userId); - - /** - * 获取数据权限列表,通过 数据类型 x 某个数据 - * - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} - * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() - * @return Crm 数据权限列表 - */ - List getPermissionListByBiz(Integer bizType, Long bizId); - - /** - * 获取数据权限列表,通过 数据类型 x 某个数据 - * - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} - * @param bizIds 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() - * @return Crm 数据权限列表 - */ - List getPermissionListByBiz(Integer bizType, Collection bizIds); - - /** - * 获取用户参与的模块数据列表 - * - * @param bizType 模块类型 - * @param userId 用户编号 - * @return 模块数据列表 - */ - List getPermissionListByBizTypeAndUserId(Integer bizType, Long userId); - - /** - * 校验是否有指定数据的操作权限 - * - * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} - * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() - * @param userId 用户编号 - * @param level 权限级别 - * @return 是否有权限 - */ - boolean hasPermission(Integer bizType, Long bizId, Long userId, CrmPermissionLevelEnum level); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java deleted file mode 100644 index 74f43e779..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java +++ /dev/null @@ -1,335 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.permission; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionSaveReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.dal.mysql.permission.CrmPermissionMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; -import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum.isOwner; - -/** - * CRM 数据权限 Service 接口实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class CrmPermissionServiceImpl implements CrmPermissionService { - - @Resource - private CrmPermissionMapper permissionMapper; - @Resource - @Lazy // 解决依赖循环 - private CrmContactService contactService; - @Resource - @Lazy // 解决依赖循环 - private CrmBusinessService businessService; - @Resource - @Lazy // 解决依赖循环 - private CrmContractService contractService; - @Resource - private AdminUserApi adminUserApi; - - - @Override - @Transactional(rollbackFor = Exception.class) - @CrmPermission(bizTypeValue = "#reqVO.bizType", bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER) - public void createPermission(CrmPermissionSaveReqVO reqVO, Long userId) { - // 1. 创建数据权限 - createPermission0(BeanUtils.toBean(reqVO, CrmPermissionCreateReqBO.class)); - - // 2. 处理【同时添加至】的权限 - if (CollUtil.isEmpty(reqVO.getToBizTypes())) { - return; - } - List createPermissions = new ArrayList<>(); - buildContactPermissions(reqVO, userId, createPermissions); - buildBusinessPermissions(reqVO, userId, createPermissions); - buildContractPermissions(reqVO, userId, createPermissions); - if (CollUtil.isEmpty(createPermissions)) { - return; - } - createPermissionBatch(createPermissions); - } - - /** - * 处理同时添加至联系人 - * - * @param reqVO 请求 - * @param userId 操作人 - * @param createPermissions 待添加权限列表 - */ - private void buildContactPermissions(CrmPermissionSaveReqVO reqVO, Long userId, List createPermissions) { - // 1. 校验是否被同时添加 - Integer type = CrmBizTypeEnum.CRM_CONTACT.getType(); - if (!reqVO.getToBizTypes().contains(type)) { - return; - } - // 2. 添加数据权限 - List contactList = contactService.getContactListByCustomerIdOwnerUserId(reqVO.getBizId(), userId); - contactList.forEach(item -> createBizTypePermissions(reqVO, type, item.getId(), item.getName(), createPermissions)); - } - - /** - * 处理同时添加至商机 - * - * @param reqVO 请求 - * @param userId 操作人 - * @param createPermissions 待添加权限列表 - */ - private void buildBusinessPermissions(CrmPermissionSaveReqVO reqVO, Long userId, List createPermissions) { - // 1. 校验是否被同时添加 - Integer type = CrmBizTypeEnum.CRM_BUSINESS.getType(); - if (!reqVO.getToBizTypes().contains(type)) { - return; - } - // 2. 添加数据权限 - List businessList = businessService.getBusinessListByCustomerIdOwnerUserId(reqVO.getBizId(), userId); - businessList.forEach(item -> createBizTypePermissions(reqVO, type, item.getId(), item.getName(), createPermissions)); - } - - /** - * 处理同时添加至合同 - * - * @param reqVO 请求 - * @param userId 操作人 - * @param createPermissions 待添加权限列表 - */ - private void buildContractPermissions(CrmPermissionSaveReqVO reqVO, Long userId, List createPermissions) { - // 1. 校验是否被同时添加 - Integer type = CrmBizTypeEnum.CRM_CONTRACT.getType(); - if (!reqVO.getToBizTypes().contains(type)) { - return; - } - // 2. 添加数据权限 - List contractList = contractService.getContractListByCustomerIdOwnerUserId(reqVO.getBizId(), userId); - contractList.forEach(item -> createBizTypePermissions(reqVO, type, item.getId(), item.getName(), createPermissions)); - } - - private void createBizTypePermissions(CrmPermissionSaveReqVO reqVO, Integer type, Long bizId, String name, - List createPermissions) { - AdminUserRespDTO user = adminUserApi.getUser(reqVO.getUserId()).getCheckedData(); - // 1. 需要考虑,被添加人,是不是应该有对应的权限了; - CrmPermissionDO permission = hasAnyPermission(type, bizId, reqVO.getUserId()); - if (ObjUtil.isNotNull(permission)) { - throw exception(CRM_PERMISSION_CREATE_FAIL_EXISTS, user.getNickname(), CrmBizTypeEnum.getNameByType(type), - name, CrmPermissionLevelEnum.getNameByLevel(permission.getLevel())); - } - // 2. 添加数据权限 - createPermissions.add(new CrmPermissionCreateReqBO().setBizType(type) - .setBizId(bizId).setUserId(reqVO.getUserId()).setLevel(reqVO.getLevel())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createPermission(CrmPermissionCreateReqBO createReqBO) { - return createPermission0(createReqBO); - } - - private Long createPermission0(CrmPermissionCreateReqBO createReqBO) { - validatePermissionNotExists(Collections.singletonList(createReqBO)); - // 1. 校验用户是否存在 - adminUserApi.validateUserList(Collections.singletonList(createReqBO.getUserId())); - // 2. 插入权限 - CrmPermissionDO permission = BeanUtils.toBean(createReqBO, CrmPermissionDO.class); - permissionMapper.insert(permission); - return permission.getId(); - } - - @Override - public void createPermissionBatch(List createReqBOs) { - validatePermissionNotExists(createReqBOs); - // 1. 校验用户是否存在 - adminUserApi.validateUserList(convertSet(createReqBOs, CrmPermissionCreateReqBO::getUserId)); - - // 2. 创建 - List permissions = BeanUtils.toBean(createReqBOs, CrmPermissionDO.class); - permissionMapper.insertBatch(permissions); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePermission(CrmPermissionUpdateReqVO updateReqVO) { - // 1. 校验存在 - validatePermissionExists(updateReqVO.getIds()); - // 2. 更新 - List updateList = CollectionUtils.convertList(updateReqVO.getIds(), - id -> new CrmPermissionDO().setId(id).setLevel(updateReqVO.getLevel())); - permissionMapper.updateBatch(updateList); - } - - private void validatePermissionExists(Collection ids) { - List permissionList = permissionMapper.selectBatchIds(ids); - if (ObjUtil.notEqual(permissionList.size(), ids.size())) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - } - - private void validatePermissionNotExists(Collection createReqBOs) { - Set bizTypes = convertSet(createReqBOs, CrmPermissionCreateReqBO::getBizType); - Set bizIds = convertSet(createReqBOs, CrmPermissionCreateReqBO::getBizId); - Set userIds = convertSet(createReqBOs, CrmPermissionCreateReqBO::getUserId); - Long count = permissionMapper.selectListByBiz(bizTypes, bizIds, userIds); - if (count > 0) { - throw exception(CRM_PERMISSION_CREATE_FAIL); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void transferPermission(CrmPermissionTransferReqBO transferReqBO) { - // 1. 校验数据权限:是否是负责人,只有负责人才可以转移 - CrmPermissionDO oldPermission = permissionMapper.selectByBizTypeAndBizIdByUserId( - transferReqBO.getBizType(), transferReqBO.getBizId(), transferReqBO.getUserId()); - String bizTypeName = CrmBizTypeEnum.getNameByType(transferReqBO.getBizType()); - if (oldPermission == null // 不是拥有者,并且不是超管 - || (!isOwner(oldPermission.getLevel()) && !CrmPermissionUtils.isCrmAdmin())) { - throw exception(CRM_PERMISSION_DENIED, bizTypeName); - } - // 1.1 校验转移对象是否已经是该负责人 - if (ObjUtil.equal(transferReqBO.getNewOwnerUserId(), oldPermission.getUserId())) { - throw exception(CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS, bizTypeName); - } - // 1.2 校验新负责人是否存在 - adminUserApi.validateUserList(Collections.singletonList(transferReqBO.getNewOwnerUserId())); - - // 2. 修改新负责人的权限 - List permissions = permissionMapper.selectByBizTypeAndBizId( - transferReqBO.getBizType(), transferReqBO.getBizId()); // 获得所有数据权限 - CrmPermissionDO permission = CollUtil.findOne(permissions, - item -> ObjUtil.equal(item.getUserId(), transferReqBO.getNewOwnerUserId())); - if (permission == null) { - permissionMapper.insert(new CrmPermissionDO().setBizType(transferReqBO.getBizType()) - .setBizId(transferReqBO.getBizId()).setUserId(transferReqBO.getNewOwnerUserId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - } else { - permissionMapper.updateById(new CrmPermissionDO().setId(permission.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - } - - // 3. 修改老负责人的权限 - if (transferReqBO.getOldOwnerPermissionLevel() != null) { - permissionMapper.updateById(new CrmPermissionDO().setId(oldPermission.getId()) - .setLevel(transferReqBO.getOldOwnerPermissionLevel())); - } else { - permissionMapper.deleteById(oldPermission.getId()); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deletePermission(Integer bizType, Long bizId, Integer level) { - // 校验存在 - List permissions = permissionMapper.selectListByBizTypeAndBizIdAndLevel( - bizType, bizId, level); - if (CollUtil.isEmpty(permissions)) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - - // 删除数据权限 - permissionMapper.deleteBatchIds(convertSet(permissions, CrmPermissionDO::getId)); - } - - @Override - public void deletePermission(Integer bizType, Long bizId) { - int deletedCount = permissionMapper.deletePermission(bizType, bizId); - if (deletedCount == 0) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - } - - @Override - public void deletePermissionBatch(Collection ids, Long userId) { - List permissions = permissionMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(permissions)) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - // 校验:数据权限的模块数据编号是一致的不可能存在两个 - if (convertSet(permissions, CrmPermissionDO::getBizId).size() > 1) { - throw exception(CRM_PERMISSION_DELETE_FAIL); - } - // 校验操作人是否为负责人 - CrmPermissionDO permission = permissionMapper.selectByBizAndUserId(permissions.get(0).getBizType(), permissions.get(0).getBizId(), userId); - if (permission == null) { - throw exception(CRM_PERMISSION_DELETE_DENIED); - } - if (!CrmPermissionLevelEnum.isOwner(permission.getLevel())) { - throw exception(CRM_PERMISSION_DELETE_DENIED); - } - - // 删除数据权限 - permissionMapper.deleteBatchIds(ids); - } - - @Override - public void deleteSelfPermission(Long id, Long userId) { - // 校验数据存在且是自己 - CrmPermissionDO permission = permissionMapper.selectByIdAndUserId(id, userId); - if (permission == null) { - throw exception(CRM_PERMISSION_NOT_EXISTS); - } - // 校验是否是负责人 - if (CrmPermissionLevelEnum.isOwner(permission.getLevel())) { - throw exception(CRM_PERMISSION_DELETE_SELF_PERMISSION_FAIL_EXIST_OWNER); - } - - // 删除 - permissionMapper.deleteById(id); - } - - @Override - public List getPermissionListByBiz(Integer bizType, Long bizId) { - return permissionMapper.selectByBizTypeAndBizId(bizType, bizId); - } - - @Override - public List getPermissionListByBiz(Integer bizType, Collection bizIds) { - return permissionMapper.selectByBizTypeAndBizIds(bizType, bizIds); - } - - @Override - public List getPermissionListByBizTypeAndUserId(Integer bizType, Long userId) { - return permissionMapper.selectListByBizTypeAndUserId(bizType, userId); - } - - @Override - public boolean hasPermission(Integer bizType, Long bizId, Long userId, CrmPermissionLevelEnum level) { - List permissionList = permissionMapper.selectByBizTypeAndBizId(bizType, bizId); - return anyMatch(permissionList, permission -> - ObjUtil.equal(permission.getUserId(), userId) && ObjUtil.equal(permission.getLevel(), level.getLevel())); - } - - public CrmPermissionDO hasAnyPermission(Integer bizType, Long bizId, Long userId) { - List permissionList = permissionMapper.selectByBizTypeAndBizId(bizType, bizId); - return findFirst(permissionList, permission -> ObjUtil.equal(permission.getUserId(), userId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateReqBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateReqBO.java deleted file mode 100644 index ce13a2d17..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateReqBO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.permission.bo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * crm 数据权限 Create Req BO - * - * @author HUIHUI - */ -@Data -public class CrmPermissionCreateReqBO { - - /** - * 当前登录用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - - /** - * Crm 类型 - */ - @NotNull(message = "Crm 类型不能为空") - @InEnum(CrmBizTypeEnum.class) - private Integer bizType; - /** - * 数据编号 - */ - @NotNull(message = "Crm 数据编号不能为空") - private Long bizId; - - /** - * 权限级别 - */ - @NotNull(message = "权限级别不能为空") - @InEnum(CrmPermissionLevelEnum.class) - private Integer level; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionTransferReqBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionTransferReqBO.java deleted file mode 100644 index fb7813a0f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionTransferReqBO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.permission.bo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -/** - * 数据权限转移 Request BO - * - * @author HUIHUI - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CrmPermissionTransferReqBO { - - /** - * 当前登录用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - - /** - * CRM 类型 - */ - @NotNull(message = "Crm 类型不能为空") - @InEnum(CrmBizTypeEnum.class) - private Integer bizType; - /** - * 数据编号 - */ - @NotNull(message = "CRM 数据编号不能为空") - private Long bizId; - - /** - * 新负责人的用户编号 - */ - @NotNull(message = "新负责人的用户编号不能为空") - private Long newOwnerUserId; - - /** - * 老负责人加入团队后的权限级别。如果 null 说明移除 - * - * 关联 {@link CrmPermissionLevelEnum} - */ - private Integer oldOwnerPermissionLevel; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryService.java deleted file mode 100644 index c82f97c4a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryService.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.product; - -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * CRM 产品分类 Service 接口 - * - * @author ZanGe丶 - */ -public interface CrmProductCategoryService { - - /** - * 创建产品分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProductCategory(@Valid CrmProductCategoryCreateReqVO createReqVO); - - /** - * 更新产品分类 - * - * @param updateReqVO 更新信息 - */ - void updateProductCategory(@Valid CrmProductCategoryCreateReqVO updateReqVO); - - /** - * 删除产品分类 - * - * @param id 编号 - */ - void deleteProductCategory(Long id); - - /** - * 获得产品分类 - * - * @param id 编号 - * @return 产品分类 - */ - CrmProductCategoryDO getProductCategory(Long id); - - /** - * 获得产品分类列表 - * - * @param listReqVO 列表请求 - * @return 产品分类列表 - */ - List getProductCategoryList(CrmProductCategoryListReqVO listReqVO); - - /** - * 获得产品分类列表 - * - * @param ids 编号数组 - * @return 产品分类列表 - */ - List getProductCategoryList(Collection ids); - - /** - * 获得产品分类 Map - * - * @param ids 编号数组 - * @return 产品分类 Map - */ - default Map getProductCategoryMap(Collection ids) { - return convertMap(getProductCategoryList(ids), CrmProductCategoryDO::getId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java deleted file mode 100644 index 873d99622..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.product; - -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import cn.iocoder.yudao.module.crm.dal.mysql.product.CrmProductCategoryMapper; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.starter.annotation.LogRecord; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO.PARENT_ID_NULL; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -/** - * CRM 产品分类 Service 实现类 - * - * @author ZanGe丶 - */ -@Service -@Validated -public class CrmProductCategoryServiceImpl implements CrmProductCategoryService { - - @Resource(name = "crmProductCategoryMapper") - private CrmProductCategoryMapper productCategoryMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖问题 - private CrmProductService crmProductService; - - @Override - @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE, bizNo = "{{#productCategoryId}}", - success = CRM_PRODUCT_CATEGORY_CREATE_SUCCESS) - public Long createProductCategory(CrmProductCategoryCreateReqVO createReqVO) { - // 1.1 校验父分类存在 - validateParentProductCategory(createReqVO.getParentId()); - // 1.2 分类名称是否存在 - validateProductNameExists(null, createReqVO.getParentId(), createReqVO.getName()); - - // 2. 插入分类 - CrmProductCategoryDO category = BeanUtils.toBean(createReqVO, CrmProductCategoryDO.class); - productCategoryMapper.insert(category); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("productCategoryId", category.getId()); - return category.getId(); - } - - @Override - @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_PRODUCT_CATEGORY_UPDATE_SUCCESS) - public void updateProductCategory(CrmProductCategoryCreateReqVO updateReqVO) { - // 1.1 校验存在 - validateProductCategoryExists(updateReqVO.getId()); - // 1.2 校验父分类存在 - validateParentProductCategory(updateReqVO.getParentId()); - // 1.3 分类名称是否存在 - validateProductNameExists(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); - - // 2. 更新分类 - CrmProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductCategoryDO.class); - productCategoryMapper.updateById(updateObj); - } - - private void validateProductCategoryExists(Long id) { - if (productCategoryMapper.selectById(id) == null) { - throw exception(PRODUCT_CATEGORY_NOT_EXISTS); - } - } - - private void validateParentProductCategory(Long id) { - // 如果是根分类,无需验证 - if (Objects.equals(id, PARENT_ID_NULL)) { - return; - } - // 父分类不存在 - CrmProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(PRODUCT_CATEGORY_PARENT_NOT_EXISTS); - } - // 父分类不能是二级分类 - if (!Objects.equals(category.getParentId(), PARENT_ID_NULL)) { - throw exception(PRODUCT_CATEGORY_PARENT_NOT_FIRST_LEVEL); - } - } - - private void validateProductNameExists(Long id, Long parentId, String name) { - CrmProductCategoryDO category = productCategoryMapper.selectByParentIdAndName(parentId, name); - if (category == null - || category.getId().equals(id)) { - return; - } - throw exception(PRODUCT_CATEGORY_EXISTS); - } - - @Override - @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_PRODUCT_CATEGORY_DELETE_SUCCESS) - public void deleteProductCategory(Long id) { - // 1.1 校验存在 - validateProductCategoryExists(id); - // 1.2 校验是否还有子分类 - if (productCategoryMapper.selectCountByParentId(id) > 0) { - throw exception(PRODUCT_CATEGORY_EXISTS_CHILDREN); - } - // 1.3 校验是否被产品使用 - if (crmProductService.getProductByCategoryId(id) > 0) { - throw exception(PRODUCT_CATEGORY_USED); - } - // 2. 删除 - productCategoryMapper.deleteById(id); - } - - @Override - public CrmProductCategoryDO getProductCategory(Long id) { - return productCategoryMapper.selectById(id); - } - - @Override - public List getProductCategoryList(CrmProductCategoryListReqVO listReqVO) { - return productCategoryMapper.selectList(listReqVO); - } - - @Override - public List getProductCategoryList(Collection ids) { - return productCategoryMapper.selectBatchIds(ids); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductService.java deleted file mode 100644 index 943819ea0..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * CRM 产品 Service 接口 - * - * @author ZanGe丶 - */ -public interface CrmProductService { - - /** - * 创建产品 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProduct(@Valid CrmProductSaveReqVO createReqVO); - - /** - * 更新产品 - * - * @param updateReqVO 更新信息 - */ - void updateProduct(@Valid CrmProductSaveReqVO updateReqVO); - - /** - * 删除产品 - * - * @param id 编号 - */ - void deleteProduct(Long id); - - /** - * 获得产品 - * - * @param id 编号 - * @return 产品 - */ - CrmProductDO getProduct(Long id); - - /** - * 获得产品列表 - * - * @param ids 编号 - * @return 产品列表 - */ - List getProductList(Collection ids); - - /** - * 获得产品 Map - * - * @param ids 编号 - * @return 产品 Map - */ - default Map getProductMap(Collection ids) { - return convertMap(getProductList(ids), CrmProductDO::getId); - } - - /** - * 获得产品分页 - * - * @param pageReqVO 分页查询 - * @return 产品分页 - */ - PageResult getProductPage(CrmProductPageReqVO pageReqVO); - - /** - * 获得产品数量 - * - * @param categoryId 分类编号 - * @return 产品 - */ - Long getProductByCategoryId(Long categoryId); - - /** - * 获得指定状态的产品列表 - * - * @param status 状态 - * @return 产品列表 - */ - List getProductListByStatus(Integer status); - - /** - * 校验产品们的有效性 - * - * @param ids 编号数组 - * @return 产品列表 - */ - List validProductList(Collection ids); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java deleted file mode 100644 index 3903b4791..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java +++ /dev/null @@ -1,183 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.product; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; -import cn.iocoder.yudao.module.crm.dal.mysql.product.CrmProductMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.enums.product.CrmProductStatusEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - - -/** - * CRM 产品 Service 实现类 - * - * @author ZanGe丶 - */ -@Service -@Validated -public class CrmProductServiceImpl implements CrmProductService { - - @Resource(name = "crmProductMapper") - private CrmProductMapper productMapper; - - @Resource - private CrmProductCategoryService productCategoryService; - @Resource - private CrmPermissionService permissionService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_CREATE_SUB_TYPE, bizNo = "{{#productId}}", - success = CRM_PRODUCT_CREATE_SUCCESS) - public Long createProduct(CrmProductSaveReqVO createReqVO) { - // 1. 校验产品 - adminUserApi.validateUserList(Collections.singleton(createReqVO.getOwnerUserId())); - validateProductNoDuplicate(null, createReqVO.getNo()); - validateProductCategoryExists(createReqVO.getCategoryId()); - - // 2. 插入产品 - CrmProductDO product = BeanUtils.toBean(createReqVO, CrmProductDO.class); - productMapper.insert(product); - - // 3. 插入数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(product.getOwnerUserId()) - .setBizType(CrmBizTypeEnum.CRM_PRODUCT.getType()).setBizId(product.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("productId", product.getId()); - return product.getId(); - } - - @Override - @LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_PRODUCT_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateProduct(CrmProductSaveReqVO updateReqVO) { - // 1. 校验产品 - updateReqVO.setOwnerUserId(null); // 不修改负责人 - CrmProductDO crmProductDO = validateProductExists(updateReqVO.getId()); - validateProductNoDuplicate(updateReqVO.getId(), updateReqVO.getNo()); - validateProductCategoryExists(updateReqVO.getCategoryId()); - - // 2. 更新产品 - CrmProductDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductDO.class); - productMapper.updateById(updateObj); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(crmProductDO, CrmProductSaveReqVO.class)); - } - - private CrmProductDO validateProductExists(Long id) { - CrmProductDO product = productMapper.selectById(id); - if (product == null) { - throw exception(PRODUCT_NOT_EXISTS); - } - return product; - } - - private void validateProductNoDuplicate(Long id, String no) { - CrmProductDO product = productMapper.selectByNo(no); - if (product == null - || product.getId().equals(id)) { - return; - } - throw exception(PRODUCT_NO_EXISTS); - } - - private void validateProductCategoryExists(Long categoryId) { - CrmProductCategoryDO category = productCategoryService.getProductCategory(categoryId); - if (category == null) { - throw exception(PRODUCT_CATEGORY_NOT_EXISTS); - } - } - - @Override - @LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_PRODUCT_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteProduct(Long id) { - // 校验存在 - validateProductExists(id); - // 删除 - productMapper.deleteById(id); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmProductDO getProduct(Long id) { - return productMapper.selectById(id); - } - - @Override - public PageResult getProductPage(CrmProductPageReqVO pageReqVO) { - return productMapper.selectPage(pageReqVO); - } - - @Override - public Long getProductByCategoryId(Long categoryId) { - return productMapper.selectCountByCategoryId(categoryId); - } - - @Override - public List getProductListByStatus(Integer status) { - return productMapper.selectListByStatus(status); - } - - @Override - public List validProductList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - List list = productMapper.selectBatchIds(ids); - Map productMap = convertMap(list, CrmProductDO::getId); - for (Long id : ids) { - CrmProductDO product = productMap.get(id); - if (productMap.get(id) == null) { - throw exception(PRODUCT_NOT_EXISTS); - } - if (CrmProductStatusEnum.isDisable(product.getStatus())) { - throw exception(PRODUCT_NOT_ENABLE, product.getName()); - } - } - return list; - } - - @Override - public List getProductList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return productMapper.selectBatchIds(ids); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java deleted file mode 100644 index b5a6f3ab2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * CRM 回款计划 Service 接口 - * - * @author 芋道源码 - */ -public interface CrmReceivablePlanService { - - /** - * 创建回款计划 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createReceivablePlan(@Valid CrmReceivablePlanSaveReqVO createReqVO); - - /** - * 更新回款计划 - * - * @param updateReqVO 更新信息 - */ - void updateReceivablePlan(@Valid CrmReceivablePlanSaveReqVO updateReqVO); - - /** - * 更新回款计划关联的回款编号 - * - * @param id 编号 - * @param receivableId 回款编号 - */ - void updateReceivablePlanReceivableId(Long id, Long receivableId); - - /** - * 删除回款计划 - * - * @param id 编号 - */ - void deleteReceivablePlan(Long id); - - /** - * 获得回款计划 - * - * @param id 编号 - * @return 回款计划 - */ - CrmReceivablePlanDO getReceivablePlan(Long id); - - /** - * 获得回款计划列表 - * - * @param ids 编号 - * @return 回款计划列表 - */ - List getReceivablePlanList(Collection ids); - - /** - * 获得回款计划分页 - * - * 数据权限:基于 {@link CrmReceivablePlanDO} 读取 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 回款计划分页 - */ - PageResult getReceivablePlanPage(CrmReceivablePlanPageReqVO pageReqVO, Long userId); - - /** - * 获得回款计划分页,基于指定客户 - * - * 数据权限:基于 {@link CrmCustomerDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 回款计划分页 - */ - PageResult getReceivablePlanPageByCustomerId(CrmReceivablePlanPageReqVO pageReqVO); - - /** - * 获得待回款提醒数量 - * - * @param userId 用户编号 - * @return 提醒数量 - */ - Long getReceivablePlanRemindCount(Long userId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java deleted file mode 100644 index 127ef72c1..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java +++ /dev/null @@ -1,187 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivablePlanMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_PLAN_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_PLAN_UPDATE_FAIL; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; - -/** - * 回款计划 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { - - @Resource - private CrmReceivablePlanMapper receivablePlanMapper; - - @Resource - private CrmContractService contractService; - @Resource - private CrmPermissionService permissionService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_PLAN_TYPE, subType = CRM_RECEIVABLE_PLAN_CREATE_SUB_TYPE, bizNo = "{{#receivablePlan.id}}", - success = CRM_RECEIVABLE_PLAN_CREATE_SUCCESS) - public Long createReceivablePlan(CrmReceivablePlanSaveReqVO createReqVO) { - // 1. 校验关联数据是否存在 - validateRelationDataExists(createReqVO); - - // 2. 插入回款计划 - CrmReceivablePlanDO maxPeriodReceivablePlan = receivablePlanMapper.selectMaxPeriodByContractId(createReqVO.getContractId()); - int period = maxPeriodReceivablePlan == null ? 1 : maxPeriodReceivablePlan.getPeriod() + 1; - CrmReceivablePlanDO receivablePlan = BeanUtils.toBean(createReqVO, CrmReceivablePlanDO.class).setPeriod(period); - if (createReqVO.getReturnTime() != null && createReqVO.getRemindDays() != null) { - receivablePlan.setRemindTime(createReqVO.getReturnTime().minusDays(createReqVO.getRemindDays())); - } - receivablePlanMapper.insert(receivablePlan); - - // 3. 创建数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(createReqVO.getOwnerUserId()) - .setBizType(CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType()).setBizId(receivablePlan.getId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("receivablePlan", receivablePlan); - return receivablePlan.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_PLAN_TYPE, subType = CRM_RECEIVABLE_PLAN_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_RECEIVABLE_PLAN_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE_PLAN, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateReceivablePlan(CrmReceivablePlanSaveReqVO updateReqVO) { - updateReqVO.setOwnerUserId(null).setCustomerId(null).setContractId(null); // 防止修改这些字段 - // 1.1 校验存在 - validateRelationDataExists(updateReqVO); - // 1.2 校验关联数据是否存在 - CrmReceivablePlanDO oldReceivablePlan = validateReceivablePlanExists(updateReqVO.getId()); - // 1.3 如果已经有对应的回款,则不允许编辑 - if (Objects.nonNull(oldReceivablePlan.getReceivableId())) { - throw exception(RECEIVABLE_PLAN_UPDATE_FAIL); - } - - // 2. 更新回款计划 - CrmReceivablePlanDO updateObj = BeanUtils.toBean(updateReqVO, CrmReceivablePlanDO.class); - if (updateReqVO.getReturnTime() != null && updateReqVO.getRemindDays() != null) { - updateObj.setRemindTime(updateReqVO.getReturnTime().minusDays(updateReqVO.getRemindDays())); - } - receivablePlanMapper.updateById(updateObj); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldReceivablePlan, CrmReceivablePlanSaveReqVO.class)); - LogRecordContext.putVariable("receivablePlan", oldReceivablePlan); - } - - private void validateRelationDataExists(CrmReceivablePlanSaveReqVO reqVO) { - // 校验负责人存在 - if (reqVO.getOwnerUserId() != null) { - adminUserApi.validateUser(reqVO.getOwnerUserId()); - } - // 校验合同存在 - if (reqVO.getContractId() != null) { - CrmContractDO contract = contractService.getContract(reqVO.getContractId()); - reqVO.setCustomerId(contract.getCustomerId()); - } - } - - @Override - public void updateReceivablePlanReceivableId(Long id, Long receivableId) { - // 校验存在 - validateReceivablePlanExists(id); - // 更新回款计划 - receivablePlanMapper.updateById(new CrmReceivablePlanDO().setId(id).setReceivableId(receivableId)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_PLAN_TYPE, subType = CRM_RECEIVABLE_PLAN_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_RECEIVABLE_PLAN_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE_PLAN, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteReceivablePlan(Long id) { - // 1. 校验存在 - CrmReceivablePlanDO receivablePlan = validateReceivablePlanExists(id); - - // 2. 删除 - receivablePlanMapper.deleteById(id); - // 3. 删除数据权限 - permissionService.deletePermission(CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), id); - - // 4. 记录操作日志上下文 - LogRecordContext.putVariable("receivablePlan", receivablePlan); - } - - private CrmReceivablePlanDO validateReceivablePlanExists(Long id) { - CrmReceivablePlanDO receivablePlan = receivablePlanMapper.selectById(id); - if (receivablePlan == null) { - throw exception(RECEIVABLE_PLAN_NOT_EXISTS); - } - return receivablePlan; - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE_PLAN, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmReceivablePlanDO getReceivablePlan(Long id) { - return receivablePlanMapper.selectById(id); - } - - @Override - public List getReceivablePlanList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return receivablePlanMapper.selectBatchIds(ids); - } - - @Override - public PageResult getReceivablePlanPage(CrmReceivablePlanPageReqVO pageReqVO, Long userId) { - return receivablePlanMapper.selectPage(pageReqVO, userId); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getReceivablePlanPageByCustomerId(CrmReceivablePlanPageReqVO pageReqVO) { - return receivablePlanMapper.selectPageByCustomerId(pageReqVO); - } - - @Override - public Long getReceivablePlanRemindCount(Long userId) { - return receivablePlanMapper.selectReceivablePlanCountByRemind(userId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java deleted file mode 100644 index eec4cd550..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * CRM 回款 Service 接口 - * - * @author 赤焰 - */ -public interface CrmReceivableService { - - /** - * 创建回款 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createReceivable(@Valid CrmReceivableSaveReqVO createReqVO); - - /** - * 更新回款 - * - * @param updateReqVO 更新信息 - */ - void updateReceivable(@Valid CrmReceivableSaveReqVO updateReqVO); - - /** - * 更新回款流程审批结果 - * - * @param id 回款编号 - * @param bpmResult BPM 审批结果 - */ - void updateReceivableAuditStatus(Long id, Integer bpmResult); - - /** - * 删除回款 - * - * @param id 编号 - */ - void deleteReceivable(Long id); - - /** - * 发起回款审批流程 - * - * @param id 回款编号 - * @param userId 用户编号 - */ - void submitReceivable(Long id, Long userId); - - /** - * 获得回款 - * - * @param id 编号 - * @return 回款 - */ - CrmReceivableDO getReceivable(Long id); - - /** - * 获得回款列表 - * - * @param ids 编号 - * @return 回款列表 - */ - List getReceivableList(Collection ids); - - /** - * 获得回款 Map - * - * @param ids 编号 - * @return 回款 Map - */ - default Map getReceivableMap(Collection ids) { - return convertMap(getReceivableList(ids), CrmReceivableDO::getId); - } - - /** - * 获得回款分页 - * - * 数据权限:基于 {@link CrmReceivableDO} 读取 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 回款分页 - */ - PageResult getReceivablePage(CrmReceivablePageReqVO pageReqVO, Long userId); - - /** - * 获得回款分页,基于指定客户 - * - * 数据权限:基于 {@link CrmCustomerDO} 读取 - * - * @param pageReqVO 分页查询 - * @return 回款分页 - */ - PageResult getReceivablePageByCustomerId(CrmReceivablePageReqVO pageReqVO); - - /** - * 获得待审核回款数量 - * - * @param userId 用户编号 - * @return 待审批数量 - */ - Long getAuditReceivableCount(Long userId); - - /** - * 获得合同已回款金额 Map - * - * @param contractIds 合同编号 - * @return 回款金额 Map - */ - Map getReceivablePriceMapByContractId(Collection contractIds); - - /** - * 根据合同编号查询回款数量 - * - * @param contractId 合同编号 - * @return 回款数量 - */ - Long getReceivableCountByContractId(Long contractId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java deleted file mode 100644 index 83e68cce2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java +++ /dev/null @@ -1,309 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableSaveReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper; -import cn.iocoder.yudao.module.crm.dal.redis.no.CrmNoRedisDAO; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; -import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import com.mzt.logapi.context.LogRecordContext; -import com.mzt.logapi.service.impl.DiffParseFunction; -import com.mzt.logapi.starter.annotation.LogRecord; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; -import static cn.iocoder.yudao.module.crm.util.CrmAuditStatusUtils.convertBpmResultToAuditStatus; - -/** - * CRM 回款 Service 实现类 - * - * @author 赤焰 - */ -@Service -@Validated -@Slf4j -public class CrmReceivableServiceImpl implements CrmReceivableService { - - /** - * BPM 合同审批流程标识 - */ - public static final String BPM_PROCESS_DEFINITION_KEY = "crm-receivable-audit"; - - @Resource - private CrmReceivableMapper receivableMapper; - - @Resource - private CrmNoRedisDAO noRedisDAO; - - @Resource - private CrmContractService contractService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private CrmReceivablePlanService receivablePlanService; - @Resource - private CrmPermissionService permissionService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private BpmProcessInstanceApi bpmProcessInstanceApi; - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_CREATE_SUB_TYPE, bizNo = "{{#receivable.id}}", - success = CRM_RECEIVABLE_CREATE_SUCCESS) - public Long createReceivable(CrmReceivableSaveReqVO createReqVO) { - // 1.1 校验可回款金额超过上限 - validateReceivablePriceExceedsLimit(createReqVO); - // 1.2 校验关联数据存在 - validateRelationDataExists(createReqVO); - // 1.3 生成回款编号 - String no = noRedisDAO.generate(CrmNoRedisDAO.RECEIVABLE_PREFIX); - if (receivableMapper.selectByNo(no) != null) { - throw exception(RECEIVABLE_NO_EXISTS); - } - - // 2.1 插入回款 - CrmReceivableDO receivable = BeanUtils.toBean(createReqVO, CrmReceivableDO.class) - .setNo(no).setAuditStatus(CrmAuditStatusEnum.DRAFT.getStatus()); - receivableMapper.insert(receivable); - // 2.2 - - // 3. 创建数据权限 - permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_RECEIVABLE.getType()) - .setBizId(receivable.getId()).setUserId(createReqVO.getOwnerUserId()) - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 - - // 4. 更新关联的回款计划 - if (createReqVO.getPlanId() != null) { - receivablePlanService.updateReceivablePlanReceivableId(receivable.getPlanId(), receivable.getId()); - } - - // 5. 记录操作日志上下文 - LogRecordContext.putVariable("receivable", receivable); - LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId())); - return receivable.getId(); - } - - private void validateReceivablePriceExceedsLimit(CrmReceivableSaveReqVO reqVO) { - // 1. 计算剩余可退款金额,不包括 reqVO 自身 - CrmContractDO contract = contractService.validateContract(reqVO.getContractId()); - List receivables = receivableMapper.selectListByContractIdAndStatus(reqVO.getContractId(), - Arrays.asList(CrmAuditStatusEnum.APPROVE.getStatus(), CrmAuditStatusEnum.PROCESS.getStatus())); - if (reqVO.getId() != null) { - receivables.removeIf(receivable -> ObjectUtil.equal(receivable.getId(), reqVO.getId())); - } - BigDecimal notReceivablePrice = contract.getTotalPrice().subtract( - CollectionUtils.getSumValue(receivables, CrmReceivableDO::getPrice, BigDecimal::add, BigDecimal.ZERO)); - // 2. 校验金额是否超过 - if (reqVO.getPrice().compareTo(notReceivablePrice) > 0) { - throw exception(RECEIVABLE_CREATE_FAIL_PRICE_EXCEEDS_LIMIT, notReceivablePrice); - } - } - - private void validateRelationDataExists(CrmReceivableSaveReqVO reqVO) { - if (reqVO.getOwnerUserId() != null) { - adminUserApi.validateUser(reqVO.getOwnerUserId()); // 校验负责人存在 - } - if (reqVO.getContractId() != null) { - CrmContractDO contract = contractService.validateContract(reqVO.getContractId()); - if (ObjectUtil.notEqual(contract.getAuditStatus(), CrmAuditStatusEnum.APPROVE.getStatus())) { - throw exception(RECEIVABLE_CREATE_FAIL_CONTRACT_NOT_APPROVE); - } - reqVO.setCustomerId(contract.getCustomerId()); // 设置客户编号 - } - if (reqVO.getPlanId() != null) { - CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(reqVO.getPlanId()); - if (receivablePlan == null) { - throw exception(RECEIVABLE_PLAN_NOT_EXISTS); - } - if (receivablePlan.getReceivableId() != null) { - throw exception(RECEIVABLE_PLAN_EXISTS_RECEIVABLE); - } - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", - success = CRM_RECEIVABLE_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) - public void updateReceivable(CrmReceivableSaveReqVO updateReqVO) { - Assert.notNull(updateReqVO.getId(), "回款编号不能为空"); - updateReqVO.setOwnerUserId(null).setCustomerId(null).setContractId(null).setPlanId(null); // 不允许修改的字段 - // 1.1 校验存在 - CrmReceivableDO receivable = validateReceivableExists(updateReqVO.getId()); - updateReqVO.setOwnerUserId(receivable.getOwnerUserId()).setCustomerId(receivable.getCustomerId()) - .setContractId(receivable.getContractId()).setPlanId(receivable.getPlanId()); // 设置已存在的值 - // 1.2 校验可回款金额超过上限 - validateReceivablePriceExceedsLimit(updateReqVO); - - // 1.3 只有草稿、审批中,可以编辑; - if (!ObjectUtils.equalsAny(receivable.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus(), - CrmAuditStatusEnum.PROCESS.getStatus())) { - throw exception(RECEIVABLE_UPDATE_FAIL_EDITING_PROHIBITED); - } - - // 2. 更新回款 - CrmReceivableDO updateObj = BeanUtils.toBean(updateReqVO, CrmReceivableDO.class); - receivableMapper.updateById(updateObj); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("receivable", receivable); - LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId())); - LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(receivable, CrmReceivableSaveReqVO.class)); - } - - private Integer getReceivablePeriod(Long planId) { - if (Objects.isNull(planId)) { - return null; - } - CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(planId); - return receivablePlan.getPeriod(); - } - - @Override - public void updateReceivableAuditStatus(Long id, Integer bpmResult) { - // 1.1 校验存在 - CrmReceivableDO receivable = validateReceivableExists(id); - // 1.2 只有审批中,可以更新审批结果 - if (ObjUtil.notEqual(receivable.getAuditStatus(), CrmAuditStatusEnum.PROCESS.getStatus())) { - log.error("[updateReceivableAuditStatus][receivable({}) 不处于审批中,无法更新审批结果({})]", - receivable.getId(), bpmResult); - throw exception(RECEIVABLE_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS); - } - - // 2. 更新回款审批状态 - Integer auditStatus = convertBpmResultToAuditStatus(bpmResult); - receivableMapper.updateById(new CrmReceivableDO().setId(id).setAuditStatus(auditStatus)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_DELETE_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_RECEIVABLE_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) - public void deleteReceivable(Long id) { - // 1.1 校验存在 - CrmReceivableDO receivable = validateReceivableExists(id); - // 1.2 如果被 CrmReceivablePlanDO 所使用,则不允许删除 - if (receivable.getPlanId() != null && receivablePlanService.getReceivablePlan(receivable.getPlanId()) != null) { - throw exception(RECEIVABLE_DELETE_FAIL); - } - // 1.3 审批通过时,不允许删除 - if (ObjUtil.equal(receivable.getAuditStatus(), CrmAuditStatusEnum.APPROVE.getStatus())) { - throw exception(RECEIVABLE_DELETE_FAIL_IS_APPROVE); - } - - // 2.1 删除回款 - receivableMapper.deleteById(id); - // 2.2 删除数据权限 - permissionService.deletePermission(CrmBizTypeEnum.CRM_RECEIVABLE.getType(), id); - - // 3. 记录操作日志上下文 - LogRecordContext.putVariable("receivable", receivable); - LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_SUBMIT_SUB_TYPE, bizNo = "{{#id}}", - success = CRM_RECEIVABLE_SUBMIT_SUCCESS) - public void submitReceivable(Long id, Long userId) { - // 1. 校验回款是否在审批 - CrmReceivableDO receivable = validateReceivableExists(id); - if (ObjUtil.notEqual(receivable.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus())) { - throw exception(RECEIVABLE_SUBMIT_FAIL_NOT_DRAFT); - } - - // 2. 创建回款审批流程实例 - String processInstanceId = bpmProcessInstanceApi.createProcessInstance(userId, new BpmProcessInstanceCreateReqDTO() - .setProcessDefinitionKey(BPM_PROCESS_DEFINITION_KEY).setBusinessKey(String.valueOf(id))).getCheckedData(); - - // 3. 更新回款工作流编号 - receivableMapper.updateById(new CrmReceivableDO().setId(id).setProcessInstanceId(processInstanceId) - .setAuditStatus(CrmAuditStatusEnum.PROCESS.getStatus())); - - // 4. 记录日志 - LogRecordContext.putVariable("receivableNo", receivable.getNo()); - } - - private CrmReceivableDO validateReceivableExists(Long id) { - CrmReceivableDO receivable = receivableMapper.selectById(id); - if (receivable == null) { - throw exception(RECEIVABLE_NOT_EXISTS); - } - return receivable; - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE, bizId = "#id", level = CrmPermissionLevelEnum.READ) - public CrmReceivableDO getReceivable(Long id) { - return receivableMapper.selectById(id); - } - - @Override - public List getReceivableList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return receivableMapper.selectBatchIds(ids); - } - - @Override - public PageResult getReceivablePage(CrmReceivablePageReqVO pageReqVO, Long userId) { - return receivableMapper.selectPage(pageReqVO, userId); - } - - @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getReceivablePageByCustomerId(CrmReceivablePageReqVO pageReqVO) { - return receivableMapper.selectPageByCustomerId(pageReqVO); - } - - @Override - public Long getAuditReceivableCount(Long userId) { - return receivableMapper.selectCountByAudit(userId); - } - - @Override - public Map getReceivablePriceMapByContractId(Collection contractIds) { - return receivableMapper.selectReceivablePriceMapByContractId(contractIds); - } - - @Override - public Long getReceivableCountByContractId(Long contractId) { - return receivableMapper.selectCountByContractId(contractId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/listener/CrmReceivableStatusListener.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/listener/CrmReceivableStatusListener.java deleted file mode 100644 index bd76b0118..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/listener/CrmReceivableStatusListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.receivable.listener; - -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent; -import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; -import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableServiceImpl; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 回款审批的结果的监听器实现类 - * - * @author HUIHUI - */ -@Component -public class CrmReceivableStatusListener extends BpmProcessInstanceStatusEventListener { - - @Resource - private CrmReceivableService receivableService; - - @Override - public String getProcessDefinitionKey() { - return CrmReceivableServiceImpl.BPM_PROCESS_DEFINITION_KEY; - } - - @Override - public void onEvent(BpmProcessInstanceStatusEvent event) { - receivableService.updateReceivableAuditStatus(Long.parseLong(event.getBusinessKey()), event.getStatus()); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java deleted file mode 100644 index 70c720b9e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; - -import java.util.List; - -/** - * CRM 客户分析 Service 接口 - * - * @author dhb52 - */ -public interface CrmStatisticsCustomerService { - - /** - * 总量分析(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerSummaryByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 总量分析(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerSummaryByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进次数分析(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getFollowUpSummaryByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 跟进次数分析(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getFollowUpSummaryByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户跟进次数分析(按类型) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getFollowUpSummaryByType(CrmStatisticsCustomerReqVO reqVO); - - /** - * 获取客户的首次合同、回款信息列表,用于【客户转化率】页面 - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getContractSummary(CrmStatisticsCustomerReqVO reqVO); - - /** - * 公海客户分析(按日期) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getPoolSummaryByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 公海客户分析(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getPoolSummaryByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按日期) - * - * 成交周期的定义:客户 customer 在创建出来,到合同 contract 第一次成交的时间差 - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerDealCycleByDate(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按用户) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerDealCycleByUser(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按区域) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerDealCycleByArea(CrmStatisticsCustomerReqVO reqVO); - - /** - * 客户成交周期(按产品) - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerDealCycleByProduct(CrmStatisticsCustomerReqVO reqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java deleted file mode 100644 index bec5735c9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java +++ /dev/null @@ -1,368 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; -import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsCustomerMapper; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * CRM 客户分析 Service 实现类 - * - * @author dhb52 - */ -@Service -@Validated -public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerService { - - @Resource - private CrmStatisticsCustomerMapper customerMapper; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @Override - public List getCustomerSummaryByDate(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List customerCreateCountList = customerMapper.selectCustomerCreateCountGroupByDate(reqVO); - List customerDealCountList = customerMapper.selectCustomerDealCountGroupByDate(reqVO); - - // 3. 按照日期间隔,合并数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Integer customerCreateCount = customerCreateCountList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToInt(CrmStatisticsCustomerSummaryByDateRespVO::getCustomerCreateCount).sum(); - Integer customerDealCount = customerDealCountList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToInt(CrmStatisticsCustomerSummaryByDateRespVO::getCustomerDealCount).sum(); - return new CrmStatisticsCustomerSummaryByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setCustomerCreateCount(customerCreateCount).setCustomerDealCount(customerDealCount); - }); - } - - @Override - public List getCustomerSummaryByUser(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按用户统计,获取分项统计数据 - List customerCreateCountList = customerMapper.selectCustomerCreateCountGroupByUser(reqVO); - List customerDealCountList = customerMapper.selectCustomerDealCountGroupByUser(reqVO); - List contractPriceList = customerMapper.selectContractPriceGroupByUser(reqVO); - List receivablePriceList = customerMapper.selectReceivablePriceGroupByUser(reqVO); - - // 3.1 按照用户,合并统计数据 - List summaryList = convertList(reqVO.getUserIds(), userId -> { - Integer customerCreateCount = customerCreateCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsCustomerSummaryByUserRespVO::getCustomerCreateCount).sum(); - Integer customerDealCount = customerDealCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount).sum(); - BigDecimal contractPrice = contractPriceList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .reduce(BigDecimal.ZERO, (sum, vo) -> sum.add(vo.getContractPrice()), BigDecimal::add); - BigDecimal receivablePrice = receivablePriceList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .reduce(BigDecimal.ZERO, (sum, vo) -> sum.add(vo.getReceivablePrice()), BigDecimal::add); - return (CrmStatisticsCustomerSummaryByUserRespVO) new CrmStatisticsCustomerSummaryByUserRespVO() - .setCustomerCreateCount(customerCreateCount).setCustomerDealCount(customerDealCount) - .setContractPrice(contractPrice).setReceivablePrice(receivablePrice).setOwnerUserId(userId); - }); - // 3.2 拼接用户信息 - appendUserInfo(summaryList); - return summaryList; - } - - @Override - public List getFollowUpSummaryByDate(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List followUpRecordCountList = customerMapper.selectFollowUpRecordCountGroupByDate(reqVO); - List followUpCustomerCountList = customerMapper.selectFollowUpCustomerCountGroupByDate(reqVO); - - // 3. 按照时间间隔,合并统计数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Integer followUpRecordCount = followUpRecordCountList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToInt(CrmStatisticsFollowUpSummaryByDateRespVO::getFollowUpRecordCount).sum(); - Integer followUpCustomerCount = followUpCustomerCountList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToInt(CrmStatisticsFollowUpSummaryByDateRespVO::getFollowUpCustomerCount).sum(); - return new CrmStatisticsFollowUpSummaryByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setFollowUpCustomerCount(followUpRecordCount).setFollowUpRecordCount(followUpCustomerCount); - }); - } - - @Override - public List getFollowUpSummaryByUser(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按用户统计,获取分项统计数据 - List followUpRecordCountList = customerMapper.selectFollowUpRecordCountGroupByUser(reqVO); - List followUpCustomerCountList = customerMapper.selectFollowUpCustomerCountGroupByUser(reqVO); - - // 3.1 按照用户,合并统计数据 - List summaryList = convertList(reqVO.getUserIds(), userId -> { - Integer followUpRecordCount = followUpRecordCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsFollowUpSummaryByUserRespVO::getFollowUpRecordCount).sum(); - Integer followUpCustomerCount = followUpCustomerCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsFollowUpSummaryByUserRespVO::getFollowUpCustomerCount).sum(); - return (CrmStatisticsFollowUpSummaryByUserRespVO) new CrmStatisticsFollowUpSummaryByUserRespVO() - .setFollowUpCustomerCount(followUpRecordCount).setFollowUpRecordCount(followUpCustomerCount).setOwnerUserId(userId); - }); - // 3.2 拼接用户信息 - appendUserInfo(summaryList); - return summaryList; - } - - @Override - public List getFollowUpSummaryByType(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 获得跟进数据 - return customerMapper.selectFollowUpRecordCountGroupByType(reqVO); - } - - @Override - public List getContractSummary(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按用户统计,获取统计数据 - List summaryList = customerMapper.selectContractSummary(reqVO); - - // 3. 拼接信息 - Map userMap = adminUserApi.getUserMap( - convertSetByFlatMap(summaryList, vo -> Stream.of(NumberUtils.parseLong(vo.getCreator()), vo.getOwnerUserId()))); - summaryList.forEach(vo -> { - findAndThen(userMap, NumberUtils.parseLong(vo.getCreator()), user -> vo.setCreatorUserName(user.getNickname())); - findAndThen(userMap, vo.getOwnerUserId(), user -> vo.setOwnerUserName(user.getNickname())); - }); - return summaryList; - } - - @Override - public List getPoolSummaryByDate(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List customerPutCountList = customerMapper.selectPoolCustomerPutCountByDate(reqVO); - List customerTakeCountList = customerMapper.selectPoolCustomerTakeCountByDate(reqVO); - - // 3. 按照日期间隔,合并数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Integer customerPutCount = customerPutCountList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToInt(CrmStatisticsPoolSummaryByDateRespVO::getCustomerPutCount).sum(); - Integer customerTakeCount = customerTakeCountList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToInt(CrmStatisticsPoolSummaryByDateRespVO::getCustomerTakeCount).sum(); - return new CrmStatisticsPoolSummaryByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setCustomerPutCount(customerPutCount).setCustomerTakeCount(customerTakeCount); - }); - } - - @Override - public List getPoolSummaryByUser(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按用户统计,获取分项统计数据 - List customerPutCountList = customerMapper.selectPoolCustomerPutCountByUser(reqVO); - List customerTakeCountList = customerMapper.selectPoolCustomerTakeCountByUser(reqVO); - - // 3.1 按照用户,合并统计数据 - List summaryList = convertList(reqVO.getUserIds(), userId -> { - Integer customerPutCount = customerPutCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsPoolSummaryByUserRespVO::getCustomerPutCount).sum(); - Integer customerTakeCount = customerTakeCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsPoolSummaryByUserRespVO::getCustomerTakeCount).sum(); - return (CrmStatisticsPoolSummaryByUserRespVO) new CrmStatisticsPoolSummaryByUserRespVO() - .setCustomerPutCount(customerPutCount).setCustomerTakeCount(customerTakeCount) - .setOwnerUserId(userId); - }); - // 3.2 拼接用户信息 - appendUserInfo(summaryList); - return summaryList; - } - - @Override - public List getCustomerDealCycleByDate(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List customerDealCycleList = customerMapper.selectCustomerDealCycleGroupByDate(reqVO); - - // 3. 按照日期间隔,合并统计数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Double customerDealCycle = customerDealCycleList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToDouble(CrmStatisticsCustomerDealCycleByDateRespVO::getCustomerDealCycle).sum(); - return new CrmStatisticsCustomerDealCycleByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setCustomerDealCycle(customerDealCycle); - }); - } - - @Override - public List getCustomerDealCycleByUser(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按用户统计,获取分项统计数据 - List customerDealCycleList = customerMapper.selectCustomerDealCycleGroupByUser(reqVO); - List customerDealCountList = customerMapper.selectCustomerDealCountGroupByUser(reqVO); - - // 3.1 按照用户,合并统计数据 - List summaryList = convertList(reqVO.getUserIds(), userId -> { - Double customerDealCycle = customerDealCycleList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToDouble(CrmStatisticsCustomerDealCycleByUserRespVO::getCustomerDealCycle).sum(); - Integer customerDealCount = customerDealCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) - .mapToInt(CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount).sum(); - return (CrmStatisticsCustomerDealCycleByUserRespVO) new CrmStatisticsCustomerDealCycleByUserRespVO() - .setCustomerDealCycle(customerDealCycle).setCustomerDealCount(customerDealCount).setOwnerUserId(userId); - }); - // 3.2 拼接用户信息 - appendUserInfo(summaryList); - return summaryList; - } - - @Override - public List getCustomerDealCycleByArea(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - reqVO.setUserIds(userIds); - - // 2. 获取客户地区统计数据 - List dealCycleByAreaList = customerMapper.selectCustomerDealCycleGroupByAreaId(reqVO); - if (CollUtil.isEmpty(dealCycleByAreaList)) { - return Collections.emptyList(); - } - - // 3. 拼接数据 - Map areaMap = convertMap(AreaUtils.getByType(AreaTypeEnum.PROVINCE, Function.identity()), Area::getId); - return convertList(dealCycleByAreaList, vo -> { - if (vo.getAreaId() != null) { - Integer parentId = AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE); - findAndThen(areaMap, parentId, area -> vo.setAreaId(parentId).setAreaName(area.getName())); - } - return vo; - }); - } - - @Override - public List getCustomerDealCycleByProduct(CrmStatisticsCustomerReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - reqVO.setUserIds(userIds); - - // 2. 获取客户产品统计数据 - // TODO @dhb52:未读取产品名 - return customerMapper.selectCustomerDealCycleGroupByProductId(reqVO); - } - - /** - * 拼接用户信息(昵称) - * - * @param voList 统计数据 - */ - private void appendUserInfo(List voList) { - Map userMap = adminUserApi.getUserMap( - convertSet(voList, CrmStatisticsCustomerByUserBaseRespVO::getOwnerUserId)); - voList.forEach(vo -> findAndThen(userMap, vo.getOwnerUserId(), user -> vo.setOwnerUserName(user.getNickname()))); - } - - /** - * 获取用户编号数组。如果用户编号为空, 则获得部门下的用户编号数组,包括子部门的所有用户编号 - * - * @param reqVO 请求参数 - * @return 用户编号数组 - */ - private List getUserIds(CrmStatisticsCustomerReqVO reqVO) { - // 情况一:选中某个用户 - if (ObjUtil.isNotNull(reqVO.getUserId())) { - return ListUtil.of(reqVO.getUserId()); - } - // 情况二:选中某个部门 - // 2.1 获得部门列表 - List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()).getCheckedData(), DeptRespDTO::getId); - deptIds.add(reqVO.getDeptId()); - // 2.2 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java deleted file mode 100644 index 10458daac..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; - -import java.util.List; - -/** - * CRM 销售漏斗分析 Service - * - * @author HUIHUI - */ -public interface CrmStatisticsFunnelService { - - /** - * 获得销售漏斗数据 - * - * @param reqVO 请求 - * @return 销售漏斗数据 - */ - CrmStatisticFunnelSummaryRespVO getFunnelSummary(CrmStatisticsFunnelReqVO reqVO); - - /** - * 获得商机结束状态统计 - * - * @param reqVO 请求 - * @return 商机结束状态统计 - */ - List getBusinessSummaryByEndStatus(CrmStatisticsFunnelReqVO reqVO); - - /** - * 获取新增商机分析(按日期) - * - * @param reqVO 请求 - * @return 新增商机分析 - */ - List getBusinessSummaryByDate(CrmStatisticsFunnelReqVO reqVO); - - /** - * 获得商机转化率分析(按日期) - * - * @param reqVO 请求 - * @return 商机转化率分析 - */ - List getBusinessInversionRateSummaryByDate(CrmStatisticsFunnelReqVO reqVO); - - /** - * 获得商机分页(按日期) - * - * @param pageVO 请求 - * @return 商机分页 - */ - PageResult getBusinessPageByDate(CrmStatisticsFunnelReqVO pageVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java deleted file mode 100644 index e11fa2f22..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsFunnelMapper; -import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -/** - * CRM 销售漏斗分析 Service 实现类 - * - * @author HUIHUI - */ -@Service -public class CrmStatisticsFunnelServiceImpl implements CrmStatisticsFunnelService { - - @Resource - private CrmStatisticsFunnelMapper funnelMapper; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private CrmBusinessService businessService; - @Resource - private DeptApi deptApi; - - @Override - public CrmStatisticFunnelSummaryRespVO getFunnelSummary(CrmStatisticsFunnelReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return null; - } - reqVO.setUserIds(userIds); - - // 2. 获得漏斗数据 - Long customerCount = funnelMapper.selectCustomerCountByDate(reqVO); - Long businessCount = funnelMapper.selectBusinessCountByDateAndEndStatus(reqVO, null); - Long businessWinCount = funnelMapper.selectBusinessCountByDateAndEndStatus(reqVO, CrmBusinessEndStatusEnum.WIN.getStatus()); - return new CrmStatisticFunnelSummaryRespVO(customerCount, businessCount, businessWinCount); - } - - @Override - public List getBusinessSummaryByEndStatus(CrmStatisticsFunnelReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 获得统计数据 - return funnelMapper.selectBusinessSummaryListGroupByEndStatus(reqVO); - } - - @Override - public List getBusinessSummaryByDate(CrmStatisticsFunnelReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List businessSummaryList = funnelMapper.selectBusinessSummaryGroupByDate(reqVO); - // 3. 按照日期间隔,合并数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Long businessCreateCount = businessSummaryList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToLong(CrmStatisticsBusinessSummaryByDateRespVO::getBusinessCreateCount).sum(); - BigDecimal businessDealCount = businessSummaryList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .map(CrmStatisticsBusinessSummaryByDateRespVO::getTotalPrice) - .reduce(BigDecimal.ZERO, BigDecimal::add); - return new CrmStatisticsBusinessSummaryByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setBusinessCreateCount(businessCreateCount).setTotalPrice(businessDealCount); - }); - } - - @Override - public List getBusinessInversionRateSummaryByDate(CrmStatisticsFunnelReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List businessSummaryList = funnelMapper.selectBusinessInversionRateSummaryByDate(reqVO); - // 3. 按照日期间隔,合并数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Long businessCount = businessSummaryList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToLong(CrmStatisticsBusinessInversionRateSummaryByDateRespVO::getBusinessCount).sum(); - Long businessWinCount = businessSummaryList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToLong(CrmStatisticsBusinessInversionRateSummaryByDateRespVO::getBusinessWinCount).sum(); - return new CrmStatisticsBusinessInversionRateSummaryByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setBusinessCount(businessCount).setBusinessWinCount(businessWinCount); - }); - } - - @Override - public PageResult getBusinessPageByDate(CrmStatisticsFunnelReqVO pageVO) { - // 1. 获得用户编号数组 - pageVO.setUserIds(getUserIds(pageVO)); - if (CollUtil.isEmpty(pageVO.getUserIds())) { - return PageResult.empty(); - } - // 2. 执行查询 - return businessService.getBusinessPageByDate(pageVO); - } - - /** - * 获取用户编号数组。如果用户编号为空, 则获得部门下的用户编号数组,包括子部门的所有用户编号 - * - * @param reqVO 请求参数 - * @return 用户编号数组 - */ - private List getUserIds(CrmStatisticsFunnelReqVO reqVO) { - // 情况一:选中某个用户 - if (ObjUtil.isNotNull(reqVO.getUserId())) { - return ListUtil.of(reqVO.getUserId()); - } - // 情况二:选中某个部门 - // 2.1 获得部门列表 - List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()).getCheckedData(), DeptRespDTO::getId); - deptIds.add(reqVO.getDeptId()); - // 2.2 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceService.java deleted file mode 100644 index 15423af29..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceService.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - - - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO; - -import java.util.List; - -/** - * CRM 员工绩效统计 Service 接口 - * - * @author scholar - */ -public interface CrmStatisticsPerformanceService { - - /** - * 员工签约合同数量分析 - * - * @param performanceReqVO 排行参数 - * @return 员工签约合同数量排行分析 - */ - List getContractCountPerformance(CrmStatisticsPerformanceReqVO performanceReqVO); - - /** - * 员工签约合同金额分析 - * - * @param performanceReqVO 排行参数 - * @return 员工签约合同金额分析 - */ - List getContractPricePerformance(CrmStatisticsPerformanceReqVO performanceReqVO); - - /** - * 员工获得回款金额分析 - * - * @param performanceReqVO 排行参数 - * @return 员工获得回款金额分析 - */ - List getReceivablePricePerformance(CrmStatisticsPerformanceReqVO performanceReqVO); - - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java deleted file mode 100644 index c193d9ec9..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java +++ /dev/null @@ -1,177 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO; -import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsPerformanceMapper; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.function.Function; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -/** - * CRM 员工业绩分析 Service 实现类 - * - * @author scholar - */ -@Service -@Validated -public class CrmStatisticsPerformanceServiceImpl implements CrmStatisticsPerformanceService { - - @Resource - private CrmStatisticsPerformanceMapper performanceMapper; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @Override - public List getContractCountPerformance(CrmStatisticsPerformanceReqVO performanceReqVO) { - // TODO @scholar:可以把下面这个注释,你理解后,重新整理下,写到 getPerformance 里; - // 比如说,2024 年的合同数据,是不是 2022-12 到 2024-12-31,每个月的统计呢? - // 理解之后,我们可以数据 group by 年-月,20222-12 到 2024-12-31 的,然后内存在聚合出 CrmStatisticsPerformanceRespVO 这样 - // 这样,我们就可以减少数据库的计算量,提升性能;同时 SQL 也会很简单,开发者理解起来也简单哈; - return getPerformance(performanceReqVO, performanceMapper::selectContractCountPerformance); - } - - @Override - public List getContractPricePerformance(CrmStatisticsPerformanceReqVO performanceReqVO) { - return getPerformance(performanceReqVO, performanceMapper::selectContractPricePerformance); - } - - @Override - public List getReceivablePricePerformance(CrmStatisticsPerformanceReqVO performanceReqVO) { - return getPerformance(performanceReqVO, performanceMapper::selectReceivablePricePerformance); - } - - // TODO @scholar:代码注释,应该有 3 个变量哈; - /** - * 获得员工业绩数据 - * - * @param performanceReqVO 参数 - * @param performanceFunction 员工业绩统计方法 - * @return 员工业绩数据 - */ - // TODO @scholar:下面一行的变量,超过一行了,阅读不美观;可以考虑每一行一个变量; - private List getPerformance(CrmStatisticsPerformanceReqVO performanceReqVO, Function> performanceFunction) { - - // TODO @scholar:没使用到的变量,建议删除; - List performanceRespVOList; - - // 1. 获得用户编号数组 - final List userIds = getUserIds(performanceReqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - performanceReqVO.setUserIds(userIds); - // TODO @scholar:1. 和 2. 之间,可以考虑换一行;保证每一块逻辑的间隔; - // 2. 获得业绩数据 - // TODO @scholar:复数变量,建议使用 s 或者 list 结果;这里用 performanceList 好列; - List performance = performanceFunction.apply(performanceReqVO); - - // 获取查询的年份 - // TODO @scholar:逻辑可以简化一下; - // TODO 1)把 performance 转换成 map;key 是 time,value 是 count - // TODO 2)当前年,遍历 1-12 月份,去 map 拿到 count;接着月份 -1,去 map 拿 count;再年份 -1,拿 count - String currentYear = LocalDateTimeUtil.format(performanceReqVO.getTimes()[0],"yyyy"); - - // 构造查询当年和前一年,每年12个月的年月组合 - List allMonths = new ArrayList<>(); - for (int year = Integer.parseInt(currentYear)-1; year <= Integer.parseInt(currentYear); year++) { - for (int month = 1; month <= 12; month++) { - allMonths.add(String.format("%d%02d", year, month)); - } - } - - List computedList = new ArrayList<>(); - List respVOList = new ArrayList<>(); - - // 生成computedList基础数据 - // 构造完整的2*12个月的数据,如果某月数据缺失,需要补上0,一年12个月不能有缺失 - for (String month : allMonths) { - CrmStatisticsPerformanceRespVO foundData = performance.stream() - .filter(data -> data.getTime().equals(month)) - .findFirst() - .orElse(null); - - if (foundData != null) { - computedList.add(foundData); - } else { - CrmStatisticsPerformanceRespVO missingData = new CrmStatisticsPerformanceRespVO(); - missingData.setTime(month); - missingData.setCurrentMonthCount(BigDecimal.ZERO); - missingData.setLastMonthCount(BigDecimal.ZERO); - missingData.setLastYearCount(BigDecimal.ZERO); - computedList.add(missingData); - } - } - //根据查询年份和前一年的数据,计算查询年份的同比环比数据 - for (CrmStatisticsPerformanceRespVO currentData : computedList) { - String currentMonth = currentData.getTime(); - - // 根据当年和前一年的月销售数据,计算currentYear的完整数据 - if (currentMonth.startsWith(currentYear)) { - // 计算 LastMonthCount - int currentIndex = computedList.indexOf(currentData); - if (currentIndex > 0) { - CrmStatisticsPerformanceRespVO lastMonthData = computedList.get(currentIndex - 1); - currentData.setLastMonthCount(lastMonthData.getCurrentMonthCount()); - } else { - currentData.setLastMonthCount(BigDecimal.ZERO); // 第一个月的 LastMonthCount 设为0 - } - - // 计算 LastYearCount - String lastYearMonth = String.valueOf(Integer.parseInt(currentMonth) - 100); - CrmStatisticsPerformanceRespVO lastYearData = computedList.stream() - .filter(data -> data.getTime().equals(lastYearMonth)) - .findFirst() - .orElse(null); - - if (lastYearData != null) { - currentData.setLastYearCount(lastYearData.getCurrentMonthCount()); - } else { - currentData.setLastYearCount(BigDecimal.ZERO); // 如果去年同月数据不存在,设为0 - } - respVOList.add(currentData);//给前端只需要返回查询当年的数据,不需要前一年数据 - } - } - return respVOList; - } - - /** - * 获取用户编号数组。如果用户编号为空, 则获得部门下的用户编号数组,包括子部门的所有用户编号 - * - * @param reqVO 请求参数 - * @return 用户编号数组 - */ - private List getUserIds(CrmStatisticsPerformanceReqVO reqVO) { - // 情况一:选中某个用户 - if (ObjUtil.isNotNull(reqVO.getUserId())) { - return ListUtil.of(reqVO.getUserId()); - } - // 情况二:选中某个部门 - // 2.1 获得部门列表 - final Long deptId = reqVO.getDeptId(); - List deptIds = convertList(deptApi.getChildDeptList(deptId).getCheckedData(), DeptRespDTO::getId); - deptIds.add(deptId); - // 2.2 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitService.java deleted file mode 100644 index c568d3b4e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitService.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait.*; - -import java.util.List; - -/** - * CRM 客户画像 Service 接口 - * - * @author HUIHUI - */ -public interface CrmStatisticsPortraitService { - - /** - * 获取客户地区统计数据 - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerSummaryByArea(CrmStatisticsPortraitReqVO reqVO); - - /** - * 获取客户行业统计数据 - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerSummaryByIndustry(CrmStatisticsPortraitReqVO reqVO); - - /** - * 获取客户级别统计数据 - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerSummaryByLevel(CrmStatisticsPortraitReqVO reqVO); - - /** - * 获取客户来源统计数据 - * - * @param reqVO 请求参数 - * @return 统计数据 - */ - List getCustomerSummaryBySource(CrmStatisticsPortraitReqVO reqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java deleted file mode 100644 index f9b252ca6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java +++ /dev/null @@ -1,131 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.portrait.*; -import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsPortraitMapper; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * CRM 客户画像 Service 实现类 - * - * @author HUIHUI - */ -@Service -public class CrmStatisticsPortraitServiceImpl implements CrmStatisticsPortraitService { - - @Resource - private CrmStatisticsPortraitMapper portraitMapper; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @Override - public List getCustomerSummaryByArea(CrmStatisticsPortraitReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - reqVO.setUserIds(userIds); - - // 2. 获取客户地区统计数据 - List list = portraitMapper.selectSummaryListGroupByAreaId(reqVO); - if (CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - - // 3. 拼接数据 - List areaList = AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area); - Map areaMap = convertMap(areaList, Area::getId); - return convertList(list, item -> { - Integer parentId = AreaUtils.getParentIdByType(item.getAreaId(), AreaTypeEnum.PROVINCE); - if (parentId != null) { - Area area = areaMap.get(parentId); - if (area != null) { - item.setAreaId(parentId).setAreaName(area.getName()); - return item; - } - } - // 找不到,归到未知 - return item.setAreaId(null).setAreaName("未知"); - }); - } - - @Override - public List getCustomerSummaryByIndustry(CrmStatisticsPortraitReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - reqVO.setUserIds(userIds); - - // 2. 获取客户行业统计数据 - return portraitMapper.selectCustomerIndustryListGroupByIndustryId(reqVO); - } - - @Override - public List getCustomerSummaryBySource(CrmStatisticsPortraitReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - reqVO.setUserIds(userIds); - - // 2. 获取客户行业统计数据 - return portraitMapper.selectCustomerSourceListGroupBySource(reqVO); - } - - @Override - public List getCustomerSummaryByLevel(CrmStatisticsPortraitReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - reqVO.setUserIds(userIds); - - // 2. 获取客户级别统计数据 - return portraitMapper.selectCustomerLevelListGroupByLevel(reqVO); - } - - /** - * 获取用户编号数组。如果用户编号为空, 则获得部门下的用户编号数组,包括子部门的所有用户编号 - * - * @param reqVO 请求参数 - * @return 用户编号数组 - */ - private List getUserIds(CrmStatisticsPortraitReqVO reqVO) { - // 情况一:选中某个用户 - if (ObjUtil.isNotNull(reqVO.getUserId())) { - return ListUtil.of(reqVO.getUserId()); - } - // 情况二:选中某个部门 - // 2.1 获得部门列表 - List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()).getCheckedData(), DeptRespDTO::getId); - deptIds.add(reqVO.getDeptId()); - // 2.2 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankService.java deleted file mode 100644 index 626e19247..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankService.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO; - -import java.util.List; - -/** - * CRM 排行榜统计 Service 接口 - * - * @author anhaohao - */ -public interface CrmStatisticsRankService { - - /** - * 获得合同金额排行榜 - * - * @param rankReqVO 排行参数 - * @return 合同金额排行榜 - */ - List getContractPriceRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得回款金额排行榜 - * - * @param rankReqVO 排行参数 - * @return 回款金额排行榜 - */ - List getReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得签约合同数量排行榜 - * - * @param rankReqVO 排行参数 - * @return 签约合同数量排行榜 - */ - List getContractCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得产品销量排行榜 - * - * @param rankReqVO 排行参数 - * @return 产品销量排行榜 - */ - List getProductSalesRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得新增客户数排行榜 - * - * @param rankReqVO 排行参数 - * @return 新增客户数排行榜 - */ - List getCustomerCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得联系人数量排行榜 - * - * @param rankReqVO 排行参数 - * @return 联系人数量排行榜 - */ - List getContactsCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得跟进次数排行榜 - * - * @param rankReqVO 排行参数 - * @return 跟进次数排行榜 - */ - List getFollowCountRank(CrmStatisticsRankReqVO rankReqVO); - - /** - * 获得跟进客户数排行榜 - * - * @param rankReqVO 排行参数 - * @return 跟进客户数排行榜 - */ - List getFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankServiceImpl.java deleted file mode 100644 index 7b2eb5463..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankServiceImpl.java +++ /dev/null @@ -1,134 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO; -import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsRankMapper; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -/** - * CRM 排行榜统计 Service 实现类 - * - * @author anhaohao - */ -@Service -@Validated -public class CrmStatisticsRankServiceImpl implements CrmStatisticsRankService { - - @Resource - private CrmStatisticsRankMapper rankMapper; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - - @Override - public List getContractPriceRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectContractPriceRank); - } - - @Override - public List getReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectReceivablePriceRank); - } - - @Override - public List getContractCountRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectContractCountRank); - } - - @Override - public List getProductSalesRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectProductSalesRank); - } - - @Override - public List getCustomerCountRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectCustomerCountRank); - } - - @Override - public List getContactsCountRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectContactsCountRank); - } - - @Override - public List getFollowCountRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectFollowCountRank); - } - - @Override - public List getFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO) { - return getRank(rankReqVO, rankMapper::selectFollowCustomerCountRank); - } - - /** - * 获得排行版数据 - * - * @param rankReqVO 参数 - * @param rankFunction 排行榜方法 - * @return 排行版数据 - */ - private List getRank(CrmStatisticsRankReqVO rankReqVO, Function> rankFunction) { - // 1. 获得用户编号数组 - rankReqVO.setUserIds(getUserIds(rankReqVO.getDeptId())); - if (CollUtil.isEmpty(rankReqVO.getUserIds())) { - return Collections.emptyList(); - } - // 2. 获得排行数据 - List ranks = rankFunction.apply(rankReqVO); - if (CollUtil.isEmpty(ranks)) { - return Collections.emptyList(); - } - ranks.sort(Comparator.comparing(CrmStatisticsRankRespVO::getCount).reversed()); - // 3. 拼接用户信息 - appendUserInfo(ranks); - return ranks; - } - - /** - * 拼接用户信息(昵称、部门) - * - * @param ranks 排行榜数据 - */ - private void appendUserInfo(List ranks) { - Map userMap = adminUserApi.getUserMap(convertSet(ranks, CrmStatisticsRankRespVO::getOwnerUserId)); - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - ranks.forEach(rank -> MapUtils.findAndThen(userMap, rank.getOwnerUserId(), user -> { - rank.setNickname(user.getNickname()); - MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> rank.setDeptName(dept.getName())); - })); - } - - /** - * 获得部门下的用户编号数组,包括子部门的 - * - * @param deptId 部门编号 - * @return 用户编号数组 - */ - public List getUserIds(Long deptId) { - // 1. 获得部门列表 - List deptIds = convertList(deptApi.getChildDeptList(deptId).getCheckedData(), DeptRespDTO::getId); - deptIds.add(deptId); - // 2. 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); - } - -} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmAuditStatusUtils.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmAuditStatusUtils.java deleted file mode 100644 index c1d4eaab7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmAuditStatusUtils.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.crm.util; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; - -/** - * CRM 流程工具类 - * - * @author HUIHUI - */ -public class CrmAuditStatusUtils { - - /** - * BPM 审批结果转换 - * - * @param bpmResult BPM 审批结果 - */ - public static Integer convertBpmResultToAuditStatus(Integer bpmResult) { - Integer auditStatus = BpmTaskStatusEnum.APPROVE.getStatus().equals(bpmResult) ? CrmAuditStatusEnum.APPROVE.getStatus() - : BpmTaskStatusEnum.REJECT.getStatus().equals(bpmResult) ? CrmAuditStatusEnum.REJECT.getStatus() - : BpmTaskStatusEnum.CANCEL.getStatus().equals(bpmResult) ? BpmTaskStatusEnum.CANCEL.getStatus() : null; - Assert.notNull(auditStatus, "BPM 审批结果({}) 转换失败", bpmResult); - return auditStatus; - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmPermissionUtils.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmPermissionUtils.java deleted file mode 100644 index a82be864c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmPermissionUtils.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.crm.util; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum; -import com.baomidou.mybatisplus.core.toolkit.support.SFunction; -import com.github.yulichang.autoconfigure.MybatisPlusJoinProperties; -import com.github.yulichang.wrapper.MPJLambdaWrapper; - -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -/** - * 数据权限工具类 - * - * @author HUIHUI - */ -public class CrmPermissionUtils { - - /** - * 校验用户是否是 CRM 管理员 - * - * @return 是/否 - */ - public static boolean isCrmAdmin() { - PermissionApi permissionApi = SpringUtil.getBean(PermissionApi.class); - return permissionApi.hasAnyRoles(getLoginUserId(), RoleCodeEnum.CRM_ADMIN.getCode()).getCheckedData(); - } - - /** - * 构造 CRM 数据类型数据分页查询条件 - * - * @param query 连表查询对象 - * @param bizType 数据类型 {@link CrmBizTypeEnum} - * @param bizId 数据编号 - * @param userId 用户编号 - * @param sceneType 场景类型 - * @param pool 公海 - */ - public static , S> void appendPermissionCondition(T query, Integer bizType, SFunction bizId, - Long userId, Integer sceneType, Boolean pool) { - MybatisPlusJoinProperties mybatisPlusJoinProperties = SpringUtil.getBean(MybatisPlusJoinProperties.class); - final String ownerUserIdField = mybatisPlusJoinProperties.getTableAlias() + ".owner_user_id"; - // 1. 构建数据权限连表条件 - if (!CrmPermissionUtils.isCrmAdmin() && ObjUtil.notEqual(pool, Boolean.TRUE)) { // 管理员,公海不需要数据权限 - query.innerJoin(CrmPermissionDO.class, on -> on.eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId) // 只能使用 SFunction 如果传 id 解析出来的 sql 不对 - .eq(CrmPermissionDO::getUserId, userId)); - } - // 2.1 场景一:我负责的数据 - if (CrmSceneTypeEnum.isOwner(sceneType)) { - query.eq(ownerUserIdField, userId); - } - // 2.2 场景二:我参与的数据 - if (CrmSceneTypeEnum.isInvolved(sceneType)) { - query.innerJoin(CrmPermissionDO.class, on -> on.eq(CrmPermissionDO::getBizType, bizType) - .eq(CrmPermissionDO::getBizId, bizId) - .in(CrmPermissionDO::getLevel, CrmPermissionLevelEnum.READ.getLevel(), CrmPermissionLevelEnum.WRITE.getLevel())); - query.ne(ownerUserIdField, userId); - } - // 2.3 场景三:下属负责的数据 - if (CrmSceneTypeEnum.isSubordinate(sceneType)) { - AdminUserApi adminUserApi = SpringUtil.getBean(AdminUserApi.class); - List subordinateUsers = adminUserApi.getUserListBySubordinate(userId).getCheckedData(); - if (CollUtil.isEmpty(subordinateUsers)) { - query.eq(ownerUserIdField, -1); // 不返回任何结果 - } else { - query.in(ownerUserIdField, convertSet(subordinateUsers, AdminUserRespDTO::getId)); - } - } - - // 3. 拼接公海的查询条件 - if (ObjUtil.equal(pool, Boolean.TRUE)) { // 情况一:公海 - query.isNull(ownerUserIdField); - } else { // 情况二:不是公海 - query.isNotNull(ownerUserIdField); - } - } - - /** - * 构造 CRM 数据类型批量数据查询条件 - * - * @param query 连表查询对象 - * @param bizType 数据类型 {@link CrmBizTypeEnum} - * @param bizIds 数据编号 - * @param userId 用户编号 - */ - public static > void appendPermissionCondition(T query, Integer bizType, Collection bizIds, Long userId) { - if (isCrmAdmin()) {// 管理员不需要数据权限 - return; - } - query.innerJoin(CrmPermissionDO.class, on -> - on.eq(CrmPermissionDO::getBizType, bizType).in(CrmPermissionDO::getBizId, bizIds) - .eq(CollUtil.isNotEmpty(bizIds), CrmPermissionDO::getUserId, userId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application-dev.yaml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index 2f6ca7bf7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,98 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application-local.yaml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 491c50045..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,123 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:8000/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.crm.dal.mysql: debug - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - security: - mock-enable: true - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application.yaml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application.yaml deleted file mode 100644 index 35175f57f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,107 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.crm - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - -debug: false diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/bootstrap.yaml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index f87220ec2..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: crm-server - - profiles: - active: local - -server: - port: 48089 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/logback-spring.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml deleted file mode 100644 index dc10f1221..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml +++ /dev/null @@ -1,266 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml deleted file mode 100644 index a07406259..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml deleted file mode 100644 index 79ff45471..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPortraitMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPortraitMapper.xml deleted file mode 100644 index 42056a48b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPortraitMapper.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsRankMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsRankMapper.xml deleted file mode 100644 index abd63f27d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsRankMapper.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index a55b301c6..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,49 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - data: - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/logback.xml b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/logback.xml deleted file mode 100644 index 1d071e479..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-erp/pom.xml b/yudao-module-erp/pom.xml deleted file mode 100644 index bed9d7d51..000000000 --- a/yudao-module-erp/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - cn.iocoder.cloud - yudao - ${revision} - - - yudao-module-erp-api - yudao-module-erp-biz - - 4.0.0 - yudao-module-erp - pom - - ${project.artifactId} - - erp 包下,企业资源管理(Enterprise Resource Planning)。 - 例如说:采购、销售、库存、财务、产品等等 - - - \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-api/pom.xml b/yudao-module-erp/yudao-module-erp-api/pom.xml deleted file mode 100644 index ef5394f10..000000000 --- a/yudao-module-erp/yudao-module-erp-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-erp - ${revision} - - 4.0.0 - yudao-module-erp-api - jar - - ${project.artifactId} - - erp 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/api/package-info.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/api/package-info.java deleted file mode 100644 index 540f18f0e..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * erp API 包,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.erp.api; diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ApiConstants.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ApiConstants.java deleted file mode 100644 index 1241dbc91..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "erp-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/erp"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/DictTypeConstants.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/DictTypeConstants.java deleted file mode 100644 index 36d4df852..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/DictTypeConstants.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums; - -/** - * ERP 字典类型的枚举类 - * - * @author 芋道源码 - */ -public interface DictTypeConstants { - - String AUDIT_STATUS = "erp_audit_status"; // 审核状态 - String STOCK_RECORD_BIZ_TYPE = "erp_stock_record_biz_type"; // 库存明细的业务类型 - -} diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErpAuditStatus.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErpAuditStatus.java deleted file mode 100644 index a10147a70..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErpAuditStatus.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * ERP 审核状态枚举 - * - * TODO 芋艿:目前只有待审批、已审批两个状态,未来接入工作流后,会丰富下:待提交(草稿)=》已提交(待审核)=》审核通过、审核不通过;另外,工作流需要支持“反审核”,把工作流退回到原点; - * - * @author 芋道源码 - */ -@RequiredArgsConstructor -@Getter -public enum ErpAuditStatus implements IntArrayValuable { - - PROCESS(10, "未审核"), // 审核中 - APPROVE(20, "已审核"); // 审核通过 - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpAuditStatus::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErrorCodeConstants.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErrorCodeConstants.java deleted file mode 100644 index 65f64c2f5..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,168 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * ERP 错误码枚举类 - *

- * erp 系统,使用 1-030-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== ERP 供应商(1-030-100-000) ========== - ErrorCode SUPPLIER_NOT_EXISTS = new ErrorCode(1_030_100_000, "供应商不存在"); - ErrorCode SUPPLIER_NOT_ENABLE = new ErrorCode(1_030_100_000, "供应商({})未启用"); - - // ========== ERP 采购订单(1-030-101-000) ========== - ErrorCode PURCHASE_ORDER_NOT_EXISTS = new ErrorCode(1_030_101_000, "采购订单不存在"); - ErrorCode PURCHASE_ORDER_DELETE_FAIL_APPROVE = new ErrorCode(1_030_101_001, "采购订单({})已审核,无法删除"); - ErrorCode PURCHASE_ORDER_PROCESS_FAIL = new ErrorCode(1_030_101_002, "反审核失败,只有已审核的采购订单才能反审核"); - ErrorCode PURCHASE_ORDER_APPROVE_FAIL = new ErrorCode(1_030_101_003, "审核失败,只有未审核的采购订单才能审核"); - ErrorCode PURCHASE_ORDER_NO_EXISTS = new ErrorCode(1_030_101_004, "生成采购单号失败,请重新提交"); - ErrorCode PURCHASE_ORDER_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_101_005, "采购订单({})已审核,无法修改"); - ErrorCode PURCHASE_ORDER_NOT_APPROVE = new ErrorCode(1_030_101_006, "采购订单未审核,无法操作"); - ErrorCode PURCHASE_ORDER_ITEM_IN_FAIL_PRODUCT_EXCEED = new ErrorCode(1_030_101_007, "采购订单项({})超过最大允许入库数量({})"); - ErrorCode PURCHASE_ORDER_PROCESS_FAIL_EXISTS_IN = new ErrorCode(1_030_101_008, "反审核失败,已存在对应的采购入库单"); -ErrorCode PURCHASE_ORDER_ITEM_RETURN_FAIL_IN_EXCEED = new ErrorCode(1_030_101_009, "采购订单项({})超过最大允许退货数量({})"); - ErrorCode PURCHASE_ORDER_PROCESS_FAIL_EXISTS_RETURN = new ErrorCode(1_030_101_010, "反审核失败,已存在对应的采购退货单"); - - // ========== ERP 采购入库(1-030-102-000) ========== - ErrorCode PURCHASE_IN_NOT_EXISTS = new ErrorCode(1_030_102_000, "采购入库单不存在"); - ErrorCode PURCHASE_IN_DELETE_FAIL_APPROVE = new ErrorCode(1_030_102_001, "采购入库单({})已审核,无法删除"); - ErrorCode PURCHASE_IN_PROCESS_FAIL = new ErrorCode(1_030_102_002, "反审核失败,只有已审核的入库单才能反审核"); - ErrorCode PURCHASE_IN_APPROVE_FAIL = new ErrorCode(1_030_102_003, "审核失败,只有未审核的入库单才能审核"); - ErrorCode PURCHASE_IN_NO_EXISTS = new ErrorCode(1_030_102_004, "生成入库单失败,请重新提交"); - ErrorCode PURCHASE_IN_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_102_005, "采购入库单({})已审核,无法修改"); - ErrorCode PURCHASE_IN_NOT_APPROVE = new ErrorCode(1_030_102_006, "采购入库单未审核,无法操作"); - ErrorCode PURCHASE_IN_FAIL_PAYMENT_PRICE_EXCEED = new ErrorCode(1_030_102_007, "付款金额({})超过采购入库单总金额({})"); - ErrorCode PURCHASE_IN_PROCESS_FAIL_EXISTS_PAYMENT = new ErrorCode(1_030_102_008, "反审核失败,已存在对应的付款单"); - - // ========== ERP 采购退货(1-030-103-000) ========== - ErrorCode PURCHASE_RETURN_NOT_EXISTS = new ErrorCode(1_030_103_000, "采购退货单不存在"); - ErrorCode PURCHASE_RETURN_DELETE_FAIL_APPROVE = new ErrorCode(1_030_103_001, "采购退货单({})已审核,无法删除"); - ErrorCode PURCHASE_RETURN_PROCESS_FAIL = new ErrorCode(1_030_103_002, "反审核失败,只有已审核的退货单才能反审核"); - ErrorCode PURCHASE_RETURN_APPROVE_FAIL = new ErrorCode(1_030_103_003, "审核失败,只有未审核的退货单才能审核"); - ErrorCode PURCHASE_RETURN_NO_EXISTS = new ErrorCode(1_030_103_004, "生成退货单失败,请重新提交"); - ErrorCode PURCHASE_RETURN_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_103_005, "采购退货单({})已审核,无法修改"); - ErrorCode PURCHASE_RETURN_NOT_APPROVE = new ErrorCode(1_030_103_006, "采购退货单未审核,无法操作"); - ErrorCode PURCHASE_RETURN_FAIL_REFUND_PRICE_EXCEED = new ErrorCode(1_030_103_007, "退款金额({})超过采购退货单总金额({})"); - ErrorCode PURCHASE_RETURN_PROCESS_FAIL_EXISTS_REFUND = new ErrorCode(1_030_103_008, "反审核失败,已存在对应的退款单"); - - // ========== ERP 客户(1-030-200-000)========== - ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_200_000, "客户不存在"); - ErrorCode CUSTOMER_NOT_ENABLE = new ErrorCode(1_020_200_001, "客户({})未启用"); - - // ========== ERP 销售订单(1-030-201-000) ========== - ErrorCode SALE_ORDER_NOT_EXISTS = new ErrorCode(1_020_201_000, "销售订单不存在"); - ErrorCode SALE_ORDER_DELETE_FAIL_APPROVE = new ErrorCode(1_020_201_001, "销售订单({})已审核,无法删除"); - ErrorCode SALE_ORDER_PROCESS_FAIL = new ErrorCode(1_020_201_002, "反审核失败,只有已审核的销售订单才能反审核"); - ErrorCode SALE_ORDER_APPROVE_FAIL = new ErrorCode(1_020_201_003, "审核失败,只有未审核的销售订单才能审核"); - ErrorCode SALE_ORDER_NO_EXISTS = new ErrorCode(1_020_201_004, "生成销售单号失败,请重新提交"); - ErrorCode SALE_ORDER_UPDATE_FAIL_APPROVE = new ErrorCode(1_020_201_005, "销售订单({})已审核,无法修改"); - ErrorCode SALE_ORDER_NOT_APPROVE = new ErrorCode(1_020_201_006, "销售订单未审核,无法操作"); - ErrorCode SALE_ORDER_ITEM_OUT_FAIL_PRODUCT_EXCEED = new ErrorCode(1_020_201_007, "销售订单项({})超过最大允许出库数量({})"); - ErrorCode SALE_ORDER_PROCESS_FAIL_EXISTS_OUT = new ErrorCode(1_020_201_008, "反审核失败,已存在对应的销售出库单"); - ErrorCode SALE_ORDER_ITEM_RETURN_FAIL_OUT_EXCEED = new ErrorCode(1_020_201_009, "销售订单项({})超过最大允许退货数量({})"); - ErrorCode SALE_ORDER_PROCESS_FAIL_EXISTS_RETURN = new ErrorCode(1_020_201_010, "反审核失败,已存在对应的销售退货单"); - - // ========== ERP 销售出库(1-030-202-000) ========== - ErrorCode SALE_OUT_NOT_EXISTS = new ErrorCode(1_020_202_000, "销售出库单不存在"); - ErrorCode SALE_OUT_DELETE_FAIL_APPROVE = new ErrorCode(1_020_202_001, "销售出库单({})已审核,无法删除"); - ErrorCode SALE_OUT_PROCESS_FAIL = new ErrorCode(1_020_202_002, "反审核失败,只有已审核的出库单才能反审核"); - ErrorCode SALE_OUT_APPROVE_FAIL = new ErrorCode(1_020_202_003, "审核失败,只有未审核的出库单才能审核"); - ErrorCode SALE_OUT_NO_EXISTS = new ErrorCode(1_020_202_004, "生成出库单失败,请重新提交"); - ErrorCode SALE_OUT_UPDATE_FAIL_APPROVE = new ErrorCode(1_020_202_005, "销售出库单({})已审核,无法修改"); - ErrorCode SALE_OUT_NOT_APPROVE = new ErrorCode(1_020_202_006, "销售出库单未审核,无法操作"); - ErrorCode SALE_OUT_FAIL_RECEIPT_PRICE_EXCEED = new ErrorCode(1_020_202_007, "收款金额({})超过销售出库单总金额({})"); - ErrorCode SALE_OUT_PROCESS_FAIL_EXISTS_RECEIPT = new ErrorCode(1_020_202_008, "反审核失败,已存在对应的收款单"); - - // ========== ERP 销售退货(1-030-203-000) ========== - ErrorCode SALE_RETURN_NOT_EXISTS = new ErrorCode(1_020_203_000, "销售退货单不存在"); - ErrorCode SALE_RETURN_DELETE_FAIL_APPROVE = new ErrorCode(1_020_203_001, "销售退货单({})已审核,无法删除"); - ErrorCode SALE_RETURN_PROCESS_FAIL = new ErrorCode(1_020_203_002, "反审核失败,只有已审核的退货单才能反审核"); - ErrorCode SALE_RETURN_APPROVE_FAIL = new ErrorCode(1_020_203_003, "审核失败,只有未审核的退货单才能审核"); - ErrorCode SALE_RETURN_NO_EXISTS = new ErrorCode(1_020_203_004, "生成退货单失败,请重新提交"); - ErrorCode SALE_RETURN_UPDATE_FAIL_APPROVE = new ErrorCode(1_020_203_005, "销售退货单({})已审核,无法修改"); - ErrorCode SALE_RETURN_NOT_APPROVE = new ErrorCode(1_020_203_006, "销售退货单未审核,无法操作"); - ErrorCode SALE_RETURN_FAIL_REFUND_PRICE_EXCEED = new ErrorCode(1_020_203_007, "退款金额({})超过销售退货单总金额({})"); - ErrorCode SALE_RETURN_PROCESS_FAIL_EXISTS_REFUND = new ErrorCode(1_020_203_008, "反审核失败,已存在对应的退款单"); - - // ========== ERP 仓库 1-030-400-000 ========== - ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_030_400_000, "仓库不存在"); - ErrorCode WAREHOUSE_NOT_ENABLE = new ErrorCode(1_030_400_001, "仓库({})未启用"); - - // ========== ERP 其它入库单 1-030-401-000 ========== - ErrorCode STOCK_IN_NOT_EXISTS = new ErrorCode(1_030_401_000, "其它入库单不存在"); - ErrorCode STOCK_IN_DELETE_FAIL_APPROVE = new ErrorCode(1_030_401_001, "其它入库单({})已审核,无法删除"); - ErrorCode STOCK_IN_PROCESS_FAIL = new ErrorCode(1_030_401_002, "反审核失败,只有已审核的入库单才能反审核"); - ErrorCode STOCK_IN_APPROVE_FAIL = new ErrorCode(1_030_401_003, "审核失败,只有未审核的入库单才能审核"); - ErrorCode STOCK_IN_NO_EXISTS = new ErrorCode(1_030_401_004, "生成入库单失败,请重新提交"); - ErrorCode STOCK_IN_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_401_005, "其它入库单({})已审核,无法修改"); - - // ========== ERP 其它出库单 1-030-402-000 ========== - ErrorCode STOCK_OUT_NOT_EXISTS = new ErrorCode(1_030_402_000, "其它出库单不存在"); - ErrorCode STOCK_OUT_DELETE_FAIL_APPROVE = new ErrorCode(1_030_402_001, "其它出库单({})已审核,无法删除"); - ErrorCode STOCK_OUT_PROCESS_FAIL = new ErrorCode(1_030_402_002, "反审核失败,只有已审核的出库单才能反审核"); - ErrorCode STOCK_OUT_APPROVE_FAIL = new ErrorCode(1_030_402_003, "审核失败,只有未审核的出库单才能审核"); - ErrorCode STOCK_OUT_NO_EXISTS = new ErrorCode(1_030_402_004, "生成出库单失败,请重新提交"); - ErrorCode STOCK_OUT_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_402_005, "其它出库单({})已审核,无法修改"); - - // ========== ERP 库存调拨单 1-030-403-000 ========== - ErrorCode STOCK_MOVE_NOT_EXISTS = new ErrorCode(1_030_402_000, "库存调拨单不存在"); - ErrorCode STOCK_MOVE_DELETE_FAIL_APPROVE = new ErrorCode(1_030_402_001, "库存调拨单({})已审核,无法删除"); - ErrorCode STOCK_MOVE_PROCESS_FAIL = new ErrorCode(1_030_402_002, "反审核失败,只有已审核的调拨单才能反审核"); - ErrorCode STOCK_MOVE_APPROVE_FAIL = new ErrorCode(1_030_402_003, "审核失败,只有未审核的调拨单才能审核"); - ErrorCode STOCK_MOVE_NO_EXISTS = new ErrorCode(1_030_402_004, "生成调拨号失败,请重新提交"); - ErrorCode STOCK_MOVE_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_402_005, "库存调拨单({})已审核,无法修改"); - - // ========== ERP 库存盘点单 1-030-403-000 ========== - ErrorCode STOCK_CHECK_NOT_EXISTS = new ErrorCode(1_030_403_000, "库存盘点单不存在"); - ErrorCode STOCK_CHECK_DELETE_FAIL_APPROVE = new ErrorCode(1_030_403_001, "库存盘点单({})已审核,无法删除"); - ErrorCode STOCK_CHECK_PROCESS_FAIL = new ErrorCode(1_030_403_002, "反审核失败,只有已审核的盘点单才能反审核"); - ErrorCode STOCK_CHECK_APPROVE_FAIL = new ErrorCode(1_030_403_003, "审核失败,只有未审核的盘点单才能审核"); - ErrorCode STOCK_CHECK_NO_EXISTS = new ErrorCode(1_030_403_004, "生成盘点号失败,请重新提交"); - ErrorCode STOCK_CHECK_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_403_005, "库存盘点单({})已审核,无法修改"); - - // ========== ERP 产品库存 1-030-404-000 ========== - ErrorCode STOCK_COUNT_NEGATIVE = new ErrorCode(1_030_404_000, "操作失败,产品({})所在仓库({})的库存:{},小于变更数量:{}"); - ErrorCode STOCK_COUNT_NEGATIVE2 = new ErrorCode(1_030_404_001, "操作失败,产品({})所在仓库({})的库存不足"); - - // ========== ERP 产品 1-030-500-000 ========== - ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_030_500_000, "产品不存在"); - ErrorCode PRODUCT_NOT_ENABLE = new ErrorCode(1_030_500_001, "产品({})未启用"); - - // ========== ERP 产品分类 1-030-501-000 ========== - ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_030_501_000, "产品分类不存在"); - ErrorCode PRODUCT_CATEGORY_EXITS_CHILDREN = new ErrorCode(1_030_501_001, "存在存在子产品分类,无法删除"); - ErrorCode PRODUCT_CATEGORY_PARENT_NOT_EXITS = new ErrorCode(1_030_501_002,"父级产品分类不存在"); - ErrorCode PRODUCT_CATEGORY_PARENT_ERROR = new ErrorCode(1_030_501_003, "不能设置自己为父产品分类"); - ErrorCode PRODUCT_CATEGORY_NAME_DUPLICATE = new ErrorCode(1_030_501_004, "已经存在该分类名称的产品分类"); - ErrorCode PRODUCT_CATEGORY_PARENT_IS_CHILD = new ErrorCode(1_030_501_005, "不能设置自己的子分类为父分类"); - ErrorCode PRODUCT_CATEGORY_EXITS_PRODUCT = new ErrorCode(1_030_502_002, "存在产品使用该分类,无法删除"); - - // ========== ERP 产品单位 1-030-502-000 ========== - ErrorCode PRODUCT_UNIT_NOT_EXISTS = new ErrorCode(1_030_502_000, "产品单位不存在"); - ErrorCode PRODUCT_UNIT_NAME_DUPLICATE = new ErrorCode(1_030_502_001, "已存在该名字的产品单位"); - ErrorCode PRODUCT_UNIT_EXITS_PRODUCT = new ErrorCode(1_030_502_002, "存在产品使用该单位,无法删除"); - - // ========== ERP 结算账户 1-030-600-000 ========== - ErrorCode ACCOUNT_NOT_EXISTS = new ErrorCode(1_030_600_000, "结算账户不存在"); - ErrorCode ACCOUNT_NOT_ENABLE = new ErrorCode(1_030_600_001, "结算账户({})未启用"); - - // ========== ERP 付款单 1-030-601-000 ========== - ErrorCode FINANCE_PAYMENT_NOT_EXISTS = new ErrorCode(1_030_601_000, "付款单不存在"); - ErrorCode FINANCE_PAYMENT_DELETE_FAIL_APPROVE = new ErrorCode(1_030_601_001, "付款单({})已审核,无法删除"); - ErrorCode FINANCE_PAYMENT_PROCESS_FAIL = new ErrorCode(1_030_601_002, "反审核失败,只有已审核的付款单才能反审核"); - ErrorCode FINANCE_PAYMENT_APPROVE_FAIL = new ErrorCode(1_030_601_003, "审核失败,只有未审核的付款单才能审核"); - ErrorCode FINANCE_PAYMENT_NO_EXISTS = new ErrorCode(1_030_601_004, "生成付款单号失败,请重新提交"); - ErrorCode FINANCE_PAYMENT_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_601_005, "付款单({})已审核,无法修改"); - - // ========== ERP 收款单 1-030-602-000 ========== - ErrorCode FINANCE_RECEIPT_NOT_EXISTS = new ErrorCode(1_030_602_000, "收款单不存在"); - ErrorCode FINANCE_RECEIPT_DELETE_FAIL_APPROVE = new ErrorCode(1_030_602_001, "收款单({})已审核,无法删除"); - ErrorCode FINANCE_RECEIPT_PROCESS_FAIL = new ErrorCode(1_030_602_002, "反审核失败,只有已审核的收款单才能反审核"); - ErrorCode FINANCE_RECEIPT_APPROVE_FAIL = new ErrorCode(1_030_602_003, "审核失败,只有未审核的收款单才能审核"); - ErrorCode FINANCE_RECEIPT_NO_EXISTS = new ErrorCode(1_030_602_004, "生成收款单号失败,请重新提交"); - ErrorCode FINANCE_RECEIPT_UPDATE_FAIL_APPROVE = new ErrorCode(1_030_602_005, "收款单({})已审核,无法修改"); - -} diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/LogRecordConstants.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/LogRecordConstants.java deleted file mode 100644 index 73b72c0a9..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/LogRecordConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums; - -/** - * ERP 操作日志枚举 - * 目的:统一管理,也减少 Service 里各种“复杂”字符串 - * - * @author 芋道源码 - */ -public interface LogRecordConstants { - - -} diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/common/ErpBizTypeEnum.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/common/ErpBizTypeEnum.java deleted file mode 100644 index a2770598e..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/common/ErpBizTypeEnum.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * ERP 业务类型枚举 - * - * @author HUIHUI - */ -@RequiredArgsConstructor -@Getter -public enum ErpBizTypeEnum implements IntArrayValuable { - - PURCHASE_ORDER(10, "采购订单"), - PURCHASE_IN(11, "采购入库"), - PURCHASE_RETURN(12, "采购退货"), - - SALE_ORDER(20, "销售订单"), - SALE_OUT(21, "销售出库"), - SALE_RETURN(22, "销售退货"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpBizTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/stock/ErpStockRecordBizTypeEnum.java b/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/stock/ErpStockRecordBizTypeEnum.java deleted file mode 100644 index 559bf4ccf..000000000 --- a/yudao-module-erp/yudao-module-erp-api/src/main/java/cn/iocoder/yudao/module/erp/enums/stock/ErpStockRecordBizTypeEnum.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.erp.enums.stock; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * ERP 库存明细 - 业务类型枚举 - * - * @author 芋道源码 - */ -@RequiredArgsConstructor -@Getter -public enum ErpStockRecordBizTypeEnum implements IntArrayValuable { - - OTHER_IN(10, "其它入库"), - OTHER_IN_CANCEL(11, "其它入库(作废)"), - - OTHER_OUT(20, "其它出库"), - OTHER_OUT_CANCEL(21, "其它出库(作废)"), - - MOVE_IN(30, "调拨入库"), - MOVE_IN_CANCEL(31, "调拨入库(作废)"), - MOVE_OUT(32, "调拨出库"), - MOVE_OUT_CANCEL(33, "调拨出库(作废)"), - - CHECK_MORE_IN(40, "盘盈入库"), - CHECK_MORE_IN_CANCEL(41, "盘盈入库(作废)"), - CHECK_LESS_OUT(42, "盘亏出库"), - CHECK_LESS_OUT_CANCEL(43, "盘亏出库(作废)"), - - SALE_OUT(50, "销售出库"), - SALE_OUT_CANCEL(51, "销售出库(作废)"), - - SALE_RETURN(60, "销售退货入库"), - SALE_RETURN_CANCEL(61, "销售退货入库(作废)"), - - PURCHASE_IN(70, "采购入库"), - PURCHASE_IN_CANCEL(71, "采购入库(作废)"), - - PURCHASE_RETURN(80, "采购退货出库"), - PURCHASE_RETURN_CANCEL(81, "采购退货出库(作废)"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpStockRecordBizTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/Dockerfile b/yudao-module-erp/yudao-module-erp-biz/Dockerfile deleted file mode 100644 index f46f7c83f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-erp-biz -WORKDIR /yudao-module-erp-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-erp-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48088 端口 -EXPOSE 48088 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-erp/yudao-module-erp-biz/pom.xml b/yudao-module-erp/yudao-module-erp-biz/pom.xml deleted file mode 100644 index f4ce49135..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/pom.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-erp - ${revision} - - 4.0.0 - yudao-module-erp-biz - - ${project.artifactId} - - erp 包下,企业资源管理(Enterprise Resource Planning)。 - 例如说:采购、销售、库存、财务、产品等等 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - cn.iocoder.cloud - yudao-module-erp-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/ErpServerApplication.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/ErpServerApplication.java deleted file mode 100644 index 07a3cd6e1..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/ErpServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - *

- * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class ErpServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(ErpServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpAccountController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpAccountController.java deleted file mode 100644 index 6bc2f6b2b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpAccountController.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 结算账户") -@RestController -@RequestMapping("/erp/account") -@Validated -public class ErpAccountController { - - @Resource - private ErpAccountService accountService; - - @PostMapping("/create") - @Operation(summary = "创建结算账户") - @PreAuthorize("@ss.hasPermission('erp:account:create')") - public CommonResult createAccount(@Valid @RequestBody ErpAccountSaveReqVO createReqVO) { - return success(accountService.createAccount(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新结算账户") - @PreAuthorize("@ss.hasPermission('erp:account:update')") - public CommonResult updateAccount(@Valid @RequestBody ErpAccountSaveReqVO updateReqVO) { - accountService.updateAccount(updateReqVO); - return success(true); - } - - @PutMapping("/update-default-status") - @Operation(summary = "更新结算账户默认状态") - @Parameters({ - @Parameter(name = "id", description = "编号", required = true), - @Parameter(name = "status", description = "状态", required = true) - }) - public CommonResult updateAccountDefaultStatus(@RequestParam("id") Long id, - @RequestParam("defaultStatus") Boolean defaultStatus) { - accountService.updateAccountDefaultStatus(id, defaultStatus); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除结算账户") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:account:delete')") - public CommonResult deleteAccount(@RequestParam("id") Long id) { - accountService.deleteAccount(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得结算账户") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:account:query')") - public CommonResult getAccount(@RequestParam("id") Long id) { - ErpAccountDO account = accountService.getAccount(id); - return success(BeanUtils.toBean(account, ErpAccountRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得结算账户精简列表", description = "只包含被开启的结算账户,主要用于前端的下拉选项") - public CommonResult> getWarehouseSimpleList() { - List list = accountService.getAccountListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, account -> new ErpAccountRespVO().setId(account.getId()) - .setName(account.getName()).setDefaultStatus(account.getDefaultStatus()))); - } - - @GetMapping("/page") - @Operation(summary = "获得结算账户分页") - @PreAuthorize("@ss.hasPermission('erp:account:query')") - public CommonResult> getAccountPage(@Valid ErpAccountPageReqVO pageReqVO) { - PageResult pageResult = accountService.getAccountPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ErpAccountRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出结算账户 Excel") - @PreAuthorize("@ss.hasPermission('erp:account:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportAccountExcel(@Valid ErpAccountPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = accountService.getAccountPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "结算账户.xls", "数据", ErpAccountRespVO.class, - BeanUtils.toBean(list, ErpAccountRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinancePaymentController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinancePaymentController.java deleted file mode 100644 index 22d620821..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinancePaymentController.java +++ /dev/null @@ -1,153 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.finance.ErpFinancePaymentService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; - -@Tag(name = "管理后台 - ERP 付款单") -@RestController -@RequestMapping("/erp/finance-payment") -@Validated -public class ErpFinancePaymentController { - - @Resource - private ErpFinancePaymentService financePaymentService; - @Resource - private ErpSupplierService supplierService; - @Resource - private ErpAccountService accountService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建付款单") - @PreAuthorize("@ss.hasPermission('erp:finance-payment:create')") - public CommonResult createFinancePayment(@Valid @RequestBody ErpFinancePaymentSaveReqVO createReqVO) { - return success(financePaymentService.createFinancePayment(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新付款单") - @PreAuthorize("@ss.hasPermission('erp:finance-payment:update')") - public CommonResult updateFinancePayment(@Valid @RequestBody ErpFinancePaymentSaveReqVO updateReqVO) { - financePaymentService.updateFinancePayment(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新付款单的状态") - @PreAuthorize("@ss.hasPermission('erp:finance-payment:update-status')") - public CommonResult updateFinancePaymentStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - financePaymentService.updateFinancePaymentStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除付款单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:finance-payment:delete')") - public CommonResult deleteFinancePayment(@RequestParam("ids") List ids) { - financePaymentService.deleteFinancePayment(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得付款单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:finance-payment:query')") - public CommonResult getFinancePayment(@RequestParam("id") Long id) { - ErpFinancePaymentDO payment = financePaymentService.getFinancePayment(id); - if (payment == null) { - return success(null); - } - List paymentItemList = financePaymentService.getFinancePaymentItemListByPaymentId(id); - return success(BeanUtils.toBean(payment, ErpFinancePaymentRespVO.class, financePaymentVO -> - financePaymentVO.setItems(BeanUtils.toBean(paymentItemList, ErpFinancePaymentRespVO.Item.class)))); - } - - @GetMapping("/page") - @Operation(summary = "获得付款单分页") - @PreAuthorize("@ss.hasPermission('erp:finance-payment:query')") - public CommonResult> getFinancePaymentPage(@Valid ErpFinancePaymentPageReqVO pageReqVO) { - PageResult pageResult = financePaymentService.getFinancePaymentPage(pageReqVO); - return success(buildFinancePaymentVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出付款单 Excel") - @PreAuthorize("@ss.hasPermission('erp:finance-payment:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportFinancePaymentExcel(@Valid ErpFinancePaymentPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildFinancePaymentVOPageResult(financePaymentService.getFinancePaymentPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "付款单.xls", "数据", ErpFinancePaymentRespVO.class, list); - } - - private PageResult buildFinancePaymentVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 付款项 - List paymentItemList = financePaymentService.getFinancePaymentItemListByPaymentIds( - convertSet(pageResult.getList(), ErpFinancePaymentDO::getId)); - Map> financePaymentItemMap = convertMultiMap(paymentItemList, ErpFinancePaymentItemDO::getPaymentId); - // 1.2 供应商信息 - Map supplierMap = supplierService.getSupplierMap( - convertSet(pageResult.getList(), ErpFinancePaymentDO::getSupplierId)); - // 1.3 结算账户信息 - Map accountMap = accountService.getAccountMap( - convertSet(pageResult.getList(), ErpFinancePaymentDO::getAccountId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(pageResult.getList(), - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getFinanceUserId()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpFinancePaymentRespVO.class, payment -> { - payment.setItems(BeanUtils.toBean(financePaymentItemMap.get(payment.getId()), ErpFinancePaymentRespVO.Item.class)); - MapUtils.findAndThen(supplierMap, payment.getSupplierId(), supplier -> payment.setSupplierName(supplier.getName())); - MapUtils.findAndThen(accountMap, payment.getAccountId(), account -> payment.setAccountName(account.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(payment.getCreator()), user -> payment.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, payment.getFinanceUserId(), user -> payment.setFinanceUserName(user.getNickname())); - }); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinanceReceiptController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinanceReceiptController.java deleted file mode 100644 index b9cc01740..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinanceReceiptController.java +++ /dev/null @@ -1,153 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.finance.ErpFinanceReceiptService; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; - -@Tag(name = "管理后台 - ERP 收款单") -@RestController -@RequestMapping("/erp/finance-receipt") -@Validated -public class ErpFinanceReceiptController { - - @Resource - private ErpFinanceReceiptService financeReceiptService; - @Resource - private ErpCustomerService customerService; - @Resource - private ErpAccountService accountService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建收款单") - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:create')") - public CommonResult createFinanceReceipt(@Valid @RequestBody ErpFinanceReceiptSaveReqVO createReqVO) { - return success(financeReceiptService.createFinanceReceipt(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新收款单") - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:update')") - public CommonResult updateFinanceReceipt(@Valid @RequestBody ErpFinanceReceiptSaveReqVO updateReqVO) { - financeReceiptService.updateFinanceReceipt(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新收款单的状态") - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:update-status')") - public CommonResult updateFinanceReceiptStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - financeReceiptService.updateFinanceReceiptStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除收款单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:delete')") - public CommonResult deleteFinanceReceipt(@RequestParam("ids") List ids) { - financeReceiptService.deleteFinanceReceipt(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得收款单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:query')") - public CommonResult getFinanceReceipt(@RequestParam("id") Long id) { - ErpFinanceReceiptDO receipt = financeReceiptService.getFinanceReceipt(id); - if (receipt == null) { - return success(null); - } - List receiptItemList = financeReceiptService.getFinanceReceiptItemListByReceiptId(id); - return success(BeanUtils.toBean(receipt, ErpFinanceReceiptRespVO.class, financeReceiptVO -> - financeReceiptVO.setItems(BeanUtils.toBean(receiptItemList, ErpFinanceReceiptRespVO.Item.class)))); - } - - @GetMapping("/page") - @Operation(summary = "获得收款单分页") - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:query')") - public CommonResult> getFinanceReceiptPage(@Valid ErpFinanceReceiptPageReqVO pageReqVO) { - PageResult pageResult = financeReceiptService.getFinanceReceiptPage(pageReqVO); - return success(buildFinanceReceiptVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出收款单 Excel") - @PreAuthorize("@ss.hasPermission('erp:finance-receipt:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportFinanceReceiptExcel(@Valid ErpFinanceReceiptPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildFinanceReceiptVOPageResult(financeReceiptService.getFinanceReceiptPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "收款单.xls", "数据", ErpFinanceReceiptRespVO.class, list); - } - - private PageResult buildFinanceReceiptVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 收款项 - List receiptItemList = financeReceiptService.getFinanceReceiptItemListByReceiptIds( - convertSet(pageResult.getList(), ErpFinanceReceiptDO::getId)); - Map> financeReceiptItemMap = convertMultiMap(receiptItemList, ErpFinanceReceiptItemDO::getReceiptId); - // 1.2 客户信息 - Map customerMap = customerService.getCustomerMap( - convertSet(pageResult.getList(), ErpFinanceReceiptDO::getCustomerId)); - // 1.3 结算账户信息 - Map accountMap = accountService.getAccountMap( - convertSet(pageResult.getList(), ErpFinanceReceiptDO::getAccountId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(pageResult.getList(), - contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getFinanceUserId()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpFinanceReceiptRespVO.class, receipt -> { - receipt.setItems(BeanUtils.toBean(financeReceiptItemMap.get(receipt.getId()), ErpFinanceReceiptRespVO.Item.class)); - MapUtils.findAndThen(customerMap, receipt.getCustomerId(), customer -> receipt.setCustomerName(customer.getName())); - MapUtils.findAndThen(accountMap, receipt.getAccountId(), account -> receipt.setAccountName(account.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(receipt.getCreator()), user -> receipt.setCreatorName(user.getNickname())); - MapUtils.findAndThen(userMap, receipt.getFinanceUserId(), user -> receipt.setFinanceUserName(user.getNickname())); - }); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountPageReqVO.java deleted file mode 100644 index 3e1fa72f4..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - ERP 结算账户分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpAccountPageReqVO extends PageParam { - - @Schema(description = "账户编码", example = "A88") - private String no; - - @Schema(description = "账户名称", example = "张三") - private String name; - - @Schema(description = "备注", example = "随便") - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountRespVO.java deleted file mode 100644 index a1c2e954d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountRespVO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 结算账户 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpAccountRespVO { - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28684") - @ExcelProperty("结算账户编号") - private Long id; - - @Schema(description = "账户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - @ExcelProperty("账户名称") - private String name; - - @Schema(description = "账户编码", example = "A88") - @ExcelProperty("账户编码") - private String no; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("开启状态") - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("排序") - private Integer sort; - - @Schema(description = "是否默认", example = "1") - @ExcelProperty("是否默认") - private Boolean defaultStatus; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountSaveReqVO.java deleted file mode 100644 index e2005b703..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/account/ErpAccountSaveReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -@Schema(description = "管理后台 - ERP 结算账户新增/修改 Request VO") -@Data -public class ErpAccountSaveReqVO { - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28684") - private Long id; - - @Schema(description = "账户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - @NotEmpty(message = "账户名称不能为空") - private String name; - - @Schema(description = "账户编码", example = "A88") - private String no; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "开启状态不能为空") - @InEnum(value = CommonStatusEnum.class) - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "排序不能为空") - private Integer sort; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentPageReqVO.java deleted file mode 100644 index b5618cadc..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentPageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 付款单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpFinancePaymentPageReqVO extends PageParam { - - @Schema(description = "付款单编号", example = "XS001") - private String no; - - @Schema(description = "付款时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] paymentTime; - - @Schema(description = "供应商编号", example = "1724") - private Long supplierId; - - @Schema(description = "创建者", example = "666") - private String creator; - - @Schema(description = "财务人员编号", example = "888") - private String financeUserId; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "付款状态", example = "2") - private Integer status; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "业务编号", example = "123") - private String bizNo; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentRespVO.java deleted file mode 100644 index 6fbab164c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentRespVO.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment; - -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 付款单 Response VO") -@Data -public class ErpFinancePaymentRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23752") - private Long id; - - @Schema(description = "付款单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "FKD888") - private String no; - - @Schema(description = "付款状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "付款时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime paymentTime; - - @Schema(description = "财务人员编号", example = "19690") - private Long financeUserId; - @Schema(description = "财务人员名称", example = "张三") - private String financeUserName; - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29399") - private Long supplierId; - @Schema(description = "供应商名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小番茄公司") - private String supplierName; - - @Schema(description = "付款账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28989") - private Long accountId; - @Schema(description = "付款账户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String accountName; - - @Schema(description = "合计价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "13832") - private BigDecimal totalPrice; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "11600") - private BigDecimal discountPrice; - - @Schema(description = "实际价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - private BigDecimal paymentPrice; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "付款项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Data - public static class Item { - - @Schema(description = "付款项编号", example = "11756") - private Long id; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer bizType; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long bizId; - - @Schema(description = "业务单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private String bizNo; - - @Schema(description = "应付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - private BigDecimal totalPrice; - - @Schema(description = "已付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - private BigDecimal paidPrice; - - @Schema(description = "本次付款,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @NotNull(message = "本次付款不能为空") - private BigDecimal paymentPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentSaveReqVO.java deleted file mode 100644 index 3842f3d2f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/payment/ErpFinancePaymentSaveReqVO.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 付款单新增/修改 Request VO") -@Data -public class ErpFinancePaymentSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23752") - private Long id; - - @Schema(description = "付款时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "付款时间不能为空") - private LocalDateTime paymentTime; - - @Schema(description = "财务人员编号", example = "19690") - private Long financeUserId; - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29399") - @NotNull(message = "供应商编号不能为空") - private Long supplierId; - - @Schema(description = "付款账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28989") - @NotNull(message = "付款账户编号不能为空") - private Long accountId; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "11600") - @NotNull(message = "优惠金额不能为空") - private BigDecimal discountPrice; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "付款项列表", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "付款项列表不能为空") - @Valid - private List items; - - @Data - public static class Item { - - @Schema(description = "付款项编号", example = "11756") - private Long id; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "业务类型不能为空") - private Integer bizType; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @NotNull(message = "业务编号不能为空") - private Long bizId; - - @Schema(description = "已付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @NotNull(message = "已付金额不能为空") - private BigDecimal paidPrice; - - @Schema(description = "本次付款,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @NotNull(message = "本次付款不能为空") - private BigDecimal paymentPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptPageReqVO.java deleted file mode 100644 index d3e938c66..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptPageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 收款单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpFinanceReceiptPageReqVO extends PageParam { - - @Schema(description = "收款单编号", example = "XS001") - private String no; - - @Schema(description = "收款时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] receiptTime; - - @Schema(description = "客户编号", example = "1724") - private Long customerId; - - @Schema(description = "创建者", example = "666") - private String creator; - - @Schema(description = "财务人员编号", example = "888") - private String financeUserId; - - @Schema(description = "收款账户编号", example = "31189") - private Long accountId; - - @Schema(description = "收款状态", example = "2") - private Integer status; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "业务编号", example = "123") - private String bizNo; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptRespVO.java deleted file mode 100644 index f29e0a740..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptRespVO.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt; - -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 收款单 Response VO") -@Data -public class ErpFinanceReceiptRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23752") - private Long id; - - @Schema(description = "收款单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "FKD888") - private String no; - - @Schema(description = "收款状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "收款时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime receiptTime; - - @Schema(description = "财务人员编号", example = "19690") - private Long financeUserId; - @Schema(description = "财务人员名称", example = "张三") - private String financeUserName; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29399") - private Long customerId; - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小番茄公司") - private String customerName; - - @Schema(description = "收款账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28989") - private Long accountId; - @Schema(description = "收款账户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String accountName; - - @Schema(description = "合计价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "13832") - private BigDecimal totalPrice; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "11600") - private BigDecimal discountPrice; - - @Schema(description = "实际价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - private BigDecimal receiptPrice; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "收款项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Data - public static class Item { - - @Schema(description = "收款项编号", example = "11756") - private Long id; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer bizType; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long bizId; - - @Schema(description = "业务单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private String bizNo; - - @Schema(description = "应收金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - private BigDecimal totalPrice; - - @Schema(description = "已收金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - private BigDecimal receiptedPrice; - - @Schema(description = "本次收款,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @NotNull(message = "本次收款不能为空") - private BigDecimal receiptPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptSaveReqVO.java deleted file mode 100644 index 0cb190c0d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/vo/receipt/ErpFinanceReceiptSaveReqVO.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 收款单新增/修改 Request VO") -@Data -public class ErpFinanceReceiptSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23752") - private Long id; - - @Schema(description = "收款时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "收款时间不能为空") - private LocalDateTime receiptTime; - - @Schema(description = "财务人员编号", example = "19690") - private Long financeUserId; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29399") - @NotNull(message = "客户编号不能为空") - private Long customerId; - - @Schema(description = "收款账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28989") - @NotNull(message = "收款账户编号不能为空") - private Long accountId; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "11600") - @NotNull(message = "优惠金额不能为空") - private BigDecimal discountPrice; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "收款项列表", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "收款项列表不能为空") - @Valid - private List items; - - @Data - public static class Item { - - @Schema(description = "收款项编号", example = "11756") - private Long id; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "业务类型不能为空") - private Integer bizType; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @NotNull(message = "业务编号不能为空") - private Long bizId; - - @Schema(description = "已收金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @NotNull(message = "已收金额不能为空") - private BigDecimal receiptedPrice; - - @Schema(description = "本次收款,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @NotNull(message = "本次收款不能为空") - private BigDecimal receiptPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductCategoryController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductCategoryController.java deleted file mode 100644 index 444f0af95..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductCategoryController.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategoryListReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategoryRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategorySaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 产品分类") -@RestController -@RequestMapping("/erp/product-category") -@Validated -public class ErpProductCategoryController { - - @Resource - private ErpProductCategoryService productCategoryService; - - @PostMapping("/create") - @Operation(summary = "创建产品分类") - @PreAuthorize("@ss.hasPermission('erp:product-category:create')") - public CommonResult createProductCategory(@Valid @RequestBody ErpProductCategorySaveReqVO createReqVO) { - return success(productCategoryService.createProductCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新产品分类") - @PreAuthorize("@ss.hasPermission('erp:product-category:update')") - public CommonResult updateProductCategory(@Valid @RequestBody ErpProductCategorySaveReqVO updateReqVO) { - productCategoryService.updateProductCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除产品分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:product-category:delete')") - public CommonResult deleteProductCategory(@RequestParam("id") Long id) { - productCategoryService.deleteProductCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得产品分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:product-category:query')") - public CommonResult getProductCategory(@RequestParam("id") Long id) { - ErpProductCategoryDO category = productCategoryService.getProductCategory(id); - return success(BeanUtils.toBean(category, ErpProductCategoryRespVO.class)); - } - - @GetMapping("/list") - @Operation(summary = "获得产品分类列表") - @PreAuthorize("@ss.hasPermission('erp:product-category:query')") - public CommonResult> getProductCategoryList(@Valid ErpProductCategoryListReqVO listReqVO) { - List list = productCategoryService.getProductCategoryList(listReqVO); - return success(BeanUtils.toBean(list, ErpProductCategoryRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得产品分类精简列表", description = "只包含被开启的分类,主要用于前端的下拉选项") - public CommonResult> getProductCategorySimpleList() { - List list = productCategoryService.getProductCategoryList( - new ErpProductCategoryListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus())); - return success(convertList(list, category -> new ErpProductCategoryRespVO() - .setId(category.getId()).setName(category.getName()).setParentId(category.getParentId()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出产品分类 Excel") - @PreAuthorize("@ss.hasPermission('erp:product-category:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportProductCategoryExcel(@Valid ErpProductCategoryListReqVO listReqVO, - HttpServletResponse response) throws IOException { - List list = productCategoryService.getProductCategoryList(listReqVO); - // 导出 Excel - ExcelUtils.write(response, "产品分类.xls", "数据", ErpProductCategoryRespVO.class, - BeanUtils.toBean(list, ErpProductCategoryRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductController.java deleted file mode 100644 index 8242837a3..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductController.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 产品") -@RestController -@RequestMapping("/erp/product") -@Validated -public class ErpProductController { - - @Resource - private ErpProductService productService; - - @PostMapping("/create") - @Operation(summary = "创建产品") - @PreAuthorize("@ss.hasPermission('erp:product:create')") - public CommonResult createProduct(@Valid @RequestBody ProductSaveReqVO createReqVO) { - return success(productService.createProduct(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新产品") - @PreAuthorize("@ss.hasPermission('erp:product:update')") - public CommonResult updateProduct(@Valid @RequestBody ProductSaveReqVO updateReqVO) { - productService.updateProduct(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除产品") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:product:delete')") - public CommonResult deleteProduct(@RequestParam("id") Long id) { - productService.deleteProduct(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得产品") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:product:query')") - public CommonResult getProduct(@RequestParam("id") Long id) { - ErpProductDO product = productService.getProduct(id); - return success(BeanUtils.toBean(product, ErpProductRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得产品分页") - @PreAuthorize("@ss.hasPermission('erp:product:query')") - public CommonResult> getProductPage(@Valid ErpProductPageReqVO pageReqVO) { - return success(productService.getProductVOPage(pageReqVO)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得产品精简列表", description = "只包含被开启的产品,主要用于前端的下拉选项") - public CommonResult> getProductSimpleList() { - List list = productService.getProductVOListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, product -> new ErpProductRespVO().setId(product.getId()) - .setName(product.getName()).setBarCode(product.getBarCode()) - .setCategoryId(product.getCategoryId()).setCategoryName(product.getCategoryName()) - .setUnitId(product.getUnitId()).setUnitName(product.getUnitName()) - .setPurchasePrice(product.getPurchasePrice()).setSalePrice(product.getSalePrice()).setMinPrice(product.getMinPrice()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出产品 Excel") - @PreAuthorize("@ss.hasPermission('erp:product:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportProductExcel(@Valid ErpProductPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - PageResult pageResult = productService.getProductVOPage(pageReqVO); - // 导出 Excel - ExcelUtils.write(response, "产品.xls", "数据", ErpProductRespVO.class, - pageResult.getList()); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductUnitController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductUnitController.java deleted file mode 100644 index 3a567c3d7..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductUnitController.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 产品单位") -@RestController -@RequestMapping("/erp/product-unit") -@Validated -public class ErpProductUnitController { - - @Resource - private ErpProductUnitService productUnitService; - - @PostMapping("/create") - @Operation(summary = "创建产品单位") - @PreAuthorize("@ss.hasPermission('erp:product-unit:create')") - public CommonResult createProductUnit(@Valid @RequestBody ErpProductUnitSaveReqVO createReqVO) { - return success(productUnitService.createProductUnit(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新产品单位") - @PreAuthorize("@ss.hasPermission('erp:product-unit:update')") - public CommonResult updateProductUnit(@Valid @RequestBody ErpProductUnitSaveReqVO updateReqVO) { - productUnitService.updateProductUnit(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除产品单位") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:product-unit:delete')") - public CommonResult deleteProductUnit(@RequestParam("id") Long id) { - productUnitService.deleteProductUnit(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得产品单位") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:product-unit:query')") - public CommonResult getProductUnit(@RequestParam("id") Long id) { - ErpProductUnitDO productUnit = productUnitService.getProductUnit(id); - return success(BeanUtils.toBean(productUnit, ErpProductUnitRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得产品单位分页") - @PreAuthorize("@ss.hasPermission('erp:product-unit:query')") - public CommonResult> getProductUnitPage(@Valid ErpProductUnitPageReqVO pageReqVO) { - PageResult pageResult = productUnitService.getProductUnitPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ErpProductUnitRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得产品单位精简列表", description = "只包含被开启的单位,主要用于前端的下拉选项") - public CommonResult> getProductUnitSimpleList() { - List list = productUnitService.getProductUnitListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, unit -> new ErpProductUnitRespVO().setId(unit.getId()).setName(unit.getName()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出产品单位 Excel") - @PreAuthorize("@ss.hasPermission('erp:product-unit:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportProductUnitExcel(@Valid ErpProductUnitPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = productUnitService.getProductUnitPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "产品单位.xls", "数据", ErpProductUnitRespVO.class, - BeanUtils.toBean(list, ErpProductUnitRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategoryListReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategoryListReqVO.java deleted file mode 100644 index b9b530e7d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategoryListReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - ERP 产品分类列表 Request VO") -@Data -public class ErpProductCategoryListReqVO { - - @Schema(description = "分类名称", example = "芋艿") - private String name; - - @Schema(description = "开启状态", example = "1") - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategoryRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategoryRespVO.java deleted file mode 100644 index 23d7d9e8f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategoryRespVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.category; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 产品分类 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpProductCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5860") - @ExcelProperty("分类编号") - private Long id; - - @Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21829") - @ExcelProperty("父分类编号") - private Long parentId; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @ExcelProperty("分类名称") - private String name; - - @Schema(description = "分类编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "S110") - @ExcelProperty("分类编码") - private String code; - - @Schema(description = "分类排序", example = "10") - @ExcelProperty("分类排序") - private Integer sort; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "开启状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategorySaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategorySaveReqVO.java deleted file mode 100644 index 6c1ddef7a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/category/ErpProductCategorySaveReqVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -@Schema(description = "管理后台 - ERP 产品分类新增/修改 Request VO") -@Data -public class ErpProductCategorySaveReqVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5860") - private Long id; - - @Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21829") - @NotNull(message = "父分类编号不能为空") - private Long parentId; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @NotEmpty(message = "分类名称不能为空") - private String name; - - @Schema(description = "分类编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "S110") - @NotEmpty(message = "分类编码不能为空") - private String code; - - @Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "分类排序不能为空") - private Integer sort; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "开启状态不能为空") - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductPageReqVO.java deleted file mode 100644 index 12818b2a6..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 产品分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpProductPageReqVO extends PageParam { - - @Schema(description = "产品名称", example = "李四") - private String name; - - @Schema(description = "产品分类编号", example = "11161") - private Long categoryId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductRespVO.java deleted file mode 100644 index 9be9bc255..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ErpProductRespVO.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 产品 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpProductRespVO { - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15672") - @ExcelProperty("产品编号") - private Long id; - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("产品名称") - private String name; - - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "X110") - @ExcelProperty("产品条码") - private String barCode; - - @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11161") - private Long categoryId; - @Schema(description = "产品分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "水果") - @ExcelProperty("产品分类") - private String categoryName; - - @Schema(description = "单位编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8869") - private Long unitId; - @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") - @ExcelProperty("单位") - private String unitName; - - @Schema(description = "产品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("产品状态") - private Integer status; - - @Schema(description = "产品规格", example = "红色") - @ExcelProperty("产品规格") - private String standard; - - @Schema(description = "产品备注", example = "你猜") - @ExcelProperty("产品备注") - private String remark; - - @Schema(description = "保质期天数", example = "10") - @ExcelProperty("保质期天数") - private Integer expiryDay; - - @Schema(description = "基础重量(kg)", example = "1.00") - @ExcelProperty("基础重量(kg)") - private BigDecimal weight; - - @Schema(description = "采购价格,单位:元", example = "10.30") - @ExcelProperty("采购价格,单位:元") - private BigDecimal purchasePrice; - - @Schema(description = "销售价格,单位:元", example = "74.32") - @ExcelProperty("销售价格,单位:元") - private BigDecimal salePrice; - - @Schema(description = "最低价格,单位:元", example = "161.87") - @ExcelProperty("最低价格,单位:元") - private BigDecimal minPrice; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ProductSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ProductSaveReqVO.java deleted file mode 100644 index 8841541b0..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/product/ProductSaveReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 产品新增/修改 Request VO") -@Data -public class ProductSaveReqVO { - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15672") - private Long id; - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotEmpty(message = "产品名称不能为空") - private String name; - - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "X110") - @NotEmpty(message = "产品条码不能为空") - private String barCode; - - @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11161") - @NotNull(message = "产品分类编号不能为空") - private Long categoryId; - - @Schema(description = "单位编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8869") - @NotNull(message = "单位编号不能为空") - private Long unitId; - - @Schema(description = "产品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "产品状态不能为空") - private Integer status; - - @Schema(description = "产品规格", example = "红色") - private String standard; - - @Schema(description = "产品备注", example = "你猜") - private String remark; - - @Schema(description = "保质期天数", example = "10") - private Integer expiryDay; - - @Schema(description = "基础重量(kg)", example = "1.00") - private BigDecimal weight; - - @Schema(description = "采购价格,单位:元", example = "10.30") - private BigDecimal purchasePrice; - - @Schema(description = "销售价格,单位:元", example = "74.32") - private BigDecimal salePrice; - - @Schema(description = "最低价格,单位:元", example = "161.87") - private BigDecimal minPrice; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitPageReqVO.java deleted file mode 100644 index 87119c126..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - ERP 产品单位分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpProductUnitPageReqVO extends PageParam { - - @Schema(description = "单位名字", example = "芋艿") - private String name; - - @Schema(description = "单位状态", example = "1") - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitRespVO.java deleted file mode 100644 index 06f604920..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 产品单位 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpProductUnitRespVO { - - @Schema(description = "单位编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31254") - @ExcelProperty("单位编号") - private Long id; - - @Schema(description = "单位名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @ExcelProperty("单位名字") - private String name; - - @Schema(description = "单位状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("单位状态") - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitSaveReqVO.java deleted file mode 100644 index 67f52337c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/vo/unit/ErpProductUnitSaveReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -@Schema(description = "管理后台 - ERP 产品单位新增/修改 Request VO") -@Data -public class ErpProductUnitSaveReqVO { - - @Schema(description = "单位编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31254") - private Long id; - - @Schema(description = "单位名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - @NotEmpty(message = "单位名字不能为空") - private String name; - - @Schema(description = "单位状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "单位状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseInController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseInController.java deleted file mode 100644 index 36d6f48b9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseInController.java +++ /dev/null @@ -1,165 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchaseInService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 采购入库") -@RestController -@RequestMapping("/erp/purchase-in") -@Validated -public class ErpPurchaseInController { - - @Resource - private ErpPurchaseInService purchaseInService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpSupplierService supplierService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建采购入库") - @PreAuthorize("@ss.hasPermission('erp:purchase-in:create')") - public CommonResult createPurchaseIn(@Valid @RequestBody ErpPurchaseInSaveReqVO createReqVO) { - return success(purchaseInService.createPurchaseIn(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新采购入库") - @PreAuthorize("@ss.hasPermission('erp:purchase-in:update')") - public CommonResult updatePurchaseIn(@Valid @RequestBody ErpPurchaseInSaveReqVO updateReqVO) { - purchaseInService.updatePurchaseIn(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新采购入库的状态") - @PreAuthorize("@ss.hasPermission('erp:purchase-in:update-status')") - public CommonResult updatePurchaseInStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - purchaseInService.updatePurchaseInStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除采购入库") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:purchase-in:delete')") - public CommonResult deletePurchaseIn(@RequestParam("ids") List ids) { - purchaseInService.deletePurchaseIn(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得采购入库") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:purchase-in:query')") - public CommonResult getPurchaseIn(@RequestParam("id") Long id) { - ErpPurchaseInDO purchaseIn = purchaseInService.getPurchaseIn(id); - if (purchaseIn == null) { - return success(null); - } - List purchaseInItemList = purchaseInService.getPurchaseInItemListByInId(id); - Map productMap = productService.getProductVOMap( - convertSet(purchaseInItemList, ErpPurchaseInItemDO::getProductId)); - return success(BeanUtils.toBean(purchaseIn, ErpPurchaseInRespVO.class, purchaseInVO -> - purchaseInVO.setItems(BeanUtils.toBean(purchaseInItemList, ErpPurchaseInRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得采购入库分页") - @PreAuthorize("@ss.hasPermission('erp:purchase-in:query')") - public CommonResult> getPurchaseInPage(@Valid ErpPurchaseInPageReqVO pageReqVO) { - PageResult pageResult = purchaseInService.getPurchaseInPage(pageReqVO); - return success(buildPurchaseInVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出采购入库 Excel") - @PreAuthorize("@ss.hasPermission('erp:purchase-in:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportPurchaseInExcel(@Valid ErpPurchaseInPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildPurchaseInVOPageResult(purchaseInService.getPurchaseInPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "采购入库.xls", "数据", ErpPurchaseInRespVO.class, list); - } - - private PageResult buildPurchaseInVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 入库项 - List purchaseInItemList = purchaseInService.getPurchaseInItemListByInIds( - convertSet(pageResult.getList(), ErpPurchaseInDO::getId)); - Map> purchaseInItemMap = convertMultiMap(purchaseInItemList, ErpPurchaseInItemDO::getInId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(purchaseInItemList, ErpPurchaseInItemDO::getProductId)); - // 1.3 供应商信息 - Map supplierMap = supplierService.getSupplierMap( - convertSet(pageResult.getList(), ErpPurchaseInDO::getSupplierId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), purchaseIn -> Long.parseLong(purchaseIn.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpPurchaseInRespVO.class, purchaseIn -> { - purchaseIn.setItems(BeanUtils.toBean(purchaseInItemMap.get(purchaseIn.getId()), ErpPurchaseInRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - purchaseIn.setProductNames(CollUtil.join(purchaseIn.getItems(), ",", ErpPurchaseInRespVO.Item::getProductName)); - MapUtils.findAndThen(supplierMap, purchaseIn.getSupplierId(), supplier -> purchaseIn.setSupplierName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(purchaseIn.getCreator()), user -> purchaseIn.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseOrderController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseOrderController.java deleted file mode 100644 index 10cbb6226..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseOrderController.java +++ /dev/null @@ -1,164 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchaseOrderService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 采购订单") -@RestController -@RequestMapping("/erp/purchase-order") -@Validated -public class ErpPurchaseOrderController { - - @Resource - private ErpPurchaseOrderService purchaseOrderService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpSupplierService supplierService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建采购订单") - @PreAuthorize("@ss.hasPermission('erp:purchase-order:create')") - public CommonResult createPurchaseOrder(@Valid @RequestBody ErpPurchaseOrderSaveReqVO createReqVO) { - return success(purchaseOrderService.createPurchaseOrder(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新采购订单") - @PreAuthorize("@ss.hasPermission('erp:purchase-order:update')") - public CommonResult updatePurchaseOrder(@Valid @RequestBody ErpPurchaseOrderSaveReqVO updateReqVO) { - purchaseOrderService.updatePurchaseOrder(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新采购订单的状态") - @PreAuthorize("@ss.hasPermission('erp:purchase-order:update-status')") - public CommonResult updatePurchaseOrderStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - purchaseOrderService.updatePurchaseOrderStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除采购订单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:purchase-order:delete')") - public CommonResult deletePurchaseOrder(@RequestParam("ids") List ids) { - purchaseOrderService.deletePurchaseOrder(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得采购订单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:purchase-order:query')") - public CommonResult getPurchaseOrder(@RequestParam("id") Long id) { - ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.getPurchaseOrder(id); - if (purchaseOrder == null) { - return success(null); - } - List purchaseOrderItemList = purchaseOrderService.getPurchaseOrderItemListByOrderId(id); - Map productMap = productService.getProductVOMap( - convertSet(purchaseOrderItemList, ErpPurchaseOrderItemDO::getProductId)); - return success(BeanUtils.toBean(purchaseOrder, ErpPurchaseOrderRespVO.class, purchaseOrderVO -> - purchaseOrderVO.setItems(BeanUtils.toBean(purchaseOrderItemList, ErpPurchaseOrderRespVO.Item.class, item -> { - BigDecimal purchaseCount = stockService.getStockCount(item.getProductId()); - item.setStockCount(purchaseCount != null ? purchaseCount : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得采购订单分页") - @PreAuthorize("@ss.hasPermission('erp:purchase-order:query')") - public CommonResult> getPurchaseOrderPage(@Valid ErpPurchaseOrderPageReqVO pageReqVO) { - PageResult pageResult = purchaseOrderService.getPurchaseOrderPage(pageReqVO); - return success(buildPurchaseOrderVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出采购订单 Excel") - @PreAuthorize("@ss.hasPermission('erp:purchase-order:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportPurchaseOrderExcel(@Valid ErpPurchaseOrderPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildPurchaseOrderVOPageResult(purchaseOrderService.getPurchaseOrderPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "采购订单.xls", "数据", ErpPurchaseOrderRespVO.class, list); - } - - private PageResult buildPurchaseOrderVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 订单项 - List purchaseOrderItemList = purchaseOrderService.getPurchaseOrderItemListByOrderIds( - convertSet(pageResult.getList(), ErpPurchaseOrderDO::getId)); - Map> purchaseOrderItemMap = convertMultiMap(purchaseOrderItemList, ErpPurchaseOrderItemDO::getOrderId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(purchaseOrderItemList, ErpPurchaseOrderItemDO::getProductId)); - // 1.3 供应商信息 - Map supplierMap = supplierService.getSupplierMap( - convertSet(pageResult.getList(), ErpPurchaseOrderDO::getSupplierId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), purchaseOrder -> Long.parseLong(purchaseOrder.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpPurchaseOrderRespVO.class, purchaseOrder -> { - purchaseOrder.setItems(BeanUtils.toBean(purchaseOrderItemMap.get(purchaseOrder.getId()), ErpPurchaseOrderRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - purchaseOrder.setProductNames(CollUtil.join(purchaseOrder.getItems(), ",", ErpPurchaseOrderRespVO.Item::getProductName)); - MapUtils.findAndThen(supplierMap, purchaseOrder.getSupplierId(), supplier -> purchaseOrder.setSupplierName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(purchaseOrder.getCreator()), user -> purchaseOrder.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseReturnController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseReturnController.java deleted file mode 100644 index 74eec7861..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpPurchaseReturnController.java +++ /dev/null @@ -1,165 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchaseReturnService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 采购退货") -@RestController -@RequestMapping("/erp/purchase-return") -@Validated -public class ErpPurchaseReturnController { - - @Resource - private ErpPurchaseReturnService purchaseReturnService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpSupplierService supplierService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建采购退货") - @PreAuthorize("@ss.hasPermission('erp:purchase-return:create')") - public CommonResult createPurchaseReturn(@Valid @RequestBody ErpPurchaseReturnSaveReqVO createReqVO) { - return success(purchaseReturnService.createPurchaseReturn(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新采购退货") - @PreAuthorize("@ss.hasPermission('erp:purchase-return:update')") - public CommonResult updatePurchaseReturn(@Valid @RequestBody ErpPurchaseReturnSaveReqVO updateReqVO) { - purchaseReturnService.updatePurchaseReturn(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新采购退货的状态") - @PreAuthorize("@ss.hasPermission('erp:purchase-return:update-status')") - public CommonResult updatePurchaseReturnStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - purchaseReturnService.updatePurchaseReturnStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除采购退货") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:purchase-return:delete')") - public CommonResult deletePurchaseReturn(@RequestParam("ids") List ids) { - purchaseReturnService.deletePurchaseReturn(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得采购退货") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:purchase-return:query')") - public CommonResult getPurchaseReturn(@RequestParam("id") Long id) { - ErpPurchaseReturnDO purchaseReturn = purchaseReturnService.getPurchaseReturn(id); - if (purchaseReturn == null) { - return success(null); - } - List purchaseReturnItemList = purchaseReturnService.getPurchaseReturnItemListByReturnId(id); - Map productMap = productService.getProductVOMap( - convertSet(purchaseReturnItemList, ErpPurchaseReturnItemDO::getProductId)); - return success(BeanUtils.toBean(purchaseReturn, ErpPurchaseReturnRespVO.class, purchaseReturnVO -> - purchaseReturnVO.setItems(BeanUtils.toBean(purchaseReturnItemList, ErpPurchaseReturnRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得采购退货分页") - @PreAuthorize("@ss.hasPermission('erp:purchase-return:query')") - public CommonResult> getPurchaseReturnPage(@Valid ErpPurchaseReturnPageReqVO pageReqVO) { - PageResult pageResult = purchaseReturnService.getPurchaseReturnPage(pageReqVO); - return success(buildPurchaseReturnVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出采购退货 Excel") - @PreAuthorize("@ss.hasPermission('erp:purchase-return:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportPurchaseReturnExcel(@Valid ErpPurchaseReturnPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildPurchaseReturnVOPageResult(purchaseReturnService.getPurchaseReturnPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "采购退货.xls", "数据", ErpPurchaseReturnRespVO.class, list); - } - - private PageResult buildPurchaseReturnVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 退货项 - List purchaseReturnItemList = purchaseReturnService.getPurchaseReturnItemListByReturnIds( - convertSet(pageResult.getList(), ErpPurchaseReturnDO::getId)); - Map> purchaseReturnItemMap = convertMultiMap(purchaseReturnItemList, ErpPurchaseReturnItemDO::getReturnId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(purchaseReturnItemList, ErpPurchaseReturnItemDO::getProductId)); - // 1.3 供应商信息 - Map supplierMap = supplierService.getSupplierMap( - convertSet(pageResult.getList(), ErpPurchaseReturnDO::getSupplierId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), purchaseReturn -> Long.parseLong(purchaseReturn.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpPurchaseReturnRespVO.class, purchaseReturn -> { - purchaseReturn.setItems(BeanUtils.toBean(purchaseReturnItemMap.get(purchaseReturn.getId()), ErpPurchaseReturnRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - purchaseReturn.setProductNames(CollUtil.join(purchaseReturn.getItems(), ",", ErpPurchaseReturnRespVO.Item::getProductName)); - MapUtils.findAndThen(supplierMap, purchaseReturn.getSupplierId(), supplier -> purchaseReturn.setSupplierName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(purchaseReturn.getCreator()), user -> purchaseReturn.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpSupplierController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpSupplierController.java deleted file mode 100644 index 569de0030..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/ErpSupplierController.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 供应商") -@RestController -@RequestMapping("/erp/supplier") -@Validated -public class ErpSupplierController { - - @Resource - private ErpSupplierService supplierService; - - @PostMapping("/create") - @Operation(summary = "创建供应商") - @PreAuthorize("@ss.hasPermission('erp:supplier:create')") - public CommonResult createSupplier(@Valid @RequestBody ErpSupplierSaveReqVO createReqVO) { - return success(supplierService.createSupplier(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新供应商") - @PreAuthorize("@ss.hasPermission('erp:supplier:update')") - public CommonResult updateSupplier(@Valid @RequestBody ErpSupplierSaveReqVO updateReqVO) { - supplierService.updateSupplier(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除供应商") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:supplier:delete')") - public CommonResult deleteSupplier(@RequestParam("id") Long id) { - supplierService.deleteSupplier(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得供应商") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:supplier:query')") - public CommonResult getSupplier(@RequestParam("id") Long id) { - ErpSupplierDO supplier = supplierService.getSupplier(id); - return success(BeanUtils.toBean(supplier, ErpSupplierRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得供应商分页") - @PreAuthorize("@ss.hasPermission('erp:supplier:query')") - public CommonResult> getSupplierPage(@Valid ErpSupplierPageReqVO pageReqVO) { - PageResult pageResult = supplierService.getSupplierPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ErpSupplierRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得供应商精简列表", description = "只包含被开启的供应商,主要用于前端的下拉选项") - public CommonResult> getSupplierSimpleList() { - List list = supplierService.getSupplierListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, supplier -> new ErpSupplierRespVO().setId(supplier.getId()).setName(supplier.getName()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出供应商 Excel") - @PreAuthorize("@ss.hasPermission('erp:supplier:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportSupplierExcel(@Valid ErpSupplierPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = supplierService.getSupplierPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "供应商.xls", "数据", ErpSupplierRespVO.class, - BeanUtils.toBean(list, ErpSupplierRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInPageReqVO.java deleted file mode 100644 index e84607ce4..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInPageReqVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 采购入库分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpPurchaseInPageReqVO extends PageParam { - - public static final Integer PAYMENT_STATUS_NONE = 0; - public static final Integer PAYMENT_STATUS_PART = 1; - public static final Integer PAYMENT_STATUS_ALL = 2; - - @Schema(description = "采购单编号", example = "XS001") - private String no; - - @Schema(description = "供应商编号", example = "1724") - private Long supplierId; - - @Schema(description = "入库时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] inTime; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "入库状态", example = "2") - private Integer status; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "仓库编号", example = "1") - private Long warehouseId; - - @Schema(description = "结算账号编号", example = "1") - private Long accountId; - - @Schema(description = "付款状态", example = "1") - private Integer paymentStatus; - - @Schema(description = "是否可付款", example = "true") - private Boolean paymentEnable; // 对应 paymentStatus = [0, 1] - - @Schema(description = "采购单号", example = "1") - private String orderNo; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInRespVO.java deleted file mode 100644 index dac354f9f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInRespVO.java +++ /dev/null @@ -1,145 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 采购入库 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpPurchaseInRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "入库单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - @ExcelProperty("入库单编号") - private String no; - - @Schema(description = "入库状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("入库状态") - private Integer status; - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - private Long supplierId; - @Schema(description = "供应商名称", example = "芋道") - @ExcelProperty("供应商名称") - private String supplierName; - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") - @ExcelProperty("结算账户编号") - private Long accountId; - - @Schema(description = "入库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("入库时间") - private LocalDateTime inTime; - - @Schema(description = "采购订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long orderId; - @Schema(description = "采购订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - private String orderNo; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("最终合计价格") - private BigDecimal totalPrice; - @Schema(description = "已付款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal paymentPrice; - - @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalProductPrice; - - @Schema(description = "合计税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalTaxPrice; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal discountPrice; - - @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - @ExcelProperty("附件地址") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "入库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "入库项编号", example = "11756") - private Long id; - - @Schema(description = "采购订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "税额,单位:元", example = "100.00") - private BigDecimal taxPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInSaveReqVO.java deleted file mode 100644 index 9566de989..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/in/ErpPurchaseInSaveReqVO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 采购入库新增/修改 Request VO") -@Data -public class ErpPurchaseInSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long id; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "入库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "入库时间不能为空") - private LocalDateTime inTime; - - @Schema(description = "采购订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @NotNull(message = "采购订单编号不能为空") - private Long orderId; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "其它金额,单位:元", example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "入库清单列表") - private List items; - - @Data - public static class Item { - - @Schema(description = "入库项编号", example = "11756") - private Long id; - - @Schema(description = "采购订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @NotNull(message = "采购订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品单位单位不能为空") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderPageReqVO.java deleted file mode 100644 index 8bf70d427..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderPageReqVO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 采购订单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpPurchaseOrderPageReqVO extends PageParam { - - /** - * 入库状态 - 无 - */ - public static final Integer IN_STATUS_NONE = 0; - /** - * 入库状态 - 部分 - */ - public static final Integer IN_STATUS_PART = 1; - /** - * 入库状态 - 全部 - */ - public static final Integer IN_STATUS_ALL = 2; - - /** - * 退货状态 - 无 - */ - public static final Integer RETURN_STATUS_NONE = 0; - /** - * 退货状态 - 部分 - */ - public static final Integer RETURN_STATUS_PART = 1; - /** - * 退货状态 - 全部 - */ - public static final Integer RETURN_STATUS_ALL = 2; - - @Schema(description = "采购单编号", example = "XS001") - private String no; - - @Schema(description = "供应商编号", example = "1724") - private Long supplierId; - - @Schema(description = "采购时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] orderTime; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "采购状态", example = "2") - private Integer status; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "入库状态", example = "2") - private Integer inStatus; - - @Schema(description = "退货状态", example = "2") - private Integer returnStatus; - - @Schema(description = "是否可入库", example = "true") - private Boolean inEnable; - - @Schema(description = "是否可退货", example = "true") - private Boolean returnEnable; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderRespVO.java deleted file mode 100644 index 5653e266d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderRespVO.java +++ /dev/null @@ -1,152 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 采购订单 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpPurchaseOrderRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "采购单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - @ExcelProperty("采购单编号") - private String no; - - @Schema(description = "采购状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("采购状态") - private Integer status; - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - private Long supplierId; - @Schema(description = "供应商名称", example = "芋道") - @ExcelProperty("供应商名称") - private String supplierName; - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") - @ExcelProperty("结算账户编号") - private Long accountId; - - @Schema(description = "采购时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("采购时间") - private LocalDateTime orderTime; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("最终合计价格") - private BigDecimal totalPrice; - - @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalProductPrice; - - @Schema(description = "合计税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalTaxPrice; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal discountPrice; - - @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal depositPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - @ExcelProperty("附件地址") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "订单项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - // ========== 采购入库 ========== - - @Schema(description = "采购入库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal inCount; - - // ========== 采购退货(出库)) ========== - - @Schema(description = "采购退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal returnCount; - - @Data - public static class Item { - - @Schema(description = "订单项编号", example = "11756") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "税额,单位:元", example = "100.00") - private BigDecimal taxPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 采购入库 ========== - - @Schema(description = "采购入库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal inCount; - - // ========== 采购退货(入库)) ========== - - @Schema(description = "采购退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal returnCount; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderSaveReqVO.java deleted file mode 100644 index 557400c6d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/order/ErpPurchaseOrderSaveReqVO.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 采购订单新增/修改 Request VO") -@Data -public class ErpPurchaseOrderSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long id; - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - @NotNull(message = "供应商编号不能为空") - private Long supplierId; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "采购时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "采购时间不能为空") - private LocalDateTime orderTime; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "定金金额,单位:元", example = "7127") - private BigDecimal depositPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "订单清单列表") - private List items; - - @Data - public static class Item { - - @Schema(description = "订单项编号", example = "11756") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品单位单位不能为空") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnPageReqVO.java deleted file mode 100644 index a534d2e3e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnPageReqVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 采购退货分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpPurchaseReturnPageReqVO extends PageParam { - - public static final Integer REFUND_STATUS_NONE = 0; - public static final Integer REFUND_STATUS_PART = 1; - public static final Integer REFUND_STATUS_ALL = 2; - - @Schema(description = "采购单编号", example = "XS001") - private String no; - - @Schema(description = "供应商编号", example = "1724") - private Long supplierId; - - @Schema(description = "退货时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] returnTime; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "退货状态", example = "2") - private Integer status; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "仓库编号", example = "1") - private Long warehouseId; - - @Schema(description = "结算账号编号", example = "1") - private Long accountId; - - @Schema(description = "采购单号", example = "1") - private String orderNo; - - @Schema(description = "退款状态", example = "1") - private Integer refundStatus; - - @Schema(description = "是否可退款", example = "true") - private Boolean refundEnable; // 对应 refundStatus = [0, 1] - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnRespVO.java deleted file mode 100644 index 69770ec3a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnRespVO.java +++ /dev/null @@ -1,145 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 采购退货 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpPurchaseReturnRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "退货单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - @ExcelProperty("退货单编号") - private String no; - - @Schema(description = "退货状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("退货状态") - private Integer status; - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - private Long supplierId; - @Schema(description = "供应商名称", example = "芋道") - @ExcelProperty("供应商名称") - private String supplierName; - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") - @ExcelProperty("结算账户编号") - private Long accountId; - - @Schema(description = "退货时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("退货时间") - private LocalDateTime returnTime; - - @Schema(description = "采购订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long orderId; - @Schema(description = "采购订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - private String orderNo; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("最终合计价格") - private BigDecimal totalPrice; - @Schema(description = "已退款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal refundPrice; - - @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalProductPrice; - - @Schema(description = "合计税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalTaxPrice; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal discountPrice; - - @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - @ExcelProperty("附件地址") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "退货项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "退货项编号", example = "11756") - private Long id; - - @Schema(description = "采购订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "税额,单位:元", example = "100.00") - private BigDecimal taxPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnSaveReqVO.java deleted file mode 100644 index 927e5108d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/returns/ErpPurchaseReturnSaveReqVO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 采购退货新增/修改 Request VO") -@Data -public class ErpPurchaseReturnSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long id; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "退货时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "退货时间不能为空") - private LocalDateTime returnTime; - - @Schema(description = "采购订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @NotNull(message = "采购订单编号不能为空") - private Long orderId; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "其它金额,单位:元", example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "退货清单列表") - private List items; - - @Data - public static class Item { - - @Schema(description = "退货项编号", example = "11756") - private Long id; - - @Schema(description = "采购订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @NotNull(message = "采购订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品单位单位不能为空") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierPageReqVO.java deleted file mode 100644 index 229ab63d9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - ERP 供应商分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpSupplierPageReqVO extends PageParam { - - @Schema(description = "供应商名称", example = "芋道源码") - private String name; - - @Schema(description = "手机号码", example = "15601691300") - private String mobile; - - @Schema(description = "联系电话", example = "18818288888") - private String telephone; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierRespVO.java deleted file mode 100644 index 5ba5892c1..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierRespVO.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 供应商 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpSupplierRespVO { - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17791") - @ExcelProperty("供应商编号") - private Long id; - - @Schema(description = "供应商名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @ExcelProperty("供应商名称") - private String name; - - @Schema(description = "联系人", example = "芋艿") - @ExcelProperty("联系人") - private String contact; - - @Schema(description = "手机号码", example = "15601691300") - @ExcelProperty("手机号码") - private String mobile; - - @Schema(description = "联系电话", example = "18818288888") - @ExcelProperty("联系电话") - private String telephone; - - @Schema(description = "电子邮箱", example = "76853@qq.com") - @ExcelProperty("电子邮箱") - private String email; - - @Schema(description = "传真", example = "20 7123 4567") - @ExcelProperty("传真") - private String fax; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "开启状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty("排序") - private Integer sort; - - @Schema(description = "纳税人识别号", example = "91130803MA098BY05W") - @ExcelProperty("纳税人识别号") - private String taxNo; - - @Schema(description = "税率", example = "10") - @ExcelProperty("税率") - private BigDecimal taxPercent; - - @Schema(description = "开户行", example = "张三") - @ExcelProperty("开户行") - private String bankName; - - @Schema(description = "开户账号", example = "622908212277228617") - @ExcelProperty("开户账号") - private String bankAccount; - - @Schema(description = "开户地址", example = "兴业银行浦东支行") - @ExcelProperty("开户地址") - private String bankAddress; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierSaveReqVO.java deleted file mode 100644 index 9193455bd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/purchase/vo/supplier/ErpSupplierSaveReqVO.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.framework.common.validation.Telephone; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 供应商新增/修改 Request VO") -@Data -public class ErpSupplierSaveReqVO { - - @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17791") - private Long id; - - @Schema(description = "供应商名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @NotEmpty(message = "供应商名称不能为空") - private String name; - - @Schema(description = "联系人", example = "芋艿") - private String contact; - - @Schema(description = "手机号码", example = "15601691300") - @Mobile - private String mobile; - - @Schema(description = "联系电话", example = "18818288888") - @Telephone - private String telephone; - - @Schema(description = "电子邮箱", example = "76853@qq.com") - @Email - private String email; - - @Schema(description = "传真", example = "20 7123 4567") - private String fax; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "开启状态不能为空") - @InEnum(value = CommonStatusEnum.class) - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "纳税人识别号", example = "91130803MA098BY05W") - private String taxNo; - - @Schema(description = "税率", example = "10") - private BigDecimal taxPercent; - - @Schema(description = "开户行", example = "张三") - private String bankName; - - @Schema(description = "开户账号", example = "622908212277228617") - private String bankAccount; - - @Schema(description = "开户地址", example = "兴业银行浦东支行") - private String bankAddress; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpCustomerController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpCustomerController.java deleted file mode 100644 index 3354fbc81..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpCustomerController.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 客户") -@RestController -@RequestMapping("/erp/customer") -@Validated -public class ErpCustomerController { - - @Resource - private ErpCustomerService customerService; - - @PostMapping("/create") - @Operation(summary = "创建客户") - @PreAuthorize("@ss.hasPermission('erp:customer:create')") - public CommonResult createCustomer(@Valid @RequestBody ErpCustomerSaveReqVO createReqVO) { - return success(customerService.createCustomer(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新客户") - @PreAuthorize("@ss.hasPermission('erp:customer:update')") - public CommonResult updateCustomer(@Valid @RequestBody ErpCustomerSaveReqVO updateReqVO) { - customerService.updateCustomer(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除客户") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:customer:delete')") - public CommonResult deleteCustomer(@RequestParam("id") Long id) { - customerService.deleteCustomer(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得客户") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:customer:query')") - public CommonResult getCustomer(@RequestParam("id") Long id) { - ErpCustomerDO customer = customerService.getCustomer(id); - return success(BeanUtils.toBean(customer, ErpCustomerRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得客户分页") - @PreAuthorize("@ss.hasPermission('erp:customer:query')") - public CommonResult> getCustomerPage(@Valid ErpCustomerPageReqVO pageReqVO) { - PageResult pageResult = customerService.getCustomerPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ErpCustomerRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得客户精简列表", description = "只包含被开启的客户,主要用于前端的下拉选项") - public CommonResult> getCustomerSimpleList() { - List list = customerService.getCustomerListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, customer -> new ErpCustomerRespVO().setId(customer.getId()).setName(customer.getName()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出客户 Excel") - @PreAuthorize("@ss.hasPermission('erp:customer:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportCustomerExcel(@Valid ErpCustomerPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = customerService.getCustomerPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "客户.xls", "数据", ErpCustomerRespVO.class, - BeanUtils.toBean(list, ErpCustomerRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOrderController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOrderController.java deleted file mode 100644 index d1011c0b9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOrderController.java +++ /dev/null @@ -1,164 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.erp.service.sale.ErpSaleOrderService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 销售订单") -@RestController -@RequestMapping("/erp/sale-order") -@Validated -public class ErpSaleOrderController { - - @Resource - private ErpSaleOrderService saleOrderService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建销售订单") - @PreAuthorize("@ss.hasPermission('erp:sale-out:create')") - public CommonResult createSaleOrder(@Valid @RequestBody ErpSaleOrderSaveReqVO createReqVO) { - return success(saleOrderService.createSaleOrder(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新销售订单") - @PreAuthorize("@ss.hasPermission('erp:sale-out:update')") - public CommonResult updateSaleOrder(@Valid @RequestBody ErpSaleOrderSaveReqVO updateReqVO) { - saleOrderService.updateSaleOrder(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新销售订单的状态") - @PreAuthorize("@ss.hasPermission('erp:sale-out:update-status')") - public CommonResult updateSaleOrderStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - saleOrderService.updateSaleOrderStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除销售订单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:sale-out:delete')") - public CommonResult deleteSaleOrder(@RequestParam("ids") List ids) { - saleOrderService.deleteSaleOrder(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得销售订单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:sale-out:query')") - public CommonResult getSaleOrder(@RequestParam("id") Long id) { - ErpSaleOrderDO saleOrder = saleOrderService.getSaleOrder(id); - if (saleOrder == null) { - return success(null); - } - List saleOrderItemList = saleOrderService.getSaleOrderItemListByOrderId(id); - Map productMap = productService.getProductVOMap( - convertSet(saleOrderItemList, ErpSaleOrderItemDO::getProductId)); - return success(BeanUtils.toBean(saleOrder, ErpSaleOrderRespVO.class, saleOrderVO -> - saleOrderVO.setItems(BeanUtils.toBean(saleOrderItemList, ErpSaleOrderRespVO.Item.class, item -> { - BigDecimal stockCount = stockService.getStockCount(item.getProductId()); - item.setStockCount(stockCount != null ? stockCount : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得销售订单分页") - @PreAuthorize("@ss.hasPermission('erp:sale-out:query')") - public CommonResult> getSaleOrderPage(@Valid ErpSaleOrderPageReqVO pageReqVO) { - PageResult pageResult = saleOrderService.getSaleOrderPage(pageReqVO); - return success(buildSaleOrderVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出销售订单 Excel") - @PreAuthorize("@ss.hasPermission('erp:sale-out:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportSaleOrderExcel(@Valid ErpSaleOrderPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildSaleOrderVOPageResult(saleOrderService.getSaleOrderPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "销售订单.xls", "数据", ErpSaleOrderRespVO.class, list); - } - - private PageResult buildSaleOrderVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 订单项 - List saleOrderItemList = saleOrderService.getSaleOrderItemListByOrderIds( - convertSet(pageResult.getList(), ErpSaleOrderDO::getId)); - Map> saleOrderItemMap = convertMultiMap(saleOrderItemList, ErpSaleOrderItemDO::getOrderId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(saleOrderItemList, ErpSaleOrderItemDO::getProductId)); - // 1.3 客户信息 - Map customerMap = customerService.getCustomerMap( - convertSet(pageResult.getList(), ErpSaleOrderDO::getCustomerId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), saleOrder -> Long.parseLong(saleOrder.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpSaleOrderRespVO.class, saleOrder -> { - saleOrder.setItems(BeanUtils.toBean(saleOrderItemMap.get(saleOrder.getId()), ErpSaleOrderRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - saleOrder.setProductNames(CollUtil.join(saleOrder.getItems(), ",", ErpSaleOrderRespVO.Item::getProductName)); - MapUtils.findAndThen(customerMap, saleOrder.getCustomerId(), supplier -> saleOrder.setCustomerName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(saleOrder.getCreator()), user -> saleOrder.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOutController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOutController.java deleted file mode 100644 index 4149dbfba..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleOutController.java +++ /dev/null @@ -1,165 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.erp.service.sale.ErpSaleOutService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 销售出库") -@RestController -@RequestMapping("/erp/sale-out") -@Validated -public class ErpSaleOutController { - - @Resource - private ErpSaleOutService saleOutService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建销售出库") - @PreAuthorize("@ss.hasPermission('erp:sale-out:create')") - public CommonResult createSaleOut(@Valid @RequestBody ErpSaleOutSaveReqVO createReqVO) { - return success(saleOutService.createSaleOut(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新销售出库") - @PreAuthorize("@ss.hasPermission('erp:sale-out:update')") - public CommonResult updateSaleOut(@Valid @RequestBody ErpSaleOutSaveReqVO updateReqVO) { - saleOutService.updateSaleOut(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新销售出库的状态") - @PreAuthorize("@ss.hasPermission('erp:sale-out:update-status')") - public CommonResult updateSaleOutStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - saleOutService.updateSaleOutStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除销售出库") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:sale-out:delete')") - public CommonResult deleteSaleOut(@RequestParam("ids") List ids) { - saleOutService.deleteSaleOut(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得销售出库") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:sale-out:query')") - public CommonResult getSaleOut(@RequestParam("id") Long id) { - ErpSaleOutDO saleOut = saleOutService.getSaleOut(id); - if (saleOut == null) { - return success(null); - } - List saleOutItemList = saleOutService.getSaleOutItemListByOutId(id); - Map productMap = productService.getProductVOMap( - convertSet(saleOutItemList, ErpSaleOutItemDO::getProductId)); - return success(BeanUtils.toBean(saleOut, ErpSaleOutRespVO.class, saleOutVO -> - saleOutVO.setItems(BeanUtils.toBean(saleOutItemList, ErpSaleOutRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得销售出库分页") - @PreAuthorize("@ss.hasPermission('erp:sale-out:query')") - public CommonResult> getSaleOutPage(@Valid ErpSaleOutPageReqVO pageReqVO) { - PageResult pageResult = saleOutService.getSaleOutPage(pageReqVO); - return success(buildSaleOutVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出销售出库 Excel") - @PreAuthorize("@ss.hasPermission('erp:sale-out:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportSaleOutExcel(@Valid ErpSaleOutPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildSaleOutVOPageResult(saleOutService.getSaleOutPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "销售出库.xls", "数据", ErpSaleOutRespVO.class, list); - } - - private PageResult buildSaleOutVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 出库项 - List saleOutItemList = saleOutService.getSaleOutItemListByOutIds( - convertSet(pageResult.getList(), ErpSaleOutDO::getId)); - Map> saleOutItemMap = convertMultiMap(saleOutItemList, ErpSaleOutItemDO::getOutId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(saleOutItemList, ErpSaleOutItemDO::getProductId)); - // 1.3 客户信息 - Map customerMap = customerService.getCustomerMap( - convertSet(pageResult.getList(), ErpSaleOutDO::getCustomerId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), stockOut -> Long.parseLong(stockOut.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpSaleOutRespVO.class, saleOut -> { - saleOut.setItems(BeanUtils.toBean(saleOutItemMap.get(saleOut.getId()), ErpSaleOutRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - saleOut.setProductNames(CollUtil.join(saleOut.getItems(), ",", ErpSaleOutRespVO.Item::getProductName)); - MapUtils.findAndThen(customerMap, saleOut.getCustomerId(), supplier -> saleOut.setCustomerName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(saleOut.getCreator()), user -> saleOut.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleReturnController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleReturnController.java deleted file mode 100644 index 1435a59fb..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/ErpSaleReturnController.java +++ /dev/null @@ -1,165 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.erp.service.sale.ErpSaleReturnService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 销售退货") -@RestController -@RequestMapping("/erp/sale-return") -@Validated -public class ErpSaleReturnController { - - @Resource - private ErpSaleReturnService saleReturnService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建销售退货") - @PreAuthorize("@ss.hasPermission('erp:sale-return:create')") - public CommonResult createSaleReturn(@Valid @RequestBody ErpSaleReturnSaveReqVO createReqVO) { - return success(saleReturnService.createSaleReturn(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新销售退货") - @PreAuthorize("@ss.hasPermission('erp:sale-return:update')") - public CommonResult updateSaleReturn(@Valid @RequestBody ErpSaleReturnSaveReqVO updateReqVO) { - saleReturnService.updateSaleReturn(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新销售退货的状态") - @PreAuthorize("@ss.hasPermission('erp:sale-return:update-status')") - public CommonResult updateSaleReturnStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - saleReturnService.updateSaleReturnStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除销售退货") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:sale-return:delete')") - public CommonResult deleteSaleReturn(@RequestParam("ids") List ids) { - saleReturnService.deleteSaleReturn(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得销售退货") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:sale-return:query')") - public CommonResult getSaleReturn(@RequestParam("id") Long id) { - ErpSaleReturnDO saleReturn = saleReturnService.getSaleReturn(id); - if (saleReturn == null) { - return success(null); - } - List saleReturnItemList = saleReturnService.getSaleReturnItemListByReturnId(id); - Map productMap = productService.getProductVOMap( - convertSet(saleReturnItemList, ErpSaleReturnItemDO::getProductId)); - return success(BeanUtils.toBean(saleReturn, ErpSaleReturnRespVO.class, saleReturnVO -> - saleReturnVO.setItems(BeanUtils.toBean(saleReturnItemList, ErpSaleReturnRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得销售退货分页") - @PreAuthorize("@ss.hasPermission('erp:sale-return:query')") - public CommonResult> getSaleReturnPage(@Valid ErpSaleReturnPageReqVO pageReqVO) { - PageResult pageResult = saleReturnService.getSaleReturnPage(pageReqVO); - return success(buildSaleReturnVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出销售退货 Excel") - @PreAuthorize("@ss.hasPermission('erp:sale-return:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportSaleReturnExcel(@Valid ErpSaleReturnPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildSaleReturnVOPageResult(saleReturnService.getSaleReturnPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "销售退货.xls", "数据", ErpSaleReturnRespVO.class, list); - } - - private PageResult buildSaleReturnVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 退货项 - List saleReturnItemList = saleReturnService.getSaleReturnItemListByReturnIds( - convertSet(pageResult.getList(), ErpSaleReturnDO::getId)); - Map> saleReturnItemMap = convertMultiMap(saleReturnItemList, ErpSaleReturnItemDO::getReturnId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(saleReturnItemList, ErpSaleReturnItemDO::getProductId)); - // 1.3 客户信息 - Map customerMap = customerService.getCustomerMap( - convertSet(pageResult.getList(), ErpSaleReturnDO::getCustomerId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), saleReturn -> Long.parseLong(saleReturn.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpSaleReturnRespVO.class, saleReturn -> { - saleReturn.setItems(BeanUtils.toBean(saleReturnItemMap.get(saleReturn.getId()), ErpSaleReturnRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - saleReturn.setProductNames(CollUtil.join(saleReturn.getItems(), ",", ErpSaleReturnRespVO.Item::getProductName)); - MapUtils.findAndThen(customerMap, saleReturn.getCustomerId(), supplier -> saleReturn.setCustomerName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(saleReturn.getCreator()), user -> saleReturn.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerPageReqVO.java deleted file mode 100644 index 8f32c0109..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - ERP 客户分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpCustomerPageReqVO extends PageParam { - - @Schema(description = "客户名称", example = "张三") - private String name; - - @Schema(description = "手机号码", example = "15601691300") - private String mobile; - - @Schema(description = "联系电话", example = "15601691300") - private String telephone; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerRespVO.java deleted file mode 100644 index be1768d04..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerRespVO.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 客户 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpCustomerRespVO { - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27520") - @ExcelProperty("客户编号") - private Long id; - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - @ExcelProperty("客户名称") - private String name; - - @Schema(description = "联系人", example = "老王") - @ExcelProperty("联系人") - private String contact; - - @Schema(description = "手机号码", example = "15601691300") - @ExcelProperty("手机号码") - private String mobile; - - @Schema(description = "联系电话", example = "15601691300") - @ExcelProperty("联系电话") - private String telephone; - - @Schema(description = "电子邮箱", example = "7685323@qq.com") - @ExcelProperty("电子邮箱") - private String email; - - @Schema(description = "传真", example = "20 7123 4567") - @ExcelProperty("传真") - private String fax; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "开启状态", converter = DictConvert.class) - @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty("排序") - private Integer sort; - - @Schema(description = "纳税人识别号", example = "91130803MA098BY05W") - @ExcelProperty("纳税人识别号") - private String taxNo; - - @Schema(description = "税率", example = "10") - @ExcelProperty("税率") - private BigDecimal taxPercent; - - @Schema(description = "开户行", example = "芋艿") - @ExcelProperty("开户行") - private String bankName; - - @Schema(description = "开户账号", example = "622908212277228617") - @ExcelProperty("开户账号") - private String bankAccount; - - @Schema(description = "开户地址", example = "兴业银行浦东支行") - @ExcelProperty("开户地址") - private String bankAddress; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerSaveReqVO.java deleted file mode 100644 index 23c4fb331..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/customer/ErpCustomerSaveReqVO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 客户新增/修改 Request VO") -@Data -public class ErpCustomerSaveReqVO { - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27520") - private Long id; - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - @NotEmpty(message = "客户名称不能为空") - private String name; - - @Schema(description = "联系人", example = "老王") - private String contact; - - @Schema(description = "手机号码", example = "15601691300") - private String mobile; - - @Schema(description = "联系电话", example = "15601691300") - private String telephone; - - @Schema(description = "电子邮箱", example = "7685323@qq.com") - private String email; - - @Schema(description = "传真", example = "20 7123 4567") - private String fax; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "开启状态不能为空") - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "纳税人识别号", example = "91130803MA098BY05W") - private String taxNo; - - @Schema(description = "税率", example = "10") - private BigDecimal taxPercent; - - @Schema(description = "开户行", example = "芋艿") - private String bankName; - - @Schema(description = "开户账号", example = "622908212277228617") - private String bankAccount; - - @Schema(description = "开户地址", example = "兴业银行浦东支行") - private String bankAddress; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderPageReqVO.java deleted file mode 100644 index 84d92fb67..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderPageReqVO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 销售订单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpSaleOrderPageReqVO extends PageParam { - - /** - * 出库状态 - 无 - */ - public static final Integer OUT_STATUS_NONE = 0; - /** - * 出库状态 - 部分 - */ - public static final Integer OUT_STATUS_PART = 1; - /** - * 出库状态 - 全部 - */ - public static final Integer OUT_STATUS_ALL = 2; - - /** - * 退货状态 - 无 - */ - public static final Integer RETURN_STATUS_NONE = 0; - /** - * 退货状态 - 部分 - */ - public static final Integer RETURN_STATUS_PART = 1; - /** - * 退货状态 - 全部 - */ - public static final Integer RETURN_STATUS_ALL = 2; - - @Schema(description = "销售单编号", example = "XS001") - private String no; - - @Schema(description = "客户编号", example = "1724") - private Long customerId; - - @Schema(description = "下单时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] orderTime; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "销售状态", example = "2") - private Integer status; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "出库状态", example = "2") - private Integer outStatus; - - @Schema(description = "退货状态", example = "2") - private Integer returnStatus; - - @Schema(description = "是否可出库", example = "true") - private Boolean outEnable; - - @Schema(description = "是否可退货", example = "true") - private Boolean returnEnable; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderRespVO.java deleted file mode 100644 index ecf35871a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderRespVO.java +++ /dev/null @@ -1,155 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 销售订单 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpSaleOrderRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "销售单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - @ExcelProperty("销售单编号") - private String no; - - @Schema(description = "销售状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("销售状态") - private Integer status; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - private Long customerId; - @Schema(description = "客户名称", example = "芋道") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") - @ExcelProperty("结算账户编号") - private Long accountId; - - @Schema(description = "销售员编号", example = "1888") - private Long saleUserId; - - @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("下单时间") - private LocalDateTime orderTime; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("最终合计价格") - private BigDecimal totalPrice; - - @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalProductPrice; - - @Schema(description = "合计税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalTaxPrice; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal discountPrice; - - @Schema(description = "定金金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal depositPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - @ExcelProperty("附件地址") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "订单项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - // ========== 销售出库 ========== - - @Schema(description = "销售出库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal outCount; - - // ========== 销售退货(出库)) ========== - - @Schema(description = "销售退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal returnCount; - - @Data - public static class Item { - - @Schema(description = "订单项编号", example = "11756") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "税额,单位:元", example = "100.00") - private BigDecimal taxPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 销售出库 ========== - - @Schema(description = "销售出库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal outCount; - - // ========== 销售退货(入库)) ========== - - @Schema(description = "销售退货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal returnCount; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderSaveReqVO.java deleted file mode 100644 index 46a440721..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/order/ErpSaleOrderSaveReqVO.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 销售订单新增/修改 Request VO") -@Data -public class ErpSaleOrderSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long id; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - @NotNull(message = "客户编号不能为空") - private Long customerId; - - @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "下单时间不能为空") - private LocalDateTime orderTime; - - @Schema(description = "销售员编号", example = "1888") - private Long saleUserId; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "定金金额,单位:元", example = "7127") - private BigDecimal depositPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "订单清单列表") - private List items; - - @Data - public static class Item { - - @Schema(description = "订单项编号", example = "11756") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品单位单位不能为空") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutPageReqVO.java deleted file mode 100644 index 5afeeea84..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutPageReqVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 销售出库分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpSaleOutPageReqVO extends PageParam { - - public static final Integer RECEIPT_STATUS_NONE = 0; - public static final Integer RECEIPT_STATUS_PART = 1; - public static final Integer RECEIPT_STATUS_ALL = 2; - - @Schema(description = "销售单编号", example = "XS001") - private String no; - - @Schema(description = "客户编号", example = "1724") - private Long customerId; - - @Schema(description = "出库时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] outTime; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "出库状态", example = "2") - private Integer status; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "仓库编号", example = "1") - private Long warehouseId; - - @Schema(description = "结算账号编号", example = "1") - private Long accountId; - - @Schema(description = "收款状态", example = "1") - private Integer receiptStatus; - - @Schema(description = "是否可收款", example = "true") - private Boolean receiptEnable; // 对应 receiptStatus = [0, 1] - - @Schema(description = "销售单号", example = "1") - private String orderNo; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutRespVO.java deleted file mode 100644 index d33f47ee9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutRespVO.java +++ /dev/null @@ -1,148 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 销售出库 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpSaleOutRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "出库单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - @ExcelProperty("出库单编号") - private String no; - - @Schema(description = "出库状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("出库状态") - private Integer status; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - private Long customerId; - @Schema(description = "客户名称", example = "芋道") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") - @ExcelProperty("结算账户编号") - private Long accountId; - - @Schema(description = "出库员编号", example = "1888") - private Long saleUserId; - - @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出库时间") - private LocalDateTime outTime; - - @Schema(description = "销售订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long orderId; - @Schema(description = "销售订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - private String orderNo; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("最终合计价格") - private BigDecimal totalPrice; - @Schema(description = "已收款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal receiptPrice; - - @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalProductPrice; - - @Schema(description = "合计税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalTaxPrice; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal discountPrice; - - @Schema(description = "其它金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - @ExcelProperty("附件地址") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "出库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "出库项编号", example = "11756") - private Long id; - - @Schema(description = "销售订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "税额,单位:元", example = "100.00") - private BigDecimal taxPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutSaveReqVO.java deleted file mode 100644 index f2c26aae3..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/out/ErpSaleOutSaveReqVO.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 销售出库新增/修改 Request VO") -@Data -public class ErpSaleOutSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long id; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "销售员编号", example = "1888") - private Long saleUserId; - - @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出库时间不能为空") - private LocalDateTime outTime; - - @Schema(description = "销售订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @NotNull(message = "销售订单编号不能为空") - private Long orderId; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "其它金额,单位:元", example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "出库清单列表") - private List items; - - @Data - public static class Item { - - @Schema(description = "出库项编号", example = "11756") - private Long id; - - @Schema(description = "销售订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @NotNull(message = "销售订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品单位单位不能为空") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnPageReqVO.java deleted file mode 100644 index a9be73beb..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnPageReqVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 销售退货分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpSaleReturnPageReqVO extends PageParam { - - public static final Integer REFUND_STATUS_NONE = 0; - public static final Integer REFUND_STATUS_PART = 1; - public static final Integer REFUND_STATUS_ALL = 2; - - @Schema(description = "销售单编号", example = "XS001") - private String no; - - @Schema(description = "客户编号", example = "1724") - private Long customerId; - - @Schema(description = "退货时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] returnTime; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "退货状态", example = "2") - private Integer status; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "仓库编号", example = "1") - private Long warehouseId; - - @Schema(description = "结算账号编号", example = "1") - private Long accountId; - - @Schema(description = "销售单号", example = "1") - private String orderNo; - - @Schema(description = "退款状态", example = "1") - private Integer refundStatus; - - @Schema(description = "是否可退款", example = "true") - private Boolean refundEnable; // 对应 refundStatus = [0, 1] - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnRespVO.java deleted file mode 100644 index 2ca3384fa..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnRespVO.java +++ /dev/null @@ -1,148 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 销售退货 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpSaleReturnRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "退货单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - @ExcelProperty("退货单编号") - private String no; - - @Schema(description = "退货状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("退货状态") - private Integer status; - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1724") - private Long customerId; - @Schema(description = "客户名称", example = "芋道") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "结算账户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "311.89") - @ExcelProperty("结算账户编号") - private Long accountId; - - @Schema(description = "退货员编号", example = "1888") - private Long saleUserId; - - @Schema(description = "退货时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("退货时间") - private LocalDateTime returnTime; - - @Schema(description = "销售订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long orderId; - @Schema(description = "销售订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "XS001") - private String orderNo; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - @Schema(description = "最终合计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("最终合计价格") - private BigDecimal totalPrice; - @Schema(description = "已退款金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal refundPrice; - - @Schema(description = "合计产品价格,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalProductPrice; - - @Schema(description = "合计税额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal totalTaxPrice; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "优惠金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal discountPrice; - - @Schema(description = "其它金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - @ExcelProperty("附件地址") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "退货项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "退货项编号", example = "11756") - private Long id; - - @Schema(description = "销售订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "税额,单位:元", example = "100.00") - private BigDecimal taxPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnSaveReqVO.java deleted file mode 100644 index 867bd68f2..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/sale/vo/returns/ErpSaleReturnSaveReqVO.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 销售退货新增/修改 Request VO") -@Data -public class ErpSaleReturnSaveReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - private Long id; - - @Schema(description = "结算账户编号", example = "31189") - private Long accountId; - - @Schema(description = "销售员编号", example = "1888") - private Long saleUserId; - - @Schema(description = "退货时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "退货时间不能为空") - private LocalDateTime returnTime; - - @Schema(description = "销售订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17386") - @NotNull(message = "销售订单编号不能为空") - private Long orderId; - - @Schema(description = "优惠率,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "99.88") - private BigDecimal discountPercent; - - @Schema(description = "其它金额,单位:元", example = "7127") - private BigDecimal otherPrice; - - @Schema(description = "附件地址", example = "https://www.iocoder.cn") - private String fileUrl; - - @Schema(description = "备注", example = "你猜") - private String remark; - - @Schema(description = "退货清单列表") - private List items; - - @Data - public static class Item { - - @Schema(description = "退货项编号", example = "11756") - private Long id; - - @Schema(description = "销售订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @NotNull(message = "销售订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单位单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品单位单位不能为空") - private Long productUnitId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "税率,百分比", example = "99.88") - private BigDecimal taxPercent; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpPurchaseStatisticsController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpPurchaseStatisticsController.java deleted file mode 100644 index be0258dab..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpPurchaseStatisticsController.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.statistics; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.purchase.ErpPurchaseSummaryRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.purchase.ErpPurchaseTimeSummaryRespVO; -import cn.iocoder.yudao.module.erp.service.statistics.ErpPurchaseStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -import static cn.hutool.core.date.DatePattern.NORM_MONTH_PATTERN; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - ERP 采购统计") -@RestController -@RequestMapping("/erp/purchase-statistics") -@Validated -public class ErpPurchaseStatisticsController { - - @Resource - private ErpPurchaseStatisticsService purchaseStatisticsService; - - @GetMapping("/summary") - @Operation(summary = "获得采购统计") - @PreAuthorize("@ss.hasPermission('erp:statistics:query')") - public CommonResult getPurchaseSummary() { - LocalDateTime today = LocalDateTimeUtils.getToday(); - LocalDateTime yesterday = LocalDateTimeUtils.getYesterday(); - LocalDateTime month = LocalDateTimeUtils.getMonth(); - LocalDateTime year = LocalDateTimeUtils.getYear(); - ErpPurchaseSummaryRespVO summary = new ErpPurchaseSummaryRespVO() - .setTodayPrice(purchaseStatisticsService.getPurchasePrice(today, null)) - .setYesterdayPrice(purchaseStatisticsService.getPurchasePrice(yesterday, today)) - .setMonthPrice(purchaseStatisticsService.getPurchasePrice(month, null)) - .setYearPrice(purchaseStatisticsService.getPurchasePrice(year, null)); - return success(summary); - } - - @GetMapping("/time-summary") - @Operation(summary = "获得采购时间段统计") - @Parameter(name = "count", description = "时间段数量", example = "6") - @PreAuthorize("@ss.hasPermission('erp:statistics:query')") - public CommonResult> getPurchaseTimeSummary( - @RequestParam(value = "count", defaultValue = "6") Integer count) { - List summaryList = new ArrayList<>(); - for (int i = count - 1; i >= 0; i--) { - LocalDateTime startTime = LocalDateTimeUtils.beginOfMonth(LocalDateTime.now().minusMonths(i)); - LocalDateTime endTime = LocalDateTimeUtils.endOfMonth(startTime); - summaryList.add(new ErpPurchaseTimeSummaryRespVO() - .setTime(LocalDateTimeUtil.format(startTime, NORM_MONTH_PATTERN)) - .setPrice(purchaseStatisticsService.getPurchasePrice(startTime, endTime))); - } - return success(summaryList); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpSaleStatisticsController.http b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpSaleStatisticsController.http deleted file mode 100644 index 5f5cab109..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpSaleStatisticsController.http +++ /dev/null @@ -1,11 +0,0 @@ -### 请求 /erp/sale-statistics/summary 接口 => 成功 -GET {{baseUrl}}/erp/sale-statistics/summary -Content-Type: application/json -tenant-id: {{adminTenentId}} -Authorization: Bearer {{token}} - -### 请求 /erp/sale-statistics/time-summary 接口 => 成功 -GET {{baseUrl}}/erp/sale-statistics/time-summary -Content-Type: application/json -tenant-id: {{adminTenentId}} -Authorization: Bearer {{token}} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpSaleStatisticsController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpSaleStatisticsController.java deleted file mode 100644 index c43c971fe..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/ErpSaleStatisticsController.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.statistics; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.sale.ErpSaleSummaryRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.sale.ErpSaleTimeSummaryRespVO; -import cn.iocoder.yudao.module.erp.service.statistics.ErpSaleStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -import static cn.hutool.core.date.DatePattern.NORM_MONTH_PATTERN; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - ERP 销售统计") -@RestController -@RequestMapping("/erp/sale-statistics") -@Validated -public class ErpSaleStatisticsController { - - @Resource - private ErpSaleStatisticsService saleStatisticsService; - - @GetMapping("/summary") - @Operation(summary = "获得销售统计") - @PreAuthorize("@ss.hasPermission('erp:statistics:query')") - public CommonResult getSaleSummary() { - LocalDateTime today = LocalDateTimeUtils.getToday(); - LocalDateTime yesterday = LocalDateTimeUtils.getYesterday(); - LocalDateTime month = LocalDateTimeUtils.getMonth(); - LocalDateTime year = LocalDateTimeUtils.getYear(); - ErpSaleSummaryRespVO summary = new ErpSaleSummaryRespVO() - .setTodayPrice(saleStatisticsService.getSalePrice(today, null)) - .setYesterdayPrice(saleStatisticsService.getSalePrice(yesterday, today)) - .setMonthPrice(saleStatisticsService.getSalePrice(month, null)) - .setYearPrice(saleStatisticsService.getSalePrice(year, null)); - return success(summary); - } - - @GetMapping("/time-summary") - @Operation(summary = "获得销售时间段统计") - @Parameter(name = "count", description = "时间段数量", example = "6") - @PreAuthorize("@ss.hasPermission('erp:statistics:query')") - public CommonResult> getSaleTimeSummary( - @RequestParam(value = "count", defaultValue = "6") Integer count) { - List summaryList = new ArrayList<>(); - for (int i = count - 1; i >= 0; i--) { - LocalDateTime startTime = LocalDateTimeUtils.beginOfMonth(LocalDateTime.now().minusMonths(i)); - LocalDateTime endTime = LocalDateTimeUtils.endOfMonth(startTime); - summaryList.add(new ErpSaleTimeSummaryRespVO() - .setTime(LocalDateTimeUtil.format(startTime, NORM_MONTH_PATTERN)) - .setPrice(saleStatisticsService.getSalePrice(startTime, endTime))); - } - return success(summaryList); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/purchase/ErpPurchaseSummaryRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/purchase/ErpPurchaseSummaryRespVO.java deleted file mode 100644 index 22635e745..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/purchase/ErpPurchaseSummaryRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.purchase; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 采购全局统计 Response VO") -@Data -public class ErpPurchaseSummaryRespVO { - - @Schema(description = "今日采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private BigDecimal todayPrice; - - @Schema(description = "昨日采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private BigDecimal yesterdayPrice; - - @Schema(description = "本月采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private BigDecimal monthPrice; - - @Schema(description = "今年采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "88888") - private BigDecimal yearPrice; - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/purchase/ErpPurchaseTimeSummaryRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/purchase/ErpPurchaseTimeSummaryRespVO.java deleted file mode 100644 index 15ae817de..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/purchase/ErpPurchaseTimeSummaryRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.purchase; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 采购某个时间段的统计 Response VO") -@Data -public class ErpPurchaseTimeSummaryRespVO { - - @Schema(description = "时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-03") - private String time; - - @Schema(description = "采购金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private BigDecimal price; - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/sale/ErpSaleSummaryRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/sale/ErpSaleSummaryRespVO.java deleted file mode 100644 index 575d7da5e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/sale/ErpSaleSummaryRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.sale; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 销售全局统计 Response VO") -@Data -public class ErpSaleSummaryRespVO { - - @Schema(description = "今日销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private BigDecimal todayPrice; - - @Schema(description = "昨日销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private BigDecimal yesterdayPrice; - - @Schema(description = "本月销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private BigDecimal monthPrice; - - @Schema(description = "今年销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "88888") - private BigDecimal yearPrice; - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/sale/ErpSaleTimeSummaryRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/sale/ErpSaleTimeSummaryRespVO.java deleted file mode 100644 index 48b9b6e9a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/statistics/vo/sale/ErpSaleTimeSummaryRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.statistics.vo.sale; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 销售某个时间段的统计 Response VO") -@Data -public class ErpSaleTimeSummaryRespVO { - - @Schema(description = "时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-03") - private String time; - - @Schema(description = "销售金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private BigDecimal price; - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockCheckController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockCheckController.java deleted file mode 100644 index b7b3c0991..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockCheckController.java +++ /dev/null @@ -1,149 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockCheckService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 库存调拨单") -@RestController -@RequestMapping("/erp/stock-check") -@Validated -public class ErpStockCheckController { - - @Resource - private ErpStockCheckService stockCheckService; - @Resource - private ErpProductService productService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建库存调拨单") - @PreAuthorize("@ss.hasPermission('erp:stock-check:create')") - public CommonResult createStockCheck(@Valid @RequestBody ErpStockCheckSaveReqVO createReqVO) { - return success(stockCheckService.createStockCheck(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新库存调拨单") - @PreAuthorize("@ss.hasPermission('erp:stock-check:update')") - public CommonResult updateStockCheck(@Valid @RequestBody ErpStockCheckSaveReqVO updateReqVO) { - stockCheckService.updateStockCheck(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新库存调拨单的状态") - @PreAuthorize("@ss.hasPermission('erp:stock-check:update-status')") - public CommonResult updateStockCheckStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - stockCheckService.updateStockCheckStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除库存调拨单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:stock-check:delete')") - public CommonResult deleteStockCheck(@RequestParam("ids") List ids) { - stockCheckService.deleteStockCheck(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得库存调拨单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:stock-check:query')") - public CommonResult getStockCheck(@RequestParam("id") Long id) { - ErpStockCheckDO stockCheck = stockCheckService.getStockCheck(id); - if (stockCheck == null) { - return success(null); - } - List stockCheckItemList = stockCheckService.getStockCheckItemListByCheckId(id); - Map productMap = productService.getProductVOMap( - convertSet(stockCheckItemList, ErpStockCheckItemDO::getProductId)); - return success(BeanUtils.toBean(stockCheck, ErpStockCheckRespVO.class, stockCheckVO -> - stockCheckVO.setItems(BeanUtils.toBean(stockCheckItemList, ErpStockCheckRespVO.Item.class, item -> - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))))); - } - - @GetMapping("/page") - @Operation(summary = "获得库存调拨单分页") - @PreAuthorize("@ss.hasPermission('erp:stock-check:query')") - public CommonResult> getStockCheckPage(@Valid ErpStockCheckPageReqVO pageReqVO) { - PageResult pageResult = stockCheckService.getStockCheckPage(pageReqVO); - return success(buildStockCheckVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出库存调拨单 Excel") - @PreAuthorize("@ss.hasPermission('erp:stock-check:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportStockCheckExcel(@Valid ErpStockCheckPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildStockCheckVOPageResult(stockCheckService.getStockCheckPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "库存调拨单.xls", "数据", ErpStockCheckRespVO.class, list); - } - - private PageResult buildStockCheckVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 盘点项 - List stockCheckItemList = stockCheckService.getStockCheckItemListByCheckIds( - convertSet(pageResult.getList(), ErpStockCheckDO::getId)); - Map> stockCheckItemMap = convertMultiMap(stockCheckItemList, ErpStockCheckItemDO::getCheckId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(stockCheckItemList, ErpStockCheckItemDO::getProductId)); - // 1.3 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), stockCheck -> Long.parseLong(stockCheck.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpStockCheckRespVO.class, stockCheck -> { - stockCheck.setItems(BeanUtils.toBean(stockCheckItemMap.get(stockCheck.getId()), ErpStockCheckRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - stockCheck.setProductNames(CollUtil.join(stockCheck.getItems(), ",", ErpStockCheckRespVO.Item::getProductName)); - MapUtils.findAndThen(userMap, Long.parseLong(stockCheck.getCreator()), user -> stockCheck.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockController.java deleted file mode 100644 index 2d9818d36..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockController.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockRespVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.erp.service.stock.ErpWarehouseService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 产品库存") -@RestController -@RequestMapping("/erp/stock") -@Validated -public class ErpStockController { - - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - - @GetMapping("/get") - @Operation(summary = "获得产品库存") - @Parameters({ - @Parameter(name = "id", description = "编号", example = "1"), // 方案一:传递 id - @Parameter(name = "productId", description = "产品编号", example = "10"), // 方案二:传递 productId + warehouseId - @Parameter(name = "warehouseId", description = "仓库编号", example = "2") - }) - @PreAuthorize("@ss.hasPermission('erp:stock:query')") - public CommonResult getStock(@RequestParam(value = "id", required = false) Long id, - @RequestParam(value = "productId", required = false) Long productId, - @RequestParam(value = "warehouseId", required = false) Long warehouseId) { - ErpStockDO stock = id != null ? stockService.getStock(id) : stockService.getStock(productId, warehouseId); - return success(BeanUtils.toBean(stock, ErpStockRespVO.class)); - } - - @GetMapping("/get-count") - @Operation(summary = "获得产品库存数量") - @Parameter(name = "productId", description = "产品编号", example = "10") - public CommonResult getStockCount(@RequestParam("productId") Long productId) { - return success(stockService.getStockCount(productId)); - } - - @GetMapping("/page") - @Operation(summary = "获得产品库存分页") - @PreAuthorize("@ss.hasPermission('erp:stock:query')") - public CommonResult> getStockPage(@Valid ErpStockPageReqVO pageReqVO) { - PageResult pageResult = stockService.getStockPage(pageReqVO); - return success(buildStockVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出产品库存 Excel") - @PreAuthorize("@ss.hasPermission('erp:stock:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportStockExcel(@Valid ErpStockPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildStockVOPageResult(stockService.getStockPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "产品库存.xls", "数据", ErpStockRespVO.class, list); - } - - private PageResult buildStockVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - Map productMap = productService.getProductVOMap( - convertSet(pageResult.getList(), ErpStockDO::getProductId)); - Map warehouseMap = warehouseService.getWarehouseMap( - convertSet(pageResult.getList(), ErpStockDO::getWarehouseId)); - return BeanUtils.toBean(pageResult, ErpStockRespVO.class, stock -> { - MapUtils.findAndThen(productMap, stock.getProductId(), product -> stock.setProductName(product.getName()) - .setCategoryName(product.getCategoryName()).setUnitName(product.getUnitName())); - MapUtils.findAndThen(warehouseMap, stock.getWarehouseId(), warehouse -> stock.setWarehouseName(warehouse.getName())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockInController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockInController.java deleted file mode 100644 index cd9fb9241..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockInController.java +++ /dev/null @@ -1,165 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockInService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 其它入库单") -@RestController -@RequestMapping("/erp/stock-in") -@Validated -public class ErpStockInController { - - @Resource - private ErpStockInService stockInService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpSupplierService supplierService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建其它入库单") - @PreAuthorize("@ss.hasPermission('erp:stock-in:create')") - public CommonResult createStockIn(@Valid @RequestBody ErpStockInSaveReqVO createReqVO) { - return success(stockInService.createStockIn(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新其它入库单") - @PreAuthorize("@ss.hasPermission('erp:stock-in:update')") - public CommonResult updateStockIn(@Valid @RequestBody ErpStockInSaveReqVO updateReqVO) { - stockInService.updateStockIn(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新其它入库单的状态") - @PreAuthorize("@ss.hasPermission('erp:stock-in:update-status')") - public CommonResult updateStockInStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - stockInService.updateStockInStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除其它入库单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:stock-in:delete')") - public CommonResult deleteStockIn(@RequestParam("ids") List ids) { - stockInService.deleteStockIn(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得其它入库单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:stock-in:query')") - public CommonResult getStockIn(@RequestParam("id") Long id) { - ErpStockInDO stockIn = stockInService.getStockIn(id); - if (stockIn == null) { - return success(null); - } - List stockInItemList = stockInService.getStockInItemListByInId(id); - Map productMap = productService.getProductVOMap( - convertSet(stockInItemList, ErpStockInItemDO::getProductId)); - return success(BeanUtils.toBean(stockIn, ErpStockInRespVO.class, stockInVO -> - stockInVO.setItems(BeanUtils.toBean(stockInItemList, ErpStockInRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得其它入库单分页") - @PreAuthorize("@ss.hasPermission('erp:stock-in:query')") - public CommonResult> getStockInPage(@Valid ErpStockInPageReqVO pageReqVO) { - PageResult pageResult = stockInService.getStockInPage(pageReqVO); - return success(buildStockInVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出其它入库单 Excel") - @PreAuthorize("@ss.hasPermission('erp:stock-in:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportStockInExcel(@Valid ErpStockInPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildStockInVOPageResult(stockInService.getStockInPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "其它入库单.xls", "数据", ErpStockInRespVO.class, list); - } - - private PageResult buildStockInVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 入库项 - List stockInItemList = stockInService.getStockInItemListByInIds( - convertSet(pageResult.getList(), ErpStockInDO::getId)); - Map> stockInItemMap = convertMultiMap(stockInItemList, ErpStockInItemDO::getInId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(stockInItemList, ErpStockInItemDO::getProductId)); - // 1.3 供应商信息 - Map supplierMap = supplierService.getSupplierMap( - convertSet(pageResult.getList(), ErpStockInDO::getSupplierId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), stockIn -> Long.parseLong(stockIn.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpStockInRespVO.class, stockIn -> { - stockIn.setItems(BeanUtils.toBean(stockInItemMap.get(stockIn.getId()), ErpStockInRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - stockIn.setProductNames(CollUtil.join(stockIn.getItems(), ",", ErpStockInRespVO.Item::getProductName)); - MapUtils.findAndThen(supplierMap, stockIn.getSupplierId(), supplier -> stockIn.setSupplierName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(stockIn.getCreator()), user -> stockIn.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockMoveController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockMoveController.java deleted file mode 100644 index 8cb85fa3c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockMoveController.java +++ /dev/null @@ -1,160 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMovePageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMoveRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMoveSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveItemDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockMoveService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 库存调拨单") -@RestController -@RequestMapping("/erp/stock-move") -@Validated -public class ErpStockMoveController { - - @Resource - private ErpStockMoveService stockMoveService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建库存调拨单") - @PreAuthorize("@ss.hasPermission('erp:stock-move:create')") - public CommonResult createStockMove(@Valid @RequestBody ErpStockMoveSaveReqVO createReqVO) { - return success(stockMoveService.createStockMove(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新库存调拨单") - @PreAuthorize("@ss.hasPermission('erp:stock-move:update')") - public CommonResult updateStockMove(@Valid @RequestBody ErpStockMoveSaveReqVO updateReqVO) { - stockMoveService.updateStockMove(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新库存调拨单的状态") - @PreAuthorize("@ss.hasPermission('erp:stock-move:update-status')") - public CommonResult updateStockMoveStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - stockMoveService.updateStockMoveStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除库存调拨单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:stock-move:delete')") - public CommonResult deleteStockMove(@RequestParam("ids") List ids) { - stockMoveService.deleteStockMove(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得库存调拨单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:stock-move:query')") - public CommonResult getStockMove(@RequestParam("id") Long id) { - ErpStockMoveDO stockMove = stockMoveService.getStockMove(id); - if (stockMove == null) { - return success(null); - } - List stockMoveItemList = stockMoveService.getStockMoveItemListByMoveId(id); - Map productMap = productService.getProductVOMap( - convertSet(stockMoveItemList, ErpStockMoveItemDO::getProductId)); - return success(BeanUtils.toBean(stockMove, ErpStockMoveRespVO.class, stockMoveVO -> - stockMoveVO.setItems(BeanUtils.toBean(stockMoveItemList, ErpStockMoveRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getFromWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得库存调拨单分页") - @PreAuthorize("@ss.hasPermission('erp:stock-move:query')") - public CommonResult> getStockMovePage(@Valid ErpStockMovePageReqVO pageReqVO) { - PageResult pageResult = stockMoveService.getStockMovePage(pageReqVO); - return success(buildStockMoveVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出库存调拨单 Excel") - @PreAuthorize("@ss.hasPermission('erp:stock-move:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportStockMoveExcel(@Valid ErpStockMovePageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildStockMoveVOPageResult(stockMoveService.getStockMovePage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "库存调拨单.xls", "数据", ErpStockMoveRespVO.class, list); - } - - private PageResult buildStockMoveVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 调拨项 - List stockMoveItemList = stockMoveService.getStockMoveItemListByMoveIds( - convertSet(pageResult.getList(), ErpStockMoveDO::getId)); - Map> stockMoveItemMap = convertMultiMap(stockMoveItemList, ErpStockMoveItemDO::getMoveId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(stockMoveItemList, ErpStockMoveItemDO::getProductId)); - // 1.3 TODO 芋艿:搞仓库信息 - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), stockMove -> Long.parseLong(stockMove.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpStockMoveRespVO.class, stockMove -> { - stockMove.setItems(BeanUtils.toBean(stockMoveItemMap.get(stockMove.getId()), ErpStockMoveRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - stockMove.setProductNames(CollUtil.join(stockMove.getItems(), ",", ErpStockMoveRespVO.Item::getProductName)); - // TODO 芋艿: -// MapUtils.findAndThen(customerMap, stockMove.getCustomerId(), supplier -> stockMove.setCustomerName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(stockMove.getCreator()), user -> stockMove.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockOutController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockOutController.java deleted file mode 100644 index 82eb7043c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockOutController.java +++ /dev/null @@ -1,165 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockOutService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 其它出库单") -@RestController -@RequestMapping("/erp/stock-out") -@Validated -public class ErpStockOutController { - - @Resource - private ErpStockOutService stockOutService; - @Resource - private ErpStockService stockService; - @Resource - private ErpProductService productService; - @Resource - private ErpCustomerService customerService; - - @Resource - private AdminUserApi adminUserApi; - - @PostMapping("/create") - @Operation(summary = "创建其它出库单") - @PreAuthorize("@ss.hasPermission('erp:stock-out:create')") - public CommonResult createStockOut(@Valid @RequestBody ErpStockOutSaveReqVO createReqVO) { - return success(stockOutService.createStockOut(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新其它出库单") - @PreAuthorize("@ss.hasPermission('erp:stock-out:update')") - public CommonResult updateStockOut(@Valid @RequestBody ErpStockOutSaveReqVO updateReqVO) { - stockOutService.updateStockOut(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新其它出库单的状态") - @PreAuthorize("@ss.hasPermission('erp:stock-out:update-status')") - public CommonResult updateStockOutStatus(@RequestParam("id") Long id, - @RequestParam("status") Integer status) { - stockOutService.updateStockOutStatus(id, status); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除其它出库单") - @Parameter(name = "ids", description = "编号数组", required = true) - @PreAuthorize("@ss.hasPermission('erp:stock-out:delete')") - public CommonResult deleteStockOut(@RequestParam("ids") List ids) { - stockOutService.deleteStockOut(ids); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得其它出库单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:stock-out:query')") - public CommonResult getStockOut(@RequestParam("id") Long id) { - ErpStockOutDO stockOut = stockOutService.getStockOut(id); - if (stockOut == null) { - return success(null); - } - List stockOutItemList = stockOutService.getStockOutItemListByOutId(id); - Map productMap = productService.getProductVOMap( - convertSet(stockOutItemList, ErpStockOutItemDO::getProductId)); - return success(BeanUtils.toBean(stockOut, ErpStockOutRespVO.class, stockOutVO -> - stockOutVO.setItems(BeanUtils.toBean(stockOutItemList, ErpStockOutRespVO.Item.class, item -> { - ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId()); - item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO); - MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())); - })))); - } - - @GetMapping("/page") - @Operation(summary = "获得其它出库单分页") - @PreAuthorize("@ss.hasPermission('erp:stock-out:query')") - public CommonResult> getStockOutPage(@Valid ErpStockOutPageReqVO pageReqVO) { - PageResult pageResult = stockOutService.getStockOutPage(pageReqVO); - return success(buildStockOutVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出其它出库单 Excel") - @PreAuthorize("@ss.hasPermission('erp:stock-out:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportStockOutExcel(@Valid ErpStockOutPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildStockOutVOPageResult(stockOutService.getStockOutPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "其它出库单.xls", "数据", ErpStockOutRespVO.class, list); - } - - private PageResult buildStockOutVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - // 1.1 出库项 - List stockOutItemList = stockOutService.getStockOutItemListByOutIds( - convertSet(pageResult.getList(), ErpStockOutDO::getId)); - Map> stockOutItemMap = convertMultiMap(stockOutItemList, ErpStockOutItemDO::getOutId); - // 1.2 产品信息 - Map productMap = productService.getProductVOMap( - convertSet(stockOutItemList, ErpStockOutItemDO::getProductId)); - // 1.3 客户信息 - Map customerMap = customerService.getCustomerMap( - convertSet(pageResult.getList(), ErpStockOutDO::getCustomerId)); - // 1.4 管理员信息 - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), stockOut -> Long.parseLong(stockOut.getCreator()))); - // 2. 开始拼接 - return BeanUtils.toBean(pageResult, ErpStockOutRespVO.class, stockOut -> { - stockOut.setItems(BeanUtils.toBean(stockOutItemMap.get(stockOut.getId()), ErpStockOutRespVO.Item.class, - item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName()) - .setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName())))); - stockOut.setProductNames(CollUtil.join(stockOut.getItems(), ",", ErpStockOutRespVO.Item::getProductName)); - MapUtils.findAndThen(customerMap, stockOut.getCustomerId(), supplier -> stockOut.setCustomerName(supplier.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(stockOut.getCreator()), user -> stockOut.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockRecordController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockRecordController.java deleted file mode 100644 index 61fcf236a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpStockRecordController.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record.ErpStockRecordPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record.ErpStockRecordRespVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockRecordDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockRecordService; -import cn.iocoder.yudao.module.erp.service.stock.ErpWarehouseService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - ERP 产品库存明细") -@RestController -@RequestMapping("/erp/stock-record") -@Validated -public class ErpStockRecordController { - - @Resource - private ErpStockRecordService stockRecordService; - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - - @Resource - private AdminUserApi adminUserApi; - - @GetMapping("/get") - @Operation(summary = "获得产品库存明细") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:stock-record:query')") - public CommonResult getStockRecord(@RequestParam("id") Long id) { - ErpStockRecordDO stockRecord = stockRecordService.getStockRecord(id); - return success(BeanUtils.toBean(stockRecord, ErpStockRecordRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得产品库存明细分页") - @PreAuthorize("@ss.hasPermission('erp:stock-record:query')") - public CommonResult> getStockRecordPage(@Valid ErpStockRecordPageReqVO pageReqVO) { - PageResult pageResult = stockRecordService.getStockRecordPage(pageReqVO); - return success(buildStockRecrodVOPageResult(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出产品库存明细 Excel") - @PreAuthorize("@ss.hasPermission('erp:stock-record:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportStockRecordExcel(@Valid ErpStockRecordPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = buildStockRecrodVOPageResult(stockRecordService.getStockRecordPage(pageReqVO)).getList(); - // 导出 Excel - ExcelUtils.write(response, "产品库存明细.xls", "数据", ErpStockRecordRespVO.class, list); - } - - private PageResult buildStockRecrodVOPageResult(PageResult pageResult) { - if (CollUtil.isEmpty(pageResult.getList())) { - return PageResult.empty(pageResult.getTotal()); - } - Map productMap = productService.getProductVOMap( - convertSet(pageResult.getList(), ErpStockRecordDO::getProductId)); - Map warehouseMap = warehouseService.getWarehouseMap( - convertSet(pageResult.getList(), ErpStockRecordDO::getWarehouseId)); - Map userMap = adminUserApi.getUserMap( - convertSet(pageResult.getList(), record -> Long.parseLong(record.getCreator()))); - return BeanUtils.toBean(pageResult, ErpStockRecordRespVO.class, stock -> { - MapUtils.findAndThen(productMap, stock.getProductId(), product -> stock.setProductName(product.getName()) - .setCategoryName(product.getCategoryName()).setUnitName(product.getUnitName())); - MapUtils.findAndThen(warehouseMap, stock.getWarehouseId(), warehouse -> stock.setWarehouseName(warehouse.getName())); - MapUtils.findAndThen(userMap, Long.parseLong(stock.getCreator()), user -> stock.setCreatorName(user.getNickname())); - }); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpWarehouseController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpWarehouseController.java deleted file mode 100644 index 110525568..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/ErpWarehouseController.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import cn.iocoder.yudao.module.erp.service.stock.ErpWarehouseService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - ERP 仓库") -@RestController -@RequestMapping("/erp/warehouse") -@Validated -public class ErpWarehouseController { - - @Resource - private ErpWarehouseService warehouseService; - - @PostMapping("/create") - @Operation(summary = "创建仓库") - @PreAuthorize("@ss.hasPermission('erp:warehouse:create')") - public CommonResult createWarehouse(@Valid @RequestBody ErpWarehouseSaveReqVO createReqVO) { - return success(warehouseService.createWarehouse(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新仓库") - @PreAuthorize("@ss.hasPermission('erp:warehouse:update')") - public CommonResult updateWarehouse(@Valid @RequestBody ErpWarehouseSaveReqVO updateReqVO) { - warehouseService.updateWarehouse(updateReqVO); - return success(true); - } - - @PutMapping("/update-default-status") - @Operation(summary = "更新仓库默认状态") - @Parameters({ - @Parameter(name = "id", description = "编号", required = true), - @Parameter(name = "status", description = "状态", required = true) - }) - public CommonResult updateWarehouseDefaultStatus(@RequestParam("id") Long id, - @RequestParam("defaultStatus") Boolean defaultStatus) { - warehouseService.updateWarehouseDefaultStatus(id, defaultStatus); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除仓库") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('erp:warehouse:delete')") - public CommonResult deleteWarehouse(@RequestParam("id") Long id) { - warehouseService.deleteWarehouse(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得仓库") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('erp:warehouse:query')") - public CommonResult getWarehouse(@RequestParam("id") Long id) { - ErpWarehouseDO warehouse = warehouseService.getWarehouse(id); - return success(BeanUtils.toBean(warehouse, ErpWarehouseRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得仓库分页") - @PreAuthorize("@ss.hasPermission('erp:warehouse:query')") - public CommonResult> getWarehousePage(@Valid ErpWarehousePageReqVO pageReqVO) { - PageResult pageResult = warehouseService.getWarehousePage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ErpWarehouseRespVO.class)); - } - - @GetMapping("/simple-list") - @Operation(summary = "获得仓库精简列表", description = "只包含被开启的仓库,主要用于前端的下拉选项") - public CommonResult> getWarehouseSimpleList() { - List list = warehouseService.getWarehouseListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(convertList(list, warehouse -> new ErpWarehouseRespVO().setId(warehouse.getId()) - .setName(warehouse.getName()).setDefaultStatus(warehouse.getDefaultStatus()))); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出仓库 Excel") - @PreAuthorize("@ss.hasPermission('erp:warehouse:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportWarehouseExcel(@Valid ErpWarehousePageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = warehouseService.getWarehousePage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "仓库.xls", "数据", ErpWarehouseRespVO.class, - BeanUtils.toBean(list, ErpWarehouseRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckPageReqVO.java deleted file mode 100644 index 2bae14c1e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckPageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 库存盘点单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpStockCheckPageReqVO extends PageParam { - - @Schema(description = "盘点单号", example = "S123") - private String no; - - @Schema(description = "仓库编号", example = "3113") - private Long warehouseId; - - @Schema(description = "盘点时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] checkTime; - - @Schema(description = "状态", example = "10") - @InEnum(ErpAuditStatus.class) - private Integer status; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckRespVO.java deleted file mode 100644 index 88b75bb9c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckRespVO.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.module.erp.enums.DictTypeConstants.AUDIT_STATUS; - -@Schema(description = "管理后台 - ERP 库存盘点单 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpStockCheckRespVO { - - @Schema(description = "盘点编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @ExcelProperty("盘点编号") - private Long id; - - @Schema(description = "盘点单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "S123") - @ExcelProperty("盘点单号") - private String no; - - @Schema(description = "盘点时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("盘点时间") - private LocalDateTime checkTime; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - - @Schema(description = "合计金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("合计金额") - private BigDecimal totalPrice; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(AUDIT_STATUS) - private Integer status; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "盘点项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "盘点项编号", example = "11756") - private Long id; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "账面数量(当前库存)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "账面数量不能为空") - private BigDecimal stockCount; - - @Schema(description = "实际数量(实际库存)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "实际数量不能为空") - private BigDecimal actualCount; - - @Schema(description = "盈亏数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "盈亏数量不能为空") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckSaveReqVO.java deleted file mode 100644 index 9197eb008..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/check/ErpStockCheckSaveReqVO.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 其它出库单新增/修改 Request VO") -@Data -public class ErpStockCheckSaveReqVO { - - @Schema(description = "出库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long id; - - @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出库时间不能为空") - private LocalDateTime checkTime; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "出库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "出库项列表不能为空") - @Valid - private List items; - - @Data - public static class Item { - - @Schema(description = "出库项编号", example = "11756") - private Long id; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "账面数量(当前库存)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "账面数量不能为空") - private BigDecimal stockCount; - - @Schema(description = "实际数量(实际库存)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "实际数量不能为空") - private BigDecimal actualCount; - - @Schema(description = "盈亏数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "盈亏数量不能为空") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInPageReqVO.java deleted file mode 100644 index 02e3db37a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInPageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 其它入库单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpStockInPageReqVO extends PageParam { - - @Schema(description = "入库单号", example = "S123") - private String no; - - @Schema(description = "供应商编号", example = "3113") - private Long supplierId; - - @Schema(description = "入库时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] inTime; - - @Schema(description = "状态", example = "10") - @InEnum(ErpAuditStatus.class) - private Integer status; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "仓库编号", example = "1") - private Long warehouseId; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInRespVO.java deleted file mode 100644 index 077b9dd1b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInRespVO.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.module.erp.enums.DictTypeConstants.AUDIT_STATUS; - -@Schema(description = "管理后台 - ERP 其它入库单 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpStockInRespVO { - - @Schema(description = "入库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @ExcelProperty("入库编号") - private Long id; - - @Schema(description = "入库单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "S123") - @ExcelProperty("入库单号") - private String no; - - @Schema(description = "供应商编号", example = "3113") - private Long supplierId; - @Schema(description = "供应商名称", example = "芋道") - @ExcelProperty("供应商名称") - private String supplierName; - - @Schema(description = "入库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("入库时间") - private LocalDateTime inTime; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - - @Schema(description = "合计金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("合计金额") - private BigDecimal totalPrice; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(AUDIT_STATUS) - private Integer status; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "入库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "入库项编号", example = "11756") - private Long id; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInSaveReqVO.java deleted file mode 100644 index fc1cc7e4e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/in/ErpStockInSaveReqVO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 其它入库单新增/修改 Request VO") -@Data -public class ErpStockInSaveReqVO { - - @Schema(description = "入库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long id; - - @Schema(description = "供应商编号", example = "3113") - private Long supplierId; - - @Schema(description = "入库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "入库时间不能为空") - private LocalDateTime inTime; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "入库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "入库项列表不能为空") - @Valid - private List items; - - @Data - public static class Item { - - @Schema(description = "入库项编号", example = "11756") - private Long id; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMovePageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMovePageReqVO.java deleted file mode 100644 index 98a1fe95e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMovePageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 库存调拨单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpStockMovePageReqVO extends PageParam { - - @Schema(description = "调拨单号", example = "S123") - private String no; - - @Schema(description = "调拨时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] moveTime; - - @Schema(description = "状态", example = "10") - @InEnum(ErpAuditStatus.class) - private Integer status; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "调出仓库编号", example = "1") - private Long fromWarehouseId; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMoveRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMoveRespVO.java deleted file mode 100644 index 799ddc3f1..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMoveRespVO.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.module.erp.enums.DictTypeConstants.AUDIT_STATUS; - -@Schema(description = "管理后台 - ERP 库存调拨单 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpStockMoveRespVO { - - @Schema(description = "调拨编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @ExcelProperty("调拨编号") - private Long id; - - @Schema(description = "调拨单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "S123") - @ExcelProperty("调拨单号") - private String no; - - @Schema(description = "调拨时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("调拨时间") - private LocalDateTime moveTime; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - - @Schema(description = "合计金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("合计金额") - private BigDecimal totalPrice; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(AUDIT_STATUS) - private Integer status; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "调拨项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "调拨项编号", example = "11756") - private Long id; - - @Schema(description = "调出仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long fromWarehouseId; - - @Schema(description = "调入仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Long toWarehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMoveSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMoveSaveReqVO.java deleted file mode 100644 index 1930241ff..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/move/ErpStockMoveSaveReqVO.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move; - -import cn.hutool.core.util.ObjectUtil; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.Valid; -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 库存调拨单新增/修改 Request VO") -@Data -public class ErpStockMoveSaveReqVO { - - @Schema(description = "调拨编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long id; - - @Schema(description = "客户编号", example = "3113") - private Long customerId; - - @Schema(description = "调拨时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "调拨时间不能为空") - private LocalDateTime moveTime; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "调拨项列表", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "调拨项列表不能为空") - @Valid - private List items; - - @Data - public static class Item { - - @Schema(description = "调拨项编号", example = "11756") - private Long id; - - @Schema(description = "调出仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "调出仓库编号不能为空") - private Long fromWarehouseId; - - @Schema(description = "调入仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - @NotNull(message = "调入仓库编号不能为空") - private Long toWarehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - @AssertTrue(message = "调出、调仓仓库不能相同") - @JsonIgnore - public boolean isWarehouseValid() { - return ObjectUtil.notEqual(fromWarehouseId, toWarehouseId); - } - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutPageReqVO.java deleted file mode 100644 index 5f6558b19..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutPageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 其它出库单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpStockOutPageReqVO extends PageParam { - - @Schema(description = "出库单号", example = "S123") - private String no; - - @Schema(description = "客户编号", example = "3113") - private Long customerId; - - @Schema(description = "出库时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] outTime; - - @Schema(description = "状态", example = "10") - @InEnum(ErpAuditStatus.class) - private Integer status; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "创建者") - private String creator; - - @Schema(description = "产品编号", example = "1") - private Long productId; - - @Schema(description = "仓库编号", example = "1") - private Long warehouseId; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutRespVO.java deleted file mode 100644 index 22a88e7c9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutRespVO.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.module.erp.enums.DictTypeConstants.AUDIT_STATUS; - -@Schema(description = "管理后台 - ERP 其它出库单 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpStockOutRespVO { - - @Schema(description = "出库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - @ExcelProperty("出库编号") - private Long id; - - @Schema(description = "出库单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "S123") - @ExcelProperty("出库单号") - private String no; - - @Schema(description = "客户编号", example = "3113") - private Long customerId; - @Schema(description = "客户名称", example = "芋道") - @ExcelProperty("客户名称") - private String customerName; - - @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("出库时间") - private LocalDateTime outTime; - - @Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663") - @ExcelProperty("合计数量") - private BigDecimal totalCount; - - @Schema(description = "合计金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906") - @ExcelProperty("合计金额") - private BigDecimal totalPrice; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(AUDIT_STATUS) - private Integer status; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "创建人", example = "芋道") - private String creator; - @Schema(description = "创建人名称", example = "芋道") - private String creatorName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "出库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("产品信息") - private String productNames; - - @Data - public static class Item { - - @Schema(description = "出库项编号", example = "11756") - private Long id; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - private Long productId; - - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - // ========== 关联字段 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力") - private String productName; - @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985") - private String productBarCode; - @Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒") - private String productUnitName; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal stockCount; // 该字段仅仅在“详情”和“编辑”时使用 - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutSaveReqVO.java deleted file mode 100644 index 26abca036..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/out/ErpStockOutSaveReqVO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out; - -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - ERP 其它出库单新增/修改 Request VO") -@Data -public class ErpStockOutSaveReqVO { - - @Schema(description = "出库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756") - private Long id; - - @Schema(description = "客户编号", example = "3113") - private Long customerId; - - @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "出库时间不能为空") - private LocalDateTime outTime; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc") - private String fileUrl; - - @Schema(description = "出库项列表", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "出库项列表不能为空") - @Valid - private List items; - - @Data - public static class Item { - - @Schema(description = "出库项编号", example = "11756") - private Long id; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113") - @NotNull(message = "产品编号不能为空") - private Long productId; - - @Schema(description = "产品单价", example = "100.00") - private BigDecimal productPrice; - - @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - @NotNull(message = "产品数量不能为空") - private BigDecimal count; - - @Schema(description = "备注", example = "随便") - private String remark; - - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/record/ErpStockRecordPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/record/ErpStockRecordPageReqVO.java deleted file mode 100644 index c478e4fef..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/record/ErpStockRecordPageReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - ERP 产品库存明细分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpStockRecordPageReqVO extends PageParam { - - @Schema(description = "产品编号", example = "10625") - private Long productId; - - @Schema(description = "仓库编号", example = "32407") - private Long warehouseId; - - @Schema(description = "业务类型", example = "10") - private Integer bizType; - - @Schema(description = "业务单号", example = "Z110") - private String bizNo; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/record/ErpStockRecordRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/record/ErpStockRecordRespVO.java deleted file mode 100644 index ff4b3e12a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/record/ErpStockRecordRespVO.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.erp.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 产品库存明细 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpStockRecordRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18909") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10625") - private Long productId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32407") - private Long warehouseId; - - @Schema(description = "出入库数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "11084") - @ExcelProperty("出入库数量") - private BigDecimal count; - - @Schema(description = "总库存量", requiredMode = Schema.RequiredMode.REQUIRED, example = "4307") - @ExcelProperty("总库存量") - private BigDecimal totalCount; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty(value = "业务类型", converter = DictConvert.class) - @DictFormat(DictTypeConstants.STOCK_RECORD_BIZ_TYPE) - private Integer bizType; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27093") - @ExcelProperty("业务编号") - private Long bizId; - - @Schema(description = "业务项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23516") - @ExcelProperty("业务项编号") - private Long bizItemId; - - @Schema(description = "业务单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "Z110") - @ExcelProperty("业务单号") - private String bizNo; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "25682") - private String creator; - - // ========== 产品信息 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果") - @ExcelProperty("产品名称") - private String productName; - - @Schema(description = "产品分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "水果") - @ExcelProperty("产品分类") - private String categoryName; - - @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") - @ExcelProperty("单位") - private String unitName; - - // ========== 仓库信息 ========== - - @Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("仓库名称") - private String warehouseName; - - // ========== 用户信息 ========== - - @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - @ExcelProperty("创建人") - private String creatorName; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockPageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockPageReqVO.java deleted file mode 100644 index f7f3fa343..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - ERP 库存分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpStockPageReqVO extends PageParam { - - @Schema(description = "产品编号", example = "19614") - private Long productId; - - @Schema(description = "仓库编号", example = "2802") - private Long warehouseId; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockRespVO.java deleted file mode 100644 index 06366a0dd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/stock/ErpStockRespVO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 库存 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpStockRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17086") - @ExcelProperty("编号") - private Long id; - - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19614") - private Long productId; - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2802") - private Long warehouseId; - - @Schema(description = "库存数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "21935") - @ExcelProperty("库存数量") - private BigDecimal count; - - // ========== 产品信息 ========== - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果") - @ExcelProperty("产品名称") - private String productName; - - @Schema(description = "产品分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "水果") - @ExcelProperty("产品分类") - private String categoryName; - - @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") - @ExcelProperty("单位") - private String unitName; - - // ========== 仓库信息 ========== - - @Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("仓库名称") - private String warehouseName; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehousePageReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehousePageReqVO.java deleted file mode 100644 index 2accf9a0f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehousePageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - ERP 仓库分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ErpWarehousePageReqVO extends PageParam { - - @Schema(description = "仓库名称", example = "李四") - private String name; - - @Schema(description = "开启状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehouseRespVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehouseRespVO.java deleted file mode 100644 index 188d42699..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehouseRespVO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - ERP 仓库 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ErpWarehouseRespVO { - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11614") - @ExcelProperty("仓库编号") - private Long id; - - @Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @ExcelProperty("仓库名称") - private String name; - - @Schema(description = "仓库地址", example = "上海陆家嘴") - @ExcelProperty("仓库地址") - private String address; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @ExcelProperty("排序") - private Long sort; - - @Schema(description = "备注", example = "随便") - @ExcelProperty("备注") - private String remark; - - @Schema(description = "负责人", example = "芋头") - @ExcelProperty("负责人") - private String principal; - - @Schema(description = "仓储费,单位:元", example = "13973") - @ExcelProperty("仓储费,单位:元") - private BigDecimal warehousePrice; - - @Schema(description = "搬运费,单位:元", example = "9903") - @ExcelProperty("搬运费,单位:元") - private BigDecimal truckagePrice; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "开启状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @Schema(description = "是否默认", example = "1") - @ExcelProperty("是否默认") - private Boolean defaultStatus; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehouseSaveReqVO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehouseSaveReqVO.java deleted file mode 100644 index 06bf5580e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/stock/vo/warehouse/ErpWarehouseSaveReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - ERP 仓库新增/修改 Request VO") -@Data -public class ErpWarehouseSaveReqVO { - - @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11614") - private Long id; - - @Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotEmpty(message = "仓库名称不能为空") - private String name; - - @Schema(description = "仓库地址", example = "上海陆家嘴") - private String address; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "排序不能为空") - private Long sort; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "负责人", example = "芋头") - private String principal; - - @Schema(description = "仓储费,单位:元", example = "13973") - private BigDecimal warehousePrice; - - @Schema(description = "搬运费,单位:元", example = "9903") - private BigDecimal truckagePrice; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "开启状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/package-info.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/package-info.java deleted file mode 100644 index ef0e5accf..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.erp.controller; diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpAccountDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpAccountDO.java deleted file mode 100644 index fe01cc228..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpAccountDO.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.finance; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * ERP 结算账户 DO - * - * @author 芋道源码 - */ -@TableName("erp_account") -@KeySequence("erp_account_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpAccountDO extends BaseDO { - - /** - * 结算账户编号 - */ - @TableId - private Long id; - /** - * 账户名称 - */ - private String name; - /** - * 账户编码 - */ - private String no; - /** - * 备注 - */ - private String remark; - /** - * 开启状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 排序 - */ - private Integer sort; - /** - * 是否默认 - */ - private Boolean defaultStatus; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentDO.java deleted file mode 100644 index edb55edbf..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentDO.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.finance; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 付款单 DO - * - * @author 芋道源码 - */ -@TableName("erp_finance_payment") -@KeySequence("erp_finance_payment_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpFinancePaymentDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 付款单号 - */ - private String no; - /** - * 付款状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 付款时间 - */ - private LocalDateTime paymentTime; - /** - * 财务人员编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long financeUserId; - /** - * 供应商编号 - * - * 关联 {@link ErpSupplierDO#getId()} - */ - private Long supplierId; - /** - * 付款账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - - /** - * 合计价格,单位:元 - */ - private BigDecimal totalPrice; - /** - * 优惠金额,单位:元 - */ - private BigDecimal discountPrice; - /** - * 实付金额,单位:分 - * - * paymentPrice = totalPrice - discountPrice - */ - private BigDecimal paymentPrice; - - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentItemDO.java deleted file mode 100644 index dd5bc5f69..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinancePaymentItemDO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.finance; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 付款项 DO - * - * @author 芋道源码 - */ -@TableName("erp_finance_payment_item") -@KeySequence("erp_finance_payment_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpFinancePaymentItemDO extends BaseDO { - - /** - * 入库项编号 - */ - @TableId - private Long id; - /** - * 付款单编号 - * - * 关联 {@link ErpFinancePaymentDO#getId()} - */ - private Long paymentId; - - /** - * 业务类型 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.common.ErpBizTypeEnum} 的采购入库、退货 - */ - private Integer bizType; - /** - * 业务编号 - * - * 例如说:{@link ErpPurchaseInDO#getId()} - */ - private Long bizId; - /** - * 业务单号 - * - * 例如说:{@link ErpPurchaseInDO#getNo()} - */ - private String bizNo; - - /** - * 应付金额,单位:分 - */ - private BigDecimal totalPrice; - /** - * 已付金额,单位:分 - */ - private BigDecimal paidPrice; - /** - * 本次付款,单位:分 - */ - private BigDecimal paymentPrice; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinanceReceiptDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinanceReceiptDO.java deleted file mode 100644 index 46a559505..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinanceReceiptDO.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.finance; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 收款单 DO - * - * @author 芋道源码 - */ -@TableName("erp_finance_receipt") -@KeySequence("erp_finance_receipt_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpFinanceReceiptDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 收款单号 - */ - private String no; - /** - * 收款状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 收款时间 - */ - private LocalDateTime receiptTime; - /** - * 财务人员编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long financeUserId; - /** - * 客户编号 - * - * 关联 {@link ErpCustomerDO#getId()} - */ - private Long customerId; - /** - * 收款账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - - /** - * 合计价格,单位:元 - */ - private BigDecimal totalPrice; - /** - * 优惠金额,单位:元 - */ - private BigDecimal discountPrice; - /** - * 实付金额,单位:分 - * - * receiptPrice = totalPrice - discountPrice - */ - private BigDecimal receiptPrice; - - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinanceReceiptItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinanceReceiptItemDO.java deleted file mode 100644 index 87f051d5c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/finance/ErpFinanceReceiptItemDO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.finance; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 收款项 DO - * - * @author 芋道源码 - */ -@TableName("erp_finance_receipt_item") -@KeySequence("erp_finance_receipt_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpFinanceReceiptItemDO extends BaseDO { - - /** - * 入库项编号 - */ - @TableId - private Long id; - /** - * 收款单编号 - * - * 关联 {@link ErpFinanceReceiptDO#getId()} - */ - private Long receiptId; - - /** - * 业务类型 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.common.ErpBizTypeEnum} 的销售出库、退货 - */ - private Integer bizType; - /** - * 业务编号 - * - * 例如说:{@link ErpSaleOutDO#getId()} - */ - private Long bizId; - /** - * 业务单号 - * - * 例如说:{@link ErpSaleOutDO#getNo()} - */ - private String bizNo; - - /** - * 应收金额,单位:分 - */ - private BigDecimal totalPrice; - /** - * 已收金额,单位:分 - */ - private BigDecimal receiptedPrice; - /** - * 本次收款,单位:分 - */ - private BigDecimal receiptPrice; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductCategoryDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductCategoryDO.java deleted file mode 100644 index 4c6225158..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductCategoryDO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * ERP 产品分类 DO - * - * @author 芋道源码 - */ -@TableName("erp_product_category") -@KeySequence("erp_product_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpProductCategoryDO extends BaseDO { - - public static final Long PARENT_ID_ROOT = 0L; - - /** - * 分类编号 - */ - @TableId - private Long id; - /** - * 父分类编号 - */ - private Long parentId; - /** - * 分类名称 - */ - private String name; - /** - * 分类编码 - */ - private String code; - /** - * 分类排序 - */ - private Integer sort; - /** - * 开启状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductDO.java deleted file mode 100644 index 31e4aa2d9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductDO.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 产品 DO - * - * @author 芋道源码 - */ -@TableName("erp_product") -@KeySequence("erp_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpProductDO extends BaseDO { - - /** - * 产品编号 - */ - @TableId - private Long id; - /** - * 产品名称 - */ - private String name; - /** - * 产品条码 - */ - private String barCode; - /** - * 产品分类编号 - * - * 关联 {@link ErpProductCategoryDO#getId()} - */ - private Long categoryId; - /** - * 单位编号 - * - * 关联 {@link ErpProductUnitDO#getId()} - */ - private Long unitId; - /** - * 产品状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 产品规格 - */ - private String standard; - /** - * 产品备注 - */ - private String remark; - /** - * 保质期天数 - */ - private Integer expiryDay; - /** - * 基础重量(kg) - */ - private BigDecimal weight; - /** - * 采购价格,单位:元 - */ - private BigDecimal purchasePrice; - /** - * 销售价格,单位:元 - */ - private BigDecimal salePrice; - /** - * 最低价格,单位:元 - */ - private BigDecimal minPrice; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductUnitDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductUnitDO.java deleted file mode 100644 index e8ce906e0..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/product/ErpProductUnitDO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * ERP 产品单位 DO - * - * @author 芋道源码 - */ -@TableName("erp_product_unit") -@KeySequence("erp_product_unit_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpProductUnitDO extends BaseDO { - - /** - * 单位编号 - */ - @TableId - private Long id; - /** - * 单位名字 - */ - private String name; - /** - * 单位状态 - */ - private Integer status; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseInDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseInDO.java deleted file mode 100644 index b8186f509..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseInDO.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 采购入库 DO - * - * @author 芋道源码 - */ -@TableName(value = "erp_purchase_in") -@KeySequence("erp_purchase_in_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpPurchaseInDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 采购入库单号 - */ - private String no; - /** - * 入库状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 供应商编号 - * - * 关联 {@link ErpSupplierDO#getId()} - */ - private Long supplierId; - /** - * 结算账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - /** - * 入库时间 - */ - private LocalDateTime inTime; - - /** - * 采购订单编号 - * - * 关联 {@link ErpPurchaseOrderDO#getId()} - */ - private Long orderId; - /** - * 采购订单号 - * - * 冗余 {@link ErpPurchaseOrderDO#getNo()} - */ - private String orderNo; - - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 最终合计价格,单位:元 - * - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice - */ - private BigDecimal totalPrice; - /** - * 已支付金额,单位:元 - * - * 目的:和 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO} 结合,记录已支付金额 - */ - private BigDecimal paymentPrice; - - /** - * 合计产品价格,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 合计税额,单位:元 - */ - private BigDecimal totalTaxPrice; - /** - * 优惠率,百分比 - */ - private BigDecimal discountPercent; - /** - * 优惠金额,单位:元 - * - * discountPrice = (totalProductPrice + totalTaxPrice) * discountPercent - */ - private BigDecimal discountPrice; - /** - * 其它金额,单位:元 - */ - private BigDecimal otherPrice; - - /** - * 附件地址 - */ - private String fileUrl; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseInItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseInItemDO.java deleted file mode 100644 index 1597bc10b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseInItemDO.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 采购入库项 DO - * - * @author 芋道源码 - */ -@TableName("erp_purchase_in_items") -@KeySequence("erp_purchase_in_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpPurchaseInItemDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 采购入库编号 - * - * 关联 {@link ErpPurchaseInDO##getId()} - */ - private Long inId; - /** - * 采购订单项编号 - * - * 关联 {@link ErpPurchaseOrderItemDO#getId()} - * 目的:方便更新关联的采购订单项的入库数量 - */ - private Long orderItemId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位单位 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - - /** - * 产品单位单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总价,单位:元 - * - * totalPrice = productPrice * count - */ - private BigDecimal totalPrice; - /** - * 税率,百分比 - */ - private BigDecimal taxPercent; - /** - * 税额,单位:元 - * - * taxPrice = totalPrice * taxPercent - */ - private BigDecimal taxPrice; - - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderDO.java deleted file mode 100644 index bba1542e3..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderDO.java +++ /dev/null @@ -1,115 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 采购订单 DO - * - * @author 芋道源码 - */ -@TableName(value = "erp_purchase_order") -@KeySequence("erp_purchase_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpPurchaseOrderDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 采购订单号 - */ - private String no; - /** - * 采购状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 供应商编号 - * - * 关联 {@link ErpSupplierDO#getId()} - */ - private Long supplierId; - /** - * 结算账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - /** - * 下单时间 - */ - private LocalDateTime orderTime; - - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 最终合计价格,单位:元 - * - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice - */ - private BigDecimal totalPrice; - - /** - * 合计产品价格,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 合计税额,单位:元 - */ - private BigDecimal totalTaxPrice; - /** - * 优惠率,百分比 - */ - private BigDecimal discountPercent; - /** - * 优惠金额,单位:元 - * - * discountPrice = (totalProductPrice + totalTaxPrice) * discountPercent - */ - private BigDecimal discountPrice; - /** - * 定金金额,单位:元 - */ - private BigDecimal depositPrice; - - /** - * 附件地址 - */ - private String fileUrl; - /** - * 备注 - */ - private String remark; - - // ========== 采购入库 ========== - /** - * 采购入库数量 - */ - private BigDecimal inCount; - - // ========== 采购退货(出库)) ========== - /** - * 采购退货数量 - */ - private BigDecimal returnCount; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderItemDO.java deleted file mode 100644 index aa54d336b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseOrderItemDO.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 采购订单项 DO - * - * @author 芋道源码 - */ -@TableName("erp_purchase_order_items") -@KeySequence("erp_purchase_order_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpPurchaseOrderItemDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 采购订单编号 - * - * 关联 {@link ErpPurchaseOrderDO#getId()} - */ - private Long orderId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位单位 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - - /** - * 产品单位单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总价,单位:元 - * - * totalPrice = productPrice * count - */ - private BigDecimal totalPrice; - /** - * 税率,百分比 - */ - private BigDecimal taxPercent; - /** - * 税额,单位:元 - * - * taxPrice = totalPrice * taxPercent - */ - private BigDecimal taxPrice; - - /** - * 备注 - */ - private String remark; - - // ========== 采购入库 ========== - /** - * 采购入库数量 - */ - private BigDecimal inCount; - - // ========== 采购退货(出库)) ========== - /** - * 采购退货数量 - */ - private BigDecimal returnCount; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseReturnDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseReturnDO.java deleted file mode 100644 index 4189e0adc..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseReturnDO.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 采购退货 DO - * - * @author 芋道源码 - */ -@TableName(value = "erp_purchase_return") -@KeySequence("erp_purchase_return_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpPurchaseReturnDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 采购退货单号 - */ - private String no; - /** - * 退货状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 供应商编号 - * - * 关联 {@link ErpSupplierDO#getId()} - */ - private Long supplierId; - /** - * 结算账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - /** - * 退货时间 - */ - private LocalDateTime returnTime; - - /** - * 采购订单编号 - * - * 关联 {@link ErpPurchaseOrderDO#getId()} - */ - private Long orderId; - /** - * 采购订单号 - * - * 冗余 {@link ErpPurchaseOrderDO#getNo()} - */ - private String orderNo; - - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 最终合计价格,单位:元 - * - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice - */ - private BigDecimal totalPrice; - /** - * 已退款金额,单位:元 - * - * 目的:和 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO} 结合,记录已支付金额 - */ - private BigDecimal refundPrice; - - /** - * 合计产品价格,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 合计税额,单位:元 - */ - private BigDecimal totalTaxPrice; - /** - * 优惠率,百分比 - */ - private BigDecimal discountPercent; - /** - * 优惠金额,单位:元 - * - * discountPrice = (totalProductPrice + totalTaxPrice) * discountPercent - */ - private BigDecimal discountPrice; - /** - * 其它金额,单位:元 - */ - private BigDecimal otherPrice; - - /** - * 附件地址 - */ - private String fileUrl; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseReturnItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseReturnItemDO.java deleted file mode 100644 index 1e1713277..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpPurchaseReturnItemDO.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 采购退货项 DO - * - * @author 芋道源码 - */ -@TableName("erp_purchase_return_items") -@KeySequence("erp_purchase_return_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpPurchaseReturnItemDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 采购退货编号 - * - * 关联 {@link ErpPurchaseReturnDO##getId()} - */ - private Long returnId; - /** - * 采购订单项编号 - * - * 关联 {@link ErpPurchaseOrderItemDO#getId()} - * 目的:方便更新关联的采购订单项的退货数量 - */ - private Long orderItemId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位单位 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - - /** - * 产品单位单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总价,单位:元 - * - * totalPrice = productPrice * count - */ - private BigDecimal totalPrice; - /** - * 税率,百分比 - */ - private BigDecimal taxPercent; - /** - * 税额,单位:元 - * - * taxPrice = totalPrice * taxPercent - */ - private BigDecimal taxPrice; - - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpSupplierDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpSupplierDO.java deleted file mode 100644 index 6e94c6669..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/purchase/ErpSupplierDO.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 供应商 DO - * - * @author 芋道源码 - */ -@TableName("erp_supplier") -@KeySequence("erp_supplier_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSupplierDO extends BaseDO { - - /** - * 供应商编号 - */ - @TableId - private Long id; - /** - * 供应商名称 - */ - private String name; - /** - * 联系人 - */ - private String contact; - /** - * 手机号码 - */ - private String mobile; - /** - * 联系电话 - */ - private String telephone; - /** - * 电子邮箱 - */ - private String email; - /** - * 传真 - */ - private String fax; - /** - * 备注 - */ - private String remark; - /** - * 开启状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 排序 - */ - private Integer sort; - /** - * 纳税人识别号 - */ - private String taxNo; - /** - * 税率 - */ - private BigDecimal taxPercent; - /** - * 开户行 - */ - private String bankName; - /** - * 开户账号 - */ - private String bankAccount; - /** - * 开户地址 - */ - private String bankAddress; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpCustomerDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpCustomerDO.java deleted file mode 100644 index 7bffcc17c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpCustomerDO.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 客户 DO - * - * @author 芋道源码 - */ -@TableName("erp_customer") -@KeySequence("erp_customer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpCustomerDO extends BaseDO { - - /** - * 客户编号 - */ - @TableId - private Long id; - /** - * 客户名称 - */ - private String name; - /** - * 联系人 - */ - private String contact; - /** - * 手机号码 - */ - private String mobile; - /** - * 联系电话 - */ - private String telephone; - /** - * 电子邮箱 - */ - private String email; - /** - * 传真 - */ - private String fax; - /** - * 备注 - */ - private String remark; - /** - * 开启状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 排序 - */ - private Integer sort; - /** - * 纳税人识别号 - */ - private String taxNo; - /** - * 税率 - */ - private BigDecimal taxPercent; - /** - * 开户行 - */ - private String bankName; - /** - * 开户账号 - */ - private String bankAccount; - /** - * 开户地址 - */ - private String bankAddress; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderDO.java deleted file mode 100644 index 5cdd4344e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderDO.java +++ /dev/null @@ -1,121 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 销售订单 DO - * - * @author 芋道源码 - */ -@TableName(value = "erp_sale_order") -@KeySequence("erp_sale_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSaleOrderDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 销售订单号 - */ - private String no; - /** - * 销售状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 客户编号 - * - * 关联 {@link ErpCustomerDO#getId()} - */ - private Long customerId; - /** - * 结算账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - /** - * 销售员编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long saleUserId; - /** - * 下单时间 - */ - private LocalDateTime orderTime; - - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 最终合计价格,单位:元 - * - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice - */ - private BigDecimal totalPrice; - - /** - * 合计产品价格,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 合计税额,单位:元 - */ - private BigDecimal totalTaxPrice; - /** - * 优惠率,百分比 - */ - private BigDecimal discountPercent; - /** - * 优惠金额,单位:元 - * - * discountPrice = (totalProductPrice + totalTaxPrice) * discountPercent - */ - private BigDecimal discountPrice; - /** - * 定金金额,单位:元 - */ - private BigDecimal depositPrice; - - /** - * 附件地址 - */ - private String fileUrl; - /** - * 备注 - */ - private String remark; - - // ========== 销售出库 ========== - /** - * 销售出库数量 - */ - private BigDecimal outCount; - - // ========== 销售退货(入库)) ========== - /** - * 销售退货数量 - */ - private BigDecimal returnCount; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderItemDO.java deleted file mode 100644 index 4c829765b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOrderItemDO.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 销售订单项 DO - * - * @author 芋道源码 - */ -@TableName("erp_sale_order_items") -@KeySequence("erp_sale_order_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSaleOrderItemDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 销售订单编号 - * - * 关联 {@link ErpSaleOrderDO#getId()} - */ - private Long orderId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位单位 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - - /** - * 产品单位单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总价,单位:元 - * - * totalPrice = productPrice * count - */ - private BigDecimal totalPrice; - /** - * 税率,百分比 - */ - private BigDecimal taxPercent; - /** - * 税额,单位:元 - * - * taxPrice = totalPrice * taxPercent - */ - private BigDecimal taxPrice; - - /** - * 备注 - */ - private String remark; - - // ========== 销售出库 ========== - /** - * 销售出库数量 - */ - private BigDecimal outCount; - - // ========== 销售退货(入库)) ========== - /** - * 销售退货数量 - */ - private BigDecimal returnCount; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutDO.java deleted file mode 100644 index 65b9d941f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutDO.java +++ /dev/null @@ -1,128 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 销售出库 DO - * - * @author 芋道源码 - */ -@TableName(value = "erp_sale_out") -@KeySequence("erp_sale_out_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSaleOutDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 销售出库单号 - */ - private String no; - /** - * 出库状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 客户编号 - * - * 关联 {@link ErpCustomerDO#getId()} - */ - private Long customerId; - /** - * 结算账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - /** - * 销售员编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long saleUserId; - /** - * 出库时间 - */ - private LocalDateTime outTime; - - /** - * 销售订单编号 - * - * 关联 {@link ErpSaleOrderDO#getId()} - */ - private Long orderId; - /** - * 销售订单号 - * - * 冗余 {@link ErpSaleOrderDO#getNo()} - */ - private String orderNo; - - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 最终合计价格,单位:元 - * - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice - */ - private BigDecimal totalPrice; - /** - * 已收款金额,单位:元 - * - * 目的:和 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO} 结合,记录已收款金额 - */ - private BigDecimal receiptPrice; - - /** - * 合计产品价格,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 合计税额,单位:元 - */ - private BigDecimal totalTaxPrice; - /** - * 优惠率,百分比 - */ - private BigDecimal discountPercent; - /** - * 优惠金额,单位:元 - * - * discountPrice = (totalProductPrice + totalTaxPrice) * discountPercent - */ - private BigDecimal discountPrice; - /** - * 其它金额,单位:元 - */ - private BigDecimal otherPrice; - - /** - * 附件地址 - */ - private String fileUrl; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutItemDO.java deleted file mode 100644 index b9b406413..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleOutItemDO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 销售出库项 DO - * - * @author 芋道源码 - */ -@TableName("erp_sale_out_items") -@KeySequence("erp_sale_out_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSaleOutItemDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 销售出库编号 - * - * 关联 {@link ErpStockOutDO##getId()} - */ - private Long outId; - /** - * 销售订单项编号 - * - * 关联 {@link ErpSaleOrderItemDO#getId()} - * 目的:方便更新关联的销售订单项的出库数量 - */ - private Long orderItemId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位单位 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - - /** - * 产品单位单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总价,单位:元 - * - * totalPrice = productPrice * count - */ - private BigDecimal totalPrice; - /** - * 税率,百分比 - */ - private BigDecimal taxPercent; - /** - * 税额,单位:元 - * - * taxPrice = totalPrice * taxPercent - */ - private BigDecimal taxPrice; - - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleReturnDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleReturnDO.java deleted file mode 100644 index ba41ac91b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleReturnDO.java +++ /dev/null @@ -1,128 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 销售退货 DO - * - * @author 芋道源码 - */ -@TableName(value = "erp_sale_return") -@KeySequence("erp_sale_return_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSaleReturnDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 销售退货单号 - */ - private String no; - /** - * 退货状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 客户编号 - * - * 关联 {@link ErpCustomerDO#getId()} - */ - private Long customerId; - /** - * 结算账户编号 - * - * 关联 {@link ErpAccountDO#getId()} - */ - private Long accountId; - /** - * 销售员编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long saleUserId; - /** - * 退货时间 - */ - private LocalDateTime returnTime; - - /** - * 销售订单编号 - * - * 关联 {@link ErpSaleOrderDO#getId()} - */ - private Long orderId; - /** - * 销售订单号 - * - * 冗余 {@link ErpSaleOrderDO#getNo()} - */ - private String orderNo; - - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 最终合计价格,单位:元 - * - * totalPrice = totalProductPrice + totalTaxPrice - discountPrice + otherPrice - */ - private BigDecimal totalPrice; - /** - * 已退款金额,单位:元 - * - * 目的:和 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO} 结合,记录已退款金额 - */ - private BigDecimal refundPrice; - - /** - * 合计产品价格,单位:元 - */ - private BigDecimal totalProductPrice; - /** - * 合计税额,单位:元 - */ - private BigDecimal totalTaxPrice; - /** - * 优惠率,百分比 - */ - private BigDecimal discountPercent; - /** - * 优惠金额,单位:元 - * - * discountPrice = (totalProductPrice + totalTaxPrice) * discountPercent - */ - private BigDecimal discountPrice; - /** - * 其它金额,单位:元 - */ - private BigDecimal otherPrice; - - /** - * 附件地址 - */ - private String fileUrl; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleReturnItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleReturnItemDO.java deleted file mode 100644 index 8851d157c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/sale/ErpSaleReturnItemDO.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.sale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 销售退货项 DO - * - * @author 芋道源码 - */ -@TableName("erp_sale_return_items") -@KeySequence("erp_sale_return_items_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpSaleReturnItemDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 销售退货编号 - * - * 关联 {@link ErpSaleReturnDO##getId()} - */ - private Long returnId; - /** - * 销售订单项编号 - * - * 关联 {@link ErpSaleOrderItemDO#getId()} - * 目的:方便更新关联的销售订单项的退货数量 - */ - private Long orderItemId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位单位 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - - /** - * 产品单位单价,单位:元 - */ - private BigDecimal productPrice; - /** - * 数量 - */ - private BigDecimal count; - /** - * 总价,单位:元 - * - * totalPrice = productPrice * count - */ - private BigDecimal totalPrice; - /** - * 税率,百分比 - */ - private BigDecimal taxPercent; - /** - * 税额,单位:元 - * - * taxPrice = totalPrice * taxPercent - */ - private BigDecimal taxPrice; - - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockCheckDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockCheckDO.java deleted file mode 100644 index e9168275f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockCheckDO.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 库存盘点单 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_check") -@KeySequence("erp_stock_check_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockCheckDO extends BaseDO { - - /** - * 盘点编号 - */ - @TableId - private Long id; - /** - * 盘点单号 - */ - private String no; - /** - * 盘点时间 - */ - private LocalDateTime checkTime; - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 附件 URL - */ - private String fileUrl; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockCheckItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockCheckItemDO.java deleted file mode 100644 index c3c4dbf99..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockCheckItemDO.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 库存盘点单项 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_check_item") -@KeySequence("erp_stock_check_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockCheckItemDO extends BaseDO { - - /** - * 盘点项编号 - */ - @TableId - private Long id; - /** - * 盘点编号 - * - * 关联 {@link ErpStockCheckDO#getId()} - */ - private Long checkId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位编号 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - /** - * 产品单价 - */ - private BigDecimal productPrice; - /** - * 账面数量(当前库存) - */ - private BigDecimal stockCount; - /** - * 实际数量(实际库存) - */ - private BigDecimal actualCount; - /** - * 盈亏数量 - * - * count = stockCount - actualCount - */ - private BigDecimal count; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockDO.java deleted file mode 100644 index 558c6c6e5..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 产品库存 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock") -@KeySequence("erp_stock_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 库存数量 - */ - private BigDecimal count; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockInDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockInDO.java deleted file mode 100644 index ee2512ab6..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockInDO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 其它入库单 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_in") -@KeySequence("erp_stock_in_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockInDO extends BaseDO { - - /** - * 入库编号 - */ - @TableId - private Long id; - /** - * 入库单号 - */ - private String no; - /** - * 供应商编号 - * - * 关联 {@link ErpSupplierDO#getId()} - */ - private Long supplierId; - /** - * 入库时间 - */ - private LocalDateTime inTime; - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 附件 URL - */ - private String fileUrl; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockInItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockInItemDO.java deleted file mode 100644 index 3e3ca9c5c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockInItemDO.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 其它入库单项 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_in_item") -@KeySequence("erp_stock_in_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockInItemDO extends BaseDO { - - /** - * 入库项编号 - */ - @TableId - private Long id; - /** - * 入库编号 - * - * 关联 {@link ErpStockInDO#getId()} - */ - private Long inId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位编号 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - /** - * 产品单价 - */ - private BigDecimal productPrice; - /** - * 产品数量 - */ - private BigDecimal count; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockMoveDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockMoveDO.java deleted file mode 100644 index 682b33104..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockMoveDO.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 库存调拨单 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_move") -@KeySequence("erp_stock_move_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockMoveDO extends BaseDO { - - /** - * 调拨编号 - */ - @TableId - private Long id; - /** - * 调拨单号 - */ - private String no; - /** - * 调拨时间 - */ - private LocalDateTime moveTime; - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 附件 URL - */ - private String fileUrl; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockMoveItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockMoveItemDO.java deleted file mode 100644 index aee203670..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockMoveItemDO.java +++ /dev/null @@ -1,79 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 库存调拨单项 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_move_item") -@KeySequence("erp_stock_move_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockMoveItemDO extends BaseDO { - - /** - * 调拨项编号 - */ - @TableId - private Long id; - /** - * 调拨编号 - * - * 关联 {@link ErpStockMoveDO#getId()} - */ - private Long moveId; - /** - * 调出仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long fromWarehouseId; - /** - * 调入仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long toWarehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位编号 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - /** - * 产品单价 - */ - private BigDecimal productPrice; - /** - * 产品数量 - */ - private BigDecimal count; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockOutDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockOutDO.java deleted file mode 100644 index e0b337adb..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockOutDO.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 其它出库单 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_out") -@KeySequence("erp_stock_out_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockOutDO extends BaseDO { - - /** - * 出库编号 - */ - @TableId - private Long id; - /** - * 出库单号 - */ - private String no; - /** - * 客户编号 - * - * TODO 芋艿:待关联 - */ - private Long customerId; - /** - * 出库时间 - */ - private LocalDateTime outTime; - /** - * 合计数量 - */ - private BigDecimal totalCount; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.module.erp.enums.ErpAuditStatus} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 附件 URL - */ - private String fileUrl; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockOutItemDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockOutItemDO.java deleted file mode 100644 index 065c5255a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockOutItemDO.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 其它出库单项 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_out_item") -@KeySequence("erp_stock_out_item_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockOutItemDO extends BaseDO { - - /** - * 出库项编号 - */ - @TableId - private Long id; - /** - * 出库编号 - * - * 关联 {@link ErpStockOutDO#getId()} - */ - private Long outId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 产品单位编号 - * - * 冗余 {@link ErpProductDO#getUnitId()} - */ - private Long productUnitId; - /** - * 产品单价 - */ - private BigDecimal productPrice; - /** - * 产品数量 - */ - private BigDecimal count; - /** - * 合计金额,单位:元 - */ - private BigDecimal totalPrice; - /** - * 备注 - */ - private String remark; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockRecordDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockRecordDO.java deleted file mode 100644 index 7bc5e5a01..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpStockRecordDO.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 产品库存明细 DO - * - * @author 芋道源码 - */ -@TableName("erp_stock_record") -@KeySequence("erp_stock_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 产品编号 - * - * 关联 {@link ErpProductDO#getId()} - */ - private Long productId; - /** - * 仓库编号 - * - * 关联 {@link ErpWarehouseDO#getId()} - */ - private Long warehouseId; - /** - * 出入库数量 - * - * 正数,表示入库;负数,表示出库 - */ - private BigDecimal count; - /** - * 总库存量 - * - * 出入库之后,目前的库存量 - */ - private BigDecimal totalCount; - /** - * 业务类型 - * - * 枚举 {@link ErpStockRecordBizTypeEnum} - */ - private Integer bizType; - /** - * 业务编号 - * - * 例如说:{@link ErpStockInDO#getId()} - */ - private Long bizId; - /** - * 业务项编号 - * - * 例如说:{@link ErpStockInItemDO#getId()} - */ - private Long bizItemId; - /** - * 业务单号 - * - * 例如说:{@link ErpStockInDO#getNo()} - */ - private String bizNo; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpWarehouseDO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpWarehouseDO.java deleted file mode 100644 index 4f206173f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/dataobject/stock/ErpWarehouseDO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.dataobject.stock; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.math.BigDecimal; - -/** - * ERP 仓库 DO - * - * @author 芋道源码 - */ -@TableName("erp_warehouse") -@KeySequence("erp_warehouse_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ErpWarehouseDO extends BaseDO { - - /** - * 仓库编号 - */ - @TableId - private Long id; - /** - * 仓库名称 - */ - private String name; - /** - * 仓库地址 - */ - private String address; - /** - * 排序 - */ - private Long sort; - /** - * 备注 - */ - private String remark; - /** - * 负责人 - */ - private String principal; - /** - * 仓储费,单位:元 - */ - private BigDecimal warehousePrice; - /** - * 搬运费,单位:元 - */ - private BigDecimal truckagePrice; - /** - * 开启状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 是否默认 - */ - private Boolean defaultStatus; - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpAccountMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpAccountMapper.java deleted file mode 100644 index 2f98147e2..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpAccountMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.finance; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 结算账户 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpAccountMapper extends BaseMapperX { - - default PageResult selectPage(ErpAccountPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ErpAccountDO::getName, reqVO.getName()) - .likeIfPresent(ErpAccountDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpAccountDO::getRemark, reqVO.getRemark()) - .orderByDesc(ErpAccountDO::getId)); - } - - default ErpAccountDO selectByDefaultStatus() { - return selectOne(ErpAccountDO::getDefaultStatus, true); - } - - default List selectListByStatus(Integer status) { - return selectList(ErpAccountDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentItemMapper.java deleted file mode 100644 index 7787e8d70..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentItemMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.finance; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * ERP 付款单项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpFinancePaymentItemMapper extends BaseMapperX { - - default List selectListByPaymentId(Long paymentId) { - return selectList(ErpFinancePaymentItemDO::getPaymentId, paymentId); - } - - default List selectListByPaymentIds(Collection paymentIds) { - return selectList(ErpFinancePaymentItemDO::getPaymentId, paymentIds); - } - - default BigDecimal selectPaymentPriceSumByBizIdAndBizType(Long bizId, Integer bizType) { - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("SUM(payment_price) AS paymentPriceSum") - .eq("biz_id", bizId) - .eq("biz_type", bizType)); - // 获得数量 - if (CollUtil.isEmpty(result)) { - return BigDecimal.ZERO; - } - return BigDecimal.valueOf(MapUtil.getDouble(result.get(0), "paymentPriceSum", 0D)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentMapper.java deleted file mode 100644 index 5ad0cccfd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentMapper.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.finance; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 付款单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpFinancePaymentMapper extends BaseMapperX { - - default PageResult selectPage(ErpFinancePaymentPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpFinancePaymentDO::getNo, reqVO.getNo()) - .betweenIfPresent(ErpFinancePaymentDO::getPaymentTime, reqVO.getPaymentTime()) - .eqIfPresent(ErpFinancePaymentDO::getSupplierId, reqVO.getSupplierId()) - .eqIfPresent(ErpFinancePaymentDO::getCreator, reqVO.getCreator()) - .eqIfPresent(ErpFinancePaymentDO::getFinanceUserId, reqVO.getFinanceUserId()) - .eqIfPresent(ErpFinancePaymentDO::getAccountId, reqVO.getAccountId()) - .eqIfPresent(ErpFinancePaymentDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpFinancePaymentDO::getRemark, reqVO.getRemark()) - .orderByDesc(ErpFinancePaymentDO::getId); - if (reqVO.getBizNo() != null) { - query.leftJoin(ErpFinancePaymentItemDO.class, ErpFinancePaymentItemDO::getPaymentId, ErpFinancePaymentDO::getId) - .eq(reqVO.getBizNo() != null, ErpFinancePaymentItemDO::getBizNo, reqVO.getBizNo()) - .groupBy(ErpFinancePaymentDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpFinancePaymentDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpFinancePaymentDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpFinancePaymentDO::getId, id).eq(ErpFinancePaymentDO::getStatus, status)); - } - - default ErpFinancePaymentDO selectByNo(String no) { - return selectOne(ErpFinancePaymentDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinanceReceiptItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinanceReceiptItemMapper.java deleted file mode 100644 index cb6082b0e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinanceReceiptItemMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.finance; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * ERP 收款单项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpFinanceReceiptItemMapper extends BaseMapperX { - - default List selectListByReceiptId(Long receiptId) { - return selectList(ErpFinanceReceiptItemDO::getReceiptId, receiptId); - } - - default List selectListByReceiptIds(Collection receiptIds) { - return selectList(ErpFinanceReceiptItemDO::getReceiptId, receiptIds); - } - - default BigDecimal selectReceiptPriceSumByBizIdAndBizType(Long bizId, Integer bizType) { - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("SUM(receipt_price) AS receiptPriceSum") - .eq("biz_id", bizId) - .eq("biz_type", bizType)); - // 获得数量 - if (CollUtil.isEmpty(result)) { - return BigDecimal.ZERO; - } - return BigDecimal.valueOf(MapUtil.getDouble(result.get(0), "receiptPriceSum", 0D)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinanceReceiptMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinanceReceiptMapper.java deleted file mode 100644 index d895adea4..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinanceReceiptMapper.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.finance; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptItemDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 收款单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpFinanceReceiptMapper extends BaseMapperX { - - default PageResult selectPage(ErpFinanceReceiptPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpFinanceReceiptDO::getNo, reqVO.getNo()) - .betweenIfPresent(ErpFinanceReceiptDO::getReceiptTime, reqVO.getReceiptTime()) - .eqIfPresent(ErpFinanceReceiptDO::getCustomerId, reqVO.getCustomerId()) - .eqIfPresent(ErpFinanceReceiptDO::getCreator, reqVO.getCreator()) - .eqIfPresent(ErpFinanceReceiptDO::getFinanceUserId, reqVO.getFinanceUserId()) - .eqIfPresent(ErpFinanceReceiptDO::getAccountId, reqVO.getAccountId()) - .eqIfPresent(ErpFinanceReceiptDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpFinanceReceiptDO::getRemark, reqVO.getRemark()) - .orderByDesc(ErpFinanceReceiptDO::getId); - if (reqVO.getBizNo() != null) { - query.leftJoin(ErpFinanceReceiptItemDO.class, ErpFinanceReceiptItemDO::getReceiptId, ErpFinanceReceiptDO::getId) - .eq(reqVO.getBizNo() != null, ErpFinanceReceiptItemDO::getBizNo, reqVO.getBizNo()) - .groupBy(ErpFinanceReceiptDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpFinanceReceiptDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpFinanceReceiptDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpFinanceReceiptDO::getId, id).eq(ErpFinanceReceiptDO::getStatus, status)); - } - - default ErpFinanceReceiptDO selectByNo(String no) { - return selectOne(ErpFinanceReceiptDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductCategoryMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductCategoryMapper.java deleted file mode 100644 index 70bbc6429..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductCategoryMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.product; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategoryListReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 产品分类 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpProductCategoryMapper extends BaseMapperX { - - default List selectList(ErpProductCategoryListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(ErpProductCategoryDO::getName, reqVO.getName()) - .eqIfPresent(ErpProductCategoryDO::getStatus, reqVO.getStatus()) - .orderByDesc(ErpProductCategoryDO::getId)); - } - - default ErpProductCategoryDO selectByParentIdAndName(Long parentId, String name) { - return selectOne(ErpProductCategoryDO::getParentId, parentId, ErpProductCategoryDO::getName, name); - } - - default Long selectCountByParentId(Long parentId) { - return selectCount(ErpProductCategoryDO::getParentId, parentId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java deleted file mode 100644 index 28a0d38bb..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 产品 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpProductMapper extends BaseMapperX { - - default PageResult selectPage(ErpProductPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ErpProductDO::getName, reqVO.getName()) - .eqIfPresent(ErpProductDO::getCategoryId, reqVO.getCategoryId()) - .betweenIfPresent(ErpProductDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ErpProductDO::getId)); - } - - default Long selectCountByCategoryId(Long categoryId) { - return selectCount(ErpProductDO::getCategoryId, categoryId); - } - - default Long selectCountByUnitId(Long unitId) { - return selectCount(ErpProductDO::getUnitId, unitId); - } - - default List selectListByStatus(Integer status) { - return selectList(ErpProductDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductUnitMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductUnitMapper.java deleted file mode 100644 index 198ea8094..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductUnitMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 产品单位 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpProductUnitMapper extends BaseMapperX { - - default PageResult selectPage(ErpProductUnitPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ErpProductUnitDO::getName, reqVO.getName()) - .eqIfPresent(ErpProductUnitDO::getStatus, reqVO.getStatus()) - .orderByDesc(ErpProductUnitDO::getId)); - } - - default ErpProductUnitDO selectByName(String name) { - return selectOne(ErpProductUnitDO::getName, name); - } - - default List selectListByStatus(Integer status) { - return selectList(ErpProductUnitDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseInItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseInItemMapper.java deleted file mode 100644 index 9140f9548..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseInItemMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 采购入库项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseInItemMapper extends BaseMapperX { - - default List selectListByInId(Long inId) { - return selectList(ErpPurchaseInItemDO::getInId, inId); - } - - default List selectListByInIds(Collection inIds) { - return selectList(ErpPurchaseInItemDO::getInId, inIds); - } - - default int deleteByInId(Long inId) { - return delete(ErpPurchaseInItemDO::getInId, inId); - } - - /** - * 基于采购订单编号,查询每个采购订单项的入库数量之和 - * - * @param inIds 入库订单项编号数组 - * @return key:采购订单项编号;value:入库数量之和 - */ - default Map selectOrderItemCountSumMapByInIds(Collection inIds) { - if (CollUtil.isEmpty(inIds)) { - return Collections.emptyMap(); - } - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("order_item_id, SUM(count) AS sumCount") - .groupBy("order_item_id") - .in("in_id", inIds)); - // 获得数量 - return convertMap(result, obj -> (Long) obj.get("order_item_id"), obj -> (BigDecimal) obj.get("sumCount")); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseInMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseInMapper.java deleted file mode 100644 index c155d8cbe..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseInMapper.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInItemDO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.Objects; - -/** - * ERP 采购入库 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseInMapper extends BaseMapperX { - - default PageResult selectPage(ErpPurchaseInPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpPurchaseInDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpPurchaseInDO::getSupplierId, reqVO.getSupplierId()) - .betweenIfPresent(ErpPurchaseInDO::getInTime, reqVO.getInTime()) - .eqIfPresent(ErpPurchaseInDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpPurchaseInDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpPurchaseInDO::getCreator, reqVO.getCreator()) - .eqIfPresent(ErpPurchaseInDO::getAccountId, reqVO.getAccountId()) - .likeIfPresent(ErpPurchaseInDO::getOrderNo, reqVO.getOrderNo()) - .orderByDesc(ErpPurchaseInDO::getId); - // 付款状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报字段不存在的错误 - if (Objects.equals(reqVO.getPaymentStatus(), ErpPurchaseInPageReqVO.PAYMENT_STATUS_NONE)) { - query.eq(ErpPurchaseInDO::getPaymentPrice, 0); - } else if (Objects.equals(reqVO.getPaymentStatus(), ErpPurchaseInPageReqVO.PAYMENT_STATUS_PART)) { - query.gt(ErpPurchaseInDO::getPaymentPrice, 0).apply("t.payment_price < t.total_price"); - } else if (Objects.equals(reqVO.getPaymentStatus(), ErpPurchaseInPageReqVO.PAYMENT_STATUS_ALL)) { - query.apply("t.payment_price = t.total_price"); - } - if (Boolean.TRUE.equals(reqVO.getPaymentEnable())) { - query.eq(ErpPurchaseInDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.payment_price < t.total_price"); - } - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpPurchaseInItemDO.class, ErpPurchaseInItemDO::getInId, ErpPurchaseInDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpPurchaseInItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpPurchaseInItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpPurchaseInDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpPurchaseInDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpPurchaseInDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpPurchaseInDO::getId, id).eq(ErpPurchaseInDO::getStatus, status)); - } - - default ErpPurchaseInDO selectByNo(String no) { - return selectOne(ErpPurchaseInDO::getNo, no); - } - - default List selectListByOrderId(Long orderId) { - return selectList(ErpPurchaseInDO::getOrderId, orderId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseOrderItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseOrderItemMapper.java deleted file mode 100644 index 17f1fe290..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseOrderItemMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 采购订单明项目 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseOrderItemMapper extends BaseMapperX { - - default List selectListByOrderId(Long orderId) { - return selectList(ErpPurchaseOrderItemDO::getOrderId, orderId); - } - - default List selectListByOrderIds(Collection orderIds) { - return selectList(ErpPurchaseOrderItemDO::getOrderId, orderIds); - } - - default int deleteByOrderId(Long orderId) { - return delete(ErpPurchaseOrderItemDO::getOrderId, orderId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseOrderMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseOrderMapper.java deleted file mode 100644 index 01f0303f9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseOrderMapper.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Objects; - -/** - * ERP 采购订单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseOrderMapper extends BaseMapperX { - - default PageResult selectPage(ErpPurchaseOrderPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpPurchaseOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpPurchaseOrderDO::getSupplierId, reqVO.getSupplierId()) - .betweenIfPresent(ErpPurchaseOrderDO::getOrderTime, reqVO.getOrderTime()) - .eqIfPresent(ErpPurchaseOrderDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpPurchaseOrderDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpPurchaseOrderDO::getCreator, reqVO.getCreator()) - .orderByDesc(ErpPurchaseOrderDO::getId); - // 入库状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报 in_count 错误 - if (Objects.equals(reqVO.getInStatus(), ErpPurchaseOrderPageReqVO.IN_STATUS_NONE)) { - query.eq(ErpPurchaseOrderDO::getInCount, 0); - } else if (Objects.equals(reqVO.getInStatus(), ErpPurchaseOrderPageReqVO.IN_STATUS_PART)) { - query.gt(ErpPurchaseOrderDO::getInCount, 0).apply("t.in_count < t.total_count"); - } else if (Objects.equals(reqVO.getInStatus(), ErpPurchaseOrderPageReqVO.IN_STATUS_ALL)) { - query.apply("t.in_count = t.total_count"); - } - // 退货状态 - if (Objects.equals(reqVO.getReturnStatus(), ErpPurchaseOrderPageReqVO.RETURN_STATUS_NONE)) { - query.eq(ErpPurchaseOrderDO::getReturnCount, 0); - } else if (Objects.equals(reqVO.getReturnStatus(), ErpPurchaseOrderPageReqVO.RETURN_STATUS_PART)) { - query.gt(ErpPurchaseOrderDO::getReturnCount, 0).apply("t.return_count < t.total_count"); - } else if (Objects.equals(reqVO.getReturnStatus(), ErpPurchaseOrderPageReqVO.RETURN_STATUS_ALL)) { - query.apply("t.return_count = t.total_count"); - } - // 可采购入库 - if (Boolean.TRUE.equals(reqVO.getInEnable())) { - query.eq(ErpPurchaseOrderDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.in_count < t.total_count"); - } - // 可采购退货 - if (Boolean.TRUE.equals(reqVO.getReturnEnable())) { - query.eq(ErpPurchaseOrderDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.return_count < t.in_count"); - } - if (reqVO.getProductId() != null) { - query.leftJoin(ErpPurchaseOrderItemDO.class, ErpPurchaseOrderItemDO::getOrderId, ErpPurchaseOrderDO::getId) - .eq(reqVO.getProductId() != null, ErpPurchaseOrderItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpPurchaseOrderDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpPurchaseOrderDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpPurchaseOrderDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpPurchaseOrderDO::getId, id).eq(ErpPurchaseOrderDO::getStatus, status)); - } - - default ErpPurchaseOrderDO selectByNo(String no) { - return selectOne(ErpPurchaseOrderDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseReturnItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseReturnItemMapper.java deleted file mode 100644 index 2a8011900..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseReturnItemMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 采购退货项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseReturnItemMapper extends BaseMapperX { - - default List selectListByReturnId(Long returnId) { - return selectList(ErpPurchaseReturnItemDO::getReturnId, returnId); - } - - default List selectListByReturnIds(Collection returnIds) { - return selectList(ErpPurchaseReturnItemDO::getReturnId, returnIds); - } - - default int deleteByReturnId(Long returnId) { - return delete(ErpPurchaseReturnItemDO::getReturnId, returnId); - } - - /** - * 基于采购订单编号,查询每个采购订单项的退货数量之和 - * - * @param returnIds 入库订单项编号数组 - * @return key:采购订单项编号;value:退货数量之和 - */ - default Map selectOrderItemCountSumMapByReturnIds(Collection returnIds) { - if (CollUtil.isEmpty(returnIds)) { - return Collections.emptyMap(); - } - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("order_item_id, SUM(count) AS sumCount") - .groupBy("order_item_id") - .in("return_id", returnIds)); - // 获得数量 - return convertMap(result, obj -> (Long) obj.get("order_item_id"), obj -> (BigDecimal) obj.get("sumCount")); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseReturnMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseReturnMapper.java deleted file mode 100644 index 689a55dfd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpPurchaseReturnMapper.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnItemDO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.Objects; - -/** - * ERP 采购退货 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseReturnMapper extends BaseMapperX { - - default PageResult selectPage(ErpPurchaseReturnPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpPurchaseReturnDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpPurchaseReturnDO::getSupplierId, reqVO.getSupplierId()) - .betweenIfPresent(ErpPurchaseReturnDO::getReturnTime, reqVO.getReturnTime()) - .eqIfPresent(ErpPurchaseReturnDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpPurchaseReturnDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpPurchaseReturnDO::getCreator, reqVO.getCreator()) - .eqIfPresent(ErpPurchaseReturnDO::getAccountId, reqVO.getAccountId()) - .likeIfPresent(ErpPurchaseReturnDO::getOrderNo, reqVO.getOrderNo()) - .orderByDesc(ErpPurchaseReturnDO::getId); - // 退款状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报字段不存在的错误 - if (Objects.equals(reqVO.getRefundStatus(), ErpPurchaseReturnPageReqVO.REFUND_STATUS_NONE)) { - query.eq(ErpPurchaseReturnDO::getRefundPrice, 0); - } else if (Objects.equals(reqVO.getRefundStatus(), ErpPurchaseReturnPageReqVO.REFUND_STATUS_PART)) { - query.gt(ErpPurchaseReturnDO::getRefundPrice, 0).apply("t.refund_price < t.total_price"); - } else if (Objects.equals(reqVO.getRefundStatus(), ErpPurchaseReturnPageReqVO.REFUND_STATUS_ALL)) { - query.apply("t.refund_price = t.total_price"); - } - if (Boolean.TRUE.equals(reqVO.getRefundEnable())) { - query.eq(ErpPurchaseInDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.refund_price < t.total_price"); - } - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpPurchaseReturnItemDO.class, ErpPurchaseReturnItemDO::getReturnId, ErpPurchaseReturnDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpPurchaseReturnItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpPurchaseReturnItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpPurchaseReturnDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpPurchaseReturnDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpPurchaseReturnDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpPurchaseReturnDO::getId, id).eq(ErpPurchaseReturnDO::getStatus, status)); - } - - default ErpPurchaseReturnDO selectByNo(String no) { - return selectOne(ErpPurchaseReturnDO::getNo, no); - } - - default List selectListByOrderId(Long orderId) { - return selectList(ErpPurchaseReturnDO::getOrderId, orderId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpSupplierMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpSupplierMapper.java deleted file mode 100644 index f65ab9405..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/purchase/ErpSupplierMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 供应商 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSupplierMapper extends BaseMapperX { - - default PageResult selectPage(ErpSupplierPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ErpSupplierDO::getName, reqVO.getName()) - .likeIfPresent(ErpSupplierDO::getMobile, reqVO.getMobile()) - .likeIfPresent(ErpSupplierDO::getTelephone, reqVO.getTelephone()) - .orderByDesc(ErpSupplierDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(ErpSupplierDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpCustomerMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpCustomerMapper.java deleted file mode 100644 index 4970f9ad5..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpCustomerMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 客户 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpCustomerMapper extends BaseMapperX { - - default PageResult selectPage(ErpCustomerPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ErpCustomerDO::getName, reqVO.getName()) - .eqIfPresent(ErpCustomerDO::getMobile, reqVO.getMobile()) - .eqIfPresent(ErpCustomerDO::getTelephone, reqVO.getTelephone()) - .orderByDesc(ErpCustomerDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(ErpCustomerDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderItemMapper.java deleted file mode 100644 index d2825e563..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderItemMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 销售订单明项目 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleOrderItemMapper extends BaseMapperX { - - default List selectListByOrderId(Long orderId) { - return selectList(ErpSaleOrderItemDO::getOrderId, orderId); - } - - default List selectListByOrderIds(Collection orderIds) { - return selectList(ErpSaleOrderItemDO::getOrderId, orderIds); - } - - default int deleteByOrderId(Long orderId) { - return delete(ErpSaleOrderItemDO::getOrderId, orderId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderMapper.java deleted file mode 100644 index 8ed3b6fcd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOrderMapper.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Objects; - -/** - * ERP 销售订单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleOrderMapper extends BaseMapperX { - - default PageResult selectPage(ErpSaleOrderPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpSaleOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpSaleOrderDO::getCustomerId, reqVO.getCustomerId()) - .betweenIfPresent(ErpSaleOrderDO::getOrderTime, reqVO.getOrderTime()) - .eqIfPresent(ErpSaleOrderDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpSaleOrderDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpSaleOrderDO::getCreator, reqVO.getCreator()) - .orderByDesc(ErpSaleOrderDO::getId); - // 入库状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报 out_count 错误 - if (Objects.equals(reqVO.getOutStatus(), ErpSaleOrderPageReqVO.OUT_STATUS_NONE)) { - query.eq(ErpSaleOrderDO::getOutCount, 0); - } else if (Objects.equals(reqVO.getOutStatus(), ErpSaleOrderPageReqVO.OUT_STATUS_PART)) { - query.gt(ErpSaleOrderDO::getOutCount, 0).apply("t.out_count < t.total_count"); - } else if (Objects.equals(reqVO.getOutStatus(), ErpSaleOrderPageReqVO.OUT_STATUS_ALL)) { - query.apply("t.out_count = t.total_count"); - } - // 退货状态 - if (Objects.equals(reqVO.getReturnStatus(), ErpSaleOrderPageReqVO.RETURN_STATUS_NONE)) { - query.eq(ErpSaleOrderDO::getReturnCount, 0); - } else if (Objects.equals(reqVO.getReturnStatus(), ErpSaleOrderPageReqVO.RETURN_STATUS_PART)) { - query.gt(ErpSaleOrderDO::getReturnCount, 0).apply("t.return_count < t.total_count"); - } else if (Objects.equals(reqVO.getReturnStatus(), ErpSaleOrderPageReqVO.RETURN_STATUS_ALL)) { - query.apply("t.return_count = t.total_count"); - } - // 可销售出库 - if (Boolean.TRUE.equals(reqVO.getOutEnable())) { - query.eq(ErpSaleOrderDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.out_count < t.total_count"); - } - // 可销售退货 - if (Boolean.TRUE.equals(reqVO.getReturnEnable())) { - query.eq(ErpSaleOrderDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.return_count < t.out_count"); - } - if (reqVO.getProductId() != null) { - query.leftJoin(ErpSaleOrderItemDO.class, ErpSaleOrderItemDO::getOrderId, ErpSaleOrderDO::getId) - .eq(reqVO.getProductId() != null, ErpSaleOrderItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpSaleOrderDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpSaleOrderDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpSaleOrderDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpSaleOrderDO::getId, id).eq(ErpSaleOrderDO::getStatus, status)); - } - - default ErpSaleOrderDO selectByNo(String no) { - return selectOne(ErpSaleOrderDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutItemMapper.java deleted file mode 100644 index 9cd5dede0..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutItemMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 销售出库项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleOutItemMapper extends BaseMapperX { - - default List selectListByOutId(Long outId) { - return selectList(ErpSaleOutItemDO::getOutId, outId); - } - - default List selectListByOutIds(Collection outIds) { - return selectList(ErpSaleOutItemDO::getOutId, outIds); - } - - default int deleteByOutId(Long outId) { - return delete(ErpSaleOutItemDO::getOutId, outId); - } - - /** - * 基于销售订单编号,查询每个销售订单项的出库数量之和 - * - * @param outIds 出库订单项编号数组 - * @return key:销售订单项编号;value:出库数量之和 - */ - default Map selectOrderItemCountSumMapByOutIds(Collection outIds) { - if (CollUtil.isEmpty(outIds)) { - return Collections.emptyMap(); - } - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("order_item_id, SUM(count) AS sumCount") - .groupBy("order_item_id") - .in("out_id", outIds)); - // 获得数量 - return convertMap(result, obj -> (Long) obj.get("order_item_id"), obj -> (BigDecimal) obj.get("sumCount")); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutMapper.java deleted file mode 100644 index 128913fcd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleOutMapper.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.Objects; - -/** - * ERP 销售出库 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleOutMapper extends BaseMapperX { - - default PageResult selectPage(ErpSaleOutPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpSaleOutDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpSaleOutDO::getCustomerId, reqVO.getCustomerId()) - .betweenIfPresent(ErpSaleOutDO::getOutTime, reqVO.getOutTime()) - .eqIfPresent(ErpSaleOutDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpSaleOutDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpSaleOutDO::getCreator, reqVO.getCreator()) - .eqIfPresent(ErpSaleOutDO::getAccountId, reqVO.getAccountId()) - .likeIfPresent(ErpSaleOutDO::getOrderNo, reqVO.getOrderNo()) - .orderByDesc(ErpSaleOutDO::getId); - // 收款状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报字段不存在的错误 - if (Objects.equals(reqVO.getReceiptStatus(), ErpSaleOutPageReqVO.RECEIPT_STATUS_NONE)) { - query.eq(ErpSaleOutDO::getReceiptPrice, 0); - } else if (Objects.equals(reqVO.getReceiptStatus(), ErpSaleOutPageReqVO.RECEIPT_STATUS_PART)) { - query.gt(ErpSaleOutDO::getReceiptPrice, 0).apply("t.receipt_price < t.total_price"); - } else if (Objects.equals(reqVO.getReceiptStatus(), ErpSaleOutPageReqVO.RECEIPT_STATUS_ALL)) { - query.apply("t.receipt_price = t.total_price"); - } - if (Boolean.TRUE.equals(reqVO.getReceiptEnable())) { - query.eq(ErpSaleOutDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.receipt_price < t.total_price"); - } - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpSaleOutItemDO.class, ErpSaleOutItemDO::getOutId, ErpSaleOutDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpSaleOutItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpSaleOutItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpSaleOutDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpSaleOutDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpSaleOutDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpSaleOutDO::getId, id).eq(ErpSaleOutDO::getStatus, status)); - } - - default ErpSaleOutDO selectByNo(String no) { - return selectOne(ErpSaleOutDO::getNo, no); - } - - default List selectListByOrderId(Long orderId) { - return selectList(ErpSaleOutDO::getOrderId, orderId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleReturnItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleReturnItemMapper.java deleted file mode 100644 index fdc572964..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleReturnItemMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 销售退货项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleReturnItemMapper extends BaseMapperX { - - default List selectListByReturnId(Long returnId) { - return selectList(ErpSaleReturnItemDO::getReturnId, returnId); - } - - default List selectListByReturnIds(Collection returnIds) { - return selectList(ErpSaleReturnItemDO::getReturnId, returnIds); - } - - default int deleteByReturnId(Long returnId) { - return delete(ErpSaleReturnItemDO::getReturnId, returnId); - } - - /** - * 基于销售订单编号,查询每个销售订单项的退货数量之和 - * - * @param returnIds 出库订单项编号数组 - * @return key:销售订单项编号;value:退货数量之和 - */ - default Map selectOrderItemCountSumMapByReturnIds(Collection returnIds) { - if (CollUtil.isEmpty(returnIds)) { - return Collections.emptyMap(); - } - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("order_item_id, SUM(count) AS sumCount") - .groupBy("order_item_id") - .in("return_id", returnIds)); - // 获得数量 - return convertMap(result, obj -> (Long) obj.get("order_item_id"), obj -> (BigDecimal) obj.get("sumCount")); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleReturnMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleReturnMapper.java deleted file mode 100644 index 867b45499..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/sale/ErpSaleReturnMapper.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.sale; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnItemDO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; -import java.util.Objects; - -/** - * ERP 销售退货 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleReturnMapper extends BaseMapperX { - - default PageResult selectPage(ErpSaleReturnPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpSaleReturnDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpSaleReturnDO::getCustomerId, reqVO.getCustomerId()) - .betweenIfPresent(ErpSaleReturnDO::getReturnTime, reqVO.getReturnTime()) - .eqIfPresent(ErpSaleReturnDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpSaleReturnDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpSaleReturnDO::getCreator, reqVO.getCreator()) - .eqIfPresent(ErpSaleReturnDO::getAccountId, reqVO.getAccountId()) - .likeIfPresent(ErpSaleReturnDO::getOrderNo, reqVO.getOrderNo()) - .orderByDesc(ErpSaleReturnDO::getId); - // 退款状态。为什么需要 t. 的原因,是因为联表查询时,需要指定表名,不然会报字段不存在的错误 - if (Objects.equals(reqVO.getRefundStatus(), ErpSaleReturnPageReqVO.REFUND_STATUS_NONE)) { - query.eq(ErpSaleReturnDO::getRefundPrice, 0); - } else if (Objects.equals(reqVO.getRefundStatus(), ErpSaleReturnPageReqVO.REFUND_STATUS_PART)) { - query.gt(ErpSaleReturnDO::getRefundPrice, 0).apply("t.refund_price < t.total_price"); - } else if (Objects.equals(reqVO.getRefundStatus(), ErpSaleReturnPageReqVO.REFUND_STATUS_ALL)) { - query.apply("t.refund_price = t.total_price"); - } - if (Boolean.TRUE.equals(reqVO.getRefundEnable())) { - query.eq(ErpSaleOutDO::getStatus, ErpAuditStatus.APPROVE.getStatus()) - .apply("t.refund_price < t.total_price"); - } - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpSaleReturnItemDO.class, ErpSaleReturnItemDO::getReturnId, ErpSaleReturnDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpSaleReturnItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpSaleReturnItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpSaleReturnDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpSaleReturnDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpSaleReturnDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpSaleReturnDO::getId, id).eq(ErpSaleReturnDO::getStatus, status)); - } - - default ErpSaleReturnDO selectByNo(String no) { - return selectOne(ErpSaleReturnDO::getNo, no); - } - - default List selectListByOrderId(Long orderId) { - return selectList(ErpSaleReturnDO::getOrderId, orderId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/statistics/ErpPurchaseStatisticsMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/statistics/ErpPurchaseStatisticsMapper.java deleted file mode 100644 index 14b4e517b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/statistics/ErpPurchaseStatisticsMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.statistics; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 采购统计 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpPurchaseStatisticsMapper { - - BigDecimal getPurchasePrice(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/statistics/ErpSaleStatisticsMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/statistics/ErpSaleStatisticsMapper.java deleted file mode 100644 index b29f1944d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/statistics/ErpSaleStatisticsMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.statistics; - -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 销售统计 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpSaleStatisticsMapper { - - BigDecimal getSalePrice(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockCheckItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockCheckItemMapper.java deleted file mode 100644 index ae13f9f96..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockCheckItemMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 库存盘点单项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockCheckItemMapper extends BaseMapperX { - - default List selectListByCheckId(Long checkId) { - return selectList(ErpStockCheckItemDO::getCheckId, checkId); - } - - default List selectListByCheckIds(Collection checkIds) { - return selectList(ErpStockCheckItemDO::getCheckId, checkIds); - } - - default int deleteByCheckId(Long checkId) { - return delete(ErpStockCheckItemDO::getCheckId, checkId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockCheckMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockCheckMapper.java deleted file mode 100644 index dd976df3d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockCheckMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 库存调拨单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockCheckMapper extends BaseMapperX { - - default PageResult selectPage(ErpStockCheckPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpStockCheckDO::getNo, reqVO.getNo()) - .betweenIfPresent(ErpStockCheckDO::getCheckTime, reqVO.getCheckTime()) - .eqIfPresent(ErpStockCheckDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpStockCheckDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpStockCheckDO::getCreator, reqVO.getCreator()) - .orderByDesc(ErpStockCheckDO::getId); - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpStockCheckItemDO.class, ErpStockCheckItemDO::getCheckId, ErpStockCheckDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpStockCheckItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpStockCheckItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpStockCheckDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpStockCheckDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpStockCheckDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpStockCheckDO::getId, id).eq(ErpStockCheckDO::getStatus, status)); - } - - default ErpStockCheckDO selectByNo(String no) { - return selectOne(ErpStockCheckDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockInItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockInItemMapper.java deleted file mode 100644 index 2731aa7bb..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockInItemMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 其它入库单项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockInItemMapper extends BaseMapperX { - - default List selectListByInId(Long inId) { - return selectList(ErpStockInItemDO::getInId, inId); - } - - default List selectListByInIds(Collection inIds) { - return selectList(ErpStockInItemDO::getInId, inIds); - } - - default int deleteByInId(Long inId) { - return delete(ErpStockInItemDO::getInId, inId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockInMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockInMapper.java deleted file mode 100644 index e815583ac..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockInMapper.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 其它入库单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockInMapper extends BaseMapperX { - - default PageResult selectPage(ErpStockInPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpStockInDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpStockInDO::getSupplierId, reqVO.getSupplierId()) - .betweenIfPresent(ErpStockInDO::getInTime, reqVO.getInTime()) - .eqIfPresent(ErpStockInDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpStockInDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpStockInDO::getCreator, reqVO.getCreator()) - .orderByDesc(ErpStockInDO::getId); - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpStockInItemDO.class, ErpStockInItemDO::getInId, ErpStockInDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpStockInItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpStockInItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpStockInDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpStockInDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpStockInDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpStockInDO::getId, id).eq(ErpStockInDO::getStatus, status)); - } - - default ErpStockInDO selectByNo(String no) { - return selectOne(ErpStockInDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMapper.java deleted file mode 100644 index 0ebc98597..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMapper.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -/** - * ERP 产品库存 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockMapper extends BaseMapperX { - - default PageResult selectPage(ErpStockPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ErpStockDO::getProductId, reqVO.getProductId()) - .eqIfPresent(ErpStockDO::getWarehouseId, reqVO.getWarehouseId()) - .orderByDesc(ErpStockDO::getId)); - } - - default ErpStockDO selectByProductIdAndWarehouseId(Long productId, Long warehouseId) { - return selectOne(ErpStockDO::getProductId, productId, - ErpStockDO::getWarehouseId, warehouseId); - } - - default int updateCountIncrement(Long id, BigDecimal count, boolean negativeEnable) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() - .eq(ErpStockDO::getId, id); - if (count.compareTo(BigDecimal.ZERO) > 0) { - updateWrapper.setSql("count = count + " + count); - } else if (count.compareTo(BigDecimal.ZERO) < 0) { - if (!negativeEnable) { - updateWrapper.ge(ErpStockDO::getCount, count.abs()); - } - updateWrapper.setSql("count = count - " + count.abs()); - } - return update(null, updateWrapper); - } - - default BigDecimal selectSumByProductId(Long productId) { - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("SUM(count) AS sumCount") - .eq("product_id", productId)); - // 获得数量 - if (CollUtil.isEmpty(result)) { - return BigDecimal.ZERO; - } - return BigDecimal.valueOf(MapUtil.getDouble(result.get(0), "sumCount", 0D)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMoveItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMoveItemMapper.java deleted file mode 100644 index 21a267029..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMoveItemMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveItemDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 库存调拨单项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockMoveItemMapper extends BaseMapperX { - - default List selectListByMoveId(Long moveId) { - return selectList(ErpStockMoveItemDO::getMoveId, moveId); - } - - default List selectListByMoveIds(Collection moveIds) { - return selectList(ErpStockMoveItemDO::getMoveId, moveIds); - } - - default int deleteByMoveId(Long moveId) { - return delete(ErpStockMoveItemDO::getMoveId, moveId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMoveMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMoveMapper.java deleted file mode 100644 index 9a8ce0b64..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockMoveMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMovePageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveItemDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 库存调拨单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockMoveMapper extends BaseMapperX { - - default PageResult selectPage(ErpStockMovePageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpStockMoveDO::getNo, reqVO.getNo()) - .betweenIfPresent(ErpStockMoveDO::getMoveTime, reqVO.getMoveTime()) - .eqIfPresent(ErpStockMoveDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpStockMoveDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpStockMoveDO::getCreator, reqVO.getCreator()) - .orderByDesc(ErpStockMoveDO::getId); - if (reqVO.getFromWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpStockMoveItemDO.class, ErpStockMoveItemDO::getMoveId, ErpStockMoveDO::getId) - .eq(reqVO.getFromWarehouseId() != null, ErpStockMoveItemDO::getFromWarehouseId, reqVO.getFromWarehouseId()) - .eq(reqVO.getProductId() != null, ErpStockMoveItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpStockMoveDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpStockMoveDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpStockMoveDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpStockMoveDO::getId, id).eq(ErpStockMoveDO::getStatus, status)); - } - - default ErpStockMoveDO selectByNo(String no) { - return selectOne(ErpStockMoveDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockOutItemMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockOutItemMapper.java deleted file mode 100644 index 3b27cd3dc..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockOutItemMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 其它出库单项 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockOutItemMapper extends BaseMapperX { - - default List selectListByOutId(Long outId) { - return selectList(ErpStockOutItemDO::getOutId, outId); - } - - default List selectListByOutIds(Collection outIds) { - return selectList(ErpStockOutItemDO::getOutId, outIds); - } - - default int deleteByOutId(Long outId) { - return delete(ErpStockOutItemDO::getOutId, outId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockOutMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockOutMapper.java deleted file mode 100644 index a73dd3ccf..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockOutMapper.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 其它出库单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockOutMapper extends BaseMapperX { - - default PageResult selectPage(ErpStockOutPageReqVO reqVO) { - MPJLambdaWrapperX query = new MPJLambdaWrapperX() - .likeIfPresent(ErpStockOutDO::getNo, reqVO.getNo()) - .eqIfPresent(ErpStockOutDO::getCustomerId, reqVO.getCustomerId()) - .betweenIfPresent(ErpStockOutDO::getOutTime, reqVO.getOutTime()) - .eqIfPresent(ErpStockOutDO::getStatus, reqVO.getStatus()) - .likeIfPresent(ErpStockOutDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ErpStockOutDO::getCreator, reqVO.getCreator()) - .orderByDesc(ErpStockOutDO::getId); - if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) { - query.leftJoin(ErpStockOutItemDO.class, ErpStockOutItemDO::getOutId, ErpStockOutDO::getId) - .eq(reqVO.getWarehouseId() != null, ErpStockOutItemDO::getWarehouseId, reqVO.getWarehouseId()) - .eq(reqVO.getProductId() != null, ErpStockOutItemDO::getProductId, reqVO.getProductId()) - .groupBy(ErpStockOutDO::getId); // 避免 1 对多查询,产生相同的 1 - } - return selectJoinPage(reqVO, ErpStockOutDO.class, query); - } - - default int updateByIdAndStatus(Long id, Integer status, ErpStockOutDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(ErpStockOutDO::getId, id).eq(ErpStockOutDO::getStatus, status)); - } - - default ErpStockOutDO selectByNo(String no) { - return selectOne(ErpStockOutDO::getNo, no); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockRecordMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockRecordMapper.java deleted file mode 100644 index bfd8b6751..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpStockRecordMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record.ErpStockRecordPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockRecordDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * ERP 产品库存明细 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpStockRecordMapper extends BaseMapperX { - - default PageResult selectPage(ErpStockRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ErpStockRecordDO::getProductId, reqVO.getProductId()) - .eqIfPresent(ErpStockRecordDO::getWarehouseId, reqVO.getWarehouseId()) - .eqIfPresent(ErpStockRecordDO::getBizType, reqVO.getBizType()) - .likeIfPresent(ErpStockRecordDO::getBizNo, reqVO.getBizNo()) - .betweenIfPresent(ErpStockRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ErpStockRecordDO::getId)); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpWarehouseMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpWarehouseMapper.java deleted file mode 100644 index b6ef0d8cf..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/stock/ErpWarehouseMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.mysql.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * ERP 仓库 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ErpWarehouseMapper extends BaseMapperX { - - default PageResult selectPage(ErpWarehousePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ErpWarehouseDO::getName, reqVO.getName()) - .eqIfPresent(ErpWarehouseDO::getStatus, reqVO.getStatus()) - .orderByDesc(ErpWarehouseDO::getId)); - } - - default ErpWarehouseDO selectByDefaultStatus() { - return selectOne(ErpWarehouseDO::getDefaultStatus, true); - } - - default List selectListByStatus(Integer status) { - return selectList(ErpWarehouseDO::getStatus, status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/redis/RedisKeyConstants.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/redis/RedisKeyConstants.java deleted file mode 100644 index daa5c1614..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/redis/RedisKeyConstants.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.redis; - -/** - * ERP Redis Key 枚举类 - * - * @author 芋道源码 - */ -public interface RedisKeyConstants { - - /** - * 序号的缓存 - * - * KEY 格式:trade_no:{prefix} - * VALUE 数据格式:编号自增 - */ - String NO = "erp:seq_no:"; - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/redis/no/ErpNoRedisDAO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/redis/no/ErpNoRedisDAO.java deleted file mode 100644 index c71f3f56c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/redis/no/ErpNoRedisDAO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.erp.dal.redis.no; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.module.erp.dal.redis.RedisKeyConstants; -import javax.annotation.Resource; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Repository; - -import java.time.Duration; -import java.time.LocalDateTime; - - -/** - * Erp 订单序号的 Redis DAO - * - * @author HUIHUI - */ -@Repository -public class ErpNoRedisDAO { - - /** - * 其它入库 {@link cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO} - */ - public static final String STOCK_IN_NO_PREFIX = "QTRK"; - /** - * 其它出库 {@link cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO} - */ - public static final String STOCK_OUT_NO_PREFIX = "QCKD"; - - /** - * 库存调拨 {@link cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveDO} - */ - public static final String STOCK_MOVE_NO_PREFIX = "QCDB"; - - /** - * 库存盘点 {@link cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckDO} - */ - public static final String STOCK_CHECK_NO_PREFIX = "QCPD"; - - /** - * 销售订单 {@link cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO} - */ - public static final String SALE_ORDER_NO_PREFIX = "XSDD"; - /** - * 销售出库 {@link cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO} - */ - public static final String SALE_OUT_NO_PREFIX = "XSCK"; - /** - * 销售退货 {@link cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO} - */ - public static final String SALE_RETURN_NO_PREFIX = "XSTH"; - - /** - * 采购订单 {@link cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO} - */ - public static final String PURCHASE_ORDER_NO_PREFIX = "CGDD"; - /** - * 采购入库 {@link cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO} - */ - public static final String PURCHASE_IN_NO_PREFIX = "CGRK"; - /** - * 采购退货 {@link cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO} - */ - public static final String PURCHASE_RETURN_NO_PREFIX = "CGTH"; - - /** - * 付款单 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO} - */ - public static final String FINANCE_PAYMENT_NO_PREFIX = "FKD"; - /** - * 收款单 {@link cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO} - */ - public static final String FINANCE_RECEIPT_NO_PREFIX = "SKD"; - - @Resource - private StringRedisTemplate stringRedisTemplate; - - /** - * 生成序号,使用当前日期,格式为 {PREFIX} + yyyyMMdd + 6 位自增 - * 例如说:QTRK 202109 000001 (没有中间空格) - * - * @param prefix 前缀 - * @return 序号 - */ - public String generate(String prefix) { - // 递增序号 - String noPrefix = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATE_PATTERN); - String key = RedisKeyConstants.NO + noPrefix; - Long no = stringRedisTemplate.opsForValue().increment(key); - // 设置过期时间 - stringRedisTemplate.expire(key, Duration.ofDays(1L)); - return noPrefix + String.format("%06d", no); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/package-info.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/package-info.java deleted file mode 100644 index af7bc123c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 erp 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.erp.framework; diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/rpc/config/RpcConfiguration.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index c49608e21..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.erp.framework.rpc.config; - -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = AdminUserApi.class) -public class RpcConfiguration { -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/rpc/package-info.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/rpc/package-info.java deleted file mode 100644 index 9f5d622be..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.erp.framework.rpc; diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/security/config/SecurityConfiguration.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index c1825942e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.erp.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.erp.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Erp 模块的 Security 配置 - */ -@Configuration("erpSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("erpAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").permitAll() - .antMatchers("/actuator/**").permitAll(); - // Druid 监控 - registry.antMatchers("/druid/**").permitAll(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/security/core/package-info.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/security/core/package-info.java deleted file mode 100644 index f01cc8be5..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.erp.framework.security.core; diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/package-info.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/package-info.java deleted file mode 100644 index 2608a9889..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * erp 包下,企业资源管理(Enterprise Resource Planning)。 - * 例如说:采购、销售、库存、财务、产品等等 - * - * 1. Controller URL:以 /erp/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 erp_ 开头,方便在数据库中区分 - * - * 注意,由于 Erp 模块下,容易和其它模块重名,所以类名都加载 Erp 的前缀~ - */ -package cn.iocoder.yudao.module.erp; diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountService.java deleted file mode 100644 index 9ac3221a9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.finance; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 结算账户 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpAccountService { - - /** - * 创建结算账户 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createAccount(@Valid ErpAccountSaveReqVO createReqVO); - - /** - * 更新ERP 结算账户 - * - * @param updateReqVO 更新信息 - */ - void updateAccount(@Valid ErpAccountSaveReqVO updateReqVO); - - /** - * 更新结算账户默认状态 - * - * @param id 编号 - * @param defaultStatus 默认状态 - */ - void updateAccountDefaultStatus(Long id, Boolean defaultStatus); - - /** - * 删除结算账户 - * - * @param id 编号 - */ - void deleteAccount(Long id); - - /** - * 获得结算账户 - * - * @param id 编号 - * @return 结算账户 - */ - ErpAccountDO getAccount(Long id); - - /** - * 校验结算账户 - * - * @param id 编号 - * @return 结算账户 - */ - ErpAccountDO validateAccount(Long id); - - /** - * 获得指定状态的结算账户列表 - * - * @param status 状态 - * @return 结算账户 - */ - List getAccountListByStatus(Integer status); - - /** - * 获得结算账户列表 - * - * @param ids 编号数组 - * @return 结算账户列表 - */ - List getAccountList(Collection ids); - - /** - * 获得结算账户 Map - * - * @param ids 编号数组 - * @return 结算账户 Map - */ - default Map getAccountMap(Collection ids) { - return convertMap(getAccountList(ids), ErpAccountDO::getId); - } - - /** - * 获得结算账户分页 - * - * @param pageReqVO 分页查询 - * @return 结算账户分页 - */ - PageResult getAccountPage(ErpAccountPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountServiceImpl.java deleted file mode 100644 index 578698b54..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpAccountServiceImpl.java +++ /dev/null @@ -1,113 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.finance; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.account.ErpAccountSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; -import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpAccountMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.ACCOUNT_NOT_ENABLE; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.ACCOUNT_NOT_EXISTS; - -/** - * ERP 结算账户 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpAccountServiceImpl implements ErpAccountService { - - @Resource - private ErpAccountMapper accountMapper; - - @Override - public Long createAccount(ErpAccountSaveReqVO createReqVO) { - // 插入 - ErpAccountDO account = BeanUtils.toBean(createReqVO, ErpAccountDO.class); - accountMapper.insert(account); - // 返回 - return account.getId(); - } - - @Override - public void updateAccount(ErpAccountSaveReqVO updateReqVO) { - // 校验存在 - validateAccountExists(updateReqVO.getId()); - // 更新 - ErpAccountDO updateObj = BeanUtils.toBean(updateReqVO, ErpAccountDO.class); - accountMapper.updateById(updateObj); - } - - @Override - public void updateAccountDefaultStatus(Long id, Boolean defaultStatus) { - // 1. 校验存在 - validateAccountExists(id); - - // 2.1 如果开启,则需要关闭所有其它的默认 - if (defaultStatus) { - ErpAccountDO account = accountMapper.selectByDefaultStatus(); - if (account != null) { - accountMapper.updateById(new ErpAccountDO().setId(account.getId()).setDefaultStatus(false)); - } - } - // 2.2 更新对应的默认状态 - accountMapper.updateById(new ErpAccountDO().setId(id).setDefaultStatus(defaultStatus)); - } - - @Override - public void deleteAccount(Long id) { - // 校验存在 - validateAccountExists(id); - // 删除 - accountMapper.deleteById(id); - } - - private void validateAccountExists(Long id) { - if (accountMapper.selectById(id) == null) { - throw exception(ACCOUNT_NOT_EXISTS); - } - } - - @Override - public ErpAccountDO getAccount(Long id) { - return accountMapper.selectById(id); - } - - @Override - public ErpAccountDO validateAccount(Long id) { - ErpAccountDO account = accountMapper.selectById(id); - if (account == null) { - throw exception(ACCOUNT_NOT_EXISTS); - } - if (CommonStatusEnum.isDisable(account.getStatus())) { - throw exception(ACCOUNT_NOT_ENABLE, account.getName()); - } - return account; - } - - @Override - public List getAccountListByStatus(Integer status) { - return accountMapper.selectListByStatus(status); - } - - @Override - public List getAccountList(Collection ids) { - return accountMapper.selectBatchIds(ids); - } - - @Override - public PageResult getAccountPage(ErpAccountPageReqVO pageReqVO) { - return accountMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentService.java deleted file mode 100644 index 7cad807b2..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.finance; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 付款单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpFinancePaymentService { - - /** - * 创建付款单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createFinancePayment(@Valid ErpFinancePaymentSaveReqVO createReqVO); - - /** - * 更新付款单 - * - * @param updateReqVO 更新信息 - */ - void updateFinancePayment(@Valid ErpFinancePaymentSaveReqVO updateReqVO); - - /** - * 更新付款单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateFinancePaymentStatus(Long id, Integer status); - - /** - * 删除付款单 - * - * @param ids 编号数组 - */ - void deleteFinancePayment(List ids); - - /** - * 获得付款单 - * - * @param id 编号 - * @return 付款单 - */ - ErpFinancePaymentDO getFinancePayment(Long id); - - /** - * 获得付款单分页 - * - * @param pageReqVO 分页查询 - * @return 付款单分页 - */ - PageResult getFinancePaymentPage(ErpFinancePaymentPageReqVO pageReqVO); - - // ==================== 付款单项 ==================== - - /** - * 获得付款单项列表 - * - * @param paymentId 付款单编号 - * @return 付款单项列表 - */ - List getFinancePaymentItemListByPaymentId(Long paymentId); - - /** - * 获得付款单项 List - * - * @param paymentIds 付款单编号数组 - * @return 付款单项 List - */ - List getFinancePaymentItemListByPaymentIds(Collection paymentIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentServiceImpl.java deleted file mode 100644 index c7ed6b77d..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentServiceImpl.java +++ /dev/null @@ -1,273 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.finance; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO; -import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpFinancePaymentItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpFinancePaymentMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.common.ErpBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchaseInService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchaseReturnService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 付款单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpFinancePaymentServiceImpl implements ErpFinancePaymentService { - - @Resource - private ErpFinancePaymentMapper financePaymentMapper; - @Resource - private ErpFinancePaymentItemMapper financePaymentItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpSupplierService supplierService; - @Resource - private ErpAccountService accountService; - @Resource - private ErpPurchaseInService purchaseInService; - @Resource - private ErpPurchaseReturnService purchaseReturnService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createFinancePayment(ErpFinancePaymentSaveReqVO createReqVO) { - // 1.1 校验订单项的有效性 - List paymentItems = validateFinancePaymentItems( - createReqVO.getSupplierId(), createReqVO.getItems()); - // 1.2 校验供应商 - supplierService.validateSupplier(createReqVO.getSupplierId()); - // 1.3 校验结算账户 - if (createReqVO.getAccountId() != null) { - accountService.validateAccount(createReqVO.getAccountId()); - } - // 1.4 校验财务人员 - if (createReqVO.getFinanceUserId() != null) { - adminUserApi.validateUser(createReqVO.getFinanceUserId()); - } - // 1.5 生成付款单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.FINANCE_PAYMENT_NO_PREFIX); - if (financePaymentMapper.selectByNo(no) != null) { - throw exception(FINANCE_PAYMENT_NO_EXISTS); - } - - // 2.1 插入付款单 - ErpFinancePaymentDO payment = BeanUtils.toBean(createReqVO, ErpFinancePaymentDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())); - calculateTotalPrice(payment, paymentItems); - financePaymentMapper.insert(payment); - // 2.2 插入付款单项 - paymentItems.forEach(o -> o.setPaymentId(payment.getId())); - financePaymentItemMapper.insertBatch(paymentItems); - - // 3. 更新采购入库、退货的付款金额情况 - updatePurchasePrice(paymentItems); - return payment.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateFinancePayment(ErpFinancePaymentSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpFinancePaymentDO payment = validateFinancePaymentExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(payment.getStatus())) { - throw exception(FINANCE_PAYMENT_UPDATE_FAIL_APPROVE, payment.getNo()); - } - // 1.2 校验供应商 - supplierService.validateSupplier(updateReqVO.getSupplierId()); - // 1.3 校验结算账户 - if (updateReqVO.getAccountId() != null) { - accountService.validateAccount(updateReqVO.getAccountId()); - } - // 1.4 校验财务人员 - if (updateReqVO.getFinanceUserId() != null) { - adminUserApi.validateUser(updateReqVO.getFinanceUserId()); - } - // 1.5 校验付款单项的有效性 - List paymentItems = validateFinancePaymentItems( - updateReqVO.getSupplierId(), updateReqVO.getItems()); - - // 2.1 更新付款单 - ErpFinancePaymentDO updateObj = BeanUtils.toBean(updateReqVO, ErpFinancePaymentDO.class); - calculateTotalPrice(updateObj, paymentItems); - financePaymentMapper.updateById(updateObj); - // 2.2 更新付款单项 - updateFinancePaymentItemList(updateReqVO.getId(), paymentItems); - } - - private void calculateTotalPrice(ErpFinancePaymentDO payment, List paymentItems) { - payment.setTotalPrice(getSumValue(paymentItems, ErpFinancePaymentItemDO::getPaymentPrice, BigDecimal::add, BigDecimal.ZERO)); - payment.setPaymentPrice(payment.getTotalPrice().subtract(payment.getDiscountPrice())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateFinancePaymentStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpFinancePaymentDO payment = validateFinancePaymentExists(id); - // 1.2 校验状态 - if (payment.getStatus().equals(status)) { - throw exception(approve ? FINANCE_PAYMENT_APPROVE_FAIL : FINANCE_PAYMENT_PROCESS_FAIL); - } - - // 2. 更新状态 - int updateCount = financePaymentMapper.updateByIdAndStatus(id, payment.getStatus(), - new ErpFinancePaymentDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? FINANCE_PAYMENT_APPROVE_FAIL : FINANCE_PAYMENT_PROCESS_FAIL); - } - } - - private List validateFinancePaymentItems( - Long supplierId, - List list) { - return convertList(list, o -> BeanUtils.toBean(o, ErpFinancePaymentItemDO.class, item -> { - if (ObjectUtil.equal(item.getBizType(), ErpBizTypeEnum.PURCHASE_IN.getType())) { - ErpPurchaseInDO purchaseIn = purchaseInService.validatePurchaseIn(item.getBizId()); - Assert.equals(purchaseIn.getSupplierId(), supplierId, "供应商必须相同"); - item.setTotalPrice(purchaseIn.getTotalPrice()).setBizNo(purchaseIn.getNo()); - } else if (ObjectUtil.equal(item.getBizType(), ErpBizTypeEnum.PURCHASE_RETURN.getType())) { - ErpPurchaseReturnDO purchaseReturn = purchaseReturnService.validatePurchaseReturn(item.getBizId()); - Assert.equals(purchaseReturn.getSupplierId(), supplierId, "供应商必须相同"); - item.setTotalPrice(purchaseReturn.getTotalPrice().negate()).setBizNo(purchaseReturn.getNo()); - } else { - throw new IllegalArgumentException("业务类型不正确:" + item.getBizType()); - } - })); - } - - private void updateFinancePaymentItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = financePaymentItemMapper.selectListByPaymentId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setPaymentId(id)); - financePaymentItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - financePaymentItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - financePaymentItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpFinancePaymentItemDO::getId)); - } - - // 第三步,更新采购入库、退货的付款金额情况 - updatePurchasePrice(CollectionUtils.newArrayList(diffList)); - } - - private void updatePurchasePrice(List paymentItems) { - paymentItems.forEach(paymentItem -> { - BigDecimal totalPaymentPrice = financePaymentItemMapper.selectPaymentPriceSumByBizIdAndBizType( - paymentItem.getBizId(), paymentItem.getBizType()); - if (ErpBizTypeEnum.PURCHASE_IN.getType().equals(paymentItem.getBizType())) { - purchaseInService.updatePurchaseInPaymentPrice(paymentItem.getBizId(), totalPaymentPrice); - } else if (ErpBizTypeEnum.PURCHASE_RETURN.getType().equals(paymentItem.getBizType())) { - purchaseReturnService.updatePurchaseReturnRefundPrice(paymentItem.getBizId(), totalPaymentPrice.negate()); - } else { - throw new IllegalArgumentException("业务类型不正确:" + paymentItem.getBizType()); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteFinancePayment(List ids) { - // 1. 校验不处于已审批 - List payments = financePaymentMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(payments)) { - return; - } - payments.forEach(payment -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(payment.getStatus())) { - throw exception(FINANCE_PAYMENT_DELETE_FAIL_APPROVE, payment.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - payments.forEach(payment -> { - // 2.1 删除付款单 - financePaymentMapper.deleteById(payment.getId()); - // 2.2 删除付款单项 - List paymentItems = financePaymentItemMapper.selectListByPaymentId(payment.getId()); - financePaymentItemMapper.deleteBatchIds(convertSet(paymentItems, ErpFinancePaymentItemDO::getId)); - - // 2.3 更新采购入库、退货的付款金额情况 - updatePurchasePrice(paymentItems); - }); - } - - private ErpFinancePaymentDO validateFinancePaymentExists(Long id) { - ErpFinancePaymentDO payment = financePaymentMapper.selectById(id); - if (payment == null) { - throw exception(FINANCE_PAYMENT_NOT_EXISTS); - } - return payment; - } - - @Override - public ErpFinancePaymentDO getFinancePayment(Long id) { - return financePaymentMapper.selectById(id); - } - - @Override - public PageResult getFinancePaymentPage(ErpFinancePaymentPageReqVO pageReqVO) { - return financePaymentMapper.selectPage(pageReqVO); - } - - // ==================== 付款单项 ==================== - - @Override - public List getFinancePaymentItemListByPaymentId(Long paymentId) { - return financePaymentItemMapper.selectListByPaymentId(paymentId); - } - - @Override - public List getFinancePaymentItemListByPaymentIds(Collection paymentIds) { - if (CollUtil.isEmpty(paymentIds)) { - return Collections.emptyList(); - } - return financePaymentItemMapper.selectListByPaymentIds(paymentIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinanceReceiptService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinanceReceiptService.java deleted file mode 100644 index e7bd335c5..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinanceReceiptService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.finance; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptItemDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 收款单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpFinanceReceiptService { - - /** - * 创建收款单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createFinanceReceipt(@Valid ErpFinanceReceiptSaveReqVO createReqVO); - - /** - * 更新收款单 - * - * @param updateReqVO 更新信息 - */ - void updateFinanceReceipt(@Valid ErpFinanceReceiptSaveReqVO updateReqVO); - - /** - * 更新收款单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateFinanceReceiptStatus(Long id, Integer status); - - /** - * 删除收款单 - * - * @param ids 编号数组 - */ - void deleteFinanceReceipt(List ids); - - /** - * 获得收款单 - * - * @param id 编号 - * @return 收款单 - */ - ErpFinanceReceiptDO getFinanceReceipt(Long id); - - /** - * 获得收款单分页 - * - * @param pageReqVO 分页查询 - * @return 收款单分页 - */ - PageResult getFinanceReceiptPage(ErpFinanceReceiptPageReqVO pageReqVO); - - // ==================== 收款单项 ==================== - - /** - * 获得收款单项列表 - * - * @param receiptId 收款单编号 - * @return 收款单项列表 - */ - List getFinanceReceiptItemListByReceiptId(Long receiptId); - - /** - * 获得收款单项 List - * - * @param receiptIds 收款单编号数组 - * @return 收款单项 List - */ - List getFinanceReceiptItemListByReceiptIds(Collection receiptIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinanceReceiptServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinanceReceiptServiceImpl.java deleted file mode 100644 index 031043a43..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinanceReceiptServiceImpl.java +++ /dev/null @@ -1,273 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.finance; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.receipt.ErpFinanceReceiptSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinanceReceiptItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO; -import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpFinanceReceiptItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.finance.ErpFinanceReceiptMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.common.ErpBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.erp.service.sale.ErpSaleOutService; -import cn.iocoder.yudao.module.erp.service.sale.ErpSaleReturnService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 收款单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpFinanceReceiptServiceImpl implements ErpFinanceReceiptService { - - @Resource - private ErpFinanceReceiptMapper financeReceiptMapper; - @Resource - private ErpFinanceReceiptItemMapper financeReceiptItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpCustomerService customerService; - @Resource - private ErpAccountService accountService; - @Resource - private ErpSaleOutService saleOutService; - @Resource - private ErpSaleReturnService saleReturnService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createFinanceReceipt(ErpFinanceReceiptSaveReqVO createReqVO) { - // 1.1 校验订单项的有效性 - List receiptItems = validateFinanceReceiptItems( - createReqVO.getCustomerId(), createReqVO.getItems()); - // 1.2 校验客户 - customerService.validateCustomer(createReqVO.getCustomerId()); - // 1.3 校验结算账户 - if (createReqVO.getAccountId() != null) { - accountService.validateAccount(createReqVO.getAccountId()); - } - // 1.4 校验财务人员 - if (createReqVO.getFinanceUserId() != null) { - adminUserApi.validateUser(createReqVO.getFinanceUserId()); - } - // 1.5 生成收款单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.FINANCE_RECEIPT_NO_PREFIX); - if (financeReceiptMapper.selectByNo(no) != null) { - throw exception(FINANCE_RECEIPT_NO_EXISTS); - } - - // 2.1 插入收款单 - ErpFinanceReceiptDO receipt = BeanUtils.toBean(createReqVO, ErpFinanceReceiptDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())); - calculateTotalPrice(receipt, receiptItems); - financeReceiptMapper.insert(receipt); - // 2.2 插入收款单项 - receiptItems.forEach(o -> o.setReceiptId(receipt.getId())); - financeReceiptItemMapper.insertBatch(receiptItems); - - // 3. 更新销售出库、退货的收款金额情况 - updateSalePrice(receiptItems); - return receipt.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateFinanceReceipt(ErpFinanceReceiptSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpFinanceReceiptDO receipt = validateFinanceReceiptExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(receipt.getStatus())) { - throw exception(FINANCE_RECEIPT_UPDATE_FAIL_APPROVE, receipt.getNo()); - } - // 1.2 校验客户 - customerService.validateCustomer(updateReqVO.getCustomerId()); - // 1.3 校验结算账户 - if (updateReqVO.getAccountId() != null) { - accountService.validateAccount(updateReqVO.getAccountId()); - } - // 1.4 校验财务人员 - if (updateReqVO.getFinanceUserId() != null) { - adminUserApi.validateUser(updateReqVO.getFinanceUserId()); - } - // 1.5 校验收款单项的有效性 - List receiptItems = validateFinanceReceiptItems( - updateReqVO.getCustomerId(), updateReqVO.getItems()); - - // 2.1 更新收款单 - ErpFinanceReceiptDO updateObj = BeanUtils.toBean(updateReqVO, ErpFinanceReceiptDO.class); - calculateTotalPrice(updateObj, receiptItems); - financeReceiptMapper.updateById(updateObj); - // 2.2 更新收款单项 - updateFinanceReceiptItemList(updateReqVO.getId(), receiptItems); - } - - private void calculateTotalPrice(ErpFinanceReceiptDO receipt, List receiptItems) { - receipt.setTotalPrice(getSumValue(receiptItems, ErpFinanceReceiptItemDO::getReceiptPrice, BigDecimal::add, BigDecimal.ZERO)); - receipt.setReceiptPrice(receipt.getTotalPrice().subtract(receipt.getDiscountPrice())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateFinanceReceiptStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpFinanceReceiptDO receipt = validateFinanceReceiptExists(id); - // 1.2 校验状态 - if (receipt.getStatus().equals(status)) { - throw exception(approve ? FINANCE_RECEIPT_APPROVE_FAIL : FINANCE_RECEIPT_PROCESS_FAIL); - } - - // 2. 更新状态 - int updateCount = financeReceiptMapper.updateByIdAndStatus(id, receipt.getStatus(), - new ErpFinanceReceiptDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? FINANCE_RECEIPT_APPROVE_FAIL : FINANCE_RECEIPT_PROCESS_FAIL); - } - } - - private List validateFinanceReceiptItems( - Long customerId, - List list) { - return convertList(list, o -> BeanUtils.toBean(o, ErpFinanceReceiptItemDO.class, item -> { - if (ObjectUtil.equal(item.getBizType(), ErpBizTypeEnum.SALE_OUT.getType())) { - ErpSaleOutDO saleOut = saleOutService.validateSaleOut(item.getBizId()); - Assert.equals(saleOut.getCustomerId(), customerId, "客户必须相同"); - item.setTotalPrice(saleOut.getTotalPrice()).setBizNo(saleOut.getNo()); - } else if (ObjectUtil.equal(item.getBizType(), ErpBizTypeEnum.SALE_RETURN.getType())) { - ErpSaleReturnDO saleReturn = saleReturnService.validateSaleReturn(item.getBizId()); - Assert.equals(saleReturn.getCustomerId(), customerId, "客户必须相同"); - item.setTotalPrice(saleReturn.getTotalPrice().negate()).setBizNo(saleReturn.getNo()); - } else { - throw new IllegalArgumentException("业务类型不正确:" + item.getBizType()); - } - })); - } - - private void updateFinanceReceiptItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = financeReceiptItemMapper.selectListByReceiptId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setReceiptId(id)); - financeReceiptItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - financeReceiptItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - financeReceiptItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpFinanceReceiptItemDO::getId)); - } - - // 第三步,更新销售出库、退货的收款金额情况 - updateSalePrice(CollectionUtils.newArrayList(diffList)); - } - - private void updateSalePrice(List receiptItems) { - receiptItems.forEach(receiptItem -> { - BigDecimal totalReceiptPrice = financeReceiptItemMapper.selectReceiptPriceSumByBizIdAndBizType( - receiptItem.getBizId(), receiptItem.getBizType()); - if (ErpBizTypeEnum.SALE_OUT.getType().equals(receiptItem.getBizType())) { - saleOutService.updateSaleInReceiptPrice(receiptItem.getBizId(), totalReceiptPrice); - } else if (ErpBizTypeEnum.SALE_RETURN.getType().equals(receiptItem.getBizType())) { - saleReturnService.updateSaleReturnRefundPrice(receiptItem.getBizId(), totalReceiptPrice.negate()); - } else { - throw new IllegalArgumentException("业务类型不正确:" + receiptItem.getBizType()); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteFinanceReceipt(List ids) { - // 1. 校验不处于已审批 - List receipts = financeReceiptMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(receipts)) { - return; - } - receipts.forEach(receipt -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(receipt.getStatus())) { - throw exception(FINANCE_RECEIPT_DELETE_FAIL_APPROVE, receipt.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - receipts.forEach(receipt -> { - // 2.1 删除收款单 - financeReceiptMapper.deleteById(receipt.getId()); - // 2.2 删除收款单项 - List receiptItems = financeReceiptItemMapper.selectListByReceiptId(receipt.getId()); - financeReceiptItemMapper.deleteBatchIds(convertSet(receiptItems, ErpFinanceReceiptItemDO::getId)); - - // 2.3 更新销售出库、退货的收款金额情况 - updateSalePrice(receiptItems); - }); - } - - private ErpFinanceReceiptDO validateFinanceReceiptExists(Long id) { - ErpFinanceReceiptDO receipt = financeReceiptMapper.selectById(id); - if (receipt == null) { - throw exception(FINANCE_RECEIPT_NOT_EXISTS); - } - return receipt; - } - - @Override - public ErpFinanceReceiptDO getFinanceReceipt(Long id) { - return financeReceiptMapper.selectById(id); - } - - @Override - public PageResult getFinanceReceiptPage(ErpFinanceReceiptPageReqVO pageReqVO) { - return financeReceiptMapper.selectPage(pageReqVO); - } - - // ==================== 收款单项 ==================== - - @Override - public List getFinanceReceiptItemListByReceiptId(Long receiptId) { - return financeReceiptItemMapper.selectListByReceiptId(receiptId); - } - - @Override - public List getFinanceReceiptItemListByReceiptIds(Collection receiptIds) { - if (CollUtil.isEmpty(receiptIds)) { - return Collections.emptyList(); - } - return financeReceiptItemMapper.selectListByReceiptIds(receiptIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductCategoryService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductCategoryService.java deleted file mode 100644 index 2123dc79f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductCategoryService.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.product; - -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategoryListReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategorySaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 产品分类 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpProductCategoryService { - - /** - * 创建产品分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProductCategory(@Valid ErpProductCategorySaveReqVO createReqVO); - - /** - * 更新产品分类 - * - * @param updateReqVO 更新信息 - */ - void updateProductCategory(@Valid ErpProductCategorySaveReqVO updateReqVO); - - /** - * 删除产品分类 - * - * @param id 编号 - */ - void deleteProductCategory(Long id); - - /** - * 获得产品分类 - * - * @param id 编号 - * @return 产品分类 - */ - ErpProductCategoryDO getProductCategory(Long id); - - /** - * 获得产品分类列表 - * - * @param listReqVO 查询条件 - * @return 产品分类列表 - */ - List getProductCategoryList(ErpProductCategoryListReqVO listReqVO); - - /** - * 获得产品分类列表 - * - * @param ids 编号数组 - * @return 产品分类列表 - */ - List getProductCategoryList(Collection ids); - - /** - * 获得产品分类 Map - * - * @param ids 编号数组 - * @return 产品分类 Map - */ - default Map getProductCategoryMap(Collection ids) { - return convertMap(getProductCategoryList(ids), ErpProductCategoryDO::getId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductCategoryServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductCategoryServiceImpl.java deleted file mode 100644 index 4b552ac00..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductCategoryServiceImpl.java +++ /dev/null @@ -1,149 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.product; - -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategoryListReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategorySaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; -import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductCategoryMapper; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -/** - * ERP 产品分类 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpProductCategoryServiceImpl implements ErpProductCategoryService { - - @Resource - private ErpProductCategoryMapper erpProductCategoryMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ErpProductService productService; - - @Override - public Long createProductCategory(ErpProductCategorySaveReqVO createReqVO) { - // 校验父分类编号的有效性 - validateParentProductCategory(null, createReqVO.getParentId()); - // 校验分类名称的唯一性 - validateProductCategoryNameUnique(null, createReqVO.getParentId(), createReqVO.getName()); - - // 插入 - ErpProductCategoryDO category = BeanUtils.toBean(createReqVO, ErpProductCategoryDO.class); - erpProductCategoryMapper.insert(category); - // 返回 - return category.getId(); - } - - @Override - public void updateProductCategory(ErpProductCategorySaveReqVO updateReqVO) { - // 校验存在 - validateProductCategoryExists(updateReqVO.getId()); - // 校验父分类编号的有效性 - validateParentProductCategory(updateReqVO.getId(), updateReqVO.getParentId()); - // 校验分类名称的唯一性 - validateProductCategoryNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); - - // 更新 - ErpProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, ErpProductCategoryDO.class); - erpProductCategoryMapper.updateById(updateObj); - } - - @Override - public void deleteProductCategory(Long id) { - // 1.1 校验存在 - validateProductCategoryExists(id); - // 1.2 校验是否有子产品分类 - if (erpProductCategoryMapper.selectCountByParentId(id) > 0) { - throw exception(PRODUCT_CATEGORY_EXITS_CHILDREN); - } - // 1.3 校验是否有产品 - if (productService.getProductCountByCategoryId(id) > 0) { - throw exception(PRODUCT_CATEGORY_EXITS_PRODUCT); - } - // 2. 删除 - erpProductCategoryMapper.deleteById(id); - } - - private void validateProductCategoryExists(Long id) { - if (erpProductCategoryMapper.selectById(id) == null) { - throw exception(PRODUCT_CATEGORY_NOT_EXISTS); - } - } - - private void validateParentProductCategory(Long id, Long parentId) { - if (parentId == null || ErpProductCategoryDO.PARENT_ID_ROOT.equals(parentId)) { - return; - } - // 1. 不能设置自己为父产品分类 - if (Objects.equals(id, parentId)) { - throw exception(PRODUCT_CATEGORY_PARENT_ERROR); - } - // 2. 父产品分类不存在 - ErpProductCategoryDO parentCategory = erpProductCategoryMapper.selectById(parentId); - if (parentCategory == null) { - throw exception(PRODUCT_CATEGORY_PARENT_NOT_EXITS); - } - // 3. 递归校验父产品分类,如果父产品分类是自己的子产品分类,则报错,避免形成环路 - if (id == null) { // id 为空,说明新增,不需要考虑环路 - return; - } - for (int i = 0; i < Short.MAX_VALUE; i++) { - // 3.1 校验环路 - parentId = parentCategory.getParentId(); - if (Objects.equals(id, parentId)) { - throw exception(PRODUCT_CATEGORY_PARENT_IS_CHILD); - } - // 3.2 继续递归下一级父产品分类 - if (parentId == null || ErpProductCategoryDO.PARENT_ID_ROOT.equals(parentId)) { - break; - } - parentCategory = erpProductCategoryMapper.selectById(parentId); - if (parentCategory == null) { - break; - } - } - } - - private void validateProductCategoryNameUnique(Long id, Long parentId, String name) { - ErpProductCategoryDO productCategory = erpProductCategoryMapper.selectByParentIdAndName(parentId, name); - if (productCategory == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的产品分类 - if (id == null) { - throw exception(PRODUCT_CATEGORY_NAME_DUPLICATE); - } - if (!Objects.equals(productCategory.getId(), id)) { - throw exception(PRODUCT_CATEGORY_NAME_DUPLICATE); - } - } - - @Override - public ErpProductCategoryDO getProductCategory(Long id) { - return erpProductCategoryMapper.selectById(id); - } - - @Override - public List getProductCategoryList(ErpProductCategoryListReqVO listReqVO) { - return erpProductCategoryMapper.selectList(listReqVO); - } - - @Override - public List getProductCategoryList(Collection ids) { - return erpProductCategoryMapper.selectBatchIds(ids); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductService.java deleted file mode 100644 index 03b3de9f1..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductService.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 产品 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpProductService { - - /** - * 创建产品 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProduct(@Valid ProductSaveReqVO createReqVO); - - /** - * 更新产品 - * - * @param updateReqVO 更新信息 - */ - void updateProduct(@Valid ProductSaveReqVO updateReqVO); - - /** - * 删除产品 - * - * @param id 编号 - */ - void deleteProduct(Long id); - - /** - * 校验产品们的有效性 - * - * @param ids 编号数组 - * @return 产品列表 - */ - List validProductList(Collection ids); - - /** - * 获得产品 - * - * @param id 编号 - * @return 产品 - */ - ErpProductDO getProduct(Long id); - - /** - * 获得指定状态的产品 VO 列表 - * - * @param status 状态 - * @return 产品 VO 列表 - */ - List getProductVOListByStatus(Integer status); - - /** - * 获得产品 VO 列表 - * - * @param ids 编号数组 - * @return 产品 VO 列表 - */ - List getProductVOList(Collection ids); - - /** - * 获得产品 VO Map - * - * @param ids 编号数组 - * @return 产品 VO Map - */ - default Map getProductVOMap(Collection ids) { - return convertMap(getProductVOList(ids), ErpProductRespVO::getId); - } - - /** - * 获得产品 VO 分页 - * - * @param pageReqVO 分页查询 - * @return 产品分页 - */ - PageResult getProductVOPage(ErpProductPageReqVO pageReqVO); - - /** - * 基于产品分类编号,获得产品数量 - * - * @param categoryId 产品分类编号 - * @return 产品数量 - */ - Long getProductCountByCategoryId(Long categoryId); - - /** - * 基于产品单位编号,获得产品数量 - * - * @param unitId 产品单位编号 - * @return 产品数量 - */ - Long getProductCountByUnitId(Long unitId); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java deleted file mode 100644 index c264b8e74..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java +++ /dev/null @@ -1,152 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.product; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; -import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.PRODUCT_NOT_ENABLE; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.PRODUCT_NOT_EXISTS; - -/** - * ERP 产品 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpProductServiceImpl implements ErpProductService { - - @Resource - private ErpProductMapper productMapper; - - @Resource - private ErpProductCategoryService productCategoryService; - @Resource - private ErpProductUnitService productUnitService; - - @Override - public Long createProduct(ProductSaveReqVO createReqVO) { - // TODO 芋艿:校验分类 - // 插入 - ErpProductDO product = BeanUtils.toBean(createReqVO, ErpProductDO.class); - productMapper.insert(product); - // 返回 - return product.getId(); - } - - @Override - public void updateProduct(ProductSaveReqVO updateReqVO) { - // TODO 芋艿:校验分类 - // 校验存在 - validateProductExists(updateReqVO.getId()); - // 更新 - ErpProductDO updateObj = BeanUtils.toBean(updateReqVO, ErpProductDO.class); - productMapper.updateById(updateObj); - } - - @Override - public void deleteProduct(Long id) { - // 校验存在 - validateProductExists(id); - // 删除 - productMapper.deleteById(id); - } - - @Override - public List validProductList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - List list = productMapper.selectBatchIds(ids); - Map productMap = convertMap(list, ErpProductDO::getId); - for (Long id : ids) { - ErpProductDO product = productMap.get(id); - if (productMap.get(id) == null) { - throw exception(PRODUCT_NOT_EXISTS); - } - if (CommonStatusEnum.isDisable(product.getStatus())) { - throw exception(PRODUCT_NOT_ENABLE, product.getName()); - } - } - return list; - } - - private void validateProductExists(Long id) { - if (productMapper.selectById(id) == null) { - throw exception(PRODUCT_NOT_EXISTS); - } - } - - @Override - public ErpProductDO getProduct(Long id) { - return productMapper.selectById(id); - } - - @Override - public List getProductVOListByStatus(Integer status) { - List list = productMapper.selectListByStatus(status); - return buildProductVOList(list); - } - - @Override - public List getProductVOList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - List list = productMapper.selectBatchIds(ids); - return buildProductVOList(list); - } - - @Override - public PageResult getProductVOPage(ErpProductPageReqVO pageReqVO) { - PageResult pageResult = productMapper.selectPage(pageReqVO); - return new PageResult<>(buildProductVOList(pageResult.getList()), pageResult.getTotal()); - } - - private List buildProductVOList(List list) { - if (CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - Map categoryMap = productCategoryService.getProductCategoryMap( - convertSet(list, ErpProductDO::getCategoryId)); - Map unitMap = productUnitService.getProductUnitMap( - convertSet(list, ErpProductDO::getUnitId)); - return BeanUtils.toBean(list, ErpProductRespVO.class, product -> { - MapUtils.findAndThen(categoryMap, product.getCategoryId(), - category -> product.setCategoryName(category.getName())); - MapUtils.findAndThen(unitMap, product.getUnitId(), - unit -> product.setUnitName(unit.getName())); - }); - } - - @Override - public Long getProductCountByCategoryId(Long categoryId) { - return productMapper.selectCountByCategoryId(categoryId); - } - - @Override - public Long getProductCountByUnitId(Long unitId) { - return productMapper.selectCountByUnitId(unitId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitService.java deleted file mode 100644 index b425af87b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitService.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 产品单位 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpProductUnitService { - - /** - * 创建产品单位 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProductUnit(@Valid ErpProductUnitSaveReqVO createReqVO); - - /** - * 更新产品单位 - * - * @param updateReqVO 更新信息 - */ - void updateProductUnit(@Valid ErpProductUnitSaveReqVO updateReqVO); - - /** - * 删除产品单位 - * - * @param id 编号 - */ - void deleteProductUnit(Long id); - - /** - * 获得产品单位 - * - * @param id 编号 - * @return 产品单位 - */ - ErpProductUnitDO getProductUnit(Long id); - - /** - * 获得产品单位分页 - * - * @param pageReqVO 分页查询 - * @return 产品单位分页 - */ - PageResult getProductUnitPage(ErpProductUnitPageReqVO pageReqVO); - - /** - * 获得指定状态的产品单位列表 - * - * @param status 状态 - * @return 产品单位列表 - */ - List getProductUnitListByStatus(Integer status); - - /** - * 获得产品单位列表 - * - * @param ids 编号数组 - * @return 产品单位列表 - */ - List getProductUnitList(Collection ids); - - /** - * 获得产品单位 Map - * - * @param ids 编号数组 - * @return 产品单位 Map - */ - default Map getProductUnitMap(Collection ids) { - return convertMap(getProductUnitList(ids), ErpProductUnitDO::getId); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitServiceImpl.java deleted file mode 100644 index 95497a88b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitServiceImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; -import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductUnitMapper; -import com.google.common.annotations.VisibleForTesting; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -/** - * ERP 产品单位 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpProductUnitServiceImpl implements ErpProductUnitService { - - @Resource - private ErpProductUnitMapper productUnitMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ErpProductService productService; - - @Override - public Long createProductUnit(ErpProductUnitSaveReqVO createReqVO) { - // 1. 校验名字唯一 - validateProductUnitNameUnique(null, createReqVO.getName()); - // 2. 插入 - ErpProductUnitDO unit = BeanUtils.toBean(createReqVO, ErpProductUnitDO.class); - productUnitMapper.insert(unit); - return unit.getId(); - } - - @Override - public void updateProductUnit(ErpProductUnitSaveReqVO updateReqVO) { - // 1.1 校验存在 - validateProductUnitExists(updateReqVO.getId()); - // 1.2 校验名字唯一 - validateProductUnitNameUnique(updateReqVO.getId(), updateReqVO.getName()); - // 2. 更新 - ErpProductUnitDO updateObj = BeanUtils.toBean(updateReqVO, ErpProductUnitDO.class); - productUnitMapper.updateById(updateObj); - } - - @VisibleForTesting - void validateProductUnitNameUnique(Long id, String name) { - ErpProductUnitDO unit = productUnitMapper.selectByName(name); - if (unit == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的字典类型 - if (id == null) { - throw exception(PRODUCT_UNIT_NAME_DUPLICATE); - } - if (!unit.getId().equals(id)) { - throw exception(PRODUCT_UNIT_NAME_DUPLICATE); - } - } - - @Override - public void deleteProductUnit(Long id) { - // 1.1 校验存在 - validateProductUnitExists(id); - // 1.2 校验产品是否使用 - if (productService.getProductCountByUnitId(id) > 0) { - throw exception(PRODUCT_UNIT_EXITS_PRODUCT); - } - // 2. 删除 - productUnitMapper.deleteById(id); - } - - private void validateProductUnitExists(Long id) { - if (productUnitMapper.selectById(id) == null) { - throw exception(PRODUCT_UNIT_NOT_EXISTS); - } - } - - @Override - public ErpProductUnitDO getProductUnit(Long id) { - return productUnitMapper.selectById(id); - } - - @Override - public PageResult getProductUnitPage(ErpProductUnitPageReqVO pageReqVO) { - return productUnitMapper.selectPage(pageReqVO); - } - - @Override - public List getProductUnitListByStatus(Integer status) { - return productUnitMapper.selectListByStatus(status); - } - - @Override - public List getProductUnitList(Collection ids) { - return productUnitMapper.selectBatchIds(ids); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInService.java deleted file mode 100644 index 6256c3425..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInService.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInItemDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; - -/** - * ERP 采购入库 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpPurchaseInService { - - /** - * 创建采购入库 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createPurchaseIn(@Valid ErpPurchaseInSaveReqVO createReqVO); - - /** - * 更新采购入库 - * - * @param updateReqVO 更新信息 - */ - void updatePurchaseIn(@Valid ErpPurchaseInSaveReqVO updateReqVO); - - /** - * 更新采购入库的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updatePurchaseInStatus(Long id, Integer status); - - /** - * 更新采购入库的付款金额 - * - * @param id 编号 - * @param paymentPrice 付款金额 - */ - void updatePurchaseInPaymentPrice(Long id, BigDecimal paymentPrice); - - /** - * 删除采购入库 - * - * @param ids 编号数组 - */ - void deletePurchaseIn(List ids); - - /** - * 获得采购入库 - * - * @param id 编号 - * @return 采购入库 - */ - ErpPurchaseInDO getPurchaseIn(Long id); - - /** - * 校验采购入库,已经审核通过 - * - * @param id 编号 - * @return 采购入库 - */ - ErpPurchaseInDO validatePurchaseIn(Long id); - - /** - * 获得采购入库分页 - * - * @param pageReqVO 分页查询 - * @return 采购入库分页 - */ - PageResult getPurchaseInPage(ErpPurchaseInPageReqVO pageReqVO); - - // ==================== 采购入库项 ==================== - - /** - * 获得采购入库项列表 - * - * @param inId 采购入库编号 - * @return 采购入库项列表 - */ - List getPurchaseInItemListByInId(Long inId); - - /** - * 获得采购入库项 List - * - * @param inIds 采购入库编号数组 - * @return 采购入库项 List - */ - List getPurchaseInItemListByInIds(Collection inIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInServiceImpl.java deleted file mode 100644 index 939a787cc..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseInServiceImpl.java +++ /dev/null @@ -1,308 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.in.ErpPurchaseInSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInItemDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpPurchaseInItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpPurchaseInMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockRecordService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 采购入库 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpPurchaseInServiceImpl implements ErpPurchaseInService { - - @Resource - private ErpPurchaseInMapper purchaseInMapper; - @Resource - private ErpPurchaseInItemMapper purchaseInItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ErpPurchaseOrderService purchaseOrderService; - @Resource - private ErpAccountService accountService; - @Resource - private ErpStockRecordService stockRecordService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createPurchaseIn(ErpPurchaseInSaveReqVO createReqVO) { - // 1.1 校验采购订单已审核 - ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.validatePurchaseOrder(createReqVO.getOrderId()); - // 1.2 校验入库项的有效性 - List purchaseInItems = validatePurchaseInItems(createReqVO.getItems()); - // 1.3 校验结算账户 - accountService.validateAccount(createReqVO.getAccountId()); - // 1.4 生成入库单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.PURCHASE_IN_NO_PREFIX); - if (purchaseInMapper.selectByNo(no) != null) { - throw exception(PURCHASE_IN_NO_EXISTS); - } - - // 2.1 插入入库 - ErpPurchaseInDO purchaseIn = BeanUtils.toBean(createReqVO, ErpPurchaseInDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())) - .setOrderNo(purchaseOrder.getNo()).setSupplierId(purchaseOrder.getSupplierId()); - calculateTotalPrice(purchaseIn, purchaseInItems); - purchaseInMapper.insert(purchaseIn); - // 2.2 插入入库项 - purchaseInItems.forEach(o -> o.setInId(purchaseIn.getId())); - purchaseInItemMapper.insertBatch(purchaseInItems); - - // 3. 更新采购订单的入库数量 - updatePurchaseOrderInCount(createReqVO.getOrderId()); - return purchaseIn.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePurchaseIn(ErpPurchaseInSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpPurchaseInDO purchaseIn = validatePurchaseInExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(purchaseIn.getStatus())) { - throw exception(PURCHASE_IN_UPDATE_FAIL_APPROVE, purchaseIn.getNo()); - } - // 1.2 校验采购订单已审核 - ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.validatePurchaseOrder(updateReqVO.getOrderId()); - // 1.3 校验结算账户 - accountService.validateAccount(updateReqVO.getAccountId()); - // 1.4 校验订单项的有效性 - List purchaseInItems = validatePurchaseInItems(updateReqVO.getItems()); - - // 2.1 更新入库 - ErpPurchaseInDO updateObj = BeanUtils.toBean(updateReqVO, ErpPurchaseInDO.class) - .setOrderNo(purchaseOrder.getNo()).setSupplierId(purchaseOrder.getSupplierId()); - calculateTotalPrice(updateObj, purchaseInItems); - purchaseInMapper.updateById(updateObj); - // 2.2 更新入库项 - updatePurchaseInItemList(updateReqVO.getId(), purchaseInItems); - - // 3.1 更新采购订单的入库数量 - updatePurchaseOrderInCount(updateObj.getOrderId()); - // 3.2 注意:如果采购订单编号变更了,需要更新“老”采购订单的入库数量 - if (ObjectUtil.notEqual(purchaseIn.getOrderId(), updateObj.getOrderId())) { - updatePurchaseOrderInCount(purchaseIn.getOrderId()); - } - } - - private void calculateTotalPrice(ErpPurchaseInDO purchaseIn, List purchaseInItems) { - purchaseIn.setTotalCount(getSumValue(purchaseInItems, ErpPurchaseInItemDO::getCount, BigDecimal::add)); - purchaseIn.setTotalProductPrice(getSumValue(purchaseInItems, ErpPurchaseInItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - purchaseIn.setTotalTaxPrice(getSumValue(purchaseInItems, ErpPurchaseInItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); - purchaseIn.setTotalPrice(purchaseIn.getTotalProductPrice().add(purchaseIn.getTotalTaxPrice())); - // 计算优惠价格 - if (purchaseIn.getDiscountPercent() == null) { - purchaseIn.setDiscountPercent(BigDecimal.ZERO); - } - purchaseIn.setDiscountPrice(MoneyUtils.priceMultiplyPercent(purchaseIn.getTotalPrice(), purchaseIn.getDiscountPercent())); - purchaseIn.setTotalPrice(purchaseIn.getTotalPrice().subtract(purchaseIn.getDiscountPrice().add(purchaseIn.getOtherPrice()))); - } - - private void updatePurchaseOrderInCount(Long orderId) { - // 1.1 查询采购订单对应的采购入库单列表 - List purchaseIns = purchaseInMapper.selectListByOrderId(orderId); - // 1.2 查询对应的采购订单项的入库数量 - Map returnCountMap = purchaseInItemMapper.selectOrderItemCountSumMapByInIds( - convertList(purchaseIns, ErpPurchaseInDO::getId)); - // 2. 更新采购订单的入库数量 - purchaseOrderService.updatePurchaseOrderInCount(orderId, returnCountMap); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePurchaseInStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpPurchaseInDO purchaseIn = validatePurchaseInExists(id); - // 1.2 校验状态 - if (purchaseIn.getStatus().equals(status)) { - throw exception(approve ? PURCHASE_IN_APPROVE_FAIL : PURCHASE_IN_PROCESS_FAIL); - } - // 1.3 校验已付款 - if (!approve && purchaseIn.getPaymentPrice().compareTo(BigDecimal.ZERO) > 0) { - throw exception(PURCHASE_IN_PROCESS_FAIL_EXISTS_PAYMENT); - } - - // 2. 更新状态 - int updateCount = purchaseInMapper.updateByIdAndStatus(id, purchaseIn.getStatus(), - new ErpPurchaseInDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? PURCHASE_IN_APPROVE_FAIL : PURCHASE_IN_PROCESS_FAIL); - } - - // 3. 变更库存 - List purchaseInItems = purchaseInItemMapper.selectListByInId(id); - Integer bizType = approve ? ErpStockRecordBizTypeEnum.PURCHASE_IN.getType() - : ErpStockRecordBizTypeEnum.PURCHASE_IN_CANCEL.getType(); - purchaseInItems.forEach(purchaseInItem -> { - BigDecimal count = approve ? purchaseInItem.getCount() : purchaseInItem.getCount().negate(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - purchaseInItem.getProductId(), purchaseInItem.getWarehouseId(), count, - bizType, purchaseInItem.getInId(), purchaseInItem.getId(), purchaseIn.getNo())); - }); - } - - @Override - public void updatePurchaseInPaymentPrice(Long id, BigDecimal paymentPrice) { - ErpPurchaseInDO purchaseIn = purchaseInMapper.selectById(id); - if (purchaseIn.getPaymentPrice().equals(paymentPrice)) { - return; - } - if (paymentPrice.compareTo(purchaseIn.getTotalPrice()) > 0) { - throw exception(PURCHASE_IN_FAIL_PAYMENT_PRICE_EXCEED, paymentPrice, purchaseIn.getTotalPrice()); - } - purchaseInMapper.updateById(new ErpPurchaseInDO().setId(id).setPaymentPrice(paymentPrice)); - } - - private List validatePurchaseInItems(List list) { - // 1. 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpPurchaseInSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 2. 转化为 ErpPurchaseInItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpPurchaseInItemDO.class, item -> { - item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); - item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); - if (item.getTotalPrice() == null) { - return; - } - if (item.getTaxPercent() != null) { - item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent())); - } - })); - } - - private void updatePurchaseInItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = purchaseInItemMapper.selectListByInId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setInId(id)); - purchaseInItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - purchaseInItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - purchaseInItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpPurchaseInItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deletePurchaseIn(List ids) { - // 1. 校验不处于已审批 - List purchaseIns = purchaseInMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(purchaseIns)) { - return; - } - purchaseIns.forEach(purchaseIn -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(purchaseIn.getStatus())) { - throw exception(PURCHASE_IN_DELETE_FAIL_APPROVE, purchaseIn.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - purchaseIns.forEach(purchaseIn -> { - // 2.1 删除订单 - purchaseInMapper.deleteById(purchaseIn.getId()); - // 2.2 删除订单项 - purchaseInItemMapper.deleteByInId(purchaseIn.getId()); - - // 2.3 更新采购订单的入库数量 - updatePurchaseOrderInCount(purchaseIn.getOrderId()); - }); - - } - - private ErpPurchaseInDO validatePurchaseInExists(Long id) { - ErpPurchaseInDO purchaseIn = purchaseInMapper.selectById(id); - if (purchaseIn == null) { - throw exception(PURCHASE_IN_NOT_EXISTS); - } - return purchaseIn; - } - - @Override - public ErpPurchaseInDO getPurchaseIn(Long id) { - return purchaseInMapper.selectById(id); - } - - @Override - public ErpPurchaseInDO validatePurchaseIn(Long id) { - ErpPurchaseInDO purchaseIn = validatePurchaseInExists(id); - if (ObjectUtil.notEqual(purchaseIn.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { - throw exception(PURCHASE_IN_NOT_APPROVE); - } - return purchaseIn; - } - - @Override - public PageResult getPurchaseInPage(ErpPurchaseInPageReqVO pageReqVO) { - return purchaseInMapper.selectPage(pageReqVO); - } - - // ==================== 采购入库项 ==================== - - @Override - public List getPurchaseInItemListByInId(Long inId) { - return purchaseInItemMapper.selectListByInId(inId); - } - - @Override - public List getPurchaseInItemListByInIds(Collection inIds) { - if (CollUtil.isEmpty(inIds)) { - return Collections.emptyList(); - } - return purchaseInItemMapper.selectListByInIds(inIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderService.java deleted file mode 100644 index 2b220e57f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderService.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * ERP 采购订单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpPurchaseOrderService { - - /** - * 创建采购订单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createPurchaseOrder(@Valid ErpPurchaseOrderSaveReqVO createReqVO); - - /** - * 更新采购订单 - * - * @param updateReqVO 更新信息 - */ - void updatePurchaseOrder(@Valid ErpPurchaseOrderSaveReqVO updateReqVO); - - /** - * 更新采购订单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updatePurchaseOrderStatus(Long id, Integer status); - - /** - * 更新采购订单的入库数量 - * - * @param id 编号 - * @param inCountMap 入库数量 Map:key 采购订单项编号;value 入库数量 - */ - void updatePurchaseOrderInCount(Long id, Map inCountMap); - - /** - * 更新采购订单的退货数量 - * - * @param orderId 编号 - * @param returnCountMap 退货数量 Map:key 采购订单项编号;value 退货数量 - */ - void updatePurchaseOrderReturnCount(Long orderId, Map returnCountMap); - - /** - * 删除采购订单 - * - * @param ids 编号数组 - */ - void deletePurchaseOrder(List ids); - - /** - * 获得采购订单 - * - * @param id 编号 - * @return 采购订单 - */ - ErpPurchaseOrderDO getPurchaseOrder(Long id); - - /** - * 校验采购订单,已经审核通过 - * - * @param id 编号 - * @return 采购订单 - */ - ErpPurchaseOrderDO validatePurchaseOrder(Long id); - - /** - * 获得采购订单分页 - * - * @param pageReqVO 分页查询 - * @return 采购订单分页 - */ - PageResult getPurchaseOrderPage(ErpPurchaseOrderPageReqVO pageReqVO); - - // ==================== 采购订单项 ==================== - - /** - * 获得采购订单项列表 - * - * @param orderId 采购订单编号 - * @return 采购订单项列表 - */ - List getPurchaseOrderItemListByOrderId(Long orderId); - - /** - * 获得采购订单项 List - * - * @param orderIds 采购订单编号数组 - * @return 采购订单项 List - */ - List getPurchaseOrderItemListByOrderIds(Collection orderIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderServiceImpl.java deleted file mode 100644 index c585490b9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseOrderServiceImpl.java +++ /dev/null @@ -1,295 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.order.ErpPurchaseOrderSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpPurchaseOrderItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpPurchaseOrderMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 采购订单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpPurchaseOrderServiceImpl implements ErpPurchaseOrderService { - - @Resource - private ErpPurchaseOrderMapper purchaseOrderMapper; - @Resource - private ErpPurchaseOrderItemMapper purchaseOrderItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - private ErpSupplierService supplierService; - @Resource - private ErpAccountService accountService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createPurchaseOrder(ErpPurchaseOrderSaveReqVO createReqVO) { - // 1.1 校验订单项的有效性 - List purchaseOrderItems = validatePurchaseOrderItems(createReqVO.getItems()); - // 1.2 校验供应商 - supplierService.validateSupplier(createReqVO.getSupplierId()); - // 1.3 校验结算账户 - if (createReqVO.getAccountId() != null) { - accountService.validateAccount(createReqVO.getAccountId()); - } - // 1.4 生成订单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.PURCHASE_ORDER_NO_PREFIX); - if (purchaseOrderMapper.selectByNo(no) != null) { - throw exception(PURCHASE_ORDER_NO_EXISTS); - } - - // 2.1 插入订单 - ErpPurchaseOrderDO purchaseOrder = BeanUtils.toBean(createReqVO, ErpPurchaseOrderDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())); - calculateTotalPrice(purchaseOrder, purchaseOrderItems); - purchaseOrderMapper.insert(purchaseOrder); - // 2.2 插入订单项 - purchaseOrderItems.forEach(o -> o.setOrderId(purchaseOrder.getId())); - purchaseOrderItemMapper.insertBatch(purchaseOrderItems); - return purchaseOrder.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePurchaseOrder(ErpPurchaseOrderSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpPurchaseOrderDO purchaseOrder = validatePurchaseOrderExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(purchaseOrder.getStatus())) { - throw exception(PURCHASE_ORDER_UPDATE_FAIL_APPROVE, purchaseOrder.getNo()); - } - // 1.2 校验供应商 - supplierService.validateSupplier(updateReqVO.getSupplierId()); - // 1.3 校验结算账户 - if (updateReqVO.getAccountId() != null) { - accountService.validateAccount(updateReqVO.getAccountId()); - } - // 1.4 校验订单项的有效性 - List purchaseOrderItems = validatePurchaseOrderItems(updateReqVO.getItems()); - - // 2.1 更新订单 - ErpPurchaseOrderDO updateObj = BeanUtils.toBean(updateReqVO, ErpPurchaseOrderDO.class); - calculateTotalPrice(updateObj, purchaseOrderItems); - purchaseOrderMapper.updateById(updateObj); - // 2.2 更新订单项 - updatePurchaseOrderItemList(updateReqVO.getId(), purchaseOrderItems); - } - - private void calculateTotalPrice(ErpPurchaseOrderDO purchaseOrder, List purchaseOrderItems) { - purchaseOrder.setTotalCount(getSumValue(purchaseOrderItems, ErpPurchaseOrderItemDO::getCount, BigDecimal::add)); - purchaseOrder.setTotalProductPrice(getSumValue(purchaseOrderItems, ErpPurchaseOrderItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - purchaseOrder.setTotalTaxPrice(getSumValue(purchaseOrderItems, ErpPurchaseOrderItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); - purchaseOrder.setTotalPrice(purchaseOrder.getTotalProductPrice().add(purchaseOrder.getTotalTaxPrice())); - // 计算优惠价格 - if (purchaseOrder.getDiscountPercent() == null) { - purchaseOrder.setDiscountPercent(BigDecimal.ZERO); - } - purchaseOrder.setDiscountPrice(MoneyUtils.priceMultiplyPercent(purchaseOrder.getTotalPrice(), purchaseOrder.getDiscountPercent())); - purchaseOrder.setTotalPrice(purchaseOrder.getTotalPrice().subtract(purchaseOrder.getDiscountPrice())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePurchaseOrderStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpPurchaseOrderDO purchaseOrder = validatePurchaseOrderExists(id); - // 1.2 校验状态 - if (purchaseOrder.getStatus().equals(status)) { - throw exception(approve ? PURCHASE_ORDER_APPROVE_FAIL : PURCHASE_ORDER_PROCESS_FAIL); - } - // 1.3 存在采购入单,无法反审核 - if (!approve && purchaseOrder.getInCount().compareTo(BigDecimal.ZERO) > 0) { - throw exception(PURCHASE_ORDER_PROCESS_FAIL_EXISTS_IN); - } - // 1.4 存在采购退货单,无法反审核 - if (!approve && purchaseOrder.getReturnCount().compareTo(BigDecimal.ZERO) > 0) { - throw exception(PURCHASE_ORDER_PROCESS_FAIL_EXISTS_RETURN); - } - - // 2. 更新状态 - int updateCount = purchaseOrderMapper.updateByIdAndStatus(id, purchaseOrder.getStatus(), - new ErpPurchaseOrderDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? PURCHASE_ORDER_APPROVE_FAIL : PURCHASE_ORDER_PROCESS_FAIL); - } - } - - private List validatePurchaseOrderItems(List list) { - // 1. 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpPurchaseOrderSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 2. 转化为 ErpPurchaseOrderItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpPurchaseOrderItemDO.class, item -> { - item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); - item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); - if (item.getTotalPrice() == null) { - return; - } - if (item.getTaxPercent() != null) { - item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent())); - } - })); - } - - private void updatePurchaseOrderItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = purchaseOrderItemMapper.selectListByOrderId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setOrderId(id)); - purchaseOrderItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - purchaseOrderItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - purchaseOrderItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpPurchaseOrderItemDO::getId)); - } - } - - @Override - public void updatePurchaseOrderInCount(Long id, Map inCountMap) { - List orderItems = purchaseOrderItemMapper.selectListByOrderId(id); - // 1. 更新每个采购订单项 - orderItems.forEach(item -> { - BigDecimal inCount = inCountMap.getOrDefault(item.getId(), BigDecimal.ZERO); - if (item.getInCount().equals(inCount)) { - return; - } - if (inCount.compareTo(item.getCount()) > 0) { - throw exception(PURCHASE_ORDER_ITEM_IN_FAIL_PRODUCT_EXCEED, - productService.getProduct(item.getProductId()).getName(), item.getCount()); - } - purchaseOrderItemMapper.updateById(new ErpPurchaseOrderItemDO().setId(item.getId()).setInCount(inCount)); - }); - // 2. 更新采购订单 - BigDecimal totalInCount = getSumValue(inCountMap.values(), value -> value, BigDecimal::add, BigDecimal.ZERO); - purchaseOrderMapper.updateById(new ErpPurchaseOrderDO().setId(id).setInCount(totalInCount)); - } - - @Override - public void updatePurchaseOrderReturnCount(Long orderId, Map returnCountMap) { - List orderItems = purchaseOrderItemMapper.selectListByOrderId(orderId); - // 1. 更新每个采购订单项 - orderItems.forEach(item -> { - BigDecimal returnCount = returnCountMap.getOrDefault(item.getId(), BigDecimal.ZERO); - if (item.getReturnCount().equals(returnCount)) { - return; - } - if (returnCount.compareTo(item.getInCount()) > 0) { - throw exception(PURCHASE_ORDER_ITEM_RETURN_FAIL_IN_EXCEED, - productService.getProduct(item.getProductId()).getName(), item.getInCount()); - } - purchaseOrderItemMapper.updateById(new ErpPurchaseOrderItemDO().setId(item.getId()).setReturnCount(returnCount)); - }); - // 2. 更新采购订单 - BigDecimal totalReturnCount = getSumValue(returnCountMap.values(), value -> value, BigDecimal::add, BigDecimal.ZERO); - purchaseOrderMapper.updateById(new ErpPurchaseOrderDO().setId(orderId).setReturnCount(totalReturnCount)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deletePurchaseOrder(List ids) { - // 1. 校验不处于已审批 - List purchaseOrders = purchaseOrderMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(purchaseOrders)) { - return; - } - purchaseOrders.forEach(purchaseOrder -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(purchaseOrder.getStatus())) { - throw exception(PURCHASE_ORDER_DELETE_FAIL_APPROVE, purchaseOrder.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - purchaseOrders.forEach(purchaseOrder -> { - // 2.1 删除订单 - purchaseOrderMapper.deleteById(purchaseOrder.getId()); - // 2.2 删除订单项 - purchaseOrderItemMapper.deleteByOrderId(purchaseOrder.getId()); - }); - } - - private ErpPurchaseOrderDO validatePurchaseOrderExists(Long id) { - ErpPurchaseOrderDO purchaseOrder = purchaseOrderMapper.selectById(id); - if (purchaseOrder == null) { - throw exception(PURCHASE_ORDER_NOT_EXISTS); - } - return purchaseOrder; - } - - @Override - public ErpPurchaseOrderDO getPurchaseOrder(Long id) { - return purchaseOrderMapper.selectById(id); - } - - @Override - public ErpPurchaseOrderDO validatePurchaseOrder(Long id) { - ErpPurchaseOrderDO purchaseOrder = validatePurchaseOrderExists(id); - if (ObjectUtil.notEqual(purchaseOrder.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { - throw exception(PURCHASE_ORDER_NOT_APPROVE); - } - return purchaseOrder; - } - - @Override - public PageResult getPurchaseOrderPage(ErpPurchaseOrderPageReqVO pageReqVO) { - return purchaseOrderMapper.selectPage(pageReqVO); - } - - // ==================== 订单项 ==================== - - @Override - public List getPurchaseOrderItemListByOrderId(Long orderId) { - return purchaseOrderItemMapper.selectListByOrderId(orderId); - } - - @Override - public List getPurchaseOrderItemListByOrderIds(Collection orderIds) { - if (CollUtil.isEmpty(orderIds)) { - return Collections.emptyList(); - } - return purchaseOrderItemMapper.selectListByOrderIds(orderIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnService.java deleted file mode 100644 index 9e157925b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnService.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnItemDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; - -/** - * ERP 采购退货 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpPurchaseReturnService { - - /** - * 创建采购退货 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createPurchaseReturn(@Valid ErpPurchaseReturnSaveReqVO createReqVO); - - /** - * 更新采购退货 - * - * @param updateReqVO 更新信息 - */ - void updatePurchaseReturn(@Valid ErpPurchaseReturnSaveReqVO updateReqVO); - - /** - * 更新采购退货的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updatePurchaseReturnStatus(Long id, Integer status); - - /** - * 更新采购退货的退款金额 - * - * @param id 编号 - * @param refundPrice 退款金额 - */ - void updatePurchaseReturnRefundPrice(Long id, BigDecimal refundPrice); - - /** - * 删除采购退货 - * - * @param ids 编号数组 - */ - void deletePurchaseReturn(List ids); - - /** - * 获得采购退货 - * - * @param id 编号 - * @return 采购退货 - */ - ErpPurchaseReturnDO getPurchaseReturn(Long id); - - /** - * 校验采购退货,已经审核通过 - * - * @param id 编号 - * @return 采购退货 - */ - ErpPurchaseReturnDO validatePurchaseReturn(Long id); - - /** - * 获得采购退货分页 - * - * @param pageReqVO 分页查询 - * @return 采购退货分页 - */ - PageResult getPurchaseReturnPage(ErpPurchaseReturnPageReqVO pageReqVO); - - // ==================== 采购退货项 ==================== - - /** - * 获得采购退货项列表 - * - * @param returnId 采购退货编号 - * @return 采购退货项列表 - */ - List getPurchaseReturnItemListByReturnId(Long returnId); - - /** - * 获得采购退货项 List - * - * @param returnIds 采购退货编号数组 - * @return 采购退货项 List - */ - List getPurchaseReturnItemListByReturnIds(Collection returnIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnServiceImpl.java deleted file mode 100644 index 94e8af802..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpPurchaseReturnServiceImpl.java +++ /dev/null @@ -1,304 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.returns.ErpPurchaseReturnSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseReturnItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpPurchaseReturnItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpPurchaseReturnMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockRecordService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import javax.annotation.Resource; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 采购退货 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpPurchaseReturnServiceImpl implements ErpPurchaseReturnService { - - @Resource - private ErpPurchaseReturnMapper purchaseReturnMapper; - @Resource - private ErpPurchaseReturnItemMapper purchaseReturnItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ErpPurchaseOrderService purchaseOrderService; - @Resource - private ErpAccountService accountService; - @Resource - private ErpStockRecordService stockRecordService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createPurchaseReturn(ErpPurchaseReturnSaveReqVO createReqVO) { - // 1.1 校验采购订单已审核 - ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.validatePurchaseOrder(createReqVO.getOrderId()); - // 1.2 校验退货项的有效性 - List purchaseReturnItems = validatePurchaseReturnItems(createReqVO.getItems()); - // 1.3 校验结算账户 - accountService.validateAccount(createReqVO.getAccountId()); - // 1.4 生成退货单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.PURCHASE_RETURN_NO_PREFIX); - if (purchaseReturnMapper.selectByNo(no) != null) { - throw exception(PURCHASE_RETURN_NO_EXISTS); - } - - // 2.1 插入退货 - ErpPurchaseReturnDO purchaseReturn = BeanUtils.toBean(createReqVO, ErpPurchaseReturnDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())) - .setOrderNo(purchaseOrder.getNo()).setSupplierId(purchaseOrder.getSupplierId()); - calculateTotalPrice(purchaseReturn, purchaseReturnItems); - purchaseReturnMapper.insert(purchaseReturn); - // 2.2 插入退货项 - purchaseReturnItems.forEach(o -> o.setReturnId(purchaseReturn.getId())); - purchaseReturnItemMapper.insertBatch(purchaseReturnItems); - - // 3. 更新采购订单的退货数量 - updatePurchaseOrderReturnCount(createReqVO.getOrderId()); - return purchaseReturn.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePurchaseReturn(ErpPurchaseReturnSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpPurchaseReturnDO purchaseReturn = validatePurchaseReturnExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(purchaseReturn.getStatus())) { - throw exception(PURCHASE_RETURN_UPDATE_FAIL_APPROVE, purchaseReturn.getNo()); - } - // 1.2 校验采购订单已审核 - ErpPurchaseOrderDO purchaseOrder = purchaseOrderService.validatePurchaseOrder(updateReqVO.getOrderId()); - // 1.3 校验结算账户 - accountService.validateAccount(updateReqVO.getAccountId()); - // 1.4 校验订单项的有效性 - List purchaseReturnItems = validatePurchaseReturnItems(updateReqVO.getItems()); - - // 2.1 更新退货 - ErpPurchaseReturnDO updateObj = BeanUtils.toBean(updateReqVO, ErpPurchaseReturnDO.class) - .setOrderNo(purchaseOrder.getNo()).setSupplierId(purchaseOrder.getSupplierId()); - calculateTotalPrice(updateObj, purchaseReturnItems); - purchaseReturnMapper.updateById(updateObj); - // 2.2 更新退货项 - updatePurchaseReturnItemList(updateReqVO.getId(), purchaseReturnItems); - - // 3.1 更新采购订单的出库数量 - updatePurchaseOrderReturnCount(updateObj.getOrderId()); - // 3.2 注意:如果采购订单编号变更了,需要更新“老”采购订单的出库数量 - if (ObjectUtil.notEqual(purchaseReturn.getOrderId(), updateObj.getOrderId())) { - updatePurchaseOrderReturnCount(purchaseReturn.getOrderId()); - } - } - - private void calculateTotalPrice(ErpPurchaseReturnDO purchaseReturn, List purchaseReturnItems) { - purchaseReturn.setTotalCount(getSumValue(purchaseReturnItems, ErpPurchaseReturnItemDO::getCount, BigDecimal::add)); - purchaseReturn.setTotalProductPrice(getSumValue(purchaseReturnItems, ErpPurchaseReturnItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - purchaseReturn.setTotalTaxPrice(getSumValue(purchaseReturnItems, ErpPurchaseReturnItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); - purchaseReturn.setTotalPrice(purchaseReturn.getTotalProductPrice().add(purchaseReturn.getTotalTaxPrice())); - // 计算优惠价格 - if (purchaseReturn.getDiscountPercent() == null) { - purchaseReturn.setDiscountPercent(BigDecimal.ZERO); - } - purchaseReturn.setDiscountPrice(MoneyUtils.priceMultiplyPercent(purchaseReturn.getTotalPrice(), purchaseReturn.getDiscountPercent())); - purchaseReturn.setTotalPrice(purchaseReturn.getTotalPrice().subtract(purchaseReturn.getDiscountPrice().add(purchaseReturn.getOtherPrice()))); - } - - private void updatePurchaseOrderReturnCount(Long orderId) { - // 1.1 查询采购订单对应的采购出库单列表 - List purchaseReturns = purchaseReturnMapper.selectListByOrderId(orderId); - // 1.2 查询对应的采购订单项的退货数量 - Map returnCountMap = purchaseReturnItemMapper.selectOrderItemCountSumMapByReturnIds( - convertList(purchaseReturns, ErpPurchaseReturnDO::getId)); - // 2. 更新采购订单的出库数量 - purchaseOrderService.updatePurchaseOrderReturnCount(orderId, returnCountMap); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updatePurchaseReturnStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpPurchaseReturnDO purchaseReturn = validatePurchaseReturnExists(id); - // 1.2 校验状态 - if (purchaseReturn.getStatus().equals(status)) { - throw exception(approve ? PURCHASE_RETURN_APPROVE_FAIL : PURCHASE_RETURN_PROCESS_FAIL); - } - // 1.3 校验已退款 - if (!approve && purchaseReturn.getRefundPrice().compareTo(BigDecimal.ZERO) > 0) { - throw exception(PURCHASE_RETURN_PROCESS_FAIL_EXISTS_REFUND); - } - - // 2. 更新状态 - int updateCount = purchaseReturnMapper.updateByIdAndStatus(id, purchaseReturn.getStatus(), - new ErpPurchaseReturnDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? PURCHASE_RETURN_APPROVE_FAIL : PURCHASE_RETURN_PROCESS_FAIL); - } - - // 3. 变更库存 - List purchaseReturnItems = purchaseReturnItemMapper.selectListByReturnId(id); - Integer bizType = approve ? ErpStockRecordBizTypeEnum.PURCHASE_RETURN.getType() - : ErpStockRecordBizTypeEnum.PURCHASE_RETURN_CANCEL.getType(); - purchaseReturnItems.forEach(purchaseReturnItem -> { - BigDecimal count = approve ? purchaseReturnItem.getCount().negate() : purchaseReturnItem.getCount(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - purchaseReturnItem.getProductId(), purchaseReturnItem.getWarehouseId(), count, - bizType, purchaseReturnItem.getReturnId(), purchaseReturnItem.getId(), purchaseReturn.getNo())); - }); - } - - @Override - public void updatePurchaseReturnRefundPrice(Long id, BigDecimal refundPrice) { - ErpPurchaseReturnDO purchaseReturn = purchaseReturnMapper.selectById(id); - if (purchaseReturn.getRefundPrice().equals(refundPrice)) { - return; - } - if (refundPrice.compareTo(purchaseReturn.getTotalPrice()) > 0) { - throw exception(PURCHASE_RETURN_FAIL_REFUND_PRICE_EXCEED, refundPrice, purchaseReturn.getTotalPrice()); - } - purchaseReturnMapper.updateById(new ErpPurchaseReturnDO().setId(id).setRefundPrice(refundPrice)); - } - - private List validatePurchaseReturnItems(List list) { - // 1. 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpPurchaseReturnSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 2. 转化为 ErpPurchaseReturnItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpPurchaseReturnItemDO.class, item -> { - item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); - item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); - if (item.getTotalPrice() == null) { - return; - } - if (item.getTaxPercent() != null) { - item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent())); - } - })); - } - - private void updatePurchaseReturnItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = purchaseReturnItemMapper.selectListByReturnId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setReturnId(id)); - purchaseReturnItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - purchaseReturnItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - purchaseReturnItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpPurchaseReturnItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deletePurchaseReturn(List ids) { - // 1. 校验不处于已审批 - List purchaseReturns = purchaseReturnMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(purchaseReturns)) { - return; - } - purchaseReturns.forEach(purchaseReturn -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(purchaseReturn.getStatus())) { - throw exception(PURCHASE_RETURN_DELETE_FAIL_APPROVE, purchaseReturn.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - purchaseReturns.forEach(purchaseReturn -> { - // 2.1 删除订单 - purchaseReturnMapper.deleteById(purchaseReturn.getId()); - // 2.2 删除订单项 - purchaseReturnItemMapper.deleteByReturnId(purchaseReturn.getId()); - - // 2.3 更新采购订单的出库数量 - updatePurchaseOrderReturnCount(purchaseReturn.getOrderId()); - }); - - } - - private ErpPurchaseReturnDO validatePurchaseReturnExists(Long id) { - ErpPurchaseReturnDO purchaseReturn = purchaseReturnMapper.selectById(id); - if (purchaseReturn == null) { - throw exception(PURCHASE_RETURN_NOT_EXISTS); - } - return purchaseReturn; - } - - @Override - public ErpPurchaseReturnDO getPurchaseReturn(Long id) { - return purchaseReturnMapper.selectById(id); - } - - @Override - public ErpPurchaseReturnDO validatePurchaseReturn(Long id) { - ErpPurchaseReturnDO purchaseReturn = getPurchaseReturn(id); - if (ObjectUtil.notEqual(purchaseReturn.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { - throw exception(PURCHASE_RETURN_NOT_APPROVE); - } - return purchaseReturn; - } - - @Override - public PageResult getPurchaseReturnPage(ErpPurchaseReturnPageReqVO pageReqVO) { - return purchaseReturnMapper.selectPage(pageReqVO); - } - - // ==================== 采购退货项 ==================== - - @Override - public List getPurchaseReturnItemListByReturnId(Long returnId) { - return purchaseReturnItemMapper.selectListByReturnId(returnId); - } - - @Override - public List getPurchaseReturnItemListByReturnIds(Collection returnIds) { - if (CollUtil.isEmpty(returnIds)) { - return Collections.emptyList(); - } - return purchaseReturnItemMapper.selectListByReturnIds(returnIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierService.java deleted file mode 100644 index 71487e40e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierService.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 供应商 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpSupplierService { - - /** - * 创建供应商 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSupplier(@Valid ErpSupplierSaveReqVO createReqVO); - - /** - * 更新供应商 - * - * @param updateReqVO 更新信息 - */ - void updateSupplier(@Valid ErpSupplierSaveReqVO updateReqVO); - - /** - * 删除供应商 - * - * @param id 编号 - */ - void deleteSupplier(Long id); - - /** - * 获得供应商 - * - * @param id 编号 - * @return 供应商 - */ - ErpSupplierDO getSupplier(Long id); - - /** - * 校验供应商 - * - * @param id 编号 - * @return 供应商 - */ - ErpSupplierDO validateSupplier(Long id); - - /** - * 获得供应商列表 - * - * @param ids 编号列表 - * @return 供应商列表 - */ - List getSupplierList(Collection ids); - - /** - * 获得供应商 Map - * - * @param ids 编号列表 - * @return 供应商 Map - */ - default Map getSupplierMap(Collection ids) { - return convertMap(getSupplierList(ids), ErpSupplierDO::getId); - } - - /** - * 获得供应商分页 - * - * @param pageReqVO 分页查询 - * @return 供应商分页 - */ - PageResult getSupplierPage(ErpSupplierPageReqVO pageReqVO); - - /** - * 获得指定状态的供应商列表 - * - * @param status 状态 - * @return 供应商列表 - */ - List getSupplierListByStatus(Integer status); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierServiceImpl.java deleted file mode 100644 index 6dfbb52d4..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ErpSupplierServiceImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.purchase; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.supplier.ErpSupplierSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpSupplierDO; -import cn.iocoder.yudao.module.erp.dal.mysql.purchase.ErpSupplierMapper; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.SUPPLIER_NOT_ENABLE; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.SUPPLIER_NOT_EXISTS; - -/** - * ERP 供应商 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpSupplierServiceImpl implements ErpSupplierService { - - @Resource - private ErpSupplierMapper supplierMapper; - - @Override - public Long createSupplier(ErpSupplierSaveReqVO createReqVO) { - ErpSupplierDO supplier = BeanUtils.toBean(createReqVO, ErpSupplierDO.class); - supplierMapper.insert(supplier); - return supplier.getId(); - } - - @Override - public void updateSupplier(ErpSupplierSaveReqVO updateReqVO) { - // 校验存在 - validateSupplierExists(updateReqVO.getId()); - // 更新 - ErpSupplierDO updateObj = BeanUtils.toBean(updateReqVO, ErpSupplierDO.class); - supplierMapper.updateById(updateObj); - } - - @Override - public void deleteSupplier(Long id) { - // 校验存在 - validateSupplierExists(id); - // 删除 - supplierMapper.deleteById(id); - } - - private void validateSupplierExists(Long id) { - if (supplierMapper.selectById(id) == null) { - throw exception(SUPPLIER_NOT_EXISTS); - } - } - - @Override - public ErpSupplierDO getSupplier(Long id) { - return supplierMapper.selectById(id); - } - - @Override - public ErpSupplierDO validateSupplier(Long id) { - ErpSupplierDO supplier = supplierMapper.selectById(id); - if (supplier == null) { - throw exception(SUPPLIER_NOT_EXISTS); - } - if (CommonStatusEnum.isDisable(supplier.getStatus())) { - throw exception(SUPPLIER_NOT_ENABLE, supplier.getName()); - } - return supplier; - } - - @Override - public List getSupplierList(Collection ids) { - return supplierMapper.selectBatchIds(ids); - } - - @Override - public PageResult getSupplierPage(ErpSupplierPageReqVO pageReqVO) { - return supplierMapper.selectPage(pageReqVO); - } - - @Override - public List getSupplierListByStatus(Integer status) { - return supplierMapper.selectListByStatus(status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerService.java deleted file mode 100644 index 694634b8f..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerService.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 客户 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpCustomerService { - - /** - * 创建客户 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCustomer(@Valid ErpCustomerSaveReqVO createReqVO); - - /** - * 更新客户 - * - * @param updateReqVO 更新信息 - */ - void updateCustomer(@Valid ErpCustomerSaveReqVO updateReqVO); - - /** - * 删除客户 - * - * @param id 编号 - */ - void deleteCustomer(Long id); - - /** - * 获得客户 - * - * @param id 编号 - * @return 客户 - */ - ErpCustomerDO getCustomer(Long id); - - /** - * 校验客户 - * - * @param id 编号 - * @return 客户 - */ - ErpCustomerDO validateCustomer(Long id); - - /** - * 获得客户列表 - * - * @param ids 编号列表 - * @return 客户列表 - */ - List getCustomerList(Collection ids); - - /** - * 获得客户 Map - * - * @param ids 编号列表 - * @return 客户 Map - */ - default Map getCustomerMap(Collection ids) { - return convertMap(getCustomerList(ids), ErpCustomerDO::getId); - } - - /** - * 获得客户分页 - * - * @param pageReqVO 分页查询 - * @return 客户分页 - */ - PageResult getCustomerPage(ErpCustomerPageReqVO pageReqVO); - - /** - * 获得指定状态的客户列表 - * - * @param status 状态 - * @return 客户列表 - */ - List getCustomerListByStatus(Integer status); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerServiceImpl.java deleted file mode 100644 index 7df07fb39..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpCustomerServiceImpl.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.customer.ErpCustomerSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpCustomerMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.CUSTOMER_NOT_ENABLE; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; - -/** - * ERP 客户 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpCustomerServiceImpl implements ErpCustomerService { - - @Resource - private ErpCustomerMapper customerMapper; - - @Override - public Long createCustomer(ErpCustomerSaveReqVO createReqVO) { - // 插入 - ErpCustomerDO customer = BeanUtils.toBean(createReqVO, ErpCustomerDO.class); - customerMapper.insert(customer); - // 返回 - return customer.getId(); - } - - @Override - public void updateCustomer(ErpCustomerSaveReqVO updateReqVO) { - // 校验存在 - validateCustomerExists(updateReqVO.getId()); - // 更新 - ErpCustomerDO updateObj = BeanUtils.toBean(updateReqVO, ErpCustomerDO.class); - customerMapper.updateById(updateObj); - } - - @Override - public void deleteCustomer(Long id) { - // 校验存在 - validateCustomerExists(id); - // 删除 - customerMapper.deleteById(id); - } - - private void validateCustomerExists(Long id) { - if (customerMapper.selectById(id) == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - } - - @Override - public ErpCustomerDO getCustomer(Long id) { - return customerMapper.selectById(id); - } - - @Override - public ErpCustomerDO validateCustomer(Long id) { - ErpCustomerDO customer = customerMapper.selectById(id); - if (customer == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - if (CommonStatusEnum.isDisable(customer.getStatus())) { - throw exception(CUSTOMER_NOT_ENABLE, customer.getName()); - } - return customer; - } - - @Override - public List getCustomerList(Collection ids) { - return customerMapper.selectBatchIds(ids); - } - - @Override - public PageResult getCustomerPage(ErpCustomerPageReqVO pageReqVO) { - return customerMapper.selectPage(pageReqVO); - } - - @Override - public List getCustomerListByStatus(Integer status) { - return customerMapper.selectListByStatus(status); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderService.java deleted file mode 100644 index 1a2e0546a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderService.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * ERP 销售订单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpSaleOrderService { - - /** - * 创建销售订单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSaleOrder(@Valid ErpSaleOrderSaveReqVO createReqVO); - - /** - * 更新销售订单 - * - * @param updateReqVO 更新信息 - */ - void updateSaleOrder(@Valid ErpSaleOrderSaveReqVO updateReqVO); - - /** - * 更新销售订单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateSaleOrderStatus(Long id, Integer status); - - /** - * 更新销售订单的出库数量 - * - * @param id 编号 - * @param outCountMap 出库数量 Map:key 销售订单项编号;value 出库数量 - */ - void updateSaleOrderOutCount(Long id, Map outCountMap); - - /** - * 更新销售订单的退货数量 - * - * @param orderId 编号 - * @param returnCountMap 退货数量 Map:key 销售订单项编号;value 退货数量 - */ - void updateSaleOrderReturnCount(Long orderId, Map returnCountMap); - - /** - * 删除销售订单 - * - * @param ids 编号数组 - */ - void deleteSaleOrder(List ids); - - /** - * 获得销售订单 - * - * @param id 编号 - * @return 销售订单 - */ - ErpSaleOrderDO getSaleOrder(Long id); - - /** - * 校验销售订单,已经审核通过 - * - * @param id 编号 - * @return 销售订单 - */ - ErpSaleOrderDO validateSaleOrder(Long id); - - /** - * 获得销售订单分页 - * - * @param pageReqVO 分页查询 - * @return 销售订单分页 - */ - PageResult getSaleOrderPage(ErpSaleOrderPageReqVO pageReqVO); - - // ==================== 销售订单项 ==================== - - /** - * 获得销售订单项列表 - * - * @param orderId 销售订单编号 - * @return 销售订单项列表 - */ - List getSaleOrderItemListByOrderId(Long orderId); - - /** - * 获得销售订单项 List - * - * @param orderIds 销售订单编号数组 - * @return 销售订单项 List - */ - List getSaleOrderItemListByOrderIds(Collection orderIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderServiceImpl.java deleted file mode 100644 index 7c25d067e..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOrderServiceImpl.java +++ /dev/null @@ -1,307 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleOrderItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleOrderMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 销售订单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpSaleOrderServiceImpl implements ErpSaleOrderService { - - @Resource - private ErpSaleOrderMapper saleOrderMapper; - @Resource - private ErpSaleOrderItemMapper saleOrderItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - private ErpCustomerService customerService; - @Resource - private ErpAccountService accountService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createSaleOrder(ErpSaleOrderSaveReqVO createReqVO) { - // 1.1 校验订单项的有效性 - List saleOrderItems = validateSaleOrderItems(createReqVO.getItems()); - // 1.2 校验客户 - customerService.validateCustomer(createReqVO.getCustomerId()); - // 1.3 校验结算账户 - if (createReqVO.getAccountId() != null) { - accountService.validateAccount(createReqVO.getAccountId()); - } - // 1.4 校验销售人员 - if (createReqVO.getSaleUserId() != null) { - adminUserApi.validateUser(createReqVO.getSaleUserId()); - } - // 1.5 生成订单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.SALE_ORDER_NO_PREFIX); - if (saleOrderMapper.selectByNo(no) != null) { - throw exception(SALE_ORDER_NO_EXISTS); - } - - // 2.1 插入订单 - ErpSaleOrderDO saleOrder = BeanUtils.toBean(createReqVO, ErpSaleOrderDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())); - calculateTotalPrice(saleOrder, saleOrderItems); - saleOrderMapper.insert(saleOrder); - // 2.2 插入订单项 - saleOrderItems.forEach(o -> o.setOrderId(saleOrder.getId())); - saleOrderItemMapper.insertBatch(saleOrderItems); - return saleOrder.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSaleOrder(ErpSaleOrderSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpSaleOrderDO saleOrder = validateSaleOrderExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(saleOrder.getStatus())) { - throw exception(SALE_ORDER_UPDATE_FAIL_APPROVE, saleOrder.getNo()); - } - // 1.2 校验客户 - customerService.validateCustomer(updateReqVO.getCustomerId()); - // 1.3 校验结算账户 - if (updateReqVO.getAccountId() != null) { - accountService.validateAccount(updateReqVO.getAccountId()); - } - // 1.4 校验销售人员 - if (updateReqVO.getSaleUserId() != null) { - adminUserApi.validateUser(updateReqVO.getSaleUserId()); - } - // 1.5 校验订单项的有效性 - List saleOrderItems = validateSaleOrderItems(updateReqVO.getItems()); - - // 2.1 更新订单 - ErpSaleOrderDO updateObj = BeanUtils.toBean(updateReqVO, ErpSaleOrderDO.class); - calculateTotalPrice(updateObj, saleOrderItems); - saleOrderMapper.updateById(updateObj); - // 2.2 更新订单项 - updateSaleOrderItemList(updateReqVO.getId(), saleOrderItems); - } - - private void calculateTotalPrice(ErpSaleOrderDO saleOrder, List saleOrderItems) { - saleOrder.setTotalCount(getSumValue(saleOrderItems, ErpSaleOrderItemDO::getCount, BigDecimal::add)); - saleOrder.setTotalProductPrice(getSumValue(saleOrderItems, ErpSaleOrderItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - saleOrder.setTotalTaxPrice(getSumValue(saleOrderItems, ErpSaleOrderItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); - saleOrder.setTotalPrice(saleOrder.getTotalProductPrice().add(saleOrder.getTotalTaxPrice())); - // 计算优惠价格 - if (saleOrder.getDiscountPercent() == null) { - saleOrder.setDiscountPercent(BigDecimal.ZERO); - } - saleOrder.setDiscountPrice(MoneyUtils.priceMultiplyPercent(saleOrder.getTotalPrice(), saleOrder.getDiscountPercent())); - saleOrder.setTotalPrice(saleOrder.getTotalPrice().subtract(saleOrder.getDiscountPrice())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSaleOrderStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpSaleOrderDO saleOrder = validateSaleOrderExists(id); - // 1.2 校验状态 - if (saleOrder.getStatus().equals(status)) { - throw exception(approve ? SALE_ORDER_APPROVE_FAIL : SALE_ORDER_PROCESS_FAIL); - } - // 1.3 存在销售出库单,无法反审核 - if (!approve && saleOrder.getOutCount().compareTo(BigDecimal.ZERO) > 0) { - throw exception(SALE_ORDER_PROCESS_FAIL_EXISTS_OUT); - } - // 1.4 存在销售退货单,无法反审核 - if (!approve && saleOrder.getReturnCount().compareTo(BigDecimal.ZERO) > 0) { - throw exception(SALE_ORDER_PROCESS_FAIL_EXISTS_RETURN); - } - - // 2. 更新状态 - int updateCount = saleOrderMapper.updateByIdAndStatus(id, saleOrder.getStatus(), - new ErpSaleOrderDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? SALE_ORDER_APPROVE_FAIL : SALE_ORDER_PROCESS_FAIL); - } - } - - private List validateSaleOrderItems(List list) { - // 1. 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpSaleOrderSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 2. 转化为 ErpSaleOrderItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpSaleOrderItemDO.class, item -> { - item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); - item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); - if (item.getTotalPrice() == null) { - return; - } - if (item.getTaxPercent() != null) { - item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent())); - } - })); - } - - private void updateSaleOrderItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = saleOrderItemMapper.selectListByOrderId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setOrderId(id)); - saleOrderItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - saleOrderItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - saleOrderItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpSaleOrderItemDO::getId)); - } - } - - @Override - public void updateSaleOrderOutCount(Long id, Map outCountMap) { - List orderItems = saleOrderItemMapper.selectListByOrderId(id); - // 1. 更新每个销售订单项 - orderItems.forEach(item -> { - BigDecimal outCount = outCountMap.getOrDefault(item.getId(), BigDecimal.ZERO); - if (item.getOutCount().equals(outCount)) { - return; - } - if (outCount.compareTo(item.getCount()) > 0) { - throw exception(SALE_ORDER_ITEM_OUT_FAIL_PRODUCT_EXCEED, - productService.getProduct(item.getProductId()).getName(), item.getCount()); - } - saleOrderItemMapper.updateById(new ErpSaleOrderItemDO().setId(item.getId()).setOutCount(outCount)); - }); - // 2. 更新销售订单 - BigDecimal totalOutCount = getSumValue(outCountMap.values(), value -> value, BigDecimal::add, BigDecimal.ZERO); - saleOrderMapper.updateById(new ErpSaleOrderDO().setId(id).setOutCount(totalOutCount)); - } - - @Override - public void updateSaleOrderReturnCount(Long orderId, Map returnCountMap) { - List orderItems = saleOrderItemMapper.selectListByOrderId(orderId); - // 1. 更新每个销售订单项 - orderItems.forEach(item -> { - BigDecimal returnCount = returnCountMap.getOrDefault(item.getId(), BigDecimal.ZERO); - if (item.getReturnCount().equals(returnCount)) { - return; - } - if (returnCount.compareTo(item.getOutCount()) > 0) { - throw exception(SALE_ORDER_ITEM_RETURN_FAIL_OUT_EXCEED, - productService.getProduct(item.getProductId()).getName(), item.getOutCount()); - } - saleOrderItemMapper.updateById(new ErpSaleOrderItemDO().setId(item.getId()).setReturnCount(returnCount)); - }); - // 2. 更新销售订单 - BigDecimal totalReturnCount = getSumValue(returnCountMap.values(), value -> value, BigDecimal::add, BigDecimal.ZERO); - saleOrderMapper.updateById(new ErpSaleOrderDO().setId(orderId).setReturnCount(totalReturnCount)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSaleOrder(List ids) { - // 1. 校验不处于已审批 - List saleOrders = saleOrderMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(saleOrders)) { - return; - } - saleOrders.forEach(saleOrder -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(saleOrder.getStatus())) { - throw exception(SALE_ORDER_DELETE_FAIL_APPROVE, saleOrder.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - saleOrders.forEach(saleOrder -> { - // 2.1 删除订单 - saleOrderMapper.deleteById(saleOrder.getId()); - // 2.2 删除订单项 - saleOrderItemMapper.deleteByOrderId(saleOrder.getId()); - }); - } - - private ErpSaleOrderDO validateSaleOrderExists(Long id) { - ErpSaleOrderDO saleOrder = saleOrderMapper.selectById(id); - if (saleOrder == null) { - throw exception(SALE_ORDER_NOT_EXISTS); - } - return saleOrder; - } - - @Override - public ErpSaleOrderDO getSaleOrder(Long id) { - return saleOrderMapper.selectById(id); - } - - @Override - public ErpSaleOrderDO validateSaleOrder(Long id) { - ErpSaleOrderDO saleOrder = validateSaleOrderExists(id); - if (ObjectUtil.notEqual(saleOrder.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { - throw exception(SALE_ORDER_NOT_APPROVE); - } - return saleOrder; - } - - @Override - public PageResult getSaleOrderPage(ErpSaleOrderPageReqVO pageReqVO) { - return saleOrderMapper.selectPage(pageReqVO); - } - - // ==================== 订单项 ==================== - - @Override - public List getSaleOrderItemListByOrderId(Long orderId) { - return saleOrderItemMapper.selectListByOrderId(orderId); - } - - @Override - public List getSaleOrderItemListByOrderIds(Collection orderIds) { - if (CollUtil.isEmpty(orderIds)) { - return Collections.emptyList(); - } - return saleOrderItemMapper.selectListByOrderIds(orderIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutService.java deleted file mode 100644 index db78cb0dc..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; - -/** - * ERP 销售出库 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpSaleOutService { - - /** - * 创建销售出库 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSaleOut(@Valid ErpSaleOutSaveReqVO createReqVO); - - /** - * 更新销售出库 - * - * @param updateReqVO 更新信息 - */ - void updateSaleOut(@Valid ErpSaleOutSaveReqVO updateReqVO); - - /** - * 更新销售出库的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateSaleOutStatus(Long id, Integer status); - - /** - * 更新销售出库的收款金额 - * - * @param id 编号 - * @param receiptPrice 收款金额 - */ - void updateSaleInReceiptPrice(Long id, BigDecimal receiptPrice); - - /** - * 删除销售出库 - * - * @param ids 编号数组 - */ - void deleteSaleOut(List ids); - - /** - * 获得销售出库 - * - * @param id 编号 - * @return 销售出库 - */ - ErpSaleOutDO getSaleOut(Long id); - - /** - * 校验销售出库,已经审核通过 - * - * @param id 编号 - * @return 销售出库 - */ - ErpSaleOutDO validateSaleOut(Long id); - - /** - * 获得销售出库分页 - * - * @param pageReqVO 分页查询 - * @return 销售出库分页 - */ - PageResult getSaleOutPage(ErpSaleOutPageReqVO pageReqVO); - - // ==================== 销售出库项 ==================== - - /** - * 获得销售出库项列表 - * - * @param outId 销售出库编号 - * @return 销售出库项列表 - */ - List getSaleOutItemListByOutId(Long outId); - - /** - * 获得销售出库项 List - * - * @param outIds 销售出库编号数组 - * @return 销售出库项 List - */ - List getSaleOutItemListByOutIds(Collection outIds); - - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutServiceImpl.java deleted file mode 100644 index 16d20dd37..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleOutServiceImpl.java +++ /dev/null @@ -1,316 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.out.ErpSaleOutSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOutItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleOutItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleOutMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockRecordService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 销售出库 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpSaleOutServiceImpl implements ErpSaleOutService { - - @Resource - private ErpSaleOutMapper saleOutMapper; - @Resource - private ErpSaleOutItemMapper saleOutItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ErpSaleOrderService saleOrderService; - @Resource - private ErpAccountService accountService; - @Resource - private ErpStockRecordService stockRecordService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createSaleOut(ErpSaleOutSaveReqVO createReqVO) { - // 1.1 校验销售订单已审核 - ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(createReqVO.getOrderId()); - // 1.2 校验出库项的有效性 - List saleOutItems = validateSaleOutItems(createReqVO.getItems()); - // 1.3 校验结算账户 - accountService.validateAccount(createReqVO.getAccountId()); - // 1.4 校验销售人员 - if (createReqVO.getSaleUserId() != null) { - adminUserApi.validateUser(createReqVO.getSaleUserId()); - } - // 1.5 生成出库单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.SALE_OUT_NO_PREFIX); - if (saleOutMapper.selectByNo(no) != null) { - throw exception(SALE_OUT_NO_EXISTS); - } - - // 2.1 插入出库 - ErpSaleOutDO saleOut = BeanUtils.toBean(createReqVO, ErpSaleOutDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())) - .setOrderNo(saleOrder.getNo()).setCustomerId(saleOrder.getCustomerId()); - calculateTotalPrice(saleOut, saleOutItems); - saleOutMapper.insert(saleOut); - // 2.2 插入出库项 - saleOutItems.forEach(o -> o.setOutId(saleOut.getId())); - saleOutItemMapper.insertBatch(saleOutItems); - - // 3. 更新销售订单的出库数量 - updateSaleOrderOutCount(createReqVO.getOrderId()); - return saleOut.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSaleOut(ErpSaleOutSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpSaleOutDO saleOut = validateSaleOutExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(saleOut.getStatus())) { - throw exception(SALE_OUT_UPDATE_FAIL_APPROVE, saleOut.getNo()); - } - // 1.2 校验销售订单已审核 - ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(updateReqVO.getOrderId()); - // 1.3 校验结算账户 - accountService.validateAccount(updateReqVO.getAccountId()); - // 1.4 校验销售人员 - if (updateReqVO.getSaleUserId() != null) { - adminUserApi.validateUser(updateReqVO.getSaleUserId()); - } - // 1.5 校验订单项的有效性 - List saleOutItems = validateSaleOutItems(updateReqVO.getItems()); - - // 2.1 更新出库 - ErpSaleOutDO updateObj = BeanUtils.toBean(updateReqVO, ErpSaleOutDO.class) - .setOrderNo(saleOrder.getNo()).setCustomerId(saleOrder.getCustomerId()); - calculateTotalPrice(updateObj, saleOutItems); - saleOutMapper.updateById(updateObj); - // 2.2 更新出库项 - updateSaleOutItemList(updateReqVO.getId(), saleOutItems); - - // 3.1 更新销售订单的出库数量 - updateSaleOrderOutCount(updateObj.getOrderId()); - // 3.2 注意:如果销售订单编号变更了,需要更新“老”销售订单的出库数量 - if (ObjectUtil.notEqual(saleOut.getOrderId(), updateObj.getOrderId())) { - updateSaleOrderOutCount(saleOut.getOrderId()); - } - } - - private void calculateTotalPrice(ErpSaleOutDO saleOut, List saleOutItems) { - saleOut.setTotalCount(getSumValue(saleOutItems, ErpSaleOutItemDO::getCount, BigDecimal::add)); - saleOut.setTotalProductPrice(getSumValue(saleOutItems, ErpSaleOutItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - saleOut.setTotalTaxPrice(getSumValue(saleOutItems, ErpSaleOutItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); - saleOut.setTotalPrice(saleOut.getTotalProductPrice().add(saleOut.getTotalTaxPrice())); - // 计算优惠价格 - if (saleOut.getDiscountPercent() == null) { - saleOut.setDiscountPercent(BigDecimal.ZERO); - } - saleOut.setDiscountPrice(MoneyUtils.priceMultiplyPercent(saleOut.getTotalPrice(), saleOut.getDiscountPercent())); - saleOut.setTotalPrice(saleOut.getTotalPrice().subtract(saleOut.getDiscountPrice().add(saleOut.getOtherPrice()))); - } - - private void updateSaleOrderOutCount(Long orderId) { - // 1.1 查询销售订单对应的销售出库单列表 - List saleOuts = saleOutMapper.selectListByOrderId(orderId); - // 1.2 查询对应的销售订单项的出库数量 - Map returnCountMap = saleOutItemMapper.selectOrderItemCountSumMapByOutIds( - convertList(saleOuts, ErpSaleOutDO::getId)); - // 2. 更新销售订单的出库数量 - saleOrderService.updateSaleOrderOutCount(orderId, returnCountMap); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSaleOutStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpSaleOutDO saleOut = validateSaleOutExists(id); - // 1.2 校验状态 - if (saleOut.getStatus().equals(status)) { - throw exception(approve ? SALE_OUT_APPROVE_FAIL : SALE_OUT_PROCESS_FAIL); - } - // 1.3 校验已退款 - if (!approve && saleOut.getReceiptPrice().compareTo(BigDecimal.ZERO) > 0) { - throw exception(SALE_OUT_PROCESS_FAIL_EXISTS_RECEIPT); - } - - // 2. 更新状态 - int updateCount = saleOutMapper.updateByIdAndStatus(id, saleOut.getStatus(), - new ErpSaleOutDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? SALE_OUT_APPROVE_FAIL : SALE_OUT_PROCESS_FAIL); - } - - // 3. 变更库存 - List saleOutItems = saleOutItemMapper.selectListByOutId(id); - Integer bizType = approve ? ErpStockRecordBizTypeEnum.SALE_OUT.getType() - : ErpStockRecordBizTypeEnum.SALE_OUT_CANCEL.getType(); - saleOutItems.forEach(saleOutItem -> { - BigDecimal count = approve ? saleOutItem.getCount().negate() : saleOutItem.getCount(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - saleOutItem.getProductId(), saleOutItem.getWarehouseId(), count, - bizType, saleOutItem.getOutId(), saleOutItem.getId(), saleOut.getNo())); - }); - } - - @Override - public void updateSaleInReceiptPrice(Long id, BigDecimal receiptPrice) { - ErpSaleOutDO saleOut = saleOutMapper.selectById(id); - if (saleOut.getReceiptPrice().equals(receiptPrice)) { - return; - } - if (receiptPrice.compareTo(saleOut.getTotalPrice()) > 0) { - throw exception(SALE_OUT_FAIL_RECEIPT_PRICE_EXCEED, receiptPrice, saleOut.getTotalPrice()); - } - saleOutMapper.updateById(new ErpSaleOutDO().setId(id).setReceiptPrice(receiptPrice)); - } - - private List validateSaleOutItems(List list) { - // 1. 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpSaleOutSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 2. 转化为 ErpSaleOutItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpSaleOutItemDO.class, item -> { - item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); - item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); - if (item.getTotalPrice() == null) { - return; - } - if (item.getTaxPercent() != null) { - item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent())); - } - })); - } - - private void updateSaleOutItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = saleOutItemMapper.selectListByOutId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setOutId(id)); - saleOutItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - saleOutItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - saleOutItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpSaleOutItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSaleOut(List ids) { - // 1. 校验不处于已审批 - List saleOuts = saleOutMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(saleOuts)) { - return; - } - saleOuts.forEach(saleOut -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(saleOut.getStatus())) { - throw exception(SALE_OUT_DELETE_FAIL_APPROVE, saleOut.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - saleOuts.forEach(saleOut -> { - // 2.1 删除订单 - saleOutMapper.deleteById(saleOut.getId()); - // 2.2 删除订单项 - saleOutItemMapper.deleteByOutId(saleOut.getId()); - - // 2.3 更新销售订单的出库数量 - updateSaleOrderOutCount(saleOut.getOrderId()); - }); - - } - - private ErpSaleOutDO validateSaleOutExists(Long id) { - ErpSaleOutDO saleOut = saleOutMapper.selectById(id); - if (saleOut == null) { - throw exception(SALE_OUT_NOT_EXISTS); - } - return saleOut; - } - - @Override - public ErpSaleOutDO getSaleOut(Long id) { - return saleOutMapper.selectById(id); - } - - @Override - public ErpSaleOutDO validateSaleOut(Long id) { - ErpSaleOutDO saleOut = validateSaleOutExists(id); - if (ObjectUtil.notEqual(saleOut.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { - throw exception(SALE_OUT_NOT_APPROVE); - } - return saleOut; - } - - @Override - public PageResult getSaleOutPage(ErpSaleOutPageReqVO pageReqVO) { - return saleOutMapper.selectPage(pageReqVO); - } - - // ==================== 销售出库项 ==================== - - @Override - public List getSaleOutItemListByOutId(Long outId) { - return saleOutItemMapper.selectListByOutId(outId); - } - - @Override - public List getSaleOutItemListByOutIds(Collection outIds) { - if (CollUtil.isEmpty(outIds)) { - return Collections.emptyList(); - } - return saleOutItemMapper.selectListByOutIds(outIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleReturnService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleReturnService.java deleted file mode 100644 index 026403237..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleReturnService.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnItemDO; -import javax.validation.Valid; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; - -/** - * ERP 销售退货 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpSaleReturnService { - - /** - * 创建销售退货 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSaleReturn(@Valid ErpSaleReturnSaveReqVO createReqVO); - - /** - * 更新销售退货 - * - * @param updateReqVO 更新信息 - */ - void updateSaleReturn(@Valid ErpSaleReturnSaveReqVO updateReqVO); - - /** - * 更新销售退货的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateSaleReturnStatus(Long id, Integer status); - - /** - * 更新销售退货的退款金额 - * - * @param id 编号 - * @param refundPrice 退款金额 - */ - void updateSaleReturnRefundPrice(Long id, BigDecimal refundPrice); - - /** - * 删除销售退货 - * - * @param ids 编号数组 - */ - void deleteSaleReturn(List ids); - - /** - * 获得销售退货 - * - * @param id 编号 - * @return 销售退货 - */ - ErpSaleReturnDO getSaleReturn(Long id); - - /** - * 校验销售退货,已经审核通过 - * - * @param id 编号 - * @return 销售退货 - */ - ErpSaleReturnDO validateSaleReturn(Long id); - - /** - * 获得销售退货分页 - * - * @param pageReqVO 分页查询 - * @return 销售退货分页 - */ - PageResult getSaleReturnPage(ErpSaleReturnPageReqVO pageReqVO); - - // ==================== 销售退货项 ==================== - - /** - * 获得销售退货项列表 - * - * @param returnId 销售退货编号 - * @return 销售退货项列表 - */ - List getSaleReturnItemListByReturnId(Long returnId); - - /** - * 获得销售退货项 List - * - * @param returnIds 销售退货编号数组 - * @return 销售退货项 List - */ - List getSaleReturnItemListByReturnIds(Collection returnIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleReturnServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleReturnServiceImpl.java deleted file mode 100644 index 209df114c..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/sale/ErpSaleReturnServiceImpl.java +++ /dev/null @@ -1,316 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.sale; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.returns.ErpSaleReturnSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleReturnItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleReturnItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleReturnMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockRecordService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 销售退货 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpSaleReturnServiceImpl implements ErpSaleReturnService { - - @Resource - private ErpSaleReturnMapper saleReturnMapper; - @Resource - private ErpSaleReturnItemMapper saleReturnItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ErpSaleOrderService saleOrderService; - @Resource - private ErpAccountService accountService; - @Resource - private ErpStockRecordService stockRecordService; - - @Resource - private AdminUserApi adminUserApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createSaleReturn(ErpSaleReturnSaveReqVO createReqVO) { - // 1.1 校验销售订单已审核 - ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(createReqVO.getOrderId()); - // 1.2 校验退货项的有效性 - List saleReturnItems = validateSaleReturnItems(createReqVO.getItems()); - // 1.3 校验结算账户 - accountService.validateAccount(createReqVO.getAccountId()); - // 1.4 校验销售人员 - if (createReqVO.getSaleUserId() != null) { - adminUserApi.validateUser(createReqVO.getSaleUserId()); - } - // 1.5 生成退货单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.SALE_RETURN_NO_PREFIX); - if (saleReturnMapper.selectByNo(no) != null) { - throw exception(SALE_RETURN_NO_EXISTS); - } - - // 2.1 插入退货 - ErpSaleReturnDO saleReturn = BeanUtils.toBean(createReqVO, ErpSaleReturnDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus())) - .setOrderNo(saleOrder.getNo()).setCustomerId(saleOrder.getCustomerId()); - calculateTotalPrice(saleReturn, saleReturnItems); - saleReturnMapper.insert(saleReturn); - // 2.2 插入退货项 - saleReturnItems.forEach(o -> o.setReturnId(saleReturn.getId())); - saleReturnItemMapper.insertBatch(saleReturnItems); - - // 3. 更新销售订单的退货数量 - updateSaleOrderReturnCount(createReqVO.getOrderId()); - return saleReturn.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSaleReturn(ErpSaleReturnSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpSaleReturnDO saleReturn = validateSaleReturnExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(saleReturn.getStatus())) { - throw exception(SALE_RETURN_UPDATE_FAIL_APPROVE, saleReturn.getNo()); - } - // 1.2 校验销售订单已审核 - ErpSaleOrderDO saleOrder = saleOrderService.validateSaleOrder(updateReqVO.getOrderId()); - // 1.3 校验结算账户 - accountService.validateAccount(updateReqVO.getAccountId()); - // 1.4 校验销售人员 - if (updateReqVO.getSaleUserId() != null) { - adminUserApi.validateUser(updateReqVO.getSaleUserId()); - } - // 1.5 校验订单项的有效性 - List saleReturnItems = validateSaleReturnItems(updateReqVO.getItems()); - - // 2.1 更新退货 - ErpSaleReturnDO updateObj = BeanUtils.toBean(updateReqVO, ErpSaleReturnDO.class) - .setOrderNo(saleOrder.getNo()).setCustomerId(saleOrder.getCustomerId()); - calculateTotalPrice(updateObj, saleReturnItems); - saleReturnMapper.updateById(updateObj); - // 2.2 更新退货项 - updateSaleReturnItemList(updateReqVO.getId(), saleReturnItems); - - // 3.1 更新销售订单的出库数量 - updateSaleOrderReturnCount(updateObj.getOrderId()); - // 3.2 注意:如果销售订单编号变更了,需要更新“老”销售订单的出库数量 - if (ObjectUtil.notEqual(saleReturn.getOrderId(), updateObj.getOrderId())) { - updateSaleOrderReturnCount(saleReturn.getOrderId()); - } - } - - private void calculateTotalPrice(ErpSaleReturnDO saleReturn, List saleReturnItems) { - saleReturn.setTotalCount(getSumValue(saleReturnItems, ErpSaleReturnItemDO::getCount, BigDecimal::add)); - saleReturn.setTotalProductPrice(getSumValue(saleReturnItems, ErpSaleReturnItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); - saleReturn.setTotalTaxPrice(getSumValue(saleReturnItems, ErpSaleReturnItemDO::getTaxPrice, BigDecimal::add, BigDecimal.ZERO)); - saleReturn.setTotalPrice(saleReturn.getTotalProductPrice().add(saleReturn.getTotalTaxPrice())); - // 计算优惠价格 - if (saleReturn.getDiscountPercent() == null) { - saleReturn.setDiscountPercent(BigDecimal.ZERO); - } - saleReturn.setDiscountPrice(MoneyUtils.priceMultiplyPercent(saleReturn.getTotalPrice(), saleReturn.getDiscountPercent())); - saleReturn.setTotalPrice(saleReturn.getTotalPrice().subtract(saleReturn.getDiscountPrice().add(saleReturn.getOtherPrice()))); - } - - private void updateSaleOrderReturnCount(Long orderId) { - // 1.1 查询销售订单对应的销售出库单列表 - List saleReturns = saleReturnMapper.selectListByOrderId(orderId); - // 1.2 查询对应的销售订单项的退货数量 - Map returnCountMap = saleReturnItemMapper.selectOrderItemCountSumMapByReturnIds( - convertList(saleReturns, ErpSaleReturnDO::getId)); - // 2. 更新销售订单的出库数量 - saleOrderService.updateSaleOrderReturnCount(orderId, returnCountMap); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSaleReturnStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpSaleReturnDO saleReturn = validateSaleReturnExists(id); - // 1.2 校验状态 - if (saleReturn.getStatus().equals(status)) { - throw exception(approve ? SALE_RETURN_APPROVE_FAIL : SALE_RETURN_PROCESS_FAIL); - } - // 1.3 校验已退款 - if (!approve && saleReturn.getRefundPrice().compareTo(BigDecimal.ZERO) > 0) { - throw exception(SALE_RETURN_PROCESS_FAIL_EXISTS_REFUND); - } - - // 2. 更新状态 - int updateCount = saleReturnMapper.updateByIdAndStatus(id, saleReturn.getStatus(), - new ErpSaleReturnDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? SALE_RETURN_APPROVE_FAIL : SALE_RETURN_PROCESS_FAIL); - } - - // 3. 变更库存 - List saleReturnItems = saleReturnItemMapper.selectListByReturnId(id); - Integer bizType = approve ? ErpStockRecordBizTypeEnum.SALE_RETURN.getType() - : ErpStockRecordBizTypeEnum.SALE_RETURN_CANCEL.getType(); - saleReturnItems.forEach(saleReturnItem -> { - BigDecimal count = approve ? saleReturnItem.getCount() : saleReturnItem.getCount().negate(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - saleReturnItem.getProductId(), saleReturnItem.getWarehouseId(), count, - bizType, saleReturnItem.getReturnId(), saleReturnItem.getId(), saleReturn.getNo())); - }); - } - - @Override - public void updateSaleReturnRefundPrice(Long id, BigDecimal refundPrice) { - ErpSaleReturnDO saleReturn = saleReturnMapper.selectById(id); - if (saleReturn.getRefundPrice().equals(refundPrice)) { - return; - } - if (refundPrice.compareTo(saleReturn.getTotalPrice()) > 0) { - throw exception(SALE_RETURN_FAIL_REFUND_PRICE_EXCEED, refundPrice, saleReturn.getTotalPrice()); - } - saleReturnMapper.updateById(new ErpSaleReturnDO().setId(id).setRefundPrice(refundPrice)); - } - - private List validateSaleReturnItems(List list) { - // 1. 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpSaleReturnSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 2. 转化为 ErpSaleReturnItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpSaleReturnItemDO.class, item -> { - item.setProductUnitId(productMap.get(item.getProductId()).getUnitId()); - item.setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())); - if (item.getTotalPrice() == null) { - return; - } - if (item.getTaxPercent() != null) { - item.setTaxPrice(MoneyUtils.priceMultiplyPercent(item.getTotalPrice(), item.getTaxPercent())); - } - })); - } - - private void updateSaleReturnItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = saleReturnItemMapper.selectListByReturnId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setReturnId(id)); - saleReturnItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - saleReturnItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - saleReturnItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpSaleReturnItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSaleReturn(List ids) { - // 1. 校验不处于已审批 - List saleReturns = saleReturnMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(saleReturns)) { - return; - } - saleReturns.forEach(saleReturn -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(saleReturn.getStatus())) { - throw exception(SALE_RETURN_DELETE_FAIL_APPROVE, saleReturn.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - saleReturns.forEach(saleReturn -> { - // 2.1 删除订单 - saleReturnMapper.deleteById(saleReturn.getId()); - // 2.2 删除订单项 - saleReturnItemMapper.deleteByReturnId(saleReturn.getId()); - - // 2.3 更新销售订单的出库数量 - updateSaleOrderReturnCount(saleReturn.getOrderId()); - }); - - } - - private ErpSaleReturnDO validateSaleReturnExists(Long id) { - ErpSaleReturnDO saleReturn = saleReturnMapper.selectById(id); - if (saleReturn == null) { - throw exception(SALE_RETURN_NOT_EXISTS); - } - return saleReturn; - } - - @Override - public ErpSaleReturnDO getSaleReturn(Long id) { - return saleReturnMapper.selectById(id); - } - - @Override - public ErpSaleReturnDO validateSaleReturn(Long id) { - ErpSaleReturnDO saleReturn = validateSaleReturnExists(id); - if (ObjectUtil.notEqual(saleReturn.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { - throw exception(SALE_RETURN_NOT_APPROVE); - } - return saleReturn; - } - - @Override - public PageResult getSaleReturnPage(ErpSaleReturnPageReqVO pageReqVO) { - return saleReturnMapper.selectPage(pageReqVO); - } - - // ==================== 销售退货项 ==================== - - @Override - public List getSaleReturnItemListByReturnId(Long returnId) { - return saleReturnItemMapper.selectListByReturnId(returnId); - } - - @Override - public List getSaleReturnItemListByReturnIds(Collection returnIds) { - if (CollUtil.isEmpty(returnIds)) { - return Collections.emptyList(); - } - return saleReturnItemMapper.selectListByReturnIds(returnIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpPurchaseStatisticsService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpPurchaseStatisticsService.java deleted file mode 100644 index 913409487..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpPurchaseStatisticsService.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.statistics; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 采购统计 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpPurchaseStatisticsService { - - /** - * 获得采购金额 - * - * 计算逻辑:采购出库的金额 - 采购退货的金额 - * - * @param beginTime >= 开始时间 - * @param endTime < 结束时间 - * @return 采购金额 - */ - BigDecimal getPurchasePrice(LocalDateTime beginTime, LocalDateTime endTime); - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpPurchaseStatisticsServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpPurchaseStatisticsServiceImpl.java deleted file mode 100644 index 588ff74ba..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpPurchaseStatisticsServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.statistics; - -import cn.iocoder.yudao.module.erp.dal.mysql.statistics.ErpPurchaseStatisticsMapper; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 采购统计 Service 实现类 - * - * @author 芋道源码 - */ -@Service -public class ErpPurchaseStatisticsServiceImpl implements ErpPurchaseStatisticsService { - - @Resource - private ErpPurchaseStatisticsMapper purchaseStatisticsMapper; - - @Override - public BigDecimal getPurchasePrice(LocalDateTime beginTime, LocalDateTime endTime) { - return purchaseStatisticsMapper.getPurchasePrice(beginTime, endTime); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpSaleStatisticsService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpSaleStatisticsService.java deleted file mode 100644 index 3c28bc327..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpSaleStatisticsService.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.statistics; - -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 销售统计 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpSaleStatisticsService { - - /** - * 获得销售金额 - * - * 计算逻辑:销售出库的金额 - 销售退货的金额 - * - * @param beginTime >= 开始时间 - * @param endTime < 结束时间 - * @return 销售金额 - */ - BigDecimal getSalePrice(LocalDateTime beginTime, LocalDateTime endTime); - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpSaleStatisticsServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpSaleStatisticsServiceImpl.java deleted file mode 100644 index a6664332a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/statistics/ErpSaleStatisticsServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.statistics; - -import cn.iocoder.yudao.module.erp.dal.mysql.statistics.ErpSaleStatisticsMapper; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * ERP 销售统计 Service 实现类 - * - * @author 芋道源码 - */ -@Service -public class ErpSaleStatisticsServiceImpl implements ErpSaleStatisticsService { - - @Resource - private ErpSaleStatisticsMapper saleStatisticsMapper; - - @Override - public BigDecimal getSalePrice(LocalDateTime beginTime, LocalDateTime endTime) { - return saleStatisticsMapper.getSalePrice(beginTime, endTime); - } - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockCheckService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockCheckService.java deleted file mode 100644 index 139982905..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockCheckService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 库存盘点单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpStockCheckService { - - /** - * 创建库存盘点单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStockCheck(@Valid ErpStockCheckSaveReqVO createReqVO); - - /** - * 更新库存盘点单 - * - * @param updateReqVO 更新信息 - */ - void updateStockCheck(@Valid ErpStockCheckSaveReqVO updateReqVO); - - /** - * 更新库存盘点单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateStockCheckStatus(Long id, Integer status); - - /** - * 删除库存盘点单 - * - * @param ids 编号数组 - */ - void deleteStockCheck(List ids); - - /** - * 获得库存盘点单 - * - * @param id 编号 - * @return 库存盘点单 - */ - ErpStockCheckDO getStockCheck(Long id); - - /** - * 获得库存盘点单分页 - * - * @param pageReqVO 分页查询 - * @return 库存盘点单分页 - */ - PageResult getStockCheckPage(ErpStockCheckPageReqVO pageReqVO); - - // ==================== 盘点项 ==================== - - /** - * 获得库存盘点单项列表 - * - * @param checkId 盘点编号 - * @return 库存盘点单项列表 - */ - List getStockCheckItemListByCheckId(Long checkId); - - /** - * 获得库存盘点单项 List - * - * @param checkIds 盘点编号数组 - * @return 库存盘点单项 List - */ - List getStockCheckItemListByCheckIds(Collection checkIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockCheckServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockCheckServiceImpl.java deleted file mode 100644 index c70284aef..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockCheckServiceImpl.java +++ /dev/null @@ -1,232 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockCheckItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockCheckMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 库存盘点单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpStockCheckServiceImpl implements ErpStockCheckService { - - @Resource - private ErpStockCheckMapper stockCheckMapper; - @Resource - private ErpStockCheckItemMapper stockCheckItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - @Resource - private ErpStockRecordService stockRecordService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStockCheck(ErpStockCheckSaveReqVO createReqVO) { - // 1.1 校验盘点项的有效性 - List stockCheckItems = validateStockCheckItems(createReqVO.getItems()); - // 1.2 生成盘点单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.STOCK_CHECK_NO_PREFIX); - if (stockCheckMapper.selectByNo(no) != null) { - throw exception(STOCK_CHECK_NO_EXISTS); - } - - // 2.1 插入盘点单 - ErpStockCheckDO stockCheck = BeanUtils.toBean(createReqVO, ErpStockCheckDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus()) - .setTotalCount(getSumValue(stockCheckItems, ErpStockCheckItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockCheckItems, ErpStockCheckItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO))); - stockCheckMapper.insert(stockCheck); - // 2.2 插入盘点单项 - stockCheckItems.forEach(o -> o.setCheckId(stockCheck.getId())); - stockCheckItemMapper.insertBatch(stockCheckItems); - return stockCheck.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockCheck(ErpStockCheckSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpStockCheckDO stockCheck = validateStockCheckExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(stockCheck.getStatus())) { - throw exception(STOCK_CHECK_UPDATE_FAIL_APPROVE, stockCheck.getNo()); - } - // 1.2 校验盘点项的有效性 - List stockCheckItems = validateStockCheckItems(updateReqVO.getItems()); - - // 2.1 更新盘点单 - ErpStockCheckDO updateObj = BeanUtils.toBean(updateReqVO, ErpStockCheckDO.class, in -> in - .setTotalCount(getSumValue(stockCheckItems, ErpStockCheckItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockCheckItems, ErpStockCheckItemDO::getTotalPrice, BigDecimal::add))); - stockCheckMapper.updateById(updateObj); - // 2.2 更新盘点单项 - updateStockCheckItemList(updateReqVO.getId(), stockCheckItems); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockCheckStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpStockCheckDO stockCheck = validateStockCheckExists(id); - // 1.2 校验状态 - if (stockCheck.getStatus().equals(status)) { - throw exception(approve ? STOCK_CHECK_APPROVE_FAIL : STOCK_CHECK_PROCESS_FAIL); - } - - // 2. 更新状态 - int updateCount = stockCheckMapper.updateByIdAndStatus(id, stockCheck.getStatus(), - new ErpStockCheckDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? STOCK_CHECK_APPROVE_FAIL : STOCK_CHECK_PROCESS_FAIL); - } - - // 3. 变更库存 - List stockCheckItems = stockCheckItemMapper.selectListByCheckId(id); - stockCheckItems.forEach(stockCheckItem -> { - // 没有盈亏,不用出入库 - if (stockCheckItem.getCount().compareTo(BigDecimal.ZERO) == 0) { - return; - } - // 10;12;-2() - BigDecimal count = approve ? stockCheckItem.getCount(): stockCheckItem.getCount().negate(); - Integer bizType; - if (approve) { - bizType = count.compareTo(BigDecimal.ZERO) > 0 ? ErpStockRecordBizTypeEnum.CHECK_MORE_IN.getType() - : ErpStockRecordBizTypeEnum.CHECK_LESS_OUT.getType(); - } else { - bizType = count.compareTo(BigDecimal.ZERO) > 0 ? ErpStockRecordBizTypeEnum.CHECK_MORE_IN_CANCEL.getType() - : ErpStockRecordBizTypeEnum.CHECK_LESS_OUT_CANCEL.getType(); - } - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - stockCheckItem.getProductId(), stockCheckItem.getWarehouseId(), count, - bizType, stockCheckItem.getCheckId(), stockCheckItem.getId(), stockCheck.getNo())); - }); - } - - private List validateStockCheckItems(List list) { - // 1.1 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpStockCheckSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 1.2 校验仓库存在 - warehouseService.validWarehouseList(convertSet(list, ErpStockCheckSaveReqVO.Item::getWarehouseId)); - // 2. 转化为 ErpStockCheckItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpStockCheckItemDO.class, item -> item - .setProductUnitId(productMap.get(item.getProductId()).getUnitId()) - .setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())))); - } - - private void updateStockCheckItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = stockCheckItemMapper.selectListByCheckId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setCheckId(id)); - stockCheckItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - stockCheckItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - stockCheckItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpStockCheckItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStockCheck(List ids) { - // 1. 校验不处于已审批 - List stockChecks = stockCheckMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(stockChecks)) { - return; - } - stockChecks.forEach(stockCheck -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(stockCheck.getStatus())) { - throw exception(STOCK_CHECK_DELETE_FAIL_APPROVE, stockCheck.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - stockChecks.forEach(stockCheck -> { - // 2.1 删除盘点单 - stockCheckMapper.deleteById(stockCheck.getId()); - // 2.2 删除盘点单项 - stockCheckItemMapper.deleteByCheckId(stockCheck.getId()); - }); - } - - private ErpStockCheckDO validateStockCheckExists(Long id) { - ErpStockCheckDO stockCheck = stockCheckMapper.selectById(id); - if (stockCheck == null) { - throw exception(STOCK_CHECK_NOT_EXISTS); - } - return stockCheck; - } - - @Override - public ErpStockCheckDO getStockCheck(Long id) { - return stockCheckMapper.selectById(id); - } - - @Override - public PageResult getStockCheckPage(ErpStockCheckPageReqVO pageReqVO) { - return stockCheckMapper.selectPage(pageReqVO); - } - - // ==================== 盘点项 ==================== - - @Override - public List getStockCheckItemListByCheckId(Long checkId) { - return stockCheckItemMapper.selectListByCheckId(checkId); - } - - @Override - public List getStockCheckItemListByCheckIds(Collection checkIds) { - if (CollUtil.isEmpty(checkIds)) { - return Collections.emptyList(); - } - return stockCheckItemMapper.selectListByCheckIds(checkIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockInService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockInService.java deleted file mode 100644 index 006db5211..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockInService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 其它入库单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpStockInService { - - /** - * 创建其它入库单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStockIn(@Valid ErpStockInSaveReqVO createReqVO); - - /** - * 更新其它入库单 - * - * @param updateReqVO 更新信息 - */ - void updateStockIn(@Valid ErpStockInSaveReqVO updateReqVO); - - /** - * 更新其它入库单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateStockInStatus(Long id, Integer status); - - /** - * 删除其它入库单 - * - * @param ids 编号数组 - */ - void deleteStockIn(List ids); - - /** - * 获得其它入库单 - * - * @param id 编号 - * @return 其它入库单 - */ - ErpStockInDO getStockIn(Long id); - - /** - * 获得其它入库单分页 - * - * @param pageReqVO 分页查询 - * @return 其它入库单分页 - */ - PageResult getStockInPage(ErpStockInPageReqVO pageReqVO); - - // ==================== 入库项 ==================== - - /** - * 获得其它入库单项列表 - * - * @param inId 入库编号 - * @return 其它入库单项列表 - */ - List getStockInItemListByInId(Long inId); - - /** - * 获得其它入库单项 List - * - * @param inIds 入库编号数组 - * @return 其它入库单项 List - */ - List getStockInItemListByInIds(Collection inIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockInServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockInServiceImpl.java deleted file mode 100644 index 5bb3afb59..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockInServiceImpl.java +++ /dev/null @@ -1,228 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockInItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockInMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 -/** - * ERP 其它入库单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpStockInServiceImpl implements ErpStockInService { - - @Resource - private ErpStockInMapper stockInMapper; - @Resource - private ErpStockInItemMapper stockInItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - @Resource - private ErpSupplierService supplierService; - @Resource - private ErpStockRecordService stockRecordService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStockIn(ErpStockInSaveReqVO createReqVO) { - // 1.1 校验入库项的有效性 - List stockInItems = validateStockInItems(createReqVO.getItems()); - // 1.2 校验供应商 - supplierService.validateSupplier(createReqVO.getSupplierId()); - // 1.3 生成入库单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.STOCK_IN_NO_PREFIX); - if (stockInMapper.selectByNo(no) != null) { - throw exception(STOCK_IN_NO_EXISTS); - } - - // 2.1 插入入库单 - ErpStockInDO stockIn = BeanUtils.toBean(createReqVO, ErpStockInDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus()) - .setTotalCount(getSumValue(stockInItems, ErpStockInItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockInItems, ErpStockInItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO))); - stockInMapper.insert(stockIn); - // 2.2 插入入库单项 - stockInItems.forEach(o -> o.setInId(stockIn.getId())); - stockInItemMapper.insertBatch(stockInItems); - return stockIn.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockIn(ErpStockInSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpStockInDO stockIn = validateStockInExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(stockIn.getStatus())) { - throw exception(STOCK_IN_UPDATE_FAIL_APPROVE, stockIn.getNo()); - } - // 1.2 校验供应商 - supplierService.validateSupplier(updateReqVO.getSupplierId()); - // 1.3 校验入库项的有效性 - List stockInItems = validateStockInItems(updateReqVO.getItems()); - - // 2.1 更新入库单 - ErpStockInDO updateObj = BeanUtils.toBean(updateReqVO, ErpStockInDO.class, in -> in - .setTotalCount(getSumValue(stockInItems, ErpStockInItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockInItems, ErpStockInItemDO::getTotalPrice, BigDecimal::add))); - stockInMapper.updateById(updateObj); - // 2.2 更新入库单项 - updateStockInItemList(updateReqVO.getId(), stockInItems); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockInStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpStockInDO stockIn = validateStockInExists(id); - // 1.2 校验状态 - if (stockIn.getStatus().equals(status)) { - throw exception(approve ? STOCK_IN_APPROVE_FAIL : STOCK_IN_PROCESS_FAIL); - } - - // 2. 更新状态 - int updateCount = stockInMapper.updateByIdAndStatus(id, stockIn.getStatus(), - new ErpStockInDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? STOCK_IN_APPROVE_FAIL : STOCK_IN_PROCESS_FAIL); - } - - // 3. 变更库存 - List stockInItems = stockInItemMapper.selectListByInId(id); - Integer bizType = approve ? ErpStockRecordBizTypeEnum.OTHER_IN.getType() - : ErpStockRecordBizTypeEnum.OTHER_IN_CANCEL.getType(); - stockInItems.forEach(stockInItem -> { - BigDecimal count = approve ? stockInItem.getCount() : stockInItem.getCount().negate(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - stockInItem.getProductId(), stockInItem.getWarehouseId(), count, - bizType, stockInItem.getInId(), stockInItem.getId(), stockIn.getNo())); - }); - } - - private List validateStockInItems(List list) { - // 1.1 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpStockInSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 1.2 校验仓库存在 - warehouseService.validWarehouseList(convertSet( - list, ErpStockInSaveReqVO.Item::getWarehouseId)); - // 2. 转化为 ErpStockInItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpStockInItemDO.class, item -> item - .setProductUnitId(productMap.get(item.getProductId()).getUnitId()) - .setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())))); - } - - private void updateStockInItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = stockInItemMapper.selectListByInId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setInId(id)); - stockInItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - stockInItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - stockInItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpStockInItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStockIn(List ids) { - // 1. 校验不处于已审批 - List stockIns = stockInMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(stockIns)) { - return; - } - stockIns.forEach(stockIn -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(stockIn.getStatus())) { - throw exception(STOCK_IN_DELETE_FAIL_APPROVE, stockIn.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - stockIns.forEach(stockIn -> { - // 2.1 删除入库单 - stockInMapper.deleteById(stockIn.getId()); - // 2.2 删除入库单项 - stockInItemMapper.deleteByInId(stockIn.getId()); - }); - } - - private ErpStockInDO validateStockInExists(Long id) { - ErpStockInDO stockIn = stockInMapper.selectById(id); - if (stockIn == null) { - throw exception(STOCK_IN_NOT_EXISTS); - } - return stockIn; - } - - @Override - public ErpStockInDO getStockIn(Long id) { - return stockInMapper.selectById(id); - } - - @Override - public PageResult getStockInPage(ErpStockInPageReqVO pageReqVO) { - return stockInMapper.selectPage(pageReqVO); - } - - // ==================== 入库项 ==================== - - @Override - public List getStockInItemListByInId(Long inId) { - return stockInItemMapper.selectListByInId(inId); - } - - @Override - public List getStockInItemListByInIds(Collection inIds) { - if (CollUtil.isEmpty(inIds)) { - return Collections.emptyList(); - } - return stockInItemMapper.selectListByInIds(inIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockMoveService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockMoveService.java deleted file mode 100644 index ddb0b85fa..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockMoveService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMovePageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMoveSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveItemDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 库存调拨单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpStockMoveService { - - /** - * 创建库存调拨单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStockMove(@Valid ErpStockMoveSaveReqVO createReqVO); - - /** - * 更新库存调拨单 - * - * @param updateReqVO 更新信息 - */ - void updateStockMove(@Valid ErpStockMoveSaveReqVO updateReqVO); - - /** - * 更新库存调拨单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateStockMoveStatus(Long id, Integer status); - - /** - * 删除库存调拨单 - * - * @param ids 编号数组 - */ - void deleteStockMove(List ids); - - /** - * 获得库存调拨单 - * - * @param id 编号 - * @return 库存调拨单 - */ - ErpStockMoveDO getStockMove(Long id); - - /** - * 获得库存调拨单分页 - * - * @param pageReqVO 分页查询 - * @return 库存调拨单分页 - */ - PageResult getStockMovePage(ErpStockMovePageReqVO pageReqVO); - - // ==================== 调拨项 ==================== - - /** - * 获得库存调拨单项列表 - * - * @param moveId 调拨编号 - * @return 库存调拨单项列表 - */ - List getStockMoveItemListByMoveId(Long moveId); - - /** - * 获得库存调拨单项 List - * - * @param moveIds 调拨编号数组 - * @return 库存调拨单项 List - */ - List getStockMoveItemListByMoveIds(Collection moveIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockMoveServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockMoveServiceImpl.java deleted file mode 100644 index d99d02618..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockMoveServiceImpl.java +++ /dev/null @@ -1,229 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMovePageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.move.ErpStockMoveSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockMoveItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockMoveItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockMoveMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 库存调拨单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpStockMoveServiceImpl implements ErpStockMoveService { - - @Resource - private ErpStockMoveMapper stockMoveMapper; - @Resource - private ErpStockMoveItemMapper stockMoveItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - @Resource - private ErpStockRecordService stockRecordService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStockMove(ErpStockMoveSaveReqVO createReqVO) { - // 1.1 校验出库项的有效性 - List stockMoveItems = validateStockMoveItems(createReqVO.getItems()); - // 1.2 生成调拨单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.STOCK_MOVE_NO_PREFIX); - if (stockMoveMapper.selectByNo(no) != null) { - throw exception(STOCK_MOVE_NO_EXISTS); - } - - // 2.1 插入出库单 - ErpStockMoveDO stockMove = BeanUtils.toBean(createReqVO, ErpStockMoveDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus()) - .setTotalCount(getSumValue(stockMoveItems, ErpStockMoveItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockMoveItems, ErpStockMoveItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO))); - stockMoveMapper.insert(stockMove); - // 2.2 插入出库单项 - stockMoveItems.forEach(o -> o.setMoveId(stockMove.getId())); - stockMoveItemMapper.insertBatch(stockMoveItems); - return stockMove.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockMove(ErpStockMoveSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpStockMoveDO stockMove = validateStockMoveExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(stockMove.getStatus())) { - throw exception(STOCK_MOVE_UPDATE_FAIL_APPROVE, stockMove.getNo()); - } - // 1.2 校验出库项的有效性 - List stockMoveItems = validateStockMoveItems(updateReqVO.getItems()); - - // 2.1 更新出库单 - ErpStockMoveDO updateObj = BeanUtils.toBean(updateReqVO, ErpStockMoveDO.class, in -> in - .setTotalCount(getSumValue(stockMoveItems, ErpStockMoveItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockMoveItems, ErpStockMoveItemDO::getTotalPrice, BigDecimal::add))); - stockMoveMapper.updateById(updateObj); - // 2.2 更新出库单项 - updateStockMoveItemList(updateReqVO.getId(), stockMoveItems); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockMoveStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpStockMoveDO stockMove = validateStockMoveExists(id); - // 1.2 校验状态 - if (stockMove.getStatus().equals(status)) { - throw exception(approve ? STOCK_MOVE_APPROVE_FAIL : STOCK_MOVE_PROCESS_FAIL); - } - - // 2. 更新状态 - int updateCount = stockMoveMapper.updateByIdAndStatus(id, stockMove.getStatus(), - new ErpStockMoveDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? STOCK_MOVE_APPROVE_FAIL : STOCK_MOVE_PROCESS_FAIL); - } - - // 3. 变更库存 - List stockMoveItems = stockMoveItemMapper.selectListByMoveId(id); - Integer fromBizType = approve ? ErpStockRecordBizTypeEnum.MOVE_OUT.getType() - : ErpStockRecordBizTypeEnum.MOVE_OUT_CANCEL.getType(); - Integer toBizType = approve ? ErpStockRecordBizTypeEnum.MOVE_IN.getType() - : ErpStockRecordBizTypeEnum.MOVE_IN_CANCEL.getType(); - stockMoveItems.forEach(stockMoveItem -> { - BigDecimal fromCount = approve ? stockMoveItem.getCount().negate() : stockMoveItem.getCount(); - BigDecimal toCount = approve ? stockMoveItem.getCount() : stockMoveItem.getCount().negate(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - stockMoveItem.getProductId(), stockMoveItem.getFromWarehouseId(), fromCount, - fromBizType, stockMoveItem.getMoveId(), stockMoveItem.getId(), stockMove.getNo())); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - stockMoveItem.getProductId(), stockMoveItem.getToWarehouseId(), toCount, - toBizType, stockMoveItem.getMoveId(), stockMoveItem.getId(), stockMove.getNo())); - }); - } - - private List validateStockMoveItems(List list) { - // 1.1 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpStockMoveSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 1.2 校验仓库存在 - warehouseService.validWarehouseList(convertSetByFlatMap(list, - item -> Stream.of(item.getFromWarehouseId(), item.getToWarehouseId()))); - // 2. 转化为 ErpStockMoveItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpStockMoveItemDO.class, item -> item - .setProductUnitId(productMap.get(item.getProductId()).getUnitId()) - .setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())))); - } - - private void updateStockMoveItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = stockMoveItemMapper.selectListByMoveId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setMoveId(id)); - stockMoveItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - stockMoveItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - stockMoveItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpStockMoveItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStockMove(List ids) { - // 1. 校验不处于已审批 - List stockMoves = stockMoveMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(stockMoves)) { - return; - } - stockMoves.forEach(stockMove -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(stockMove.getStatus())) { - throw exception(STOCK_MOVE_DELETE_FAIL_APPROVE, stockMove.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - stockMoves.forEach(stockMove -> { - // 2.1 删除出库单 - stockMoveMapper.deleteById(stockMove.getId()); - // 2.2 删除出库单项 - stockMoveItemMapper.deleteByMoveId(stockMove.getId()); - }); - } - - private ErpStockMoveDO validateStockMoveExists(Long id) { - ErpStockMoveDO stockMove = stockMoveMapper.selectById(id); - if (stockMove == null) { - throw exception(STOCK_MOVE_NOT_EXISTS); - } - return stockMove; - } - - @Override - public ErpStockMoveDO getStockMove(Long id) { - return stockMoveMapper.selectById(id); - } - - @Override - public PageResult getStockMovePage(ErpStockMovePageReqVO pageReqVO) { - return stockMoveMapper.selectPage(pageReqVO); - } - - // ==================== 出库项 ==================== - - @Override - public List getStockMoveItemListByMoveId(Long moveId) { - return stockMoveItemMapper.selectListByMoveId(moveId); - } - - @Override - public List getStockMoveItemListByMoveIds(Collection moveIds) { - if (CollUtil.isEmpty(moveIds)) { - return Collections.emptyList(); - } - return stockMoveItemMapper.selectListByMoveIds(moveIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockOutService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockOutService.java deleted file mode 100644 index c1517ca13..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockOutService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; - -/** - * ERP 其它出库单 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpStockOutService { - - /** - * 创建其它出库单 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createStockOut(@Valid ErpStockOutSaveReqVO createReqVO); - - /** - * 更新其它出库单 - * - * @param updateReqVO 更新信息 - */ - void updateStockOut(@Valid ErpStockOutSaveReqVO updateReqVO); - - /** - * 更新其它出库单的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateStockOutStatus(Long id, Integer status); - - /** - * 删除其它出库单 - * - * @param ids 编号数组 - */ - void deleteStockOut(List ids); - - /** - * 获得其它出库单 - * - * @param id 编号 - * @return 其它出库单 - */ - ErpStockOutDO getStockOut(Long id); - - /** - * 获得其它出库单分页 - * - * @param pageReqVO 分页查询 - * @return 其它出库单分页 - */ - PageResult getStockOutPage(ErpStockOutPageReqVO pageReqVO); - - // ==================== 出库项 ==================== - - /** - * 获得其它出库单项列表 - * - * @param outId 出库编号 - * @return 其它出库单项列表 - */ - List getStockOutItemListByOutId(Long outId); - - /** - * 获得其它出库单项 List - * - * @param outIds 出库编号数组 - * @return 其它出库单项 List - */ - List getStockOutItemListByOutIds(Collection outIds); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockOutServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockOutServiceImpl.java deleted file mode 100644 index 22d4cf4a2..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockOutServiceImpl.java +++ /dev/null @@ -1,228 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockOutItemMapper; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockOutMapper; -import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; -import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; -import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import javax.annotation.Resource; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; - -// TODO 芋艿:记录操作日志 - -/** - * ERP 其它出库单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpStockOutServiceImpl implements ErpStockOutService { - - @Resource - private ErpStockOutMapper stockOutMapper; - @Resource - private ErpStockOutItemMapper stockOutItemMapper; - - @Resource - private ErpNoRedisDAO noRedisDAO; - - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - @Resource - private ErpCustomerService customerService; - @Resource - private ErpStockRecordService stockRecordService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createStockOut(ErpStockOutSaveReqVO createReqVO) { - // 1.1 校验出库项的有效性 - List stockOutItems = validateStockOutItems(createReqVO.getItems()); - // 1.2 校验客户 - customerService.validateCustomer(createReqVO.getCustomerId()); - // 1.3 生成出库单号,并校验唯一性 - String no = noRedisDAO.generate(ErpNoRedisDAO.STOCK_OUT_NO_PREFIX); - if (stockOutMapper.selectByNo(no) != null) { - throw exception(STOCK_OUT_NO_EXISTS); - } - - // 2.1 插入出库单 - ErpStockOutDO stockOut = BeanUtils.toBean(createReqVO, ErpStockOutDO.class, in -> in - .setNo(no).setStatus(ErpAuditStatus.PROCESS.getStatus()) - .setTotalCount(getSumValue(stockOutItems, ErpStockOutItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockOutItems, ErpStockOutItemDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO))); - stockOutMapper.insert(stockOut); - // 2.2 插入出库单项 - stockOutItems.forEach(o -> o.setOutId(stockOut.getId())); - stockOutItemMapper.insertBatch(stockOutItems); - return stockOut.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockOut(ErpStockOutSaveReqVO updateReqVO) { - // 1.1 校验存在 - ErpStockOutDO stockOut = validateStockOutExists(updateReqVO.getId()); - if (ErpAuditStatus.APPROVE.getStatus().equals(stockOut.getStatus())) { - throw exception(STOCK_OUT_UPDATE_FAIL_APPROVE, stockOut.getNo()); - } - // 1.2 校验客户 - customerService.validateCustomer(updateReqVO.getCustomerId()); - // 1.3 校验出库项的有效性 - List stockOutItems = validateStockOutItems(updateReqVO.getItems()); - - // 2.1 更新出库单 - ErpStockOutDO updateObj = BeanUtils.toBean(updateReqVO, ErpStockOutDO.class, in -> in - .setTotalCount(getSumValue(stockOutItems, ErpStockOutItemDO::getCount, BigDecimal::add)) - .setTotalPrice(getSumValue(stockOutItems, ErpStockOutItemDO::getTotalPrice, BigDecimal::add))); - stockOutMapper.updateById(updateObj); - // 2.2 更新出库单项 - updateStockOutItemList(updateReqVO.getId(), stockOutItems); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateStockOutStatus(Long id, Integer status) { - boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); - // 1.1 校验存在 - ErpStockOutDO stockOut = validateStockOutExists(id); - // 1.2 校验状态 - if (stockOut.getStatus().equals(status)) { - throw exception(approve ? STOCK_OUT_APPROVE_FAIL : STOCK_OUT_PROCESS_FAIL); - } - - // 2. 更新状态 - int updateCount = stockOutMapper.updateByIdAndStatus(id, stockOut.getStatus(), - new ErpStockOutDO().setStatus(status)); - if (updateCount == 0) { - throw exception(approve ? STOCK_OUT_APPROVE_FAIL : STOCK_OUT_PROCESS_FAIL); - } - - // 3. 变更库存 - List stockOutItems = stockOutItemMapper.selectListByOutId(id); - Integer bizType = approve ? ErpStockRecordBizTypeEnum.OTHER_OUT.getType() - : ErpStockRecordBizTypeEnum.OTHER_OUT_CANCEL.getType(); - stockOutItems.forEach(stockOutItem -> { - BigDecimal count = approve ? stockOutItem.getCount().negate() : stockOutItem.getCount(); - stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( - stockOutItem.getProductId(), stockOutItem.getWarehouseId(), count, - bizType, stockOutItem.getOutId(), stockOutItem.getId(), stockOut.getNo())); - }); - } - - private List validateStockOutItems(List list) { - // 1.1 校验产品存在 - List productList = productService.validProductList( - convertSet(list, ErpStockOutSaveReqVO.Item::getProductId)); - Map productMap = convertMap(productList, ErpProductDO::getId); - // 1.2 校验仓库存在 - warehouseService.validWarehouseList(convertSet(list, ErpStockOutSaveReqVO.Item::getWarehouseId)); - // 2. 转化为 ErpStockOutItemDO 列表 - return convertList(list, o -> BeanUtils.toBean(o, ErpStockOutItemDO.class, item -> item - .setProductUnitId(productMap.get(item.getProductId()).getUnitId()) - .setTotalPrice(MoneyUtils.priceMultiply(item.getProductPrice(), item.getCount())))); - } - - private void updateStockOutItemList(Long id, List newList) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = stockOutItemMapper.selectListByOutId(id); - List> diffList = diffList(oldList, newList, // id 不同,就认为是不同的记录 - (oldVal, newVal) -> oldVal.getId().equals(newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - diffList.get(0).forEach(o -> o.setOutId(id)); - stockOutItemMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - stockOutItemMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - stockOutItemMapper.deleteBatchIds(convertList(diffList.get(2), ErpStockOutItemDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteStockOut(List ids) { - // 1. 校验不处于已审批 - List stockOuts = stockOutMapper.selectBatchIds(ids); - if (CollUtil.isEmpty(stockOuts)) { - return; - } - stockOuts.forEach(stockOut -> { - if (ErpAuditStatus.APPROVE.getStatus().equals(stockOut.getStatus())) { - throw exception(STOCK_OUT_DELETE_FAIL_APPROVE, stockOut.getNo()); - } - }); - - // 2. 遍历删除,并记录操作日志 - stockOuts.forEach(stockOut -> { - // 2.1 删除出库单 - stockOutMapper.deleteById(stockOut.getId()); - // 2.2 删除出库单项 - stockOutItemMapper.deleteByOutId(stockOut.getId()); - }); - } - - private ErpStockOutDO validateStockOutExists(Long id) { - ErpStockOutDO stockOut = stockOutMapper.selectById(id); - if (stockOut == null) { - throw exception(STOCK_OUT_NOT_EXISTS); - } - return stockOut; - } - - @Override - public ErpStockOutDO getStockOut(Long id) { - return stockOutMapper.selectById(id); - } - - @Override - public PageResult getStockOutPage(ErpStockOutPageReqVO pageReqVO) { - return stockOutMapper.selectPage(pageReqVO); - } - - // ==================== 出库项 ==================== - - @Override - public List getStockOutItemListByOutId(Long outId) { - return stockOutItemMapper.selectListByOutId(outId); - } - - @Override - public List getStockOutItemListByOutIds(Collection outIds) { - if (CollUtil.isEmpty(outIds)) { - return Collections.emptyList(); - } - return stockOutItemMapper.selectListByOutIds(outIds); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordService.java deleted file mode 100644 index 7cf8711ae..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordService.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record.ErpStockRecordPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockRecordDO; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import javax.validation.Valid; - -/** - * ERP 产品库存明细 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpStockRecordService { - - /** - * 获得产品库存明细 - * - * @param id 编号 - * @return 产品库存明细 - */ - ErpStockRecordDO getStockRecord(Long id); - - /** - * 获得产品库存明细分页 - * - * @param pageReqVO 分页查询 - * @return 产品库存明细分页 - */ - PageResult getStockRecordPage(ErpStockRecordPageReqVO pageReqVO); - - /** - * 创建库存明细 - * - * @param createReqBO 创建库存明细 BO - */ - void createStockRecord(@Valid ErpStockRecordCreateReqBO createReqBO); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordServiceImpl.java deleted file mode 100644 index b4b3875da..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockRecordServiceImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.record.ErpStockRecordPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockRecordDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockRecordMapper; -import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; - -/** - * ERP 产品库存明细 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpStockRecordServiceImpl implements ErpStockRecordService { - - @Resource - private ErpStockRecordMapper stockRecordMapper; - - @Resource - private ErpStockService stockService; - - @Override - public ErpStockRecordDO getStockRecord(Long id) { - return stockRecordMapper.selectById(id); - } - - @Override - public PageResult getStockRecordPage(ErpStockRecordPageReqVO pageReqVO) { - return stockRecordMapper.selectPage(pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void createStockRecord(ErpStockRecordCreateReqBO createReqBO) { - // 1. 更新库存 - BigDecimal totalCount = stockService.updateStockCountIncrement( - createReqBO.getProductId(), createReqBO.getWarehouseId(), createReqBO.getCount()); - // 2. 创建库存明细 - ErpStockRecordDO stockRecord = BeanUtils.toBean(createReqBO, ErpStockRecordDO.class) - .setTotalCount(totalCount); - stockRecordMapper.insert(stockRecord); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockService.java deleted file mode 100644 index 63ad5fefa..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockService.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; - -import java.math.BigDecimal; - -/** - * ERP 产品库存 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpStockService { - - /** - * 获得产品库存 - * - * @param id 编号 - * @return 库存 - */ - ErpStockDO getStock(Long id); - - /** - * 基于产品 + 仓库,获得产品库存 - * - * @param productId 产品编号 - * @param warehouseId 仓库编号 - * @return 产品库存 - */ - ErpStockDO getStock(Long productId, Long warehouseId); - - /** - * 获得产品库存数量 - * - * 如果不存在库存记录,则返回 0 - * - * @param productId 产品编号 - * @return 产品库存数量 - */ - BigDecimal getStockCount(Long productId); - - /** - * 获得产品库存分页 - * - * @param pageReqVO 分页查询 - * @return 库存分页 - */ - PageResult getStockPage(ErpStockPageReqVO pageReqVO); - - /** - * 增量更新产品库存数量 - * - * @param productId 产品编号 - * @param warehouseId 仓库编号 - * @param count 增量数量:正数,表示增加;负数,表示减少 - * @return 更新后的库存 - */ - BigDecimal updateStockCountIncrement(Long productId, Long warehouseId, BigDecimal count); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockServiceImpl.java deleted file mode 100644 index dabe36fb9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpStockServiceImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.stock.ErpStockPageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockMapper; -import cn.iocoder.yudao.module.erp.service.product.ErpProductService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.math.BigDecimal; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.STOCK_COUNT_NEGATIVE; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.STOCK_COUNT_NEGATIVE2; - -/** - * ERP 产品库存 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpStockServiceImpl implements ErpStockService { - - /** - * 允许库存为负数 - * - * TODO 芋艿:后续做成 db 配置 - */ - private static final Boolean NEGATIVE_STOCK_COUNT_ENABLE = false; - - @Resource - private ErpProductService productService; - @Resource - private ErpWarehouseService warehouseService; - - @Resource - private ErpStockMapper stockMapper; - - @Override - public ErpStockDO getStock(Long id) { - return stockMapper.selectById(id); - } - - @Override - public ErpStockDO getStock(Long productId, Long warehouseId) { - return stockMapper.selectByProductIdAndWarehouseId(productId, warehouseId); - } - - @Override - public BigDecimal getStockCount(Long productId) { - BigDecimal count = stockMapper.selectSumByProductId(productId); - return count != null ? count : BigDecimal.ZERO; - } - - @Override - public PageResult getStockPage(ErpStockPageReqVO pageReqVO) { - return stockMapper.selectPage(pageReqVO); - } - - @Override - public BigDecimal updateStockCountIncrement(Long productId, Long warehouseId, BigDecimal count) { - // 1.1 查询当前库存 - ErpStockDO stock = stockMapper.selectByProductIdAndWarehouseId(productId, warehouseId); - if (stock == null) { - stock = new ErpStockDO().setProductId(productId).setWarehouseId(warehouseId).setCount(BigDecimal.ZERO); - stockMapper.insert(stock); - } - // 1.2 校验库存是否充足 - if (!NEGATIVE_STOCK_COUNT_ENABLE && stock.getCount().add(count).compareTo(BigDecimal.ZERO) < 0) { - throw exception(STOCK_COUNT_NEGATIVE, productService.getProduct(productId).getName(), - warehouseService.getWarehouse(warehouseId).getName(), stock.getCount(), count); - } - - // 2. 库存变更 - int updateCount = stockMapper.updateCountIncrement(stock.getId(), count, NEGATIVE_STOCK_COUNT_ENABLE); - if (updateCount == 0) { - // 此时不好去查询最新库存,所以直接抛出该提示,不提供具体库存数字 - throw exception(STOCK_COUNT_NEGATIVE2, productService.getProduct(productId).getName(), - warehouseService.getWarehouse(warehouseId).getName()); - } - - // 3. 返回最新库存 - return stock.getCount().add(count); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseService.java deleted file mode 100644 index c9578cf18..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseSaveReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import javax.validation.Valid; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * ERP 仓库 Service 接口 - * - * @author 芋道源码 - */ -public interface ErpWarehouseService { - - /** - * 创建仓库 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createWarehouse(@Valid ErpWarehouseSaveReqVO createReqVO); - - /** - * 更新ERP 仓库 - * - * @param updateReqVO 更新信息 - */ - void updateWarehouse(@Valid ErpWarehouseSaveReqVO updateReqVO); - - /** - * 更新仓库默认状态 - * - * @param id 编号 - * @param defaultStatus 默认状态 - */ - void updateWarehouseDefaultStatus(Long id, Boolean defaultStatus); - - /** - * 删除仓库 - * - * @param id 编号 - */ - void deleteWarehouse(Long id); - - /** - * 获得仓库 - * - * @param id 编号 - * @return 仓库 - */ - ErpWarehouseDO getWarehouse(Long id); - - /** - * 校验仓库列表的有效性 - * - * @param ids 编号数组 - * @return 仓库列表 - */ - List validWarehouseList(Collection ids); - - /** - * 获得指定状态的仓库列表 - * - * @param status 状态 - * @return 仓库列表 - */ - List getWarehouseListByStatus(Integer status); - - /** - * 获得仓库列表 - * - * @param ids 编号数组 - * @return 仓库列表 - */ - List getWarehouseList(Collection ids); - - /** - * 获得仓库 Map - * - * @param ids 编号数组 - * @return 仓库 Map - */ - default Map getWarehouseMap(Collection ids) { - return convertMap(getWarehouseList(ids), ErpWarehouseDO::getId); - } - - /** - * 获得仓库分页 - * - * @param pageReqVO 分页查询 - * @return 仓库分页 - */ - PageResult getWarehousePage(ErpWarehousePageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseServiceImpl.java deleted file mode 100644 index 9e80128dd..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/ErpWarehouseServiceImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseSaveReqVO; -import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO; -import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; -import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpWarehouseMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_NOT_ENABLE; -import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_NOT_EXISTS; - -/** - * ERP 仓库 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ErpWarehouseServiceImpl implements ErpWarehouseService { - - @Resource - private ErpWarehouseMapper warehouseMapper; - - @Override - public Long createWarehouse(ErpWarehouseSaveReqVO createReqVO) { - // 插入 - ErpWarehouseDO warehouse = BeanUtils.toBean(createReqVO, ErpWarehouseDO.class); - warehouseMapper.insert(warehouse); - // 返回 - return warehouse.getId(); - } - - @Override - public void updateWarehouse(ErpWarehouseSaveReqVO updateReqVO) { - // 校验存在 - validateWarehouseExists(updateReqVO.getId()); - // 更新 - ErpWarehouseDO updateObj = BeanUtils.toBean(updateReqVO, ErpWarehouseDO.class); - warehouseMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateWarehouseDefaultStatus(Long id, Boolean defaultStatus) { - // 1. 校验存在 - validateWarehouseExists(id); - - // 2.1 如果开启,则需要关闭所有其它的默认 - if (defaultStatus) { - ErpWarehouseDO warehouse = warehouseMapper.selectByDefaultStatus(); - if (warehouse != null) { - warehouseMapper.updateById(new ErpWarehouseDO().setId(warehouse.getId()).setDefaultStatus(false)); - } - } - // 2.2 更新对应的默认状态 - warehouseMapper.updateById(new ErpWarehouseDO().setId(id).setDefaultStatus(defaultStatus)); - } - - @Override - public void deleteWarehouse(Long id) { - // 校验存在 - validateWarehouseExists(id); - // 删除 - warehouseMapper.deleteById(id); - } - - private void validateWarehouseExists(Long id) { - if (warehouseMapper.selectById(id) == null) { - throw exception(WAREHOUSE_NOT_EXISTS); - } - } - - @Override - public ErpWarehouseDO getWarehouse(Long id) { - return warehouseMapper.selectById(id); - } - - @Override - public List validWarehouseList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - List list = warehouseMapper.selectBatchIds(ids); - Map warehouseMap = convertMap(list, ErpWarehouseDO::getId); - for (Long id : ids) { - ErpWarehouseDO warehouse = warehouseMap.get(id); - if (warehouseMap.get(id) == null) { - throw exception(WAREHOUSE_NOT_EXISTS); - } - if (CommonStatusEnum.isDisable(warehouse.getStatus())) { - throw exception(WAREHOUSE_NOT_ENABLE, warehouse.getName()); - } - } - return list; - } - - @Override - public List getWarehouseListByStatus(Integer status) { - return warehouseMapper.selectListByStatus(status); - } - - @Override - public List getWarehouseList(Collection ids) { - return warehouseMapper.selectBatchIds(ids); - } - - @Override - public PageResult getWarehousePage(ErpWarehousePageReqVO pageReqVO) { - return warehouseMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/bo/ErpStockRecordCreateReqBO.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/bo/ErpStockRecordCreateReqBO.java deleted file mode 100644 index 40c62a4ef..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/stock/bo/ErpStockRecordCreateReqBO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.erp.service.stock.bo; - -import javax.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.math.BigDecimal; - -/** - * 库存明细的创建 Request BO - * - * @author 芋道源码 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ErpStockRecordCreateReqBO { - - /** - * 产品编号 - */ - @NotNull(message = "产品编号不能为空") - private Long productId; - /** - * 仓库编号 - */ - @NotNull(message = "仓库编号不能为空") - private Long warehouseId; - /** - * 出入库数量 - * - * 正数,表示入库;负数,表示出库 - */ - @NotNull(message = "出入库数量不能为空") - private BigDecimal count; - - /** - * 业务类型 - */ - @NotNull(message = "业务类型不能为空") - private Integer bizType; - /** - * 业务编号 - */ - @NotNull(message = "业务编号不能为空") - private Long bizId; - /** - * 业务项编号 - */ - @NotNull(message = "业务项编号不能为空") - private Long bizItemId; - /** - * 业务单号 - */ - @NotNull(message = "业务单号不能为空") - private String bizNo; - -} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application-dev.yaml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index ea9b518b6..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,98 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application-local.yaml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application-local.yaml deleted file mode 100644 index ea9ac953b..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,123 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:8000/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.erp.dal.mysql: debug - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - security: - mock-enable: true - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application.yaml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application.yaml deleted file mode 100644 index 59a1f84b3..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,107 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.erp - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - -debug: false diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/bootstrap.yaml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 70de21db1..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: erp-server - - profiles: - active: local - -server: - port: 48088 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/logback-spring.xml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/statistics/ErpPurchaseStatisticsMapper.xml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/statistics/ErpPurchaseStatisticsMapper.xml deleted file mode 100644 index e2b25992a..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/statistics/ErpPurchaseStatisticsMapper.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/statistics/ErpSaleStatisticsMapper.xml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/statistics/ErpSaleStatisticsMapper.xml deleted file mode 100644 index 8e74606c9..000000000 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/statistics/ErpSaleStatisticsMapper.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-mall/pom.xml b/yudao-module-mall/pom.xml deleted file mode 100644 index 8cb649739..000000000 --- a/yudao-module-mall/pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - yudao - cn.iocoder.cloud - ${revision} - - 4.0.0 - - yudao-module-mall - pom - - ${project.artifactId} - - - 商城大模块,由 product 商品、promotion 营销、trade 交易、statistics 统计等组成 - - - yudao-module-promotion-api - yudao-module-promotion-biz - yudao-module-product-api - yudao-module-product-biz - yudao-module-trade-api - yudao-module-trade-biz - yudao-module-statistics-api - yudao-module-statistics-biz - - - diff --git a/yudao-module-mall/yudao-module-product-api/pom.xml b/yudao-module-mall/yudao-module-product-api/pom.xml deleted file mode 100644 index 3404a06d0..000000000 --- a/yudao-module-mall/yudao-module-product-api/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - 4.0.0 - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - - yudao-module-product-api - jar - - ${project.artifactId} - - product 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApi.java deleted file mode 100644 index 5e58b0483..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApi.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.product.api.category; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.Collection; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 商品分类") -public interface ProductCategoryApi { - - String PREFIX = ApiConstants.PREFIX + "/category"; - - @GetMapping(PREFIX + "/valid") - @Operation(summary = "校验部门是否合法") - @Parameter(name = "ids", description = "商品分类编号数组", example = "1,2", required = true) - CommonResult validateCategoryList(@RequestParam("ids") Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java deleted file mode 100644 index fe4d00ade..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApi.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.api.comment; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 产品评论") -public interface ProductCommentApi { - - String PREFIX = ApiConstants.PREFIX + "/comment"; - - @PostMapping(PREFIX + "/create") - @Operation(summary = "创建评论") - CommonResult createComment(@RequestBody @Valid ProductCommentCreateReqDTO createReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/ProductCommentCreateReqDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/ProductCommentCreateReqDTO.java deleted file mode 100644 index 158ab1dc4..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/comment/dto/ProductCommentCreateReqDTO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.product.api.comment.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "RPC 服务 - 商品评论创建 Request DTO") -@Data -public class ProductCommentCreateReqDTO { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - @Schema(description = "订单编号", example = "223") - private Long orderId; - @Schema(description = "交易订单项编号", example = "666") - private Long orderItemId; - - @Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "描述星级不能为空") - private Integer descriptionScores; - @Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "服务星级不能为空") - private Integer benefitScores; - @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "好评") - @NotNull(message = "评论内容不能为空") - private String content; - @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", example = "https://www.iocoder.cn/xxx.jpg,http://www.iocoder.cn/yyy.jpg") - private List picUrls; - - @Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否匿名不能为空") - private Boolean anonymous; - @Schema(description = "评价人", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - @NotNull(message = "评价人不能为空") - private Long userId; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java deleted file mode 100644 index b19092853..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.product.api; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/dto/ProductPropertyValueDetailRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/dto/ProductPropertyValueDetailRespDTO.java deleted file mode 100644 index ed32028cc..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/dto/ProductPropertyValueDetailRespDTO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.product.api.property.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "RPC 服务 - 商品属性项的明细 Response DTO") -@Data -public class ProductPropertyValueDetailRespDTO { - - @Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long propertyId; - @Schema(description = "属性的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String propertyName; - - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long valueId; - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java deleted file mode 100644 index 7f365e7bc..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApi.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 商品 SKU") -public interface ProductSkuApi { - - String PREFIX = ApiConstants.PREFIX + "/sku"; - - @GetMapping(PREFIX + "/get") - @Operation(summary = "查询 SKU 信息") - @Parameter(name = "id", description = "SKU 编号", required = true, example = "1024") - CommonResult getSku(@RequestParam("id") Long id); - - @GetMapping(PREFIX + "/list") - @Operation(summary = "批量查询 SKU 信息") - @Parameter(name = "ids", description = "SKU 编号列表", required = true, example = "1024,2048") - CommonResult> getSkuList(@RequestParam("ids") Collection ids); - - @GetMapping(PREFIX + "/list-by-spu-id") - @Operation(summary = "批量查询 SKU 信息") - @Parameter(name = "spuIds", description = "SPU 编号列表", required = true, example = "1024,2048") - CommonResult> getSkuListBySpuId(@RequestParam("spuIds") Collection spuIds); - - @PostMapping(PREFIX + "/update-stock") - @Operation(summary = "更新 SKU 库存(增加 or 减少)") - CommonResult updateSkuStock(@RequestBody @Valid ProductSkuUpdateStockReqDTO updateStockReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java deleted file mode 100644 index 149bcd276..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuRespDTO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku.dto; - -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "RPC 服务 - 商品 SKU 信息 Response DTO") -@Data -public class ProductSkuRespDTO { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - @Schema(description = "SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "属性数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List properties; - - @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - @Schema(description = "市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer marketPrice; - @Schema(description = "成本价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "300") - private Integer costPrice; - @Schema(description = "SKU 的条形码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456789") - private String barCode; - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String picUrl; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer stock; - @Schema(description = "商品重量,单位:kg 千克", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.5") - private Double weight; - @Schema(description = "商品体积,单位:m^3 平米", requiredMode = Schema.RequiredMode.REQUIRED, example = "3.0") - private Double volume; - - @Schema(description = "一级分销的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "550") - private Integer firstBrokeragePrice; - @Schema(description = "二级分销的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "250") - private Integer secondBrokeragePrice; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuUpdateStockReqDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuUpdateStockReqDTO.java deleted file mode 100644 index 0b1c63aca..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/sku/dto/ProductSkuUpdateStockReqDTO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "RPC 服务 - 商品 SKU 更新库存 Request DTO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ProductSkuUpdateStockReqDTO { - - @Schema(description = "商品 SKU 数组", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "商品 SKU 不能为空") - private List items; - - @Data - public static class Item { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "商品 SKU 编号不能为空") - private Long id; - - @Schema(description = "库存变化数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "库存变化数量不能为空") - private Integer incrCount; // 正数:增加库存;负数:扣减库存 - - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java deleted file mode 100644 index cc381c23e..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApi.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.product.api.spu; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.Collection; -import java.util.List; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 商品 SPU") -public interface ProductSpuApi { - - String PREFIX = ApiConstants.PREFIX + "/spu"; - - @GetMapping(PREFIX + "/list") - @Schema(description = "批量查询 SPU 数组") - @Parameter(name = "ids", description = "SPU 编号列表", required = true, example = "1,3,5") - CommonResult> getSpuList(@RequestParam("ids") Collection ids); - - @GetMapping(PREFIX + "/valid") - @Schema(description = "批量查询 SPU 数组,并且校验是否 SPU 是否有效") - @Parameter(name = "ids", description = "SPU 编号列表", required = true, example = "1,3,5") - CommonResult> validateSpuList(@RequestParam("ids") Collection ids); - - @GetMapping(PREFIX + "/get") - @Schema(description = "获得 SPU") - @Parameter(name = "id", description = "SPU 编号", required = true, example = "1") - CommonResult getSpu(@RequestParam("id") Long id); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java deleted file mode 100644 index 078c20d6e..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.product.api.spu.dto; - -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import lombok.Data; - -// TODO @LeeYan9: ProductSpuRespDTO - -/** - * 商品 SPU 信息 Response DTO - * - * @author LeeYan9 - * @since 2022-08-26 - */ -@Data -public class ProductSpuRespDTO { - - /** - * 商品 SPU 编号,自增 - */ - private Long id; - - // ========== 基本信息 ========= - - /** - * 商品名称 - */ - private String name; - /** - * 单位 - * - * 对应 product_unit 数据字典 - */ - private Integer unit; - - /** - * 商品分类编号 - */ - private Long categoryId; - /** - * 商品封面图 - */ - private String picUrl; - - /** - * 商品状态 - *

- * 枚举 {@link ProductSpuStatusEnum} - */ - private Integer status; - - // ========== SKU 相关字段 ========= - - /** - * 规格类型 - * - * false - 单规格 - * true - 多规格 - */ - private Boolean specType; - /** - * 商品价格,单位使用:分 - */ - private Integer price; - /** - * 市场价,单位使用:分 - */ - private Integer marketPrice; - /** - * 成本价,单位使用:分 - */ - private Integer costPrice; - /** - * 库存 - */ - private Integer stock; - - // ========== 物流相关字段 ========= - - /** - * 物流配置模板编号 - * - * 对应 TradeDeliveryExpressTemplateDO 的 id 编号 - */ - private Long deliveryTemplateId; - - // ========== 营销相关字段 ========= - - /** - * 赠送积分 - */ - private Integer giveIntegral; - - // ========== 分销相关字段 ========= - - /** - * 分销类型 - * - * false - 默认 - * true - 自行设置 - */ - private Boolean subCommissionType; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ApiConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ApiConstants.java deleted file mode 100644 index 1846e69da..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.product.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "product-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/product"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/DictTypeConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/DictTypeConstants.java deleted file mode 100644 index b96dde169..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/DictTypeConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.product.enums; - -/** - * product 字典类型的枚举类 - * - * @author HUIHUI - */ -public interface DictTypeConstants { - - String PRODUCT_SPU_STATUS = "product_spu_status"; // 商品 SPU 状态 - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java deleted file mode 100644 index 1d0ea189f..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.product.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Product 错误码枚举类 - * - * product 系统,使用 1-008-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 商品分类相关 1-008-001-000 ============ - ErrorCode CATEGORY_NOT_EXISTS = new ErrorCode(1_008_001_000, "商品分类不存在"); - ErrorCode CATEGORY_PARENT_NOT_EXISTS = new ErrorCode(1_008_001_001, "父分类不存在"); - ErrorCode CATEGORY_PARENT_NOT_FIRST_LEVEL = new ErrorCode(1_008_001_002, "父分类不能是二级分类"); - ErrorCode CATEGORY_EXISTS_CHILDREN = new ErrorCode(1_008_001_003, "存在子分类,无法删除"); - ErrorCode CATEGORY_DISABLED = new ErrorCode(1_008_001_004, "商品分类({})已禁用,无法使用"); - ErrorCode CATEGORY_HAVE_BIND_SPU = new ErrorCode(1_008_001_005, "类别下存在商品,无法删除"); - - // ========== 商品品牌相关编号 1-008-002-000 ========== - ErrorCode BRAND_NOT_EXISTS = new ErrorCode(1_008_002_000, "品牌不存在"); - ErrorCode BRAND_DISABLED = new ErrorCode(1_008_002_001, "品牌已禁用"); - ErrorCode BRAND_NAME_EXISTS = new ErrorCode(1_008_002_002, "品牌名称已存在"); - - // ========== 商品属性项 1-008-003-000 ========== - ErrorCode PROPERTY_NOT_EXISTS = new ErrorCode(1_008_003_000, "属性项不存在"); - ErrorCode PROPERTY_EXISTS = new ErrorCode(1_008_003_001, "属性项的名称已存在"); - ErrorCode PROPERTY_DELETE_FAIL_VALUE_EXISTS = new ErrorCode(1_008_003_002, "属性项下存在属性值,无法删除"); - - // ========== 商品属性值 1-008-004-000 ========== - ErrorCode PROPERTY_VALUE_NOT_EXISTS = new ErrorCode(1_008_004_000, "属性值不存在"); - ErrorCode PROPERTY_VALUE_EXISTS = new ErrorCode(1_008_004_001, "属性值的名称已存在"); - - // ========== 商品 SPU 1-008-005-000 ========== - ErrorCode SPU_NOT_EXISTS = new ErrorCode(1_008_005_000, "商品 SPU 不存在"); - ErrorCode SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR = new ErrorCode(1_008_005_001, "商品分类不正确,原因:必须使用第二级的商品分类及以下"); - ErrorCode SPU_SAVE_FAIL_COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1_008_005_002, "商品 SPU 保存失败,原因:优惠卷不存在"); - ErrorCode SPU_NOT_ENABLE = new ErrorCode(1_008_005_003, "商品 SPU【{}】不处于上架状态"); - ErrorCode SPU_NOT_RECYCLE = new ErrorCode(1_008_005_004, "商品 SPU 不处于回收站状态"); - - // ========== 商品 SKU 1-008-006-000 ========== - ErrorCode SKU_NOT_EXISTS = new ErrorCode(1_008_006_000, "商品 SKU 不存在"); - ErrorCode SKU_PROPERTIES_DUPLICATED = new ErrorCode(1_008_006_001, "商品 SKU 的属性组合存在重复"); - ErrorCode SPU_ATTR_NUMBERS_MUST_BE_EQUALS = new ErrorCode(1_008_006_002, "一个 SPU 下的每个 SKU,其属性项必须一致"); - ErrorCode SPU_SKU_NOT_DUPLICATE = new ErrorCode(1_008_006_003, "一个 SPU 下的每个 SKU,必须不重复"); - ErrorCode SKU_STOCK_NOT_ENOUGH = new ErrorCode(1_008_006_004, "商品 SKU 库存不足"); - - // ========== 商品 评价 1-008-007-000 ========== - ErrorCode COMMENT_NOT_EXISTS = new ErrorCode(1_008_007_000, "商品评价不存在"); - ErrorCode COMMENT_ORDER_EXISTS = new ErrorCode(1_008_007_001, "订单的商品评价已存在"); - - // ========== 商品 收藏 1-008-008-000 ========== - ErrorCode FAVORITE_EXISTS = new ErrorCode(1_008_008_000, "该商品已经被收藏"); - ErrorCode FAVORITE_NOT_EXISTS = new ErrorCode(1_008_008_001, "商品收藏不存在"); - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ProductConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ProductConstants.java deleted file mode 100644 index f3570c589..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ProductConstants.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.product.enums; - -/** - * Product 常量 - * - * @author HUIHUI - */ -public interface ProductConstants { - - /** - * 警戒库存 TODO 警戒库存暂时为 10,后期需要使用常量或者数据库配置替换 - */ - int ALERT_STOCK = 10; - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java deleted file mode 100644 index 276839daf..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentAuditStatusEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.comment; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 商品评论的审批状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum ProductCommentAuditStatusEnum implements IntArrayValuable { - - NONE(1, "待审核"), - APPROVE(2, "审批通过"), - REJECT(2, "审批不通过"),; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCommentAuditStatusEnum::getStatus).toArray(); - - /** - * 审批状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentScoresEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentScoresEnum.java deleted file mode 100644 index a114e1ab8..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/comment/ProductCommentScoresEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.comment; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 商品评论的星级枚举 - * - * @author wangzhs - */ -@Getter -@AllArgsConstructor -public enum ProductCommentScoresEnum implements IntArrayValuable { - - ONE(1, "1星"), - TWO(2, "2星"), - THREE(3, "3星"), - FOUR(4, "4星"), - FIVE(5, "5星"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCommentScoresEnum::getScores).toArray(); - - /** - * 星级 - */ - private final Integer scores; - - /** - * 星级名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java deleted file mode 100644 index 4ba6124e0..000000000 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/spu/ProductSpuStatusEnum.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.product.enums.spu; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 商品 SPU 状态 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum ProductSpuStatusEnum implements IntArrayValuable { - - RECYCLE(-1, "回收站"), - DISABLE(0, "下架"), - ENABLE(1, "上架"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductSpuStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - /** - * 判断是否处于【上架】状态 - * - * @param status 状态 - * @return 是否处于【上架】状态 - */ - public static boolean isEnable(Integer status) { - return ENABLE.getStatus().equals(status); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/Dockerfile b/yudao-module-mall/yudao-module-product-biz/Dockerfile deleted file mode 100644 index c375d0d56..000000000 --- a/yudao-module-mall/yudao-module-product-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-product-biz -WORKDIR /yudao-module-product-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-product-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48100 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-mall/yudao-module-product-biz/pom.xml b/yudao-module-mall/yudao-module-product-biz/pom.xml deleted file mode 100644 index 7295e2153..000000000 --- a/yudao-module-mall/yudao-module-product-biz/pom.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-product-biz - jar - - ${project.artifactId} - - product 模块,主要实现商品相关功能 - 例如:品牌、商品分类、spu、sku等功能。 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-product-api - ${revision} - - - cn.iocoder.cloud - yudao-module-member-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-web - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/ProductServerApplication.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/ProductServerApplication.java deleted file mode 100644 index 651481ba0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/ProductServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class ProductServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(ProductServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApiImpl.java deleted file mode 100644 index cd8e141f0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/category/ProductCategoryApiImpl.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.product.api.category; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collection; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 商品分类 API 接口实现类 - * - * @author owen - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class ProductCategoryApiImpl implements ProductCategoryApi { - - @Resource - private ProductCategoryService productCategoryService; - - @Override - public CommonResult validateCategoryList(Collection ids) { - productCategoryService.validateCategoryList(ids); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java deleted file mode 100644 index 37bcdc4d6..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/comment/ProductCommentApiImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product.api.comment; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 商品评论 API 实现类 - * - * @author HUIHUI - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class ProductCommentApiImpl implements ProductCommentApi { - - @Resource - private ProductCommentService productCommentService; - - @Override - public CommonResult createComment(ProductCommentCreateReqDTO createReqDTO) { - return success(productCommentService.createComment(createReqDTO)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java deleted file mode 100644 index 162453c3c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.product.api; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java deleted file mode 100644 index 41d1506b3..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.product.api.sku; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 商品 SKU API 实现类 - * - * @author LeeYan9 - * @since 2022-09-06 - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class ProductSkuApiImpl implements ProductSkuApi { - - @Resource - private ProductSkuService productSkuService; - - @Override - public CommonResult getSku(Long id) { - ProductSkuDO sku = productSkuService.getSku(id); - return success(BeanUtils.toBean(sku, ProductSkuRespDTO.class)); - } - - @Override - public CommonResult> getSkuList(Collection ids) { - List skus = productSkuService.getSkuList(ids); - return success(BeanUtils.toBean(skus, ProductSkuRespDTO.class)); - } - - @Override - public CommonResult> getSkuListBySpuId(Collection spuIds) { - List skus = productSkuService.getSkuListBySpuId(spuIds); - return success(BeanUtils.toBean(skus, ProductSkuRespDTO.class)); - } - - @Override - public CommonResult updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO) { - productSkuService.updateSkuStock(updateStockReqDTO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java deleted file mode 100644 index 890f4f8a9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.product.api.spu; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 商品 SPU API 接口实现类 - * - * @author LeeYan9 - * @since 2022-09-06 - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class ProductSpuApiImpl implements ProductSpuApi { - - @Resource - private ProductSpuService spuService; - - @Override - public CommonResult> getSpuList(Collection ids) { - List spus = spuService.getSpuList(ids); - return success(BeanUtils.toBean(spus, ProductSpuRespDTO.class)); - } - - @Override - public CommonResult> validateSpuList(Collection ids) { - List spus = spuService.validateSpuList(ids); - return success(BeanUtils.toBean(spus, ProductSpuRespDTO.class)); - } - - @Override - public CommonResult getSpu(Long id) { - ProductSpuDO spu = spuService.getSpu(id); - return success(BeanUtils.toBean(spu, ProductSpuRespDTO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java deleted file mode 100644 index a7c954124..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.*; -import cn.iocoder.yudao.module.product.convert.brand.ProductBrandConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品品牌") -@RestController -@RequestMapping("/product/brand") -@Validated -public class ProductBrandController { - - @Resource - private ProductBrandService brandService; - - @PostMapping("/create") - @Operation(summary = "创建品牌") - @PreAuthorize("@ss.hasPermission('product:brand:create')") - public CommonResult createBrand(@Valid @RequestBody ProductBrandCreateReqVO createReqVO) { - return success(brandService.createBrand(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新品牌") - @PreAuthorize("@ss.hasPermission('product:brand:update')") - public CommonResult updateBrand(@Valid @RequestBody ProductBrandUpdateReqVO updateReqVO) { - brandService.updateBrand(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除品牌") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:brand:delete')") - public CommonResult deleteBrand(@RequestParam("id") Long id) { - brandService.deleteBrand(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得品牌") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:brand:query')") - public CommonResult getBrand(@RequestParam("id") Long id) { - ProductBrandDO brand = brandService.getBrand(id); - return success(ProductBrandConvert.INSTANCE.convert(brand)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取品牌精简信息列表", description = "主要用于前端的下拉选项") - public CommonResult> getSimpleBrandList() { - // 获取品牌列表,只要开启状态的 - List list = brandService.getBrandListByStatus(CommonStatusEnum.ENABLE.getStatus()); - // 排序后,返回给前端 - return success(ProductBrandConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得品牌分页") - @PreAuthorize("@ss.hasPermission('product:brand:query')") - public CommonResult> getBrandPage(@Valid ProductBrandPageReqVO pageVO) { - PageResult pageResult = brandService.getBrandPage(pageVO); - return success(ProductBrandConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list") - @Operation(summary = "获得品牌列表") - @PreAuthorize("@ss.hasPermission('product:brand:query')") - public CommonResult> getBrandList(@Valid ProductBrandListReqVO listVO) { - List list = brandService.getBrandList(listVO); - list.sort(Comparator.comparing(ProductBrandDO::getSort)); - return success(ProductBrandConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java deleted file mode 100644 index a148d52de..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** -* 商品品牌 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class ProductBrandBaseVO { - - @Schema(description = "品牌名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果") - @NotNull(message = "品牌名称不能为空") - private String name; - - @Schema(description = "品牌图片", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "品牌图片不能为空") - private String picUrl; - - @Schema(description = "品牌排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "品牌排序不能为空") - private Integer sort; - - @Schema(description = "品牌描述", example = "描述") - private String description; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java deleted file mode 100644 index dc85a476b..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品品牌创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandCreateReqVO extends ProductBrandBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java deleted file mode 100644 index ed93ff090..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 商品品牌分页 Request VO") -@Data -public class ProductBrandListReqVO { - - @Schema(description = "品牌名称", example = "苹果") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java deleted file mode 100644 index 3a6efc93f..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品品牌分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandPageReqVO extends PageParam { - - @Schema(description = "品牌名称", example = "苹果") - private String name; - - @Schema(description = "状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java deleted file mode 100644 index 486fe764b..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 品牌 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandRespVO extends ProductBrandBaseVO { - - @Schema(description = "品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandSimpleRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandSimpleRespVO.java deleted file mode 100644 index 6379a5fb1..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandSimpleRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - 品牌精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ProductBrandSimpleRespVO { - - @Schema(description = "品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "品牌名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "苹果") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java deleted file mode 100644 index a39a6830d..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.brand.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品品牌更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrandUpdateReqVO extends ProductBrandBaseVO { - - @Schema(description = "品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "品牌编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java deleted file mode 100644 index d2343e81a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryRespVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategorySaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品分类") -@RestController -@RequestMapping("/product/category") -@Validated -public class ProductCategoryController { - - @Resource - private ProductCategoryService categoryService; - - @PostMapping("/create") - @Operation(summary = "创建商品分类") - @PreAuthorize("@ss.hasPermission('product:category:create')") - public CommonResult createCategory(@Valid @RequestBody ProductCategorySaveReqVO createReqVO) { - return success(categoryService.createCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新商品分类") - @PreAuthorize("@ss.hasPermission('product:category:update')") - public CommonResult updateCategory(@Valid @RequestBody ProductCategorySaveReqVO updateReqVO) { - categoryService.updateCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商品分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('product:category:delete')") - public CommonResult deleteCategory(@RequestParam("id") Long id) { - categoryService.deleteCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得商品分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:category:query')") - public CommonResult getCategory(@RequestParam("id") Long id) { - ProductCategoryDO category = categoryService.getCategory(id); - return success(BeanUtils.toBean(category, ProductCategoryRespVO.class)); - } - - @GetMapping("/list") - @Operation(summary = "获得商品分类列表") - @PreAuthorize("@ss.hasPermission('product:category:query')") - public CommonResult> getCategoryList(@Valid ProductCategoryListReqVO listReqVO) { - List list = categoryService.getCategoryList(listReqVO); - list.sort(Comparator.comparing(ProductCategoryDO::getSort)); - return success(BeanUtils.toBean(list, ProductCategoryRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java deleted file mode 100644 index 9e5364c90..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.Collection; - -@Schema(description = "管理后台 - 商品分类列表查询 Request VO") -@Data -public class ProductCategoryListReqVO { - - @Schema(description = "分类名称", example = "办公文具") - private String name; - - @Schema(description = "开启状态", example = "0") - private Integer status; - - @Schema(description = "父分类编号", example = "1") - private Long parentId; - - @Schema(description = "父分类编号数组", example = "1,2,3") - private Collection parentIds; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java deleted file mode 100644 index c8ef92e17..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 商品分类 Response VO") -@Data -public class ProductCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Long id; - - @Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long parentId; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "办公文具") - private String name; - - @Schema(description = "移动端分类图", requiredMode = Schema.RequiredMode.REQUIRED) - private String picUrl; - - @Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sort; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "分类描述", example = "描述") - private String description; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategorySaveReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategorySaveReqVO.java deleted file mode 100644 index a637fde6c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategorySaveReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品分类新增/更新 Request VO") -@Data -public class ProductCategorySaveReqVO { - - @Schema(description = "分类编号", example = "2") - private Long id; - - @Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "父分类编号不能为空") - private Long parentId; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "办公文具") - @NotBlank(message = "分类名称不能为空") - private String name; - - @Schema(description = "移动端分类图", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "移动端分类图不能为空") - private String picUrl; - - @Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sort; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "开启状态不能为空") - private Integer status; - - @Schema(description = "分类描述", example = "描述") - private String description; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.http deleted file mode 100644 index e69de29bb..000000000 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java deleted file mode 100644 index ea74713f0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.*; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 商品评价") -@RestController -@RequestMapping("/product/comment") -@Validated -public class ProductCommentController { - - @Resource - private ProductCommentService productCommentService; - - @GetMapping("/page") - @Operation(summary = "获得商品评价分页") - @PreAuthorize("@ss.hasPermission('product:comment:query')") - public CommonResult> getCommentPage(@Valid ProductCommentPageReqVO pageVO) { - PageResult pageResult = productCommentService.getCommentPage(pageVO); - return success(BeanUtils.toBean(pageResult, ProductCommentRespVO.class)); - } - - @PutMapping("/update-visible") - @Operation(summary = "显示 / 隐藏评论") - @PreAuthorize("@ss.hasPermission('product:comment:update')") - public CommonResult updateCommentVisible(@Valid @RequestBody ProductCommentUpdateVisibleReqVO updateReqVO) { - productCommentService.updateCommentVisible(updateReqVO); - return success(true); - } - - @PutMapping("/reply") - @Operation(summary = "商家回复") - @PreAuthorize("@ss.hasPermission('product:comment:update')") - public CommonResult commentReply(@Valid @RequestBody ProductCommentReplyReqVO replyVO) { - productCommentService.replyComment(replyVO, getLoginUserId()); - return success(true); - } - - @PostMapping("/create") - @Operation(summary = "添加自评") - @PreAuthorize("@ss.hasPermission('product:comment:update')") - public CommonResult createComment(@Valid @RequestBody ProductCommentCreateReqVO createReqVO) { - productCommentService.createComment(createReqVO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentCreateReqVO.java deleted file mode 100644 index 8fd8e64e9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentCreateReqVO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.List; - -@Schema(description = "管理后台 - 商品评价创建 Request VO") -@Data -public class ProductCommentCreateReqVO { - - @Schema(description = "评价人", requiredMode = Schema.RequiredMode.REQUIRED, example = "16868") - private Long userId; - - @Schema(description = "评价订单项", requiredMode = Schema.RequiredMode.REQUIRED, example = "19292") - private Long orderItemId; - - @Schema(description = "评价人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小姑凉") - @NotNull(message = "评价人名称不能为空") - private String userNickname; - - @Schema(description = "评价人头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - @NotNull(message = "评价人头像不能为空") - private String userAvatar; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "描述星级不能为空") - private Integer descriptionScores; - - @Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "服务星级分不能为空") - private Integer benefitScores; - - @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "穿起来非常丝滑凉快") - @NotNull(message = "评论内容不能为空") - private String content; - - @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, - example = "[https://www.iocoder.cn/xx.png]") - @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") - private List picUrls; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentPageReqVO.java deleted file mode 100644 index 3791f572e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentPageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.product.enums.comment.ProductCommentScoresEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品评价分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductCommentPageReqVO extends PageParam { - - @Schema(description = "评价人名称", example = "王二狗") - private String userNickname; - - @Schema(description = "交易订单编号", example = "24428") - private Long orderId; - - @Schema(description = "商品SPU编号", example = "29502") - private Long spuId; - - @Schema(description = "商品SPU名称", example = "感冒药") - private String spuName; - - @Schema(description = "评分星级 1-5 分", example = "5") - @InEnum(ProductCommentScoresEnum.class) - private Integer scores; - - @Schema(description = "商家是否回复", example = "true") - private Boolean replyStatus; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentReplyReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentReplyReqVO.java deleted file mode 100644 index 97ad39d7a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentReplyReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品评价的商家回复 Request VO") -@Data -@ToString(callSuper = true) -public class ProductCommentReplyReqVO { - - @Schema(description = "评价编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") - @NotNull(message = "评价编号不能为空") - private Long id; - - @Schema(description = "商家回复内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "谢谢亲") - @NotEmpty(message = "商家回复内容不能为空") - private String replyContent; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java deleted file mode 100644 index 605019a19..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 商品评价 Response VO") -@Data -public class ProductCommentRespVO { - - @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24965") - private Long id; - - @Schema(description = "评价人", requiredMode = Schema.RequiredMode.REQUIRED, example = "16868") - private Long userId; - - @Schema(description = "评价人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小姑凉") - private String userNickname; - - @Schema(description = "评价人头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - private String userAvatar; - @Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean anonymous; - - @Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24428") - private Long orderId; - - @Schema(description = "评价订单项", requiredMode = Schema.RequiredMode.REQUIRED, example = "19292") - private Long orderItemId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑透气小短袖") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long skuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private String spuName; - - @Schema(description = "商品 SKU 图片地址", example = "https://www.iocoder.cn/yudao.jpg") - private String skuPicUrl; - - @Schema(description = "商品 SKU 规格值数组") - private List skuProperties; - - @Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED) - private Boolean visible; - - @Schema(description = "评分星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer scores; - - @Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer descriptionScores; - - @Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer benefitScores; - - @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "穿起来非常丝滑凉快") - private String content; - - @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]") - private List picUrls; - - @Schema(description = "商家是否回复", requiredMode = Schema.RequiredMode.REQUIRED) - private Boolean replyStatus; - - @Schema(description = "回复管理员编号", example = "9527") - private Long replyUserId; - - @Schema(description = "商家回复内容", example = "感谢好评哦亲(づ ̄3 ̄)づ╭❤~") - private String replyContent; - - @Schema(description = "商家回复时间", example = "2023-08-08 12:20:55") - private LocalDateTime replyTime; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentUpdateVisibleReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentUpdateVisibleReqVO.java deleted file mode 100644 index c88fbaf34..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentUpdateVisibleReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.comment.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品评价可见修改 Request VO") -@Data -@ToString(callSuper = true) -public class ProductCommentUpdateVisibleReqVO { - - @Schema(description = "评价编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") - @NotNull(message = "评价编号不能为空") - private Long id; - - @Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - @NotNull(message = "是否可见不能为空") - private Boolean visible; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/ProductFavoriteController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/ProductFavoriteController.java deleted file mode 100644 index 721cf19c0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/ProductFavoriteController.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoriteRespVO; -import cn.iocoder.yudao.module.product.convert.favorite.ProductFavoriteConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.service.favorite.ProductFavoriteService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 商品收藏") -@RestController -@RequestMapping("/product/favorite") -@Validated -public class ProductFavoriteController { - - @Resource - private ProductFavoriteService productFavoriteService; - - @Resource - private ProductSpuService productSpuService; - - @GetMapping("/page") - @Operation(summary = "获得商品收藏分页") - @PreAuthorize("@ss.hasPermission('product:favorite:query')") - public CommonResult> getFavoritePage(@Valid ProductFavoritePageReqVO pageVO) { - PageResult pageResult = productFavoriteService.getFavoritePage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - // 拼接数据 - List spuList = productSpuService.getSpuList(convertSet(pageResult.getList(), ProductFavoriteDO::getSpuId)); - return success(ProductFavoriteConvert.INSTANCE.convertPage(pageResult, spuList)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteBaseVO.java deleted file mode 100644 index 68b0a0a16..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteBaseVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 商品收藏 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class ProductFavoriteBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5036") - @NotNull(message = "用户编号不能为空") - private Long userId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoritePageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoritePageReqVO.java deleted file mode 100644 index 3d78883ec..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoritePageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品收藏分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductFavoritePageReqVO extends PageParam { - - @Schema(description = "用户编号", example = "5036") - private Long userId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteReqVO.java deleted file mode 100644 index 3c2222643..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品收藏的单个 Response VO") -@Data -@ToString(callSuper = true) -public class ProductFavoriteReqVO extends ProductFavoriteBaseVO { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32734") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteRespVO.java deleted file mode 100644 index 3c09aa8fc..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/favorite/vo/ProductFavoriteRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.favorite.vo; - -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品收藏 Response VO") -@Data -@ToString(callSuper = true) -public class ProductFavoriteRespVO extends ProductSpuRespVO { - - @Schema(description = "userId", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - private Long userId; - - @Schema(description = "spuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java deleted file mode 100644 index e0d47f409..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/ProductBrowseHistoryController.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.history; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO; -import cn.iocoder.yudao.module.product.service.history.ProductBrowseHistoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品浏览记录") -@RestController -@RequestMapping("/product/browse-history") -@Validated -public class ProductBrowseHistoryController { - - @Resource - private ProductBrowseHistoryService browseHistoryService; - - @GetMapping("/page") - @Operation(summary = "获得商品浏览记录分页") - @PreAuthorize("@ss.hasPermission('product:browse-history:query')") - public CommonResult> getBrowseHistoryPage(@Valid ProductBrowseHistoryPageReqVO pageReqVO) { - PageResult pageResult = browseHistoryService.getBrowseHistoryPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ProductBrowseHistoryRespVO.class)); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryPageReqVO.java deleted file mode 100644 index aa3010212..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryPageReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.history.vo; - -import cn.iocoder.yudao.framework.common.pojo.SortablePageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品浏览记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductBrowseHistoryPageReqVO extends SortablePageParam { - - @Schema(description = "用户编号", example = "4314") - private Long userId; - - @Schema(description = "用户是否删除", example = "false") - private Boolean userDeleted; - - @Schema(description = "商品 SPU 编号", example = "42") - private Long spuId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java deleted file mode 100644 index 0e2e0cbed..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/history/vo/ProductBrowseHistoryRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.history.vo; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 商品浏览记录 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ProductBrowseHistoryRespVO { - - @Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "26055") - @ExcelProperty("记录编号") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4314") - @ExcelProperty("用户编号") - private Long userId; - - @Schema(description = "用户是否删除", example = "false") - private Boolean userDeleted; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "42") - @ExcelProperty("商品 SPU 编号") - private Long spuId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java deleted file mode 100644 index ee9bf556e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyRespVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertySaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品属性项") -@RestController -@RequestMapping("/product/property") -@Validated -public class ProductPropertyController { - - @Resource - private ProductPropertyService productPropertyService; - - @PostMapping("/create") - @Operation(summary = "创建属性项") - @PreAuthorize("@ss.hasPermission('product:property:create')") - public CommonResult createProperty(@Valid @RequestBody ProductPropertySaveReqVO createReqVO) { - return success(productPropertyService.createProperty(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新属性项") - @PreAuthorize("@ss.hasPermission('product:property:update')") - public CommonResult updateProperty(@Valid @RequestBody ProductPropertySaveReqVO updateReqVO) { - productPropertyService.updateProperty(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除属性项") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('product:property:delete')") - public CommonResult deleteProperty(@RequestParam("id") Long id) { - productPropertyService.deleteProperty(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得属性项") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult getProperty(@RequestParam("id") Long id) { - ProductPropertyDO property = productPropertyService.getProperty(id); - return success(BeanUtils.toBean(property, ProductPropertyRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得属性项分页") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyPage(@Valid ProductPropertyPageReqVO pageVO) { - PageResult pageResult = productPropertyService.getPropertyPage(pageVO); - return success(BeanUtils.toBean(pageResult, ProductPropertyRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java deleted file mode 100644 index d372a63da..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueSaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 商品属性值") -@RestController -@RequestMapping("/product/property/value") -@Validated -public class ProductPropertyValueController { - - @Resource - private ProductPropertyValueService productPropertyValueService; - - @PostMapping("/create") - @Operation(summary = "创建属性值") - @PreAuthorize("@ss.hasPermission('product:property:create')") - public CommonResult createPropertyValue(@Valid @RequestBody ProductPropertyValueSaveReqVO createReqVO) { - return success(productPropertyValueService.createPropertyValue(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新属性值") - @PreAuthorize("@ss.hasPermission('product:property:update')") - public CommonResult updatePropertyValue(@Valid @RequestBody ProductPropertyValueSaveReqVO updateReqVO) { - productPropertyValueService.updatePropertyValue(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除属性值") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:property:delete')") - public CommonResult deletePropertyValue(@RequestParam("id") Long id) { - productPropertyValueService.deletePropertyValue(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得属性值") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult getPropertyValue(@RequestParam("id") Long id) { - ProductPropertyValueDO value = productPropertyValueService.getPropertyValue(id); - return success(BeanUtils.toBean(value, ProductPropertyValueRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得属性值分页") - @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyValuePage(@Valid ProductPropertyValuePageReqVO pageVO) { - PageResult pageResult = productPropertyValueService.getPropertyValuePage(pageVO); - return success(BeanUtils.toBean(pageResult, ProductPropertyValueRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java deleted file mode 100644 index 97b959d6a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 属性项 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyPageReqVO extends PageParam { - - @Schema(description = "名称", example = "颜色") - private String name; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java deleted file mode 100644 index 82a3a0cac..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 属性项 Response VO") -@Data -public class ProductPropertyRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String name; - - @Schema(description = "备注", example = "颜色") - private String remark; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertySaveReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertySaveReqVO.java deleted file mode 100644 index a96568c43..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertySaveReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotBlank; - -@Schema(description = "管理后台 - 属性项新增/更新 Request VO") -@Data -public class ProductPropertySaveReqVO { - - @Schema(description = "主键", example = "1") - private Long id; - - @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - @NotBlank(message = "名称不能为空") - private String name; - - @Schema(description = "备注", example = "颜色") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java deleted file mode 100644 index ff0c32614..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品属性值分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductPropertyValuePageReqVO extends PageParam { - - @Schema(description = "属性项的编号", example = "1024") - private String propertyId; - - @Schema(description = "名称", example = "红色") - private String name; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java deleted file mode 100644 index d401df170..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 商品属性值 Response VO") -@Data -public class ProductPropertyValueRespVO { - - @Schema(description = "主键", example = "1024") - private Long id; - - @Schema(description = "属性项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "属性项的编号不能为空") - private Long propertyId; - - @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - @NotEmpty(message = "名称名字不能为空") - private String name; - - @Schema(description = "备注", example = "颜色") - private String remark; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueSaveReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueSaveReqVO.java deleted file mode 100644 index 1a33f7124..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueSaveReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品属性值新增/更新 Request VO") -@Data -public class ProductPropertyValueSaveReqVO { - - @Schema(description = "主键", example = "1024") - private Long id; - - @Schema(description = "属性项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "属性项的编号不能为空") - private Long propertyId; - - @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - @NotEmpty(message = "名称名字不能为空") - private String name; - - @Schema(description = "备注", example = "颜色") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.http deleted file mode 100644 index 4ab7b4f71..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.http +++ /dev/null @@ -1,4 +0,0 @@ -### 获得商品 SPU 明细 -GET {{baseUrl}}/product/spu/get-detail?id=4 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java deleted file mode 100755 index 0c3089781..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java +++ /dev/null @@ -1,140 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; -import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; - -@Tag(name = "管理后台 - 商品 SPU") -@RestController -@RequestMapping("/product/spu") -@Validated -public class ProductSpuController { - - @Resource - private ProductSpuService productSpuService; - @Resource - private ProductSkuService productSkuService; - - @PostMapping("/create") - @Operation(summary = "创建商品 SPU") - @PreAuthorize("@ss.hasPermission('product:spu:create')") - public CommonResult createProductSpu(@Valid @RequestBody ProductSpuSaveReqVO createReqVO) { - return success(productSpuService.createSpu(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新商品 SPU") - @PreAuthorize("@ss.hasPermission('product:spu:update')") - public CommonResult updateSpu(@Valid @RequestBody ProductSpuSaveReqVO updateReqVO) { - productSpuService.updateSpu(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新商品 SPU Status") - @PreAuthorize("@ss.hasPermission('product:spu:update')") - public CommonResult updateStatus(@Valid @RequestBody ProductSpuUpdateStatusReqVO updateReqVO) { - productSpuService.updateSpuStatus(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除商品 SPU") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:spu:delete')") - public CommonResult deleteSpu(@RequestParam("id") Long id) { - productSpuService.deleteSpu(id); - return success(true); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得商品 SPU 明细") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult getSpuDetail(@RequestParam("id") Long id) { - // 获得商品 SPU - ProductSpuDO spu = productSpuService.getSpu(id); - if (spu == null) { - return success(null); - } - // 查询商品 SKU - List skus = productSkuService.getSkuListBySpuId(spu.getId()); - return success(ProductSpuConvert.INSTANCE.convert(spu, skus)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获得商品 SPU 精简列表") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuSimpleList() { - List list = productSpuService.getSpuListByStatus(ProductSpuStatusEnum.ENABLE.getStatus()); - // 降序排序后,返回给前端 - list.sort(Comparator.comparing(ProductSpuDO::getSort).reversed()); - return success(BeanUtils.toBean(list, ProductSpuSimpleRespVO.class)); - } - - @GetMapping("/list") - @Operation(summary = "获得商品 SPU 详情列表") - @Parameter(name = "spuIds", description = "spu 编号列表", required = true, example = "[1,2,3]") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuList(@RequestParam("spuIds") Collection spuIds) { - return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespListVO( - productSpuService.getSpuList(spuIds), productSkuService.getSkuListBySpuId(spuIds))); - } - - @GetMapping("/page") - @Operation(summary = "获得商品 SPU 分页") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuPage(@Valid ProductSpuPageReqVO pageVO) { - PageResult pageResult = productSpuService.getSpuPage(pageVO); - return success(BeanUtils.toBean(pageResult, ProductSpuRespVO.class)); - } - - @GetMapping("/get-count") - @Operation(summary = "获得商品 SPU 分页 tab count") - @PreAuthorize("@ss.hasPermission('product:spu:query')") - public CommonResult> getSpuCount() { - return success(productSpuService.getTabsCount()); - } - - @GetMapping("/export") - @Operation(summary = "导出商品") - @PreAuthorize("@ss.hasPermission('product:spu:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportSpuList(@Validated ProductSpuPageReqVO reqVO, - HttpServletResponse response) throws IOException { - reqVO.setPageSize(PAGE_SIZE_NONE); - List list = productSpuService.getSpuPage(reqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "商品列表.xls", "数据", ProductSpuRespVO.class, - BeanUtils.toBean(list, ProductSpuRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuRespVO.java deleted file mode 100755 index f977d33c9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuRespVO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - 商品 SKU Response VO") -@Data -public class ProductSkuRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "商品 SKU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") - private String name; - - @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - private Integer price; - - @Schema(description = "市场价", example = "2999") - private Integer marketPrice; - - @Schema(description = "成本价", example = "19") - private Integer costPrice; - - @Schema(description = "条形码", example = "15156165456") - private String barCode; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer stock; - - @Schema(description = "商品重量,单位:kg 千克", example = "1.2") - private Double weight; - - @Schema(description = "商品体积,单位:m^3 平米", example = "2.5") - private Double volume; - - @Schema(description = "一级分销的佣金,单位:分", example = "199") - private Integer firstBrokeragePrice; - - @Schema(description = "二级分销的佣金,单位:分", example = "19") - private Integer secondBrokeragePrice; - - @Schema(description = "属性数组") - private List properties; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuSaveReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuSaveReqVO.java deleted file mode 100755 index 6aa703bb7..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuSaveReqVO.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 商品 SKU 创建/更新 Request VO") -@Data -public class ProductSkuSaveReqVO { - - @Schema(description = "商品 SKU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") - @NotEmpty(message = "商品 SKU 名字不能为空") - private String name; - - @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - @NotNull(message = "销售价格,单位:分不能为空") - private Integer price; - - @Schema(description = "市场价", example = "2999") - private Integer marketPrice; - - @Schema(description = "成本价", example = "19") - private Integer costPrice; - - @Schema(description = "条形码", example = "15156165456") - private String barCode; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - @NotNull(message = "图片地址不能为空") - private String picUrl; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - @NotNull(message = "库存不能为空") - private Integer stock; - - @Schema(description = "商品重量,单位:kg 千克", example = "1.2") - private Double weight; - - @Schema(description = "商品体积,单位:m^3 平米", example = "2.5") - private Double volume; - - @Schema(description = "一级分销的佣金,单位:分", example = "199") - private Integer firstBrokeragePrice; - - @Schema(description = "二级分销的佣金,单位:分", example = "19") - private Integer secondBrokeragePrice; - - @Schema(description = "属性数组") - private List properties; - - @Schema(description = "商品属性") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Property { - - @Schema(description = "属性编号", example = "10") - private Long propertyId; - - @Schema(description = "属性名字", example = "颜色") - private String propertyName; - - @Schema(description = "属性值编号", example = "10") - private Long valueId; - - @Schema(description = "属性值名字", example = "红色") - private String valueName; - - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java deleted file mode 100755 index 81cff4210..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品 SPU 分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ProductSpuPageReqVO extends PageParam { - - /** - * 出售中商品 - */ - public static final Integer FOR_SALE = 0; - - /** - * 仓库中商品 - */ - public static final Integer IN_WAREHOUSE = 1; - - /** - * 已售空商品 - */ - public static final Integer SOLD_OUT = 2; - - /** - * 警戒库存 - */ - public static final Integer ALERT_STOCK = 3; - - /** - * 商品回收站 - */ - public static final Integer RECYCLE_BIN = 4; - - @Schema(description = "商品名称", example = "清凉小短袖") - private String name; - - @Schema(description = "前端请求的tab类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer tabType; - - @Schema(description = "商品分类编号", example = "1") - private Long categoryId; - - @Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java deleted file mode 100755 index fbc75522a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.framework.excel.core.convert.MoneyConvert; -import cn.iocoder.yudao.module.product.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 商品 SPU Response VO") -@Data -@ExcelIgnoreUnannotated -public class ProductSpuRespVO { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - @ExcelProperty("商品编号") - private Long id; - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") - @ExcelProperty("商品名称") - private String name; - - @Schema(description = "关键字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑不出汗") - @ExcelProperty("关键字") - private String keyword; - - @Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖简介") - @ExcelProperty("商品简介") - private String introduction; - - @Schema(description = "商品详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖详情") - @ExcelProperty("商品详情") - private String description; - - @Schema(description = "商品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("商品分类编号") - private Long categoryId; - - @Schema(description = "商品品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("商品品牌编号") - private Long brandId; - - @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - @ExcelProperty("商品封面图") - private String picUrl; - - @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") - private List sliderPicUrls; - - @Schema(description = "排序字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("排序字段") - private Integer sort; - - @Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "商品状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.PRODUCT_SPU_STATUS) - private Integer status; - - @Schema(description = "商品创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-05-24 00:00:00") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - // ========== SKU 相关字段 ========= - - @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty("规格类型") - private Boolean specType; - - @Schema(description = "商品价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - @ExcelProperty(value = "商品价格", converter = MoneyConvert.class) - private Integer price; - - @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "199") - @ExcelProperty(value = "市场价", converter = MoneyConvert.class) - private Integer marketPrice; - - @Schema(description = "成本价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "19") - @ExcelProperty(value = "成本价", converter = MoneyConvert.class) - private Integer costPrice; - - @Schema(description = "商品库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000") - @ExcelProperty("库存") - private Integer stock; - - @Schema(description = "SKU 数组") - private List skus; - - // ========== 物流相关字段 ========= - - @Schema(description = "配送方式数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private List deliveryTypes; - - @Schema(description = "物流配置模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - @ExcelProperty("物流配置模板编号") - private Long deliveryTemplateId; - - // ========== 营销相关字段 ========= - - @Schema(description = "赠送积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - @ExcelProperty("赠送积分") - private Integer giveIntegral; - - @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @ExcelProperty("分销类型") - private Boolean subCommissionType; - - // ========== 统计相关字段 ========= - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - @ExcelProperty("商品销量") - private Integer salesCount; - - @Schema(description = "虚拟销量", example = "66") - @ExcelProperty("虚拟销量") - private Integer virtualSalesCount; - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - @ExcelProperty("商品点击量") - private Integer browseCount; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java deleted file mode 100755 index 340814507..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 商品 SPU 新增/更新 Request VO") -@Data -public class ProductSpuSaveReqVO { - - @Schema(description = "商品编号", example = "1") - private Long id; - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") - @NotEmpty(message = "商品名称不能为空") - private String name; - - @Schema(description = "关键字", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑不出汗") - @NotEmpty(message = "商品关键字不能为空") - private String keyword; - - @Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖简介") - @NotEmpty(message = "商品简介不能为空") - private String introduction; - - @Schema(description = "商品详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖详情") - @NotEmpty(message = "商品详情不能为空") - private String description; - - @Schema(description = "商品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品分类不能为空") - private Long categoryId; - - @Schema(description = "商品品牌编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品品牌不能为空") - private Long brandId; - - @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - @NotEmpty(message = "商品封面图不能为空") - private String picUrl; - - @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED, - example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") - private List sliderPicUrls; - - @Schema(description = "排序字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品排序字段不能为空") - private Integer sort; - - // ========== SKU 相关字段 ========= - - @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "商品规格类型不能为空") - private Boolean specType; - - // ========== 物流相关字段 ========= - - @Schema(description = "配送方式数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotEmpty(message = "配送方式不能为空") - private List deliveryTypes; - - @Schema(description = "物流配置模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - private Long deliveryTemplateId; - - // ========== 营销相关字段 ========= - - @Schema(description = "赠送积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") - @NotNull(message = "商品赠送积分不能为空") - private Integer giveIntegral; - - @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "商品分销类型不能为空") - private Boolean subCommissionType; - - // ========== 统计相关字段 ========= - - @Schema(description = "虚拟销量", example = "66") - private Integer virtualSalesCount; - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - private Integer salesCount; - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - private Integer browseCount; - - // ========== SKU 相关字段 ========= - - @Schema(description = "SKU 数组") - @Valid - private List skus; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java deleted file mode 100755 index 7d9d0d05d..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "管理后台 - 商品 SPU 精简 Response VO") -@Data -@ToString(callSuper = true) -public class ProductSpuSimpleRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "213") - private Long id; - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖") - private String name; - - @Schema(description = "商品价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999") - private Integer price; - - @Schema(description = "商品市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "199") - private Integer marketPrice; - - @Schema(description = "商品成本价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "19") - private Integer costPrice; - - @Schema(description = "商品库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - private Integer stock; - - // ========== 统计相关字段 ========= - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer salesCount; - - @Schema(description = "商品虚拟销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20000") - private Integer virtualSalesCount; - - @Schema(description = "商品浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - private Integer browseCount; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateStatusReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateStatusReqVO.java deleted file mode 100644 index e36e68466..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateStatusReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.spu.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商品 SPU Status 更新 Request VO") -@Data -public class ProductSpuUpdateStatusReqVO{ - - @Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品编号不能为空") - private Long id; - - @Schema(description = "商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品状态不能为空") - @InEnum(ProductSpuStatusEnum.class) - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java deleted file mode 100644 index eb651e747..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.category; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 商品分类") -@RestController -@RequestMapping("/product/category") -@Validated -public class AppCategoryController { - - @Resource - private ProductCategoryService categoryService; - - @GetMapping("/list") - @Operation(summary = "获得商品分类列表") - public CommonResult> getProductCategoryList() { - List list = categoryService.getEnableCategoryList(); - list.sort(Comparator.comparing(ProductCategoryDO::getSort)); - return success(BeanUtils.toBean(list, AppCategoryRespVO.class)); - } - - @GetMapping("/list-by-ids") - @Operation(summary = "获得商品分类列表,指定编号") - @Parameter(name = "ids", description = "商品分类编号数组", required = true) - public CommonResult> getProductCategoryList(@RequestParam("ids") List ids) { - if (CollUtil.isEmpty(ids)) { - return success(Collections.emptyList()); - } - List list = categoryService.getEnableCategoryList(ids); - list.sort(Comparator.comparing(ProductCategoryDO::getSort)); - return success(BeanUtils.toBean(list, AppCategoryRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java deleted file mode 100644 index 02e5f171a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.category.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Data -@Schema(description = "用户 APP - 商品分类 Response VO") -public class AppCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Long id; - - @Schema(description = "父分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "父分类编号不能为空") - private Long parentId; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "办公文具") - @NotBlank(message = "分类名称不能为空") - private String name; - - @Schema(description = "分类图片", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "分类图片不能为空") - private String picUrl; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppCommentController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppCommentController.http deleted file mode 100644 index e69de29bb..000000000 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java deleted file mode 100644 index e6e332a83..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.comment; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppProductCommentRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import cn.iocoder.yudao.module.product.service.comment.ProductCommentService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 商品评价") -@RestController -@RequestMapping("/product/comment") -@Validated -public class AppProductCommentController { - - @Resource - private ProductCommentService productCommentService; - - @GetMapping("/page") - @Operation(summary = "获得商品评价分页") - public CommonResult> getCommentPage(@Valid AppCommentPageReqVO pageVO) { - // 查询评论分页 - PageResult pageResult = productCommentService.getCommentPage(pageVO, Boolean.TRUE); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接返回 - pageResult.getList().forEach(item -> { - if (Boolean.TRUE.equals(item.getAnonymous())) { - item.setUserNickname(ProductCommentDO.NICKNAME_ANONYMOUS); - } - }); - return success(BeanUtils.toBean(pageResult, AppProductCommentRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java deleted file mode 100644 index 8a3cf5e0b..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.comment.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 商品评价分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppCommentPageReqVO extends PageParam { - - /** - * 好评 - */ - public static final Integer GOOD_COMMENT = 1; - /** - * 中评 - */ - public static final Integer MEDIOCRE_COMMENT = 2; - /** - * 差评 - */ - public static final Integer NEGATIVE_COMMENT = 3; - - @Schema(description = "商品 SPU 编号", example = "29502") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "app 评论页 tab 类型 (0 全部、1 好评、2 中评、3 差评)", example = "0") - @NotNull(message = "商品 SPU 编号不能为空") - private Integer type; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java deleted file mode 100644 index 5a77d8786..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.comment.vo; - -import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 商品评价详情 Response VO") -@Data -@ToString(callSuper = true) -public class AppProductCommentRespVO { - - @Schema(description = "评价人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15721") - private Long userId; - - @Schema(description = "评价人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String userNickname; - - @Schema(description = "评价人头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - private String userAvatar; - - @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24965") - private Long id; - - @Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean anonymous; - - @Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24428") - private Long orderId; - - @Schema(description = "交易订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8233") - private Long orderItemId; - - @Schema(description = "商家是否回复", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean replyStatus; - - @Schema(description = "回复管理员编号", example = "22212") - private Long replyUserId; - - @Schema(description = "商家回复内容", example = "亲,你的好评就是我的动力(*^▽^*)") - private String replyContent; - - @Schema(description = "商家回复时间") - private LocalDateTime replyTime; - - @Schema(description = "追加评价内容", example = "穿了很久都很丝滑诶") - private String additionalContent; - - @Schema(description = "追评评价图片地址数组,以逗号分隔最多上传 9 张", example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]") - private List additionalPicUrls; - - @Schema(description = "追加评价时间") - private LocalDateTime additionalTime; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "91192") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉丝滑小短袖") - @NotNull(message = "商品 SPU 名称不能为空") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "81192") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品 SKU 属性", requiredMode = Schema.RequiredMode.REQUIRED) - private List skuProperties; - - @Schema(description = "评分星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "评分星级 1-5 分不能为空") - private Integer scores; - - @Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "描述星级 1-5 分不能为空") - private Integer descriptionScores; - - @Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "服务星级 1-5 分不能为空") - private Integer benefitScores; - - @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "哇,真的很丝滑凉快诶,好评") - @NotNull(message = "评论内容不能为空") - private String content; - - @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, - example = "[https://www.iocoder.cn/xx.png]") - @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") - private List picUrls; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/AppFavoriteController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/AppFavoriteController.java deleted file mode 100644 index fb76e5252..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/AppFavoriteController.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteRespVO; -import cn.iocoder.yudao.module.product.convert.favorite.ProductFavoriteConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.service.favorite.ProductFavoriteService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 商品收藏") -@RestController -@RequestMapping("/product/favorite") -public class AppFavoriteController { - - @Resource - private ProductFavoriteService productFavoriteService; - @Resource - private ProductSpuService productSpuService; - - @PostMapping(value = "/create") - @Operation(summary = "添加商品收藏") - @PreAuthenticated - public CommonResult createFavorite(@RequestBody @Valid AppFavoriteReqVO reqVO) { - return success(productFavoriteService.createFavorite(getLoginUserId(), reqVO.getSpuId())); - } - - @DeleteMapping(value = "/delete") - @Operation(summary = "取消单个商品收藏") - @PreAuthenticated - public CommonResult deleteFavorite(@RequestBody @Valid AppFavoriteReqVO reqVO) { - productFavoriteService.deleteFavorite(getLoginUserId(), reqVO.getSpuId()); - return success(Boolean.TRUE); - } - - @GetMapping(value = "/page") - @Operation(summary = "获得商品收藏分页") - @PreAuthenticated - public CommonResult> getFavoritePage(AppFavoritePageReqVO reqVO) { - PageResult favoritePage = productFavoriteService.getFavoritePage(getLoginUserId(), reqVO); - if (CollUtil.isEmpty(favoritePage.getList())) { - return success(PageResult.empty()); - } - - // 得到商品 spu 信息 - List favorites = favoritePage.getList(); - List spuIds = convertList(favorites, ProductFavoriteDO::getSpuId); - List spus = productSpuService.getSpuList(spuIds); - - // 转换 VO 结果 - PageResult pageResult = new PageResult<>(favoritePage.getTotal()); - pageResult.setList(ProductFavoriteConvert.INSTANCE.convertList(favorites, spus)); - return success(pageResult); - } - - @GetMapping(value = "/exits") - @Operation(summary = "检查是否收藏过商品") - @PreAuthenticated - public CommonResult isFavoriteExists(AppFavoriteReqVO reqVO) { - ProductFavoriteDO favorite = productFavoriteService.getFavorite(getLoginUserId(), reqVO.getSpuId()); - return success(favorite != null); - } - - @GetMapping(value = "/get-count") - @Operation(summary = "获得商品收藏数量") - @PreAuthenticated - public CommonResult getFavoriteCount() { - return success(productFavoriteService.getFavoriteCount(getLoginUserId())); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteBatchReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteBatchReqVO.java deleted file mode 100644 index fbb1afb9e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteBatchReqVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.List; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; - -@Schema(description = "用户 APP - 商品收藏的批量 Request VO") // 用于收藏、取消收藏、获取收藏 -@Data -public class AppFavoriteBatchReqVO { - - @Schema(description = "商品 SPU 编号数组", requiredMode = REQUIRED, example = "29502") - @NotEmpty(message = "商品 SPU 编号数组不能为空") - private List spuIds; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoritePageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoritePageReqVO.java deleted file mode 100644 index 2aacc3e54..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoritePageReqVO.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 商品收藏分页查询 Request VO") -@Data -public class AppFavoritePageReqVO extends PageParam { -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteReqVO.java deleted file mode 100644 index 4f95a6bf0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; - -@Schema(description = "用户 APP - 商品收藏的单个 Request VO") // 用于收藏、取消收藏、获取收藏 -@Data -public class AppFavoriteReqVO { - - @Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteRespVO.java deleted file mode 100644 index 306e50048..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/favorite/vo/AppFavoriteRespVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.favorite.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; - -@Schema(description = "用户 App - 商品收藏 Response VO") -@Data -public class AppFavoriteRespVO { - - @Schema(description = "编号", requiredMode = REQUIRED, example = "1") - private Long id; - - @Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502") - private Long spuId; - - // ========== 商品相关字段 ========== - - @Schema(description = "商品 SPU 名称", example = "赵六") - private String spuName; - - @Schema(description = "商品封面图", example = "https://domain/pic.png") - private String picUrl; - - @Schema(description = "商品单价", example = "100") - private Integer price; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/AppProductBrowseHistoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/AppProductBrowseHistoryController.java deleted file mode 100644 index b275151f4..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/AppProductBrowseHistoryController.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.history; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.history.vo.AppProductBrowseHistoryDeleteReqVO; -import cn.iocoder.yudao.module.product.controller.app.history.vo.AppProductBrowseHistoryPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.history.vo.AppProductBrowseHistoryRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.service.history.ProductBrowseHistoryService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 商品浏览记录") -@RestController -@RequestMapping("/product/browse-history") -public class AppProductBrowseHistoryController { - - @Resource - private ProductBrowseHistoryService productBrowseHistoryService; - @Resource - private ProductSpuService productSpuService; - - @DeleteMapping(value = "/delete") - @Operation(summary = "删除商品浏览记录") - @PreAuthenticated - public CommonResult deleteBrowseHistory(@RequestBody @Valid AppProductBrowseHistoryDeleteReqVO reqVO) { - productBrowseHistoryService.hideUserBrowseHistory(getLoginUserId(), reqVO.getSpuIds()); - return success(Boolean.TRUE); - } - - @DeleteMapping(value = "/clean") - @Operation(summary = "清空商品浏览记录") - @PreAuthenticated - public CommonResult deleteBrowseHistory() { - productBrowseHistoryService.hideUserBrowseHistory(getLoginUserId(), null); - return success(Boolean.TRUE); - } - - @GetMapping(value = "/page") - @Operation(summary = "获得商品浏览记录分页") - @PreAuthenticated - public CommonResult> getBrowseHistoryPage(AppProductBrowseHistoryPageReqVO reqVO) { - ProductBrowseHistoryPageReqVO pageReqVO = BeanUtils.toBean(reqVO, ProductBrowseHistoryPageReqVO.class) - .setUserId(getLoginUserId()) - .setUserDeleted(false); // 排除用户已删除的(隐藏的) - PageResult pageResult = productBrowseHistoryService.getBrowseHistoryPage(pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 得到商品 spu 信息 - Set spuIds = convertSet(pageResult.getList(), ProductBrowseHistoryDO::getSpuId); - Map spuMap = convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId); - return success(BeanUtils.toBean(pageResult, AppProductBrowseHistoryRespVO.class, - vo -> Optional.ofNullable(spuMap.get(vo.getSpuId())) - .ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setPrice(spu.getPrice())))); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryDeleteReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryDeleteReqVO.java deleted file mode 100644 index 13eb7dd61..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryDeleteReqVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.history.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.List; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; - -@Schema(description = "用户 APP - 删除商品浏览记录的 Request VO") -@Data -public class AppProductBrowseHistoryDeleteReqVO { - - @Schema(description = "商品 SPU 编号数组", requiredMode = REQUIRED, example = "29502") - @NotEmpty(message = "商品 SPU 编号数组不能为空") - private List spuIds; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryPageReqVO.java deleted file mode 100644 index f959fd0d1..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.history.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "用户 APP - 商品浏览记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppProductBrowseHistoryPageReqVO extends PageParam { - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryRespVO.java deleted file mode 100644 index 05b528cdb..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/vo/AppProductBrowseHistoryRespVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.history.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; - -@Schema(description = "用户 App - 商品浏览记录 Response VO") -@Data -public class AppProductBrowseHistoryRespVO { - - @Schema(description = "编号", requiredMode = REQUIRED, example = "1") - private Long id; - - @Schema(description = "商品 SPU 编号", requiredMode = REQUIRED, example = "29502") - private Long spuId; - - // ========== 商品相关字段 ========== - - @Schema(description = "商品 SPU 名称", example = "赵六") - private String spuName; - - @Schema(description = "商品封面图", example = "https://domain/pic.png") - private String picUrl; - - @Schema(description = "商品单价", example = "100") - private Integer price; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/package-info.java deleted file mode 100644 index 379e85180..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,无时间作用,避免 package 缩进 - */ -package cn.iocoder.yudao.module.product.controller.app.property; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/property/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/property/package-info.java deleted file mode 100644 index 6538bea3c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/property/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,无时间作用,避免 package 缩进 - */ -package cn.iocoder.yudao.module.product.controller.app.property.vo.property; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java deleted file mode 100644 index 5cac09143..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.property.vo.value; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 商品属性值的明细 Response VO") -@Data -public class AppProductPropertyValueDetailRespVO { - - @Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long propertyId; - - @Schema(description = "属性的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String propertyName; - - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long valueId; - - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http deleted file mode 100644 index c391b5873..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.http +++ /dev/null @@ -1,18 +0,0 @@ -### 获得订单交易的分页(默认) -GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得订单交易的分页(价格) -GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10&sortField=price&sortAsc=true -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得订单交易的分页(销售) -GET {{appApi}}/product/spu/page?pageNo=1&pageSize=10&sortField=salesCount&sortAsc=true -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得商品 SPU 明细 -GET {{appApi}}/product/spu/get-detail?id=102 -tenant-id: {{appTenentId}} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java deleted file mode 100644 index b1cfc69c5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java +++ /dev/null @@ -1,152 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.product.service.history.ProductBrowseHistoryService; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_ENABLE; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; - -@Tag(name = "用户 APP - 商品 SPU") -@RestController -@RequestMapping("/product/spu") -@Validated -public class AppProductSpuController { - - @Resource - private ProductSpuService productSpuService; - @Resource - private ProductSkuService productSkuService; - @Resource - private ProductBrowseHistoryService productBrowseHistoryService; - - @Resource - private MemberLevelApi memberLevelApi; - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/list-by-ids") - @Operation(summary = "获得商品 SPU 列表") - @Parameter(name = "ids", description = "编号列表", required = true) - public CommonResult> getSpuList(@RequestParam("ids") Set ids) { - List list = productSpuService.getSpuList(ids); - if (CollUtil.isEmpty(list)) { - return success(Collections.emptyList()); - } - - // 拼接返回 - list.forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount())); - List voList = BeanUtils.toBean(list, AppProductSpuRespVO.class); - // 处理 vip 价格 - MemberLevelRespDTO memberLevel = getMemberLevel(); - voList.forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel))); - return success(voList); - } - - @GetMapping("/page") - @Operation(summary = "获得商品 SPU 分页") - public CommonResult> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) { - PageResult pageResult = productSpuService.getSpuPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接返回 - pageResult.getList().forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount())); - PageResult voPageResult = BeanUtils.toBean(pageResult, AppProductSpuRespVO.class); - // 处理 vip 价格 - MemberLevelRespDTO memberLevel = getMemberLevel(); - voPageResult.getList().forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel))); - return success(voPageResult); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得商品 SPU 明细") - @Parameter(name = "id", description = "编号", required = true) - public CommonResult getSpuDetail(@RequestParam("id") Long id) { - // 获得商品 SPU - ProductSpuDO spu = productSpuService.getSpu(id); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - if (!ProductSpuStatusEnum.isEnable(spu.getStatus())) { - throw exception(SPU_NOT_ENABLE, spu.getName()); - } - // 获得商品 SKU - List skus = productSkuService.getSkuListBySpuId(spu.getId()); - - // 增加浏览量 - productSpuService.updateBrowseCount(id, 1); - // 保存浏览记录 - productBrowseHistoryService.createBrowseHistory(getLoginUserId(), id); - - // 拼接返回 - spu.setBrowseCount(spu.getBrowseCount() + spu.getVirtualSalesCount()); - AppProductSpuDetailRespVO spuVO = BeanUtils.toBean(spu, AppProductSpuDetailRespVO.class) - .setSkus(BeanUtils.toBean(skus, AppProductSpuDetailRespVO.Sku.class)); - // 处理 vip 价格 - MemberLevelRespDTO memberLevel = getMemberLevel(); - spuVO.setVipPrice(calculateVipPrice(spuVO.getPrice(), memberLevel)); - return success(spuVO); - } - - private MemberLevelRespDTO getMemberLevel() { - Long userId = getLoginUserId(); - if (userId == null) { - return null; - } - MemberUserRespDTO user = memberUserApi.getUser(userId).getCheckedData(); - if (user.getLevelId() == null || user.getLevelId() <= 0) { - return null; - } - return memberLevelApi.getMemberLevel(user.getLevelId()).getCheckedData(); - } - - /** - * 计算会员 VIP 优惠价格 - * - * @param price 原价 - * @param memberLevel 会员等级 - * @return 优惠价格 - */ - public Integer calculateVipPrice(Integer price, MemberLevelRespDTO memberLevel) { - if (memberLevel == null || memberLevel.getDiscountPercent() == null) { - return 0; - } - Integer newPrice = price * memberLevel.getDiscountPercent() / 100; - return price - newPrice; - } - - // TODO 芋艿:商品的浏览记录; -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java deleted file mode 100644 index f1ee49b10..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 商品 SPU 明细 Response VO") -@Data -public class AppProductSpuDetailRespVO { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - // ========== 基本信息 ========= - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是一个快乐简介") - private String introduction; - - @Schema(description = "商品详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是商品描述") - private String description; - - @Schema(description = "商品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long categoryId; - - @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED) - private String picUrl; - - @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED) - private List sliderPicUrls; - - // ========== 营销相关字段 ========= - - // ========== SKU 相关字段 ========= - - @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean specType; - - @Schema(description = "商品价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer price; - - @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer marketPrice; - - @Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格 - private Integer vipPrice; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") - private Integer stock; - - /** - * SKU 数组 - */ - private List skus; - - // ========== 统计相关字段 ========= - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer salesCount; - - @Schema(description = "用户 App - 商品 SPU 明细的 SKU 信息") - @Data - public static class Sku { - - @Schema(description = "商品 SKU 编号", example = "1") - private Long id; - - /** - * 商品属性数组 - */ - private List properties; - - @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer price; - - @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer marketPrice; - - @Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格 - private Integer vipPrice; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer stock; - - @Schema(description = "商品重量", example = "1") // 单位:kg 千克 - private Double weight; - - @Schema(description = "商品体积", example = "1024") // 单位:m^3 平米 - private Double volume; - - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java deleted file mode 100644 index 1584dc6f3..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.AssertTrue; -import java.util.List; - -@Schema(description = "用户 App - 商品 SPU 分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppProductSpuPageReqVO extends PageParam { - - public static final String SORT_FIELD_PRICE = "price"; - public static final String SORT_FIELD_SALES_COUNT = "salesCount"; - public static final String SORT_FIELD_CREATE_TIME = "createTime"; - - @Schema(description = "商品 SPU 编号数组", example = "1,3,5") - private List ids; - - @Schema(description = "分类编号", example = "1") - private Long categoryId; - - @Schema(description = "分类编号数组", example = "1,2,3") - private List categoryIds; - - @Schema(description = "关键字", example = "好看") - private String keyword; - - @Schema(description = "排序字段", example = "price") // 参见 AppProductSpuPageReqVO.SORT_FIELD_XXX 常量 - private String sortField; - - @Schema(description = "排序方式", example = "true") - private Boolean sortAsc; - - @AssertTrue(message = "排序字段不合法") - @JsonIgnore - public boolean isSortFieldValid() { - if (StrUtil.isEmpty(sortField)) { - return true; - } - return StrUtil.equalsAny(sortField, SORT_FIELD_PRICE, SORT_FIELD_SALES_COUNT); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRespVO.java deleted file mode 100644 index df61090bb..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.app.spu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 商品 SPU Response VO") -@Data -public class AppProductSpuRespVO { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "商品简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖简介") - private String introduction; - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long categoryId; - - @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED) - private String picUrl; - - @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED) - private List sliderPicUrls; - - // ========== SKU 相关字段 ========= - - @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean specType; - - @Schema(description = "商品价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer price; - - @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer marketPrice; - - @Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格 - private Integer vipPrice; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") - private Integer stock; - - // ========== 营销相关字段 ========= - - // ========== 统计相关字段 ========= - - @Schema(description = "商品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer salesCount; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/brand/ProductBrandConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/brand/ProductBrandConvert.java deleted file mode 100644 index e6c72fb49..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/brand/ProductBrandConvert.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.brand; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandRespVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandSimpleRespVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 品牌 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductBrandConvert { - - ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class); - - ProductBrandDO convert(ProductBrandCreateReqVO bean); - - ProductBrandDO convert(ProductBrandUpdateReqVO bean); - - ProductBrandRespVO convert(ProductBrandDO bean); - - List convertList1(List list); - - List convertList(List list); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java deleted file mode 100644 index 7a3a3c011..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.comment; - -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -/** - * 商品评价 Convert - * - * @author wangzhs - */ -@Mapper -public interface ProductCommentConvert { - - ProductCommentConvert INSTANCE = Mappers.getMapper(ProductCommentConvert.class); - - default ProductCommentDO convert(ProductCommentCreateReqDTO createReqDTO, - ProductSpuDO spu, ProductSkuDO sku, MemberUserRespDTO user) { - ProductCommentDO comment = BeanUtils.toBean(createReqDTO, ProductCommentDO.class) - .setScores(convertScores(createReqDTO.getDescriptionScores(), createReqDTO.getBenefitScores())); - if (user != null) { - comment.setUserId(user.getId()).setUserNickname(user.getNickname()).setUserAvatar(user.getAvatar()); - } - if (spu != null) { - comment.setSpuId(spu.getId()).setSpuName(spu.getName()); - } - if (sku != null) { - comment.setSkuPicUrl(sku.getPicUrl()).setSkuProperties(sku.getProperties()); - } - return comment; - } - - default ProductCommentDO convert(ProductCommentCreateReqVO createReq, ProductSpuDO spu, ProductSkuDO sku) { - ProductCommentDO comment = BeanUtils.toBean(createReq, ProductCommentDO.class) - .setVisible(true).setUserId(0L).setAnonymous(false) - .setScores(convertScores(createReq.getDescriptionScores(), createReq.getBenefitScores())); - if (spu != null) { - comment.setSpuId(spu.getId()).setSpuName(spu.getName()); - } - if (sku != null) { - comment.setSkuPicUrl(sku.getPicUrl()).setSkuProperties(sku.getProperties()); - } - return comment; - } - - default Integer convertScores(Integer descriptionScores, Integer benefitScores) { - // 计算评价最终综合评分 最终星数 = (商品评星 + 服务评星) / 2 - BigDecimal sumScore = new BigDecimal(descriptionScores + benefitScores); - BigDecimal divide = sumScore.divide(BigDecimal.valueOf(2L), 0, RoundingMode.DOWN); - return divide.intValue(); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/favorite/ProductFavoriteConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/favorite/ProductFavoriteConvert.java deleted file mode 100644 index 7b419b6a8..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/favorite/ProductFavoriteConvert.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.favorite; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoriteRespVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteRespVO; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -@Mapper -public interface ProductFavoriteConvert { - - ProductFavoriteConvert INSTANCE = Mappers.getMapper(ProductFavoriteConvert.class); - - ProductFavoriteDO convert(Long userId, Long spuId); - - @Mapping(target = "id", source = "favorite.id") - @Mapping(target = "spuName", source = "spu.name") - AppFavoriteRespVO convert(ProductSpuDO spu, ProductFavoriteDO favorite); - - default List convertList(List favorites, List spus) { - List resultList = new ArrayList<>(favorites.size()); - Map spuMap = convertMap(spus, ProductSpuDO::getId); - for (ProductFavoriteDO favorite : favorites) { - ProductSpuDO spuDO = spuMap.get(favorite.getSpuId()); - resultList.add(convert(spuDO, favorite)); - } - return resultList; - } - - default PageResult convertPage(PageResult pageResult, List spuList) { - Map spuMap = convertMap(spuList, ProductSpuDO::getId); - List voList = CollectionUtils.convertList(pageResult.getList(), favorite -> { - ProductSpuDO spu = spuMap.get(favorite.getSpuId()); - return convert02(spu, favorite); - }); - return new PageResult<>(voList, pageResult.getTotal()); - } - @Mapping(target = "id", source = "favorite.id") - @Mapping(target = "userId", source = "favorite.userId") - @Mapping(target = "spuId", source = "favorite.spuId") - @Mapping(target = "createTime", source = "favorite.createTime") - ProductFavoriteRespVO convert02(ProductSpuDO spu, ProductFavoriteDO favorite); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java deleted file mode 100755 index 492f483c0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.sku; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 商品 SKU Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductSkuConvert { - - ProductSkuConvert INSTANCE = Mappers.getMapper(ProductSkuConvert.class); - - /** - * 获得 SPU 的库存变化 Map - * - * @param items SKU 库存变化 - * @param skus SKU 列表 - * @return SPU 的库存变化 Map - */ - default Map convertSpuStockMap(List items, - List skus) { - Map skuIdAndSpuIdMap = convertMap(skus, ProductSkuDO::getId, ProductSkuDO::getSpuId); // SKU 与 SKU 编号的 Map 关系 - Map spuIdAndStockMap = new HashMap<>(); // SPU 的库存变化 Map 关系 - items.forEach(item -> { - Long spuId = skuIdAndSpuIdMap.get(item.getId()); - if (spuId == null) { - return; - } - Integer stock = spuIdAndStockMap.getOrDefault(spuId, 0) + item.getIncrCount(); - spuIdAndStockMap.put(spuId, stock); - }); - return spuIdAndStockMap; - } - - default String buildPropertyKey(ProductSkuDO bean) { - if (CollUtil.isEmpty(bean.getProperties())) { - return StrUtil.EMPTY; - } - List properties = new ArrayList<>(bean.getProperties()); - properties.sort(Comparator.comparing(ProductSkuDO.Property::getValueId)); - return properties.stream().map(m -> String.valueOf(m.getValueId())).collect(Collectors.joining()); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java deleted file mode 100755 index 364434241..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.spu; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuRespVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuRespVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; - -/** - * 商品 SPU Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ProductSpuConvert { - - ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class); - - ProductSpuPageReqVO convert(AppProductSpuPageReqVO bean); - - default ProductSpuRespVO convert(ProductSpuDO spu, List skus) { - ProductSpuRespVO spuVO = BeanUtils.toBean(spu, ProductSpuRespVO.class); - spuVO.setSkus(BeanUtils.toBean(skus, ProductSkuRespVO.class)); - return spuVO; - } - - default List convertForSpuDetailRespListVO(List spus, List skus) { - Map> skuMultiMap = convertMultiMap(skus, ProductSkuDO::getSpuId); - return CollectionUtils.convertList(spus, spu -> convert(spu, skuMultiMap.get(spu.getId()))); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/brand/ProductBrandDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/brand/ProductBrandDO.java deleted file mode 100644 index 9775f36a5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/brand/ProductBrandDO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.brand; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品品牌 DO - * - * @author 芋道源码 - */ -@TableName("product_brand") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductBrandDO extends BaseDO { - - /** - * 品牌编号 - */ - @TableId - private Long id; - /** - * 品牌名称 - */ - private String name; - /** - * 品牌图片 - */ - private String picUrl; - /** - * 品牌排序 - */ - private Integer sort; - /** - * 品牌描述 - */ - private String description; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - - // TODO 芋艿:firstLetter 首字母 - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java deleted file mode 100644 index 78e35d6f5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/ProductCategoryDO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.category; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品分类 DO - * - * @author 芋道源码 - */ -@TableName("product_category") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductCategoryDO extends BaseDO { - - /** - * 父分类编号 - 根分类 - */ - public static final Long PARENT_ID_NULL = 0L; - /** - * 限定分类层级 - */ - public static final int CATEGORY_LEVEL = 2; - - /** - * 分类编号 - */ - @TableId - private Long id; - /** - * 父分类编号 - */ - private Long parentId; - /** - * 分类名称 - */ - private String name; - /** - * 移动端分类图 - * - * 建议 180*180 分辨率 - */ - private String picUrl; - /** - * 分类排序 - */ - private Integer sort; - /** - * 开启状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java deleted file mode 100644 index 40b04caf0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java +++ /dev/null @@ -1,159 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.comment; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 商品评论 DO - * - * @author 芋道源码 - */ -@TableName(value = "product_comment", autoResultMap = true) -@KeySequence("product_comment_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductCommentDO extends BaseDO { - - /** - * 默认匿名昵称 - */ - public static final String NICKNAME_ANONYMOUS = "匿名用户"; - - /** - * 评论编号,主键自增 - */ - @TableId - private Long id; - - /** - * 评价人的用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 评价人名称 - */ - private String userNickname; - /** - * 评价人头像 - */ - private String userAvatar; - /** - * 是否匿名 - */ - private Boolean anonymous; - - /** - * 交易订单编号 - * - * 关联 TradeOrderDO 的 id 编号 - */ - private Long orderId; - /** - * 交易订单项编号 - * - * 关联 TradeOrderItemDO 的 id 编号 - */ - private Long orderItemId; - - /** - * 商品 SPU 编号 - * - * 关联 {@link ProductSpuDO#getId()} - */ - private Long spuId; - /** - * 商品 SPU 名称 - * - * 关联 {@link ProductSpuDO#getName()} - */ - private String spuName; - /** - * 商品 SKU 编号 - * - * 关联 {@link ProductSkuDO#getId()} - */ - private Long skuId; - /** - * 商品 SKU 图片地址 - * - * 关联 {@link ProductSkuDO#getPicUrl()} - */ - private String skuPicUrl; - /** - * 属性数组,JSON 格式 - * - * 关联 {@link ProductSkuDO#getProperties()} - */ - @TableField(typeHandler = ProductSkuDO.PropertyTypeHandler.class) - private List skuProperties; - - /** - * 是否可见 - * - * true:显示 - * false:隐藏 - */ - private Boolean visible; - /** - * 评分星级 - * - * 1-5 分 - */ - private Integer scores; - /** - * 描述星级 - * - * 1-5 星 - */ - private Integer descriptionScores; - /** - * 服务星级 - * - * 1-5 星 - */ - private Integer benefitScores; - /** - * 评论内容 - */ - private String content; - /** - * 评论图片地址数组 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List picUrls; - - /** - * 商家是否回复 - */ - private Boolean replyStatus; - /** - * 回复管理员编号 - * 关联 AdminUserDO 的 id 编号 - */ - private Long replyUserId; - /** - * 商家回复内容 - */ - private String replyContent; - /** - * 商家回复时间 - */ - private LocalDateTime replyTime; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/favorite/ProductFavoriteDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/favorite/ProductFavoriteDO.java deleted file mode 100644 index 6e00eaa6c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/favorite/ProductFavoriteDO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.favorite; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品收藏 DO - * - * @author 芋道源码 - */ -@TableName("product_favorite") -@KeySequence("product_favorite_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductFavoriteDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 商品 SPU 编号 - * - * 关联 {@link ProductSpuDO#getId()} - */ - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/history/ProductBrowseHistoryDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/history/ProductBrowseHistoryDO.java deleted file mode 100644 index 472574bd9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/history/ProductBrowseHistoryDO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.history; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品浏览记录 DO - * - * @author owen - */ -@TableName("product_browse_history") -@KeySequence("product_browse_history_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductBrowseHistoryDO extends BaseDO { - - /** - * 记录编号 - */ - @TableId - private Long id; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 用户编号 - */ - private Long userId; - /** - * 用户是否删除 - */ - private Boolean userDeleted; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java deleted file mode 100644 index 8cc646bd5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.property; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商品属性项 DO - * - * @author 芋道源码 - */ -@TableName("product_property") -@KeySequence("product_property_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductPropertyDO extends BaseDO { - - /** - * SPU 单规格时,默认属性 id - */ - public static final Long ID_DEFAULT = 0L; - /** - * SPU 单规格时,默认属性名字 - */ - public static final String NAME_DEFAULT = "默认"; - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 名称 - */ - private String name; - /** - * 状态 - */ - private Integer status; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyValueDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyValueDO.java deleted file mode 100644 index cefa2d958..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyValueDO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.property; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - - -/** - * 商品属性值 DO - * - * @author 芋道源码 - */ -@TableName("product_property_value") -@KeySequence("product_property_value_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductPropertyValueDO extends BaseDO { - - /** - * SPU 单规格时,默认属性值 id - */ - public static final Long ID_DEFAULT = 0L; - /** - * SPU 单规格时,默认属性值名字 - */ - public static final String NAME_DEFAULT = "默认"; - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 属性项的编号 - * - * 关联 {@link ProductPropertyDO#getId()} - */ - private Long propertyId; - /** - * 名称 - */ - private String name; - /** - * 备注 - * - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java deleted file mode 100755 index dacb02ec8..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java +++ /dev/null @@ -1,156 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.sku; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 商品 SKU DO - * - * @author 芋道源码 - */ -@TableName(value = "product_sku", autoResultMap = true) -@KeySequence("product_sku_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductSkuDO extends BaseDO { - - /** - * 商品 SKU 编号,自增 - */ - @TableId - private Long id; - /** - * SPU 编号 - * - * 关联 {@link ProductSpuDO#getId()} - */ - private Long spuId; - /** - * 属性数组,JSON 格式 - */ - @TableField(typeHandler = PropertyTypeHandler.class) - private List properties; - /** - * 商品价格,单位:分 - */ - private Integer price; - /** - * 市场价,单位:分 - */ - private Integer marketPrice; - /** - * 成本价,单位:分 - */ - private Integer costPrice; - /** - * 商品条码 - */ - private String barCode; - /** - * 图片地址 - */ - private String picUrl; - /** - * 库存 - */ - private Integer stock; - /** - * 商品重量,单位:kg 千克 - */ - private Double weight; - /** - * 商品体积,单位:m^3 平米 - */ - private Double volume; - - /** - * 一级分销的佣金,单位:分 - */ - private Integer firstBrokeragePrice; - /** - * 二级分销的佣金,单位:分 - */ - private Integer secondBrokeragePrice; - - // ========== 营销相关字段 ========= - - // ========== 统计相关字段 ========= - /** - * 商品销量 - */ - private Integer salesCount; - - /** - * 商品属性 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Property { - - /** - * 属性编号 - * 关联 {@link ProductPropertyDO#getId()} - */ - private Long propertyId; - /** - * 属性名字 - * 冗余 {@link ProductPropertyDO#getName()} - * - * 注意:每次属性名字发生变化时,需要更新该冗余 - */ - private String propertyName; - - /** - * 属性值编号 - * 关联 {@link ProductPropertyValueDO#getId()} - */ - private Long valueId; - /** - * 属性值名字 - * 冗余 {@link ProductPropertyValueDO#getName()} - * - * 注意:每次属性值名字发生变化时,需要更新该冗余 - */ - private String valueName; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class PropertyTypeHandler extends AbstractJsonTypeHandler { - - @Override - protected Object parse(String json) { - return JsonUtils.parseArray(json, Property.class); - } - - @Override - protected String toJson(Object obj) { - return JsonUtils.toJsonString(obj); - } - - } - - // TODO 芋艿:integral from y - // TODO 芋艿:pinkPrice from y - // TODO 芋艿:seckillPrice from y - // TODO 芋艿:pinkStock from y - // TODO 芋艿:seckillStock from y - -} - diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java deleted file mode 100755 index d2b519596..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java +++ /dev/null @@ -1,171 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.dataobject.spu; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 商品 SPU DO - * - * @author 芋道源码 - */ -@TableName(value = "product_spu", autoResultMap = true) -@KeySequence("product_spu_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductSpuDO extends BaseDO { - - /** - * 商品 SPU 编号,自增 - */ - @TableId - private Long id; - - // ========== 基本信息 ========= - - /** - * 商品名称 - */ - private String name; - /** - * 关键字 - */ - private String keyword; - /** - * 商品简介 - */ - private String introduction; - /** - * 商品详情 - */ - private String description; - - /** - * 商品分类编号 - * - * 关联 {@link ProductCategoryDO#getId()} - */ - private Long categoryId; - /** - * 商品品牌编号 - * - * 关联 {@link ProductBrandDO#getId()} - */ - private Long brandId; - /** - * 商品封面图 - */ - private String picUrl; - /** - * 商品轮播图 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List sliderPicUrls; - - /** - * 排序字段 - */ - private Integer sort; - /** - * 商品状态 - * - * 枚举 {@link ProductSpuStatusEnum} - */ - private Integer status; - - // ========== SKU 相关字段 ========= - - /** - * 规格类型 - * - * false - 单规格 - * true - 多规格 - */ - private Boolean specType; - /** - * 商品价格,单位使用:分 - * - * 基于其对应的 {@link ProductSkuDO#getPrice()} sku单价最低的商品的 - */ - private Integer price; - /** - * 市场价,单位使用:分 - * - * 基于其对应的 {@link ProductSkuDO#getMarketPrice()} sku单价最低的商品的 - */ - private Integer marketPrice; - /** - * 成本价,单位使用:分 - * - * 基于其对应的 {@link ProductSkuDO#getCostPrice()} sku单价最低的商品的 - */ - private Integer costPrice; - /** - * 库存 - * - * 基于其对应的 {@link ProductSkuDO#getStock()} 求和 - */ - private Integer stock; - - // ========== 物流相关字段 ========= - - /** - * 配送方式数组 - * - * 对应 DeliveryTypeEnum 枚举 - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List deliveryTypes; - /** - * 物流配置模板编号 - * - * 对应 TradeDeliveryExpressTemplateDO 的 id 编号 - */ - private Long deliveryTemplateId; - - // ========== 营销相关字段 ========= - - /** - * 赠送积分 - */ - private Integer giveIntegral; - - // TODO @puhui999:字段估计要改成 brokerageType - /** - * 分销类型 - * - * false - 默认 - * true - 自行设置 - */ - private Boolean subCommissionType; - - // ========== 统计相关字段 ========= - - /** - * 商品销量 - */ - private Integer salesCount; - /** - * 虚拟销量 - */ - private Integer virtualSalesCount; - /** - * 浏览量 - */ - private Integer browseCount; -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java deleted file mode 100644 index b2c4bd5fb..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/brand/ProductBrandMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.brand; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface ProductBrandMapper extends BaseMapperX { - - default PageResult selectPage(ProductBrandPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ProductBrandDO::getName, reqVO.getName()) - .eqIfPresent(ProductBrandDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(ProductBrandDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductBrandDO::getId)); - } - - - default List selectList(ProductBrandListReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(ProductBrandDO::getName, reqVO.getName())); - } - - default ProductBrandDO selectByName(String name) { - return selectOne(ProductBrandDO::getName, name); - } - - default List selectListByStatus(Integer status) { - return selectList(ProductBrandDO::getStatus, status); - } -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java deleted file mode 100644 index 4c212de94..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.category; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 商品分类 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ProductCategoryMapper extends BaseMapperX { - - default List selectList(ProductCategoryListReqVO listReqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(ProductCategoryDO::getName, listReqVO.getName()) - .eqIfPresent(ProductCategoryDO::getParentId, listReqVO.getParentId()) - .inIfPresent(ProductCategoryDO::getId, listReqVO.getParentIds()) - .eqIfPresent(ProductCategoryDO::getStatus, listReqVO.getStatus()) - .orderByDesc(ProductCategoryDO::getId)); - } - - default Long selectCountByParentId(Long parentId) { - return selectCount(ProductCategoryDO::getParentId, parentId); - } - - default List selectListByStatus(Integer status) { - return selectList(ProductCategoryDO::getStatus, status); - } - - default List selectListByIdAndStatus(Collection ids, Integer status) { - return selectList(new LambdaQueryWrapperX() - .in(ProductCategoryDO::getId, ids) - .eq(ProductCategoryDO::getStatus, status)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java deleted file mode 100644 index 9191b9ec8..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.comment; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface ProductCommentMapper extends BaseMapperX { - - default PageResult selectPage(ProductCommentPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ProductCommentDO::getUserNickname, reqVO.getUserNickname()) - .eqIfPresent(ProductCommentDO::getOrderId, reqVO.getOrderId()) - .eqIfPresent(ProductCommentDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(ProductCommentDO::getScores, reqVO.getScores()) - .eqIfPresent(ProductCommentDO::getReplyStatus, reqVO.getReplyStatus()) - .betweenIfPresent(ProductCommentDO::getCreateTime, reqVO.getCreateTime()) - .likeIfPresent(ProductCommentDO::getSpuName, reqVO.getSpuName()) - .orderByDesc(ProductCommentDO::getId)); - } - - static void appendTabQuery(LambdaQueryWrapperX queryWrapper, Integer type) { - // 构建好评查询语句:好评计算 总评 >= 4 - if (ObjectUtil.equal(type, AppCommentPageReqVO.GOOD_COMMENT)) { - queryWrapper.ge(ProductCommentDO::getScores, 4); - } - // 构建中评查询语句:中评计算 总评 >= 3 且 总评 < 4 - if (ObjectUtil.equal(type, AppCommentPageReqVO.MEDIOCRE_COMMENT)) { - queryWrapper.ge(ProductCommentDO::getScores, 3); - queryWrapper.lt(ProductCommentDO::getScores, 4); - } - // 构建差评查询语句:差评计算 总评 < 3 - if (ObjectUtil.equal(type, AppCommentPageReqVO.NEGATIVE_COMMENT)) { - queryWrapper.lt(ProductCommentDO::getScores, 3); - } - } - - default PageResult selectPage(AppCommentPageReqVO reqVO, Boolean visible) { - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX() - .eqIfPresent(ProductCommentDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(ProductCommentDO::getVisible, visible); - // 构建评价查询语句 - appendTabQuery(queryWrapper, reqVO.getType()); - // 按评价时间排序最新的显示在前面 - queryWrapper.orderByDesc(ProductCommentDO::getCreateTime); - return selectPage(reqVO, queryWrapper); - } - - default ProductCommentDO selectByUserIdAndOrderItemId(Long userId, Long orderItemId) { - return selectOne(new LambdaQueryWrapperX() - .eq(ProductCommentDO::getUserId, userId) - .eq(ProductCommentDO::getOrderItemId, orderItemId)); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/favorite/ProductFavoriteMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/favorite/ProductFavoriteMapper.java deleted file mode 100644 index a681d42a7..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/favorite/ProductFavoriteMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.favorite; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface ProductFavoriteMapper extends BaseMapperX { - - default ProductFavoriteDO selectByUserIdAndSpuId(Long userId, Long spuId) { - return selectOne(ProductFavoriteDO::getUserId, userId, - ProductFavoriteDO::getSpuId, spuId); - } - - default PageResult selectPageByUserAndType(Long userId, AppFavoritePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapper() - .eq(ProductFavoriteDO::getUserId, userId) - .orderByDesc(ProductFavoriteDO::getId)); - } - - default PageResult selectPageByUserId(ProductFavoritePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ProductFavoriteDO::getUserId, reqVO.getUserId()) - .orderByDesc(ProductFavoriteDO::getId)); - } - - default Long selectCountByUserId(Long userId) { - return selectCount(ProductFavoriteDO::getUserId, userId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/history/ProductBrowseHistoryMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/history/ProductBrowseHistoryMapper.java deleted file mode 100644 index 124357cac..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/history/ProductBrowseHistoryMapper.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.history; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; - -/** - * 商品浏览记录 Mapper - * - * @author owen - */ -@Mapper -public interface ProductBrowseHistoryMapper extends BaseMapperX { - - default ProductBrowseHistoryDO selectByUserIdAndSpuId(Long userId, Long spuId) { - return selectOne(new LambdaQueryWrapperX() - .eq(ProductBrowseHistoryDO::getUserId, userId) - .eq(ProductBrowseHistoryDO::getSpuId, spuId)); - } - - default PageResult selectPage(ProductBrowseHistoryPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ProductBrowseHistoryDO::getUserId, reqVO.getUserId()) - .eqIfPresent(ProductBrowseHistoryDO::getUserDeleted, reqVO.getUserDeleted()) - .eqIfPresent(ProductBrowseHistoryDO::getSpuId, reqVO.getSpuId()) - .betweenIfPresent(ProductBrowseHistoryDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductBrowseHistoryDO::getId)); - } - - default void updateUserDeletedByUserId(Long userId, Collection spuIds, Boolean userDeleted) { - update(new LambdaUpdateWrapper() - .eq(ProductBrowseHistoryDO::getUserId, userId) - .in(CollUtil.isNotEmpty(spuIds), ProductBrowseHistoryDO::getSpuId, spuIds) - .set(ProductBrowseHistoryDO::getUserDeleted, userDeleted)); - } - - default Page selectPageByUserIdOrderByCreateTimeAsc(Long userId, Integer pageNo, Integer pageSize) { - Page page = Page.of(pageNo, pageSize); - return selectPage(page, new LambdaQueryWrapperX() - .eqIfPresent(ProductBrowseHistoryDO::getUserId, userId) - .orderByAsc(ProductBrowseHistoryDO::getCreateTime)); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java deleted file mode 100644 index 8a55eaf48..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface ProductPropertyMapper extends BaseMapperX { - - default PageResult selectPage(ProductPropertyPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ProductPropertyDO::getName, reqVO.getName()) - .betweenIfPresent(ProductPropertyDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductPropertyDO::getId)); - } - - default ProductPropertyDO selectByName(String name) { - return selectOne(ProductPropertyDO::getName, name); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java deleted file mode 100644 index 402df51e7..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyValueMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface ProductPropertyValueMapper extends BaseMapperX { - - default List selectListByPropertyId(Collection propertyIds) { - return selectList(new LambdaQueryWrapperX() - .inIfPresent(ProductPropertyValueDO::getPropertyId, propertyIds)); - } - - default ProductPropertyValueDO selectByName(Long propertyId, String name) { - return selectOne(new LambdaQueryWrapperX() - .eq(ProductPropertyValueDO::getPropertyId, propertyId) - .eq(ProductPropertyValueDO::getName, name)); - } - - default void deleteByPropertyId(Long propertyId) { - delete(new LambdaQueryWrapperX() - .eq(ProductPropertyValueDO::getPropertyId, propertyId)); - } - - default PageResult selectPage(ProductPropertyValuePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ProductPropertyValueDO::getPropertyId, reqVO.getPropertyId()) - .likeIfPresent(ProductPropertyValueDO::getName, reqVO.getName()) - .orderByDesc(ProductPropertyValueDO::getId)); - } - - default Integer selectCountByPropertyId(Long propertyId) { - return selectCount(ProductPropertyValueDO::getPropertyId, propertyId).intValue(); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java deleted file mode 100755 index 82bfc87fa..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.sku; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface ProductSkuMapper extends BaseMapperX { - - default List selectListBySpuId(Long spuId) { - return selectList(ProductSkuDO::getSpuId, spuId); - } - - default List selectListBySpuId(Collection spuIds) { - return selectList(ProductSkuDO::getSpuId, spuIds); - } - - default void deleteBySpuId(Long spuId) { - delete(new LambdaQueryWrapperX().eq(ProductSkuDO::getSpuId, spuId)); - } - - /** - * 更新 SKU 库存(增加) - * - * @param id 编号 - * @param incrCount 增加库存(正数) - */ - default void updateStockIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount > 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" stock = stock + " + incrCount) - .eq(ProductSkuDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新 SKU 库存(减少) - * - * @param id 编号 - * @param incrCount 减少库存(负数) - * @return 更新条数 - */ - default int updateStockDecr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() - .setSql(" stock = stock + " + incrCount) // 负数,所以使用 + 号 - .eq(ProductSkuDO::getId, id) - .ge(ProductSkuDO::getStock, -incrCount); // cas 逻辑 - return update(null, updateWrapper); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java deleted file mode 100755 index 68f2d210f..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.spu; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.enums.ProductConstants; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Objects; -import java.util.Set; - -@Mapper -public interface ProductSpuMapper extends BaseMapperX { - - /** - * 获取商品 SPU 分页列表数据 - * - * @param reqVO 分页请求参数 - * @return 商品 SPU 分页列表数据 - */ - default PageResult selectPage(ProductSpuPageReqVO reqVO) { - Integer tabType = reqVO.getTabType(); - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX() - .likeIfPresent(ProductSpuDO::getName, reqVO.getName()) - .eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()) - .betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ProductSpuDO::getSort); - appendTabQuery(tabType, queryWrapper); - return selectPage(reqVO, queryWrapper); - } - - /** - * 查询触发警戒库存的 SPU 数量 - * - * @return 触发警戒库存的 SPU 数量 - */ - default Long selectCount() { - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX<>(); - // 库存小于等于警戒库存 - queryWrapper.le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK) - // 如果库存触发警戒库存且状态为回收站的话则不计入触发警戒库存的个数 - .notIn(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()); - return selectCount(queryWrapper); - } - - /** - * 获得商品 SPU 分页,提供给用户 App 使用 - */ - default PageResult selectPage(AppProductSpuPageReqVO pageReqVO, Set categoryIds) { - LambdaQueryWrapperX query = new LambdaQueryWrapperX() - // 关键字匹配,目前只匹配商品名 - .likeIfPresent(ProductSpuDO::getName, pageReqVO.getKeyword()) - // 分类 - .inIfPresent(ProductSpuDO::getCategoryId, categoryIds); - // 上架状态 且有库存 - query.eq(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()); - - // 排序逻辑 - if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_SALES_COUNT)) { - query.last(String.format(" ORDER BY (sales_count + virtual_sales_count) %s, sort DESC, id DESC", - pageReqVO.getSortAsc() ? "ASC" : "DESC")); - } else if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_PRICE)) { - query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getPrice) - .orderByDesc(ProductSpuDO::getSort).orderByDesc(ProductSpuDO::getId); - } else if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_CREATE_TIME)) { - query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getCreateTime) - .orderByDesc(ProductSpuDO::getSort).orderByDesc(ProductSpuDO::getId); - } else { - query.orderByDesc(ProductSpuDO::getSort).orderByDesc(ProductSpuDO::getId); - } - return selectPage(pageReqVO, query); - } - - /** - * 更新商品 SPU 库存 - * - * @param id 商品 SPU 编号 - * @param incrCount 增加的库存数量 - */ - default void updateStock(Long id, Integer incrCount) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() - // 负数,所以使用 + 号 - .setSql(" stock = stock +" + incrCount) - .eq(ProductSpuDO::getId, id); - update(null, updateWrapper); - } - - /** - * 添加后台 Tab 选项的查询条件 - * - * @param tabType 标签类型 - * @param query 查询条件 - */ - static void appendTabQuery(Integer tabType, LambdaQueryWrapperX query) { - // 出售中商品 - if (ObjectUtil.equals(ProductSpuPageReqVO.FOR_SALE, tabType)) { - query.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()); - } - // 仓储中商品 - if (ObjectUtil.equals(ProductSpuPageReqVO.IN_WAREHOUSE, tabType)) { - query.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus()); - } - // 已售空商品 - if (ObjectUtil.equals(ProductSpuPageReqVO.SOLD_OUT, tabType)) { - query.eqIfPresent(ProductSpuDO::getStock, 0); - } - // 警戒库存 - if (ObjectUtil.equals(ProductSpuPageReqVO.ALERT_STOCK, tabType)) { - query.le(ProductSpuDO::getStock, ProductConstants.ALERT_STOCK) - // 如果库存触发警戒库存且状态为回收站的话则不在警戒库存列表展示 - .notIn(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()); - } - // 回收站 - if (ObjectUtil.equals(ProductSpuPageReqVO.RECYCLE_BIN, tabType)) { - query.eqIfPresent(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()); - } - } - - /** - * 更新商品 SPU 浏览量 - * - * @param id 商品 SPU 编号 - * @param incrCount 增加的数量 - */ - default void updateBrowseCount(Long id, int incrCount) { - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() - .setSql(" browse_count = browse_count +" + incrCount) - .eq(ProductSpuDO::getId, id); - update(null, updateWrapper); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/package-info.java deleted file mode 100644 index d2e1c934a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 product 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.product.framework; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/rpc/config/RpcConfiguration.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index a5f8aff4b..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.module.product.framework.rpc.config; - -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {MemberUserApi.class, MemberLevelApi.class}) -public class RpcConfiguration { -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/rpc/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/rpc/package-info.java deleted file mode 100644 index c15de0c2a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.product.framework.rpc; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/security/config/SecurityConfiguration.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index dbfb9f445..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.product.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.product.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Member 模块的 Security 配置 - */ -@Configuration("productSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("productAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/security/core/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/security/core/package-info.java deleted file mode 100644 index 8eb5274b2..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.product.framework.security.core; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java deleted file mode 100644 index e32942933..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * product 模块,主要实现交易相关功能 - * 例如:订单、退款、购物车等功能。 - * - * 1. Controller URL:以 /product/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 product_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.product; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandService.java deleted file mode 100644 index 70ee4a3d0..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandService.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.product.service.brand; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandUpdateReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 商品品牌 Service 接口 - * - * @author 芋道源码 - */ -public interface ProductBrandService { - - /** - * 创建品牌 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBrand(@Valid ProductBrandCreateReqVO createReqVO); - - /** - * 更新品牌 - * - * @param updateReqVO 更新信息 - */ - void updateBrand(@Valid ProductBrandUpdateReqVO updateReqVO); - - /** - * 删除品牌 - * - * @param id 编号 - */ - void deleteBrand(Long id); - - /** - * 获得品牌 - * - * @param id 编号 - * @return 品牌 - */ - ProductBrandDO getBrand(Long id); - - /** - * 获得品牌列表 - * - * @param ids 编号 - * @return 品牌列表 - */ - List getBrandList(Collection ids); - - /** - * 获得品牌列表 - * - * @param listReqVO 请求参数 - * @return 品牌列表 - */ - List getBrandList(ProductBrandListReqVO listReqVO); - - /** - * 验证选择的商品分类是否合法 - * - * @param id 分类编号 - */ - void validateProductBrand(Long id); - - /** - * 获得品牌分页 - * - * @param pageReqVO 分页查询 - * @return 品牌分页 - */ - PageResult getBrandPage(ProductBrandPageReqVO pageReqVO); - - /** - * 获取指定状态的品牌列表 - * - * @param status 状态 - * @return 返回品牌列表 - */ - List getBrandListByStatus(Integer status); -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImpl.java deleted file mode 100644 index b97123f6a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/brand/ProductBrandServiceImpl.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.yudao.module.product.service.brand; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.brand.vo.ProductBrandUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.brand.ProductBrandConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; -import cn.iocoder.yudao.module.product.dal.mysql.brand.ProductBrandMapper; -import com.google.common.annotations.VisibleForTesting; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 品牌 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductBrandServiceImpl implements ProductBrandService { - - @Resource - private ProductBrandMapper brandMapper; - - @Override - public Long createBrand(ProductBrandCreateReqVO createReqVO) { - // 校验 - validateBrandNameUnique(null, createReqVO.getName()); - - // 插入 - ProductBrandDO brand = ProductBrandConvert.INSTANCE.convert(createReqVO); - brandMapper.insert(brand); - // 返回 - return brand.getId(); - } - - @Override - public void updateBrand(ProductBrandUpdateReqVO updateReqVO) { - // 校验存在 - validateBrandExists(updateReqVO.getId()); - validateBrandNameUnique(updateReqVO.getId(), updateReqVO.getName()); - // 更新 - ProductBrandDO updateObj = ProductBrandConvert.INSTANCE.convert(updateReqVO); - brandMapper.updateById(updateObj); - } - - @Override - public void deleteBrand(Long id) { - // 校验存在 - validateBrandExists(id); - // 删除 - brandMapper.deleteById(id); - } - - private void validateBrandExists(Long id) { - if (brandMapper.selectById(id) == null) { - throw exception(BRAND_NOT_EXISTS); - } - } - - @VisibleForTesting - public void validateBrandNameUnique(Long id, String name) { - ProductBrandDO brand = brandMapper.selectByName(name); - if (brand == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的字典类型 - if (id == null) { - throw exception(BRAND_NAME_EXISTS); - } - if (!brand.getId().equals(id)) { - throw exception(BRAND_NAME_EXISTS); - } - } - - @Override - public ProductBrandDO getBrand(Long id) { - return brandMapper.selectById(id); - } - - @Override - public List getBrandList(Collection ids) { - return brandMapper.selectBatchIds(ids); - } - - @Override - public List getBrandList(ProductBrandListReqVO listReqVO) { - return brandMapper.selectList(listReqVO); - } - - @Override - public void validateProductBrand(Long id) { - ProductBrandDO brand = brandMapper.selectById(id); - if (brand == null) { - throw exception(BRAND_NOT_EXISTS); - } - if (brand.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { - throw exception(BRAND_DISABLED); - } - } - - @Override - public PageResult getBrandPage(ProductBrandPageReqVO pageReqVO) { - return brandMapper.selectPage(pageReqVO); - } - - @Override - public List getBrandListByStatus(Integer status) { - return brandMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java deleted file mode 100644 index 52959a800..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.product.service.category; - -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategorySaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 商品分类 Service 接口 - * - * @author 芋道源码 - */ -public interface ProductCategoryService { - - /** - * 创建商品分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCategory(@Valid ProductCategorySaveReqVO createReqVO); - - /** - * 更新商品分类 - * - * @param updateReqVO 更新信息 - */ - void updateCategory(@Valid ProductCategorySaveReqVO updateReqVO); - - /** - * 删除商品分类 - * - * @param id 编号 - */ - void deleteCategory(Long id); - - /** - * 获得商品分类 - * - * @param id 编号 - * @return 商品分类 - */ - ProductCategoryDO getCategory(Long id); - - /** - * 校验商品分类 - * - * @param id 分类编号 - */ - void validateCategory(Long id); - - /** - * 获得商品分类的层级 - * - * @param id 编号 - * @return 商品分类的层级 - */ - Integer getCategoryLevel(Long id); - - /** - * 获得商品分类列表 - * - * @param listReqVO 查询条件 - * @return 商品分类列表 - */ - List getCategoryList(ProductCategoryListReqVO listReqVO); - - /** - * 获得开启状态的商品分类列表 - * - * @return 商品分类列表 - */ - List getEnableCategoryList(); - - /** - * 获得开启状态的商品分类列表,指定编号 - * - * @param ids 商品分类编号数组 - * @return 商品分类列表 - */ - List getEnableCategoryList(List ids); - - /** - * 校验商品分类是否有效。如下情况,视为无效: - * 1. 商品分类编号不存在 - * 2. 商品分类被禁用 - * - * @param ids 商品分类编号数组 - */ - void validateCategoryList(Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java deleted file mode 100644 index 1dbf62fb9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java +++ /dev/null @@ -1,177 +0,0 @@ -package cn.iocoder.yudao.module.product.service.category; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategorySaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.dal.mysql.category.ProductCategoryMapper; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.PARENT_ID_NULL; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品分类 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductCategoryServiceImpl implements ProductCategoryService { - - @Resource - private ProductCategoryMapper productCategoryMapper; - @Resource - @Lazy // 循环依赖,避免报错 - private ProductSpuService productSpuService; - - @Override - public Long createCategory(ProductCategorySaveReqVO createReqVO) { - // 校验父分类存在 - validateParentProductCategory(createReqVO.getParentId()); - - // 插入 - ProductCategoryDO category = BeanUtils.toBean(createReqVO, ProductCategoryDO.class); - productCategoryMapper.insert(category); - // 返回 - return category.getId(); - } - - @Override - public void updateCategory(ProductCategorySaveReqVO updateReqVO) { - // 校验分类是否存在 - validateProductCategoryExists(updateReqVO.getId()); - // 校验父分类存在 - validateParentProductCategory(updateReqVO.getParentId()); - - // 更新 - ProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, ProductCategoryDO.class); - productCategoryMapper.updateById(updateObj); - } - - @Override - public void deleteCategory(Long id) { - // 校验分类是否存在 - validateProductCategoryExists(id); - // 校验是否还有子分类 - if (productCategoryMapper.selectCountByParentId(id) > 0) { - throw exception(CATEGORY_EXISTS_CHILDREN); - } - // 校验分类是否绑定了 SPU - Long spuCount = productSpuService.getSpuCountByCategoryId(id); - if (spuCount > 0) { - throw exception(CATEGORY_HAVE_BIND_SPU); - } - // 删除 - productCategoryMapper.deleteById(id); - } - - private void validateParentProductCategory(Long id) { - // 如果是根分类,无需验证 - if (Objects.equals(id, PARENT_ID_NULL)) { - return; - } - // 父分类不存在 - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(CATEGORY_PARENT_NOT_EXISTS); - } - // 父分类不能是二级分类 - if (!Objects.equals(category.getParentId(), PARENT_ID_NULL)) { - throw exception(CATEGORY_PARENT_NOT_FIRST_LEVEL); - } - } - - private void validateProductCategoryExists(Long id) { - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - } - - @Override - public void validateCategoryList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return; - } - // 获得商品分类信息 - List list = productCategoryMapper.selectBatchIds(ids); - Map categoryMap = CollectionUtils.convertMap(list, ProductCategoryDO::getId); - // 校验 - ids.forEach(id -> { - ProductCategoryDO category = categoryMap.get(id); - if (category == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - if (!CommonStatusEnum.ENABLE.getStatus().equals(category.getStatus())) { - throw exception(CATEGORY_DISABLED, category.getName()); - } - }); - } - - @Override - public ProductCategoryDO getCategory(Long id) { - return productCategoryMapper.selectById(id); - } - - @Override - public void validateCategory(Long id) { - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null) { - throw exception(CATEGORY_NOT_EXISTS); - } - if (Objects.equals(category.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(CATEGORY_DISABLED, category.getName()); - } - } - - @Override - public Integer getCategoryLevel(Long id) { - if (Objects.equals(id, PARENT_ID_NULL)) { - return 0; - } - int level = 1; - // for 的原因,是因为避免脏数据,导致可能的死循环。一般不会超过 100 层哈 - for (int i = 0; i < Byte.MAX_VALUE; i++) { - // 如果没有父节点,break 结束 - ProductCategoryDO category = productCategoryMapper.selectById(id); - if (category == null - || Objects.equals(category.getParentId(), PARENT_ID_NULL)) { - break; - } - // 继续递归父节点 - level++; - id = category.getParentId(); - } - return level; - } - - @Override - public List getCategoryList(ProductCategoryListReqVO listReqVO) { - return productCategoryMapper.selectList(listReqVO); - } - - @Override - public List getEnableCategoryList() { - return productCategoryMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); - } - - @Override - public List getEnableCategoryList(List ids) { - return productCategoryMapper.selectListByIdAndStatus(ids, CommonStatusEnum.ENABLE.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java deleted file mode 100644 index b54e21918..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.iocoder.yudao.module.product.service.comment; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -/** - * 商品评论 Service 接口 - * - * @author wangzhs - */ -@Service -@Validated -public interface ProductCommentService { - - /** - * 创建商品评论 - * 后台管理员创建评论使用 - * - * @param createReqVO 商品评价创建 Request VO 对象 - */ - void createComment(ProductCommentCreateReqVO createReqVO); - - /** - * 创建评论 - * 创建商品评论 APP 端创建商品评论使用 - * - * @param createReqDTO 创建请求 dto - * @return 返回评论 id - */ - Long createComment(ProductCommentCreateReqDTO createReqDTO); - - /** - * 修改评论是否可见 - * - * @param updateReqVO 修改评论可见 - */ - void updateCommentVisible(ProductCommentUpdateVisibleReqVO updateReqVO); - - /** - * 商家回复 - * - * @param replyVO 商家回复 - * @param userId 管理后台商家登陆人 ID - */ - void replyComment(ProductCommentReplyReqVO replyVO, Long userId); - - /** - * 【管理员】获得商品评价分页 - * - * @param pageReqVO 分页查询 - * @return 商品评价分页 - */ - PageResult getCommentPage(ProductCommentPageReqVO pageReqVO); - - /** - * 【会员】获得商品评价分页 - * - * @param pageVO 分页查询 - * @param visible 是否可见 - * @return 商品评价分页 - */ - PageResult getCommentPage(AppCommentPageReqVO pageVO, Boolean visible); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java deleted file mode 100644 index 6ce9bfc59..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.product.service.comment; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO; -import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO; -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; -import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.dal.mysql.comment.ProductCommentMapper; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品评论 Service 实现类 - * - * @author wangzhs - */ -@Service -@Validated -public class ProductCommentServiceImpl implements ProductCommentService { - - @Resource - private ProductCommentMapper productCommentMapper; - - @Resource - private ProductSpuService productSpuService; - - @Resource - @Lazy - private ProductSkuService productSkuService; - - @Resource - private MemberUserApi memberUserApi; - - @Override - public void createComment(ProductCommentCreateReqVO createReqVO) { - // 校验 SKU - ProductSkuDO sku = validateSku(createReqVO.getSkuId()); - // 校验 SPU - ProductSpuDO spu = validateSpu(sku.getSpuId()); - - // 创建评论 - ProductCommentDO comment = ProductCommentConvert.INSTANCE.convert(createReqVO, spu, sku); - productCommentMapper.insert(comment); - } - - @Override - public Long createComment(ProductCommentCreateReqDTO createReqDTO) { - // 校验 SKU - ProductSkuDO sku = validateSku(createReqDTO.getSkuId()); - // 校验 SPU - ProductSpuDO spu = validateSpu(sku.getSpuId()); - // 校验评论 - validateCommentExists(createReqDTO.getUserId(), createReqDTO.getOrderId()); - // 获取用户详细信息 - MemberUserRespDTO user = memberUserApi.getUser(createReqDTO.getUserId()).getCheckedData(); - - // 创建评论 - ProductCommentDO comment = ProductCommentConvert.INSTANCE.convert(createReqDTO, spu, sku, user); - productCommentMapper.insert(comment); - return comment.getId(); - } - - /** - * 判断当前订单的当前商品用户是否评价过 - * - * @param userId 用户编号 - * @param orderItemId 订单项编号 - */ - private void validateCommentExists(Long userId, Long orderItemId) { - ProductCommentDO exist = productCommentMapper.selectByUserIdAndOrderItemId(userId, orderItemId); - if (exist != null) { - throw exception(COMMENT_ORDER_EXISTS); - } - } - - private ProductSkuDO validateSku(Long skuId) { - ProductSkuDO sku = productSkuService.getSku(skuId); - if (sku == null) { - throw exception(SKU_NOT_EXISTS); - } - return sku; - } - - private ProductSpuDO validateSpu(Long spuId) { - ProductSpuDO spu = productSpuService.getSpu(spuId); - if (null == spu) { - throw exception(SPU_NOT_EXISTS); - } - return spu; - } - - @Override - public void updateCommentVisible(ProductCommentUpdateVisibleReqVO updateReqVO) { - // 校验评论是否存在 - validateCommentExists(updateReqVO.getId()); - - // 更新可见状态 - productCommentMapper.updateById(new ProductCommentDO().setId(updateReqVO.getId()) - .setVisible(updateReqVO.getVisible())); - } - - @Override - public void replyComment(ProductCommentReplyReqVO replyVO, Long userId) { - // 校验评论是否存在 - validateCommentExists(replyVO.getId()); - // 回复评论 - productCommentMapper.updateById(new ProductCommentDO().setId(replyVO.getId()) - .setReplyTime(LocalDateTime.now()).setReplyUserId(userId) - .setReplyStatus(Boolean.TRUE).setReplyContent(replyVO.getReplyContent())); - } - - private ProductCommentDO validateCommentExists(Long id) { - ProductCommentDO productComment = productCommentMapper.selectById(id); - if (productComment == null) { - throw exception(COMMENT_NOT_EXISTS); - } - return productComment; - } - - @Override - public PageResult getCommentPage(AppCommentPageReqVO pageVO, Boolean visible) { - return productCommentMapper.selectPage(pageVO, visible); - } - - @Override - public PageResult getCommentPage(ProductCommentPageReqVO pageReqVO) { - return productCommentMapper.selectPage(pageReqVO); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteService.java deleted file mode 100644 index 3dd3bd59e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteService.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.product.service.favorite; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; - -import javax.validation.Valid; - -/** - * 商品收藏 Service 接口 - * - * @author jason - */ -public interface ProductFavoriteService { - - /** - * 创建商品收藏 - * - * @param userId 用户编号 - * @param spuId SPU 编号 - */ - Long createFavorite(Long userId, Long spuId); - - /** - * 取消商品收藏 - * - * @param userId 用户编号 - * @param spuId SPU 编号 - */ - void deleteFavorite(Long userId, Long spuId); - - /** - * 分页查询用户收藏列表 - * - * @param userId 用户编号 - * @param reqVO 请求 vo - */ - PageResult getFavoritePage(Long userId, @Valid AppFavoritePageReqVO reqVO); - - /** - * 分页查询用户收藏列表 - * - * @param reqVO 请求 vo - */ - PageResult getFavoritePage(@Valid ProductFavoritePageReqVO reqVO); - - /** - * 获取收藏过商品 - * - * @param userId 用户编号 - * @param spuId SPU 编号 - */ - ProductFavoriteDO getFavorite(Long userId, Long spuId); - - /** - * 获取用户收藏数量 - * - * @param userId 用户编号 - * @return 数量 - */ - Long getFavoriteCount(Long userId); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteServiceImpl.java deleted file mode 100644 index 927d030d5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/favorite/ProductFavoriteServiceImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.product.service.favorite; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.favorite.vo.ProductFavoritePageReqVO; -import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO; -import cn.iocoder.yudao.module.product.convert.favorite.ProductFavoriteConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.favorite.ProductFavoriteDO; -import cn.iocoder.yudao.module.product.dal.mysql.favorite.ProductFavoriteMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.FAVORITE_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.FAVORITE_NOT_EXISTS; - -/** - * 商品收藏 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class ProductFavoriteServiceImpl implements ProductFavoriteService { - - @Resource - private ProductFavoriteMapper productFavoriteMapper; - - @Override - public Long createFavorite(Long userId, Long spuId) { - ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId); - if (favorite != null) { - throw exception(FAVORITE_EXISTS); - } - - ProductFavoriteDO entity = ProductFavoriteConvert.INSTANCE.convert(userId, spuId); - productFavoriteMapper.insert(entity); - return entity.getId(); - } - - @Override - public void deleteFavorite(Long userId, Long spuId) { - ProductFavoriteDO favorite = productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId); - if (favorite == null) { - throw exception(FAVORITE_NOT_EXISTS); - } - - productFavoriteMapper.deleteById(favorite.getId()); - } - - @Override - public PageResult getFavoritePage(Long userId, @Valid AppFavoritePageReqVO reqVO) { - return productFavoriteMapper.selectPageByUserAndType(userId, reqVO); - } - - @Override - public PageResult getFavoritePage(@Valid ProductFavoritePageReqVO reqVO) { - return productFavoriteMapper.selectPageByUserId(reqVO); - } - - @Override - public ProductFavoriteDO getFavorite(Long userId, Long spuId) { - return productFavoriteMapper.selectByUserIdAndSpuId(userId, spuId); - } - - @Override - public Long getFavoriteCount(Long userId) { - return productFavoriteMapper.selectCountByUserId(userId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryService.java deleted file mode 100644 index 10f3a71d5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryService.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.product.service.history; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO; -import org.springframework.scheduling.annotation.Async; - -import java.util.Collection; - -/** - * 商品浏览记录 Service 接口 - * - * @author owen - */ -public interface ProductBrowseHistoryService { - - /** - * 创建商品浏览记录 - * - * @param userId 用户编号 - * @param spuId SPU 编号 - */ - @Async - void createBrowseHistory(Long userId, Long spuId); - - /** - * 隐藏用户商品浏览记录 - * - * @param userId 用户编号 - * @param spuId SPU 编号 - */ - void hideUserBrowseHistory(Long userId, Collection spuId); - - /** - * 获得商品浏览记录分页 - * - * @param pageReqVO 分页查询 - * @return 商品浏览记录分页 - */ - PageResult getBrowseHistoryPage(ProductBrowseHistoryPageReqVO pageReqVO); - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryServiceImpl.java deleted file mode 100644 index 8645be72c..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryServiceImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.product.service.history; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO; -import cn.iocoder.yudao.module.product.dal.mysql.history.ProductBrowseHistoryMapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; - -/** - * 商品浏览记录 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class ProductBrowseHistoryServiceImpl implements ProductBrowseHistoryService { - - private static final int USER_STORE_MAXIMUM = 100; - - @Resource - private ProductBrowseHistoryMapper browseHistoryMapper; - - @Override - public void createBrowseHistory(Long userId, Long spuId) { - // 用户未登录时不记录 - if (userId == null) { - return; - } - - // 情况一:同一个商品,只保留最新的一条记录 - ProductBrowseHistoryDO history = browseHistoryMapper.selectByUserIdAndSpuId(userId, spuId); - if (history != null) { - browseHistoryMapper.deleteById(history); - } else { - // 情况二:限制每个用户的浏览记录的条数(只查一条最早地记录、记录总数) - // TODO @疯狂:这里最好先查询一次数量。如果发现超过了,再删除;主要考虑,可能有部分不超过,提前就多了一次 sql 查询了 - Page pageResult = browseHistoryMapper.selectPageByUserIdOrderByCreateTimeAsc(userId, 1, 1); - if (pageResult.getTotal() >= USER_STORE_MAXIMUM) { - browseHistoryMapper.deleteById(CollUtil.getFirst(pageResult.getRecords())); - } - } - - // 插入 - ProductBrowseHistoryDO browseHistory = new ProductBrowseHistoryDO() - .setUserId(userId) - .setSpuId(spuId); - browseHistoryMapper.insert(browseHistory); - } - - @Override - public void hideUserBrowseHistory(Long userId, Collection spuIds) { - browseHistoryMapper.updateUserDeletedByUserId(userId, spuIds, true); - } - - @Override - public PageResult getBrowseHistoryPage(ProductBrowseHistoryPageReqVO pageReqVO) { - return browseHistoryMapper.selectPage(pageReqVO); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java deleted file mode 100644 index c65d150d9..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertySaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 商品属性项 Service 接口 - * - * @author 芋道源码 - */ -public interface ProductPropertyService { - - /** - * 创建属性项 - * 注意,如果已经存在该属性项,直接返回它的编号即可 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProperty(@Valid ProductPropertySaveReqVO createReqVO); - - /** - * 更新属性项 - * - * @param updateReqVO 更新信息 - */ - void updateProperty(@Valid ProductPropertySaveReqVO updateReqVO); - - /** - * 删除属性项 - * - * @param id 编号 - */ - void deleteProperty(Long id); - - /** - * 获取属性名称分页 - * - * @param pageReqVO 分页条件 - * @return 属性项分页 - */ - PageResult getPropertyPage(ProductPropertyPageReqVO pageReqVO); - - /** - * 获得指定编号的属性项 - * - * @param id 编号 - * @return 属性项 - */ - ProductPropertyDO getProperty(Long id); - - /** - * 根据属性项的编号的集合,获得对应的属性项数组 - * - * @param ids 属性项的编号的集合 - * @return 属性项数组 - */ - List getPropertyList(Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java deleted file mode 100644 index 8843640fa..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertySaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyMapper; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品属性项 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductPropertyServiceImpl implements ProductPropertyService { - - @Resource - private ProductPropertyMapper productPropertyMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖问题 - private ProductPropertyValueService productPropertyValueService; - - @Resource - private ProductSkuService productSkuService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createProperty(ProductPropertySaveReqVO createReqVO) { - // 如果已经添加过该属性项,直接返回 - ProductPropertyDO dbProperty = productPropertyMapper.selectByName(createReqVO.getName()); - if (dbProperty != null) { - return dbProperty.getId(); - } - - // 插入 - ProductPropertyDO property = BeanUtils.toBean(createReqVO, ProductPropertyDO.class); - productPropertyMapper.insert(property); - // 返回 - return property.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateProperty(ProductPropertySaveReqVO updateReqVO) { - validatePropertyExists(updateReqVO.getId()); - // 校验名字重复 - ProductPropertyDO property = productPropertyMapper.selectByName(updateReqVO.getName()); - if (property != null && - ObjUtil.notEqual(property.getId(), updateReqVO.getId())) { - throw exception(PROPERTY_EXISTS); - } - - // 更新 - ProductPropertyDO updateObj = BeanUtils.toBean(updateReqVO, ProductPropertyDO.class); - productPropertyMapper.updateById(updateObj); - // 更新 sku 相关属性 - productSkuService.updateSkuProperty(updateObj.getId(), updateObj.getName()); - } - - @Override - public void deleteProperty(Long id) { - // 校验存在 - validatePropertyExists(id); - // 校验其下是否有规格值 - if (productPropertyValueService.getPropertyValueCountByPropertyId(id) > 0) { - throw exception(PROPERTY_DELETE_FAIL_VALUE_EXISTS); - } - - // 删除 - productPropertyMapper.deleteById(id); - // 同步删除属性值 - productPropertyValueService.deletePropertyValueByPropertyId(id); - } - - private void validatePropertyExists(Long id) { - if (productPropertyMapper.selectById(id) == null) { - throw exception(PROPERTY_NOT_EXISTS); - } - } - - @Override - public PageResult getPropertyPage(ProductPropertyPageReqVO pageReqVO) { - return productPropertyMapper.selectPage(pageReqVO); - } - - @Override - public ProductPropertyDO getProperty(Long id) { - return productPropertyMapper.selectById(id); - } - - @Override - public List getPropertyList(Collection ids) { - return productPropertyMapper.selectBatchIds(ids); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java deleted file mode 100644 index aaa7ff12a..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueSaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; - -import java.util.Collection; -import java.util.List; - -/** - * 商品属性值 Service 接口 - * - * @author LuoWenFeng - */ -public interface ProductPropertyValueService { - - /** - * 创建属性值 - * 注意,如果已经存在该属性值,直接返回它的编号即可 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createPropertyValue(ProductPropertyValueSaveReqVO createReqVO); - - /** - * 更新属性值 - * - * @param updateReqVO 更新信息 - */ - void updatePropertyValue(ProductPropertyValueSaveReqVO updateReqVO); - - /** - * 删除属性值 - * - * @param id 编号 - */ - void deletePropertyValue(Long id); - - /** - * 获得属性值 - * - * @param id 编号 - * @return 属性值 - */ - ProductPropertyValueDO getPropertyValue(Long id); - - /** - * 根据属性项编号数组,获得属性值列表 - * - * @param propertyIds 属性项目编号数组 - * @return 属性值列表 - */ - List getPropertyValueListByPropertyId(Collection propertyIds); - - /** - * 根据属性项编号,活的属性值数量 - * - * @param propertyId 属性项编号数 - * @return 属性值数量 - */ - Integer getPropertyValueCountByPropertyId(Long propertyId); - - /** - * 获取属性值的分页 - * - * @param pageReqVO 查询条件 - * @return 属性值的分页 - */ - PageResult getPropertyValuePage(ProductPropertyValuePageReqVO pageReqVO); - - /** - * 删除指定属性项编号下的属性值们 - * - * @param propertyId 属性项的编号 - */ - void deletePropertyValueByPropertyId(Long propertyId); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java deleted file mode 100644 index 6ef001181..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueSaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_NOT_EXISTS; - -/** - * 商品属性值 Service 实现类 - * - * @author LuoWenFeng - */ -@Service -@Validated -public class ProductPropertyValueServiceImpl implements ProductPropertyValueService { - - @Resource - private ProductPropertyValueMapper productPropertyValueMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private ProductSkuService productSkuService; - - @Override - public Long createPropertyValue(ProductPropertyValueSaveReqVO createReqVO) { - // 如果已经添加过该属性值,直接返回 - ProductPropertyValueDO dbValue = productPropertyValueMapper.selectByName( - createReqVO.getPropertyId(), createReqVO.getName()); - if (dbValue != null) { - return dbValue.getId(); - } - - // 新增 - ProductPropertyValueDO value = BeanUtils.toBean(createReqVO, ProductPropertyValueDO.class); - productPropertyValueMapper.insert(value); - return value.getId(); - } - - @Override - public void updatePropertyValue(ProductPropertyValueSaveReqVO updateReqVO) { - validatePropertyValueExists(updateReqVO.getId()); - // 校验名字唯一 - ProductPropertyValueDO value = productPropertyValueMapper.selectByName - (updateReqVO.getPropertyId(), updateReqVO.getName()); - if (value != null && !value.getId().equals(updateReqVO.getId())) { - throw exception(PROPERTY_VALUE_EXISTS); - } - - // 更新 - ProductPropertyValueDO updateObj = BeanUtils.toBean(updateReqVO, ProductPropertyValueDO.class); - productPropertyValueMapper.updateById(updateObj); - // 更新 sku 相关属性 - productSkuService.updateSkuPropertyValue(updateObj.getId(), updateObj.getName()); - } - - @Override - public void deletePropertyValue(Long id) { - validatePropertyValueExists(id); - productPropertyValueMapper.deleteById(id); - } - - private void validatePropertyValueExists(Long id) { - if (productPropertyValueMapper.selectById(id) == null) { - throw exception(PROPERTY_VALUE_NOT_EXISTS); - } - } - - @Override - public ProductPropertyValueDO getPropertyValue(Long id) { - return productPropertyValueMapper.selectById(id); - } - - @Override - public List getPropertyValueListByPropertyId(Collection propertyIds) { - return productPropertyValueMapper.selectListByPropertyId(propertyIds); - } - - @Override - public Integer getPropertyValueCountByPropertyId(Long propertyId) { - return productPropertyValueMapper.selectCountByPropertyId(propertyId); - } - - @Override - public PageResult getPropertyValuePage(ProductPropertyValuePageReqVO pageReqVO) { - return productPropertyValueMapper.selectPage(pageReqVO); - } - - @Override - public void deletePropertyValueByPropertyId(Long propertyId) { - productPropertyValueMapper.deleteByPropertyId(propertyId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java deleted file mode 100755 index a6d3f02b5..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java +++ /dev/null @@ -1,113 +0,0 @@ -package cn.iocoder.yudao.module.product.service.sku; - -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; - -import java.util.Collection; -import java.util.List; - -/** - * 商品 SKU Service 接口 - * - * @author 芋道源码 - */ -public interface ProductSkuService { - - /** - * 删除商品 SKU - * - * @param id 编号 - */ - void deleteSku(Long id); - - /** - * 获得商品 SKU 信息 - * - * @param id 编号 - * @return 商品 SKU 信息 - */ - ProductSkuDO getSku(Long id); - - /** - * 获得商品 SKU 列表 - * - * @param ids 编号 - * @return 商品sku列表 - */ - List getSkuList(Collection ids); - - /** - * 对 sku 的组合的属性等进行合法性校验 - * - * @param list sku组合的集合 - */ - void validateSkuList(List list, Boolean specType); - - /** - * 批量创建 SKU - * - * @param spuId 商品 SPU 编号 - * @param list SKU 对象集合 - */ - void createSkuList(Long spuId, List list); - - /** - * 根据 SPU 编号,批量更新它的 SKU 信息 - * - * @param spuId SPU 编码 - * @param skus SKU 的集合 - */ - void updateSkuList(Long spuId, List skus); - - /** - * 更新 SKU 库存(增量) - *

- * 如果更新的库存不足,会抛出异常 - * - * @param updateStockReqDTO 更行请求 - */ - void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO); - - /** - * 获得商品 SKU 集合 - * - * @param spuId spu 编号 - * @return 商品sku 集合 - */ - List getSkuListBySpuId(Long spuId); - - /** - * 获得 spu 对应的 SKU 集合 - * - * @param spuIds spu 编码集合 - * @return 商品 sku 集合 - */ - List getSkuListBySpuId(Collection spuIds); - - /** - * 通过 spuId 删除 sku 信息 - * - * @param spuId spu 编码 - */ - void deleteSkuBySpuId(Long spuId); - - /** - * 更新 sku 属性 - * - * @param propertyId 属性 id - * @param propertyName 属性名 - * @return int 影响的行数 - */ - int updateSkuProperty(Long propertyId, String propertyName); - - /** - * 更新 sku 属性值 - * - * @param propertyValueId 属性值 id - * @param propertyValueName 属性值名字 - * @return int 影响的行数 - */ - int updateSkuPropertyValue(Long propertyValueId, String propertyValueName); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java deleted file mode 100755 index 4d07f7ec1..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java +++ /dev/null @@ -1,270 +0,0 @@ -package cn.iocoder.yudao.module.product.service.sku; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; -import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品 SKU Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductSkuServiceImpl implements ProductSkuService { - - @Resource - private ProductSkuMapper productSkuMapper; - - @Resource - @Lazy // 循环依赖,避免报错 - private ProductSpuService productSpuService; - @Resource - @Lazy // 循环依赖,避免报错 - private ProductPropertyService productPropertyService; - @Resource - private ProductPropertyValueService productPropertyValueService; - - @Override - public void deleteSku(Long id) { - // 校验存在 - validateSkuExists(id); - // 删除 - productSkuMapper.deleteById(id); - } - - private void validateSkuExists(Long id) { - if (productSkuMapper.selectById(id) == null) { - throw exception(SKU_NOT_EXISTS); - } - } - - @Override - public ProductSkuDO getSku(Long id) { - return productSkuMapper.selectById(id); - } - - @Override - public List getSkuList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return productSkuMapper.selectBatchIds(ids); - } - - @Override - public void validateSkuList(List skus, Boolean specType) { - // 0、校验skus是否为空 - if (CollUtil.isEmpty(skus)) { - throw exception(SKU_NOT_EXISTS); - } - // 单规格,赋予单规格默认属性 - if (ObjectUtil.equal(specType, false)) { - ProductSkuSaveReqVO skuVO = skus.get(0); - List properties = new ArrayList<>(); - ProductSkuSaveReqVO.Property property = new ProductSkuSaveReqVO.Property() - .setPropertyId(ProductPropertyDO.ID_DEFAULT).setPropertyName(ProductPropertyDO.NAME_DEFAULT) - .setValueId(ProductPropertyValueDO.ID_DEFAULT).setValueName(ProductPropertyValueDO.NAME_DEFAULT); - properties.add(property); - skuVO.setProperties(properties); - return; // 单规格不需要后续的校验 - } - - // 1、校验属性项存在 - Set propertyIds = skus.stream().filter(p -> p.getProperties() != null) - // 遍历多个 Property 属性 - .flatMap(p -> p.getProperties().stream()) - // 将每个 Property 转换成对应的 propertyId,最后形成集合 - .map(ProductSkuSaveReqVO.Property::getPropertyId) - .collect(Collectors.toSet()); - List propertyList = productPropertyService.getPropertyList(propertyIds); - if (propertyList.size() != propertyIds.size()) { - throw exception(PROPERTY_NOT_EXISTS); - } - - // 2. 校验,一个 SKU 下,没有重复的属性。校验方式是,遍历每个 SKU ,看看是否有重复的属性 propertyId - Map propertyValueMap = convertMap(productPropertyValueService.getPropertyValueListByPropertyId(propertyIds), ProductPropertyValueDO::getId); - skus.forEach(sku -> { - Set skuPropertyIds = convertSet(sku.getProperties(), propertyItem -> propertyValueMap.get(propertyItem.getValueId()).getPropertyId()); - if (skuPropertyIds.size() != sku.getProperties().size()) { - throw exception(SKU_PROPERTIES_DUPLICATED); - } - }); - - // 3. 再校验,每个 Sku 的属性值的数量,是一致的。 - int attrValueIdsSize = skus.get(0).getProperties().size(); - for (int i = 1; i < skus.size(); i++) { - if (attrValueIdsSize != skus.get(i).getProperties().size()) { - throw exception(SPU_ATTR_NUMBERS_MUST_BE_EQUALS); - } - } - - // 4. 最后校验,每个 Sku 之间不是重复的 - // 每个元素,都是一个 Sku 的 attrValueId 集合。这样,通过最外层的 Set ,判断是否有重复的. - Set> skuAttrValues = new HashSet<>(); - for (ProductSkuSaveReqVO sku : skus) { - // 添加失败,说明重复 - if (!skuAttrValues.add(convertSet(sku.getProperties(), ProductSkuSaveReqVO.Property::getValueId))) { - throw exception(SPU_SKU_NOT_DUPLICATE); - } - } - } - - @Override - public void createSkuList(Long spuId, List skuCreateReqList) { - List skus = BeanUtils.toBean(skuCreateReqList, ProductSkuDO.class, sku -> sku.setSpuId(spuId)); - productSkuMapper.insertBatch(skus); - } - - @Override - public List getSkuListBySpuId(Long spuId) { - return productSkuMapper.selectListBySpuId(spuId); - } - - @Override - public List getSkuListBySpuId(Collection spuIds) { - if (CollUtil.isEmpty(spuIds)) { - return Collections.emptyList(); - } - return productSkuMapper.selectListBySpuId(spuIds); - } - - @Override - public void deleteSkuBySpuId(Long spuId) { - productSkuMapper.deleteBySpuId(spuId); - } - - @Override - public int updateSkuProperty(Long propertyId, String propertyName) { - // 获取所有的 sku - List skuDOList = productSkuMapper.selectList(); - // 处理后需要更新的 sku - List updateSkus = new ArrayList<>(); - if (CollUtil.isEmpty(skuDOList)) { - return 0; - } - skuDOList.stream().filter(sku -> sku.getProperties() != null) - .forEach(sku -> sku.getProperties().forEach(property -> { - if (property.getPropertyId().equals(propertyId)) { - property.setPropertyName(propertyName); - updateSkus.add(sku); - } - })); - if (CollUtil.isEmpty(updateSkus)) { - return 0; - } - - productSkuMapper.updateBatch(updateSkus); - return updateSkus.size(); - } - - @Override - public int updateSkuPropertyValue(Long propertyValueId, String propertyValueName) { - // 获取所有的 sku - List skuDOList = productSkuMapper.selectList(); - // 处理后需要更新的 sku - List updateSkus = new ArrayList<>(); - if (CollUtil.isEmpty(skuDOList)) { - return 0; - } - skuDOList.stream() - .filter(sku -> sku.getProperties() != null) - .forEach(sku -> sku.getProperties().forEach(property -> { - if (property.getValueId().equals(propertyValueId)) { - property.setValueName(propertyValueName); - updateSkus.add(sku); - } - })); - if (CollUtil.isEmpty(updateSkus)) { - return 0; - } - - productSkuMapper.updateBatch(updateSkus); - return updateSkus.size(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSkuList(Long spuId, List skus) { - // 构建属性与 SKU 的映射关系; - Map existsSkuMap = convertMap(productSkuMapper.selectListBySpuId(spuId), - ProductSkuConvert.INSTANCE::buildPropertyKey, ProductSkuDO::getId); - - // 拆分三个集合,新插入的、需要更新的、需要删除的 - List insertSkus = new ArrayList<>(); - List updateSkus = new ArrayList<>(); - List allUpdateSkus = BeanUtils.toBean(skus, ProductSkuDO.class, sku -> sku.setSpuId(spuId)); - allUpdateSkus.forEach(sku -> { - String propertiesKey = ProductSkuConvert.INSTANCE.buildPropertyKey(sku); - // 1、找得到的,进行更新 - Long existsSkuId = existsSkuMap.remove(propertiesKey); - if (existsSkuId != null) { - sku.setId(existsSkuId); - updateSkus.add(sku); - return; - } - // 2、找不到,进行插入 - sku.setSpuId(spuId); - insertSkus.add(sku); - }); - - // 执行最终的批量操作 - if (CollUtil.isNotEmpty(insertSkus)) { - productSkuMapper.insertBatch(insertSkus); - } - if (CollUtil.isNotEmpty(updateSkus)) { - updateSkus.forEach(sku -> productSkuMapper.updateById(sku)); - } - if (CollUtil.isNotEmpty(existsSkuMap)) { - productSkuMapper.deleteBatchIds(existsSkuMap.values()); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSkuStock(ProductSkuUpdateStockReqDTO updateStockReqDTO) { - // 更新 SKU 库存 - updateStockReqDTO.getItems().forEach(item -> { - if (item.getIncrCount() > 0) { - productSkuMapper.updateStockIncr(item.getId(), item.getIncrCount()); - } else if (item.getIncrCount() < 0) { - int updateStockIncr = productSkuMapper.updateStockDecr(item.getId(), item.getIncrCount()); - if (updateStockIncr == 0) { - throw exception(SKU_STOCK_NOT_ENOUGH); - } - } - }); - - // 更新 SPU 库存 - List skus = productSkuMapper.selectBatchIds( - convertSet(updateStockReqDTO.getItems(), ProductSkuUpdateStockReqDTO.Item::getId)); - Map spuStockIncrCounts = ProductSkuConvert.INSTANCE.convertSpuStockMap( - updateStockReqDTO.getItems(), skus); - productSpuService.updateSpuStock(spuStockIncrCounts); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java deleted file mode 100755 index 63b5dd6ba..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java +++ /dev/null @@ -1,134 +0,0 @@ -package cn.iocoder.yudao.module.product.service.spu; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import org.springframework.scheduling.annotation.Async; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 商品 SPU Service 接口 - * - * @author 芋道源码 - */ -public interface ProductSpuService { - - /** - * 创建商品 SPU - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSpu(@Valid ProductSpuSaveReqVO createReqVO); - - /** - * 更新商品 SPU - * - * @param updateReqVO 更新信息 - */ - void updateSpu(@Valid ProductSpuSaveReqVO updateReqVO); - - /** - * 删除商品 SPU - * - * @param id 编号 - */ - void deleteSpu(Long id); - - /** - * 获得商品 SPU - * - * @param id 编号 - * @return 商品 SPU - */ - ProductSpuDO getSpu(Long id); - - /** - * 获得商品 SPU 列表 - * - * @param ids 编号数组 - * @return 商品 SPU 列表 - */ - List getSpuList(Collection ids); - - /** - * 获得指定状态的商品 SPU 列表 - * - * @param status 状态 - * @return 商品 SPU 列表 - */ - List getSpuListByStatus(Integer status); - - /** - * 获得商品 SPU 分页,提供给挂你兰后台使用 - * - * @param pageReqVO 分页查询 - * @return 商品spu分页 - */ - PageResult getSpuPage(ProductSpuPageReqVO pageReqVO); - - /** - * 获得商品 SPU 分页,提供给用户 App 使用 - * - * @param pageReqVO 分页查询 - * @return 商品 SPU 分页 - */ - PageResult getSpuPage(AppProductSpuPageReqVO pageReqVO); - - /** - * 更新商品 SPU 库存(增量) - * - * @param stockIncrCounts SPU 编号与库存变化(增量)的映射 - */ - void updateSpuStock(Map stockIncrCounts); - - /** - * 更新 SPU 状态 - * - * @param updateReqVO 更新请求 - */ - void updateSpuStatus(ProductSpuUpdateStatusReqVO updateReqVO); - - /** - * 获取 SPU 列表标签对应的 Count 数量 - * - * @return Count 数量 - */ - Map getTabsCount(); - - /** - * 通过分类 categoryId 查询 SPU 个数 - * - * @param categoryId 分类 categoryId - * @return SPU 数量 - */ - Long getSpuCountByCategoryId(Long categoryId); - - - /** - * 校验商品是否有效。如下情况,视为无效: - * 1. 商品编号不存在 - * 2. 商品被禁用 - * - * @param ids 商品编号数组 - * @return 商品 SPU 列表 - */ - List validateSpuList(Collection ids); - - /** - * 更新商品 SPU 浏览量 - * - * @param id 商品 SPU 编号 - * @param incrCount 增加的数量 - */ - @Async - void updateBrowseCount(Long id, int incrCount); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java deleted file mode 100755 index 3a6cb2dcb..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ /dev/null @@ -1,274 +0,0 @@ -package cn.iocoder.yudao.module.product.service.spu; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO; -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; -import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; -import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; -import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; -import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import com.google.common.collect.Maps; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; - -/** - * 商品 SPU Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductSpuServiceImpl implements ProductSpuService { - - @Resource - private ProductSpuMapper productSpuMapper; - - @Resource - @Lazy // 循环依赖,避免报错 - private ProductSkuService productSkuService; - @Resource - private ProductBrandService brandService; - @Resource - private ProductCategoryService categoryService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createSpu(ProductSpuSaveReqVO createReqVO) { - // 校验分类、品牌 - validateCategory(createReqVO.getCategoryId()); - brandService.validateProductBrand(createReqVO.getBrandId()); - // 校验 SKU - List skuSaveReqList = createReqVO.getSkus(); - productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType()); - - ProductSpuDO spu = BeanUtils.toBean(createReqVO, ProductSpuDO.class); - // 初始化 SPU 中 SKU 相关属性 - initSpuFromSkus(spu, skuSaveReqList); - // 插入 SPU - productSpuMapper.insert(spu); - // 插入 SKU - productSkuService.createSkuList(spu.getId(), skuSaveReqList); - // 返回 - return spu.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSpu(ProductSpuSaveReqVO updateReqVO) { - // 校验 SPU 是否存在 - validateSpuExists(updateReqVO.getId()); - // 校验分类、品牌 - validateCategory(updateReqVO.getCategoryId()); - brandService.validateProductBrand(updateReqVO.getBrandId()); - // 校验SKU - List skuSaveReqList = updateReqVO.getSkus(); - productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType()); - - // 更新 SPU - ProductSpuDO updateObj = BeanUtils.toBean(updateReqVO, ProductSpuDO.class); - initSpuFromSkus(updateObj, skuSaveReqList); - productSpuMapper.updateById(updateObj); - // 批量更新 SKU - productSkuService.updateSkuList(updateObj.getId(), updateReqVO.getSkus()); - } - - /** - * 基于 SKU 的信息,初始化 SPU 的信息 - * 主要是计数相关的字段,例如说市场价、最大最小价、库存等等 - * - * @param spu 商品 SPU - * @param skus 商品 SKU 数组 - */ - private void initSpuFromSkus(ProductSpuDO spu, List skus) { - // sku 单价最低的商品的价格 - spu.setPrice(getMinValue(skus, ProductSkuSaveReqVO::getPrice)); - // sku 单价最低的商品的市场价格 - spu.setMarketPrice(getMinValue(skus, ProductSkuSaveReqVO::getMarketPrice)); - // sku 单价最低的商品的成本价格 - spu.setCostPrice(getMinValue(skus, ProductSkuSaveReqVO::getCostPrice)); - // skus 库存总数 - spu.setStock(getSumValue(skus, ProductSkuSaveReqVO::getStock, Integer::sum)); - // 若是 spu 已有状态则不处理 - if (spu.getStatus() == null) { - spu.setStatus(ProductSpuStatusEnum.ENABLE.getStatus()); // 默认状态为上架 - spu.setSalesCount(0); // 默认商品销量 - spu.setBrowseCount(0); // 默认商品浏览量 - } - } - - /** - * 校验商品分类是否合法 - * - * @param id 商品分类编号 - */ - private void validateCategory(Long id) { - categoryService.validateCategory(id); - // 校验层级 - if (categoryService.getCategoryLevel(id) < CATEGORY_LEVEL) { - throw exception(SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR); - } - } - - @Override - public List validateSpuList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - // 获得商品信息 - List list = productSpuMapper.selectBatchIds(ids); - Map spuMap = CollectionUtils.convertMap(list, ProductSpuDO::getId); - // 校验 - ids.forEach(id -> { - ProductSpuDO spu = spuMap.get(id); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - if (!ProductSpuStatusEnum.isEnable(spu.getStatus())) { - throw exception(SPU_NOT_ENABLE, spu.getName()); - } - }); - return list; - } - - @Override - public void updateBrowseCount(Long id, int incrCount) { - productSpuMapper.updateBrowseCount(id , incrCount); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSpu(Long id) { - // 校验存在 - validateSpuExists(id); - // 校验商品状态不是回收站不能删除 - ProductSpuDO spuDO = productSpuMapper.selectById(id); - // 判断 SPU 状态是否为回收站 - if (ObjectUtil.notEqual(spuDO.getStatus(), ProductSpuStatusEnum.RECYCLE.getStatus())) { - throw exception(SPU_NOT_RECYCLE); - } - // TODO 芋艿:【可选】参与活动中的商品,不允许删除??? - - // 删除 SPU - productSpuMapper.deleteById(id); - // 删除关联的 SKU - productSkuService.deleteSkuBySpuId(id); - } - - private void validateSpuExists(Long id) { - if (productSpuMapper.selectById(id) == null) { - throw exception(SPU_NOT_EXISTS); - } - } - - @Override - public ProductSpuDO getSpu(Long id) { - return productSpuMapper.selectById(id); - } - - @Override - public List getSpuList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - Map spuMap = convertMap(productSpuMapper.selectBatchIds(ids), ProductSpuDO::getId); - // 需要按照 ids 顺序返回。例如说:店铺装修选择了 [3, 1, 2] 三个商品,返回结果还是 [3, 1, 2] 这样的顺序 - return convertList(ids, spuMap::get); - } - - @Override - public List getSpuListByStatus(Integer status) { - return productSpuMapper.selectList(ProductSpuDO::getStatus, status); - } - - @Override - public PageResult getSpuPage(ProductSpuPageReqVO pageReqVO) { - return productSpuMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getSpuPage(AppProductSpuPageReqVO pageReqVO) { - // 查找时,如果查找某个分类编号,则包含它的子分类。因为顶级分类不包含商品 - Set categoryIds = new HashSet<>(); - if (pageReqVO.getCategoryId() != null && pageReqVO.getCategoryId() > 0) { - categoryIds.add(pageReqVO.getCategoryId()); - List categoryChildren = categoryService.getCategoryList(new ProductCategoryListReqVO() - .setStatus(CommonStatusEnum.ENABLE.getStatus()).setParentId(pageReqVO.getCategoryId())); - categoryIds.addAll(convertList(categoryChildren, ProductCategoryDO::getId)); - } - if (CollUtil.isNotEmpty(pageReqVO.getCategoryIds())) { - categoryIds.addAll(pageReqVO.getCategoryIds()); - List categoryChildren = categoryService.getCategoryList(new ProductCategoryListReqVO() - .setStatus(CommonStatusEnum.ENABLE.getStatus()).setParentIds(pageReqVO.getCategoryIds())); - categoryIds.addAll(convertList(categoryChildren, ProductCategoryDO::getId)); - } - // 分页查询 - return productSpuMapper.selectPage(pageReqVO, categoryIds); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSpuStock(Map stockIncrCounts) { - stockIncrCounts.forEach((id, incCount) -> productSpuMapper.updateStock(id, incCount)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSpuStatus(ProductSpuUpdateStatusReqVO updateReqVO) { - // 校验存在 - validateSpuExists(updateReqVO.getId()); - // TODO 芋艿:【可选】参与活动中的商品,不允许下架??? - - // 更新状态 - ProductSpuDO productSpuDO = productSpuMapper.selectById(updateReqVO.getId()).setStatus(updateReqVO.getStatus()); - productSpuMapper.updateById(productSpuDO); - } - - @Override - public Map getTabsCount() { - Map counts = Maps.newLinkedHashMapWithExpectedSize(5); - // 查询销售中的商品数量 - counts.put(ProductSpuPageReqVO.FOR_SALE, - productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus())); - // 查询仓库中的商品数量 - counts.put(ProductSpuPageReqVO.IN_WAREHOUSE, - productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus())); - // 查询售空的商品数量 - counts.put(ProductSpuPageReqVO.SOLD_OUT, - productSpuMapper.selectCount(ProductSpuDO::getStock, 0)); - // 查询触发警戒库存的商品数量 - counts.put(ProductSpuPageReqVO.ALERT_STOCK, - productSpuMapper.selectCount()); - // 查询回收站中的商品数量 - counts.put(ProductSpuPageReqVO.RECYCLE_BIN, - productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus())); - return counts; - } - - @Override - public Long getSpuCountByCategoryId(Long categoryId) { - return productSpuMapper.selectCount(ProductSpuDO::getCategoryId, categoryId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-dev.yaml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index b4696be2d..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,103 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - # Spring Boot Admin Server 服务端的相关配置 - context-path: /admin # 配置 Spring - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - demo: true # 开启演示模式 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-local.yaml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 09edef067..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,127 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.system.dal.mysql: debug - cn.iocoder.yudao.module.system.dal.mysql.sensitiveword.SensitiveWordMapper: INFO # 配置 SensitiveWordMapper 的日志级别为 info - cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - security: - mock-enable: true - xss: - enable: false - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application.yaml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/application.yaml deleted file mode 100644 index dedaffc2e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,109 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.product - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - captcha: - enable: true # 验证码的开关,默认为 true; - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - ignore-tables: - -debug: false diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/bootstrap.yaml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index b724707d1..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: product-server - - profiles: - active: local - -server: - port: 48100 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/resources/logback-spring.xml b/yudao-module-mall/yudao-module-product-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index b337d1ece..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,48 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module.product diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/logback.xml b/yudao-module-mall/yudao-module-product-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index e9616cd0d..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,7 +0,0 @@ -DELETE FROM "product_sku"; -DELETE FROM "product_spu"; -DELETE FROM "product_category"; -DELETE FROM "product_brand"; -DELETE FROM "product_property"; -DELETE FROM "product_property_value"; -DELETE FROM "product_comment"; diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index f0f0c70ee..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,157 +0,0 @@ -CREATE TABLE IF NOT EXISTS `product_sku` ( - `id` bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `spu_id` bigint NOT NULL COMMENT 'spu编号', - `properties` varchar(512) DEFAULT NULL COMMENT '属性数组,JSON 格式', - `price` int NOT NULL DEFAULT '-1' COMMENT '商品价格,单位:分', - `market_price` int DEFAULT NULL COMMENT '市场价,单位:分', - `cost_price` int NOT NULL DEFAULT '-1' COMMENT '成本价,单位: 分', - `bar_code` varchar(64) DEFAULT NULL COMMENT 'SKU 的条形码', - `pic_url` varchar(256) NOT NULL COMMENT '图片地址', - `stock` int DEFAULT NULL COMMENT '库存', - `weight` double DEFAULT NULL COMMENT '商品重量,单位:kg 千克', - `volume` double DEFAULT NULL COMMENT '商品体积,单位:m^3 平米', - `sub_commission_first_price` int DEFAULT NULL COMMENT '一级分销的佣金,单位:分', - `sub_commission_second_price` int DEFAULT NULL COMMENT '二级分销的佣金,单位:分', - `sales_count` int DEFAULT NULL COMMENT '商品销量', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '商品sku'; - -CREATE TABLE IF NOT EXISTS `product_spu` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '商品 SPU 编号,自增', - `name` varchar(128) NOT NULL COMMENT '商品名称', - `keyword` varchar(256) NOT NULL COMMENT '关键字', - `introduction` varchar(256) NOT NULL COMMENT '商品简介', - `description` text NOT NULL COMMENT '商品详情', - `bar_code` varchar(64) NOT NULL COMMENT '条形码', - `category_id` bigint NOT NULL COMMENT '商品分类编号', - `brand_id` int DEFAULT NULL COMMENT '商品品牌编号', - `pic_url` varchar(256) NOT NULL COMMENT '商品封面图', - `slider_pic_urls` varchar(2000) DEFAULT '' COMMENT '商品轮播图地址\n 数组,以逗号分隔\n 最多上传15张', - `video_url` varchar(256) DEFAULT NULL COMMENT '商品视频', - `unit` tinyint NOT NULL COMMENT '单位', - `sort` int NOT NULL DEFAULT '0' COMMENT '排序字段', - `status` tinyint NOT NULL COMMENT '商品状态: 0 上架(开启) 1 下架(禁用)-1 回收', - `spec_type` bit(1) NOT NULL COMMENT '规格类型:0 单规格 1 多规格', - `price` int NOT NULL DEFAULT '-1' COMMENT '商品价格,单位使用:分', - `market_price` int NOT NULL COMMENT '市场价,单位使用:分', - `cost_price` int NOT NULL DEFAULT '-1' COMMENT '成本价,单位: 分', - `stock` int NOT NULL DEFAULT '0' COMMENT '库存', - `delivery_template_id` bigint NOT NULL COMMENT '物流配置模板编号', - `recommend_hot` bit(1) NOT NULL COMMENT '是否热卖推荐: 0 默认 1 热卖', - `recommend_benefit` bit(1) NOT NULL COMMENT '是否优惠推荐: 0 默认 1 优选', - `recommend_best` bit(1) NOT NULL COMMENT '是否精品推荐: 0 默认 1 精品', - `recommend_new` bit(1) NOT NULL COMMENT '是否新品推荐: 0 默认 1 新品', - `recommend_good` bit(1) NOT NULL COMMENT '是否优品推荐', - `give_integral` int NOT NULL COMMENT '赠送积分', - `give_coupon_template_ids` varchar(512) DEFAULT '' COMMENT '赠送的优惠劵编号的数组', - `sub_commission_type` bit(1) NOT NULL COMMENT '分销类型', - `activity_orders` varchar(16) NOT NULL DEFAULT '' COMMENT '活动显示排序0=默认, 1=秒杀,2=砍价,3=拼团', - `sales_count` int DEFAULT '0' COMMENT '商品销量', - `virtual_sales_count` int DEFAULT '0' COMMENT '虚拟销量', - `browse_count` int DEFAULT '0' COMMENT '商品点击量', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '商品spu'; - -CREATE TABLE IF NOT EXISTS `product_category` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类编号', - `parent_id` bigint NOT NULL COMMENT '父分类编号', - `name` varchar(255) NOT NULL COMMENT '分类名称', - `pic_url` varchar(255) NOT NULL COMMENT '移动端分类图', - `big_pic_url` varchar(255) DEFAULT NULL COMMENT 'PC 端分类图', - `sort` int DEFAULT '0' COMMENT '分类排序', - `status` tinyint NOT NULL COMMENT '开启状态', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '商品分类'; - -CREATE TABLE IF NOT EXISTS `product_brand` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '品牌编号', - `name` varchar(255) NOT NULL COMMENT '品牌名称', - `pic_url` varchar(255) NOT NULL COMMENT '品牌图片', - `sort` int DEFAULT '0' COMMENT '品牌排序', - `description` varchar(1024) DEFAULT NULL COMMENT '品牌描述', - `status` tinyint NOT NULL COMMENT '状态', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '商品品牌'; - -CREATE TABLE IF NOT EXISTS `product_property` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(64) DEFAULT NULL COMMENT '规格名称', - `status` tinyint DEFAULT NULL COMMENT '状态: 0 开启 ,1 禁用', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - `remark` varchar(255) DEFAULT NULL COMMENT '备注', - PRIMARY KEY("id") -) COMMENT '规格名称'; - -CREATE TABLE IF NOT EXISTS `product_property_value` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `property_id` bigint DEFAULT NULL COMMENT '规格键id', - `name` varchar(128) DEFAULT NULL COMMENT '规格值名字', - `status` tinyint DEFAULT NULL COMMENT '状态: 1 开启 ,2 禁用', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - `remark` varchar(255) DEFAULT NULL COMMENT '备注', - PRIMARY KEY("id") -) COMMENT '规格值'; - -DROP TABLE IF EXISTS `product_comment` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '评论编号,主键自增', - `user_id` bigint DEFAULT NULL COMMENT '评价人的用户编号关联 MemberUserDO 的 id 编号', - `user_nickname` varchar(255) DEFAULT NULL COMMENT '评价人名称', - `user_avatar` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '评价人头像', - `anonymous` bit(1) DEFAULT NULL COMMENT '是否匿名', - `order_id` bigint DEFAULT NULL COMMENT '交易订单编号关联 TradeOrderDO 的 id 编号', - `order_item_id` bigint DEFAULT NULL COMMENT '交易订单项编号关联 TradeOrderItemDO 的 id 编号', - `spu_id` bigint DEFAULT NULL COMMENT '商品 SPU 编号关联 ProductSpuDO 的 id', - `spu_name` varchar(255) DEFAULT NULL COMMENT '商品 SPU 名称', - `sku_id` bigint DEFAULT NULL COMMENT '商品 SKU 编号关联 ProductSkuDO 的 id 编号', - `visible` bit(1) DEFAULT NULL COMMENT '是否可见true:显示false:隐藏', - `scores` tinyint DEFAULT NULL COMMENT '评分星级1-5分', - `description_scores` tinyint DEFAULT NULL COMMENT '描述星级1-5 星', - `benefit_scores` tinyint DEFAULT NULL COMMENT '服务星级1-5 星', - `content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '评论内容', - `pic_urls` varchar(4096) DEFAULT NULL COMMENT '评论图片地址数组', - `reply_status` bit(1) DEFAULT NULL COMMENT '商家是否回复', - `reply_user_id` bigint DEFAULT NULL COMMENT '回复管理员编号关联 AdminUserDO 的 id 编号', - `reply_content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '商家回复内容', - `reply_time` datetime DEFAULT NULL COMMENT '商家回复时间', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 26 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '商品评论'; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-api/pom.xml b/yudao-module-mall/yudao-module-promotion-api/pom.xml deleted file mode 100644 index 1b7a05b3f..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-promotion-api - jar - - ${project.artifactId} - - promotion 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApi.java deleted file mode 100644 index c0a0cfcdc..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApi.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 砍价活动") -public interface BargainActivityApi { - - String PREFIX = ApiConstants.PREFIX + "/bargain-activity"; - - @PutMapping(PREFIX + "/update-stock") - @Operation(summary = "更新砍价活动库存") - @Parameters({ - @Parameter(name = "id", description = "砍价活动编号", required = true, example = "1024"), - @Parameter(name = "count", description = "购买数量", required = true, example = "1"), - }) - CommonResult updateBargainActivityStock(@RequestParam("id") Long id, - @RequestParam("count") Integer count); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java deleted file mode 100644 index 5b8eed59b..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 砍价记录") -public interface BargainRecordApi { - - String PREFIX = ApiConstants.PREFIX + "/bargain-record"; - - @GetMapping(PREFIX + "/validate-join") - @Operation(summary = "【下单前】校验是否参与砍价活动") // 如果校验失败,则抛出业务异常 - @Parameters({ - @Parameter(name = "userId", description = "用户编号", required = true, example = "1024"), - @Parameter(name = "bargainRecordId", description = "砍价记录编号", required = true, example = "2048"), - @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "4096"), - }) - CommonResult validateJoinBargain(@RequestParam("userId") Long userId, - @RequestParam("bargainRecordId") Long bargainRecordId, - @RequestParam("skuId") Long skuId); - - @PutMapping(PREFIX + "/update-order-id") - @Operation(summary = "更新砍价记录的订单编号") // 在砍价成功后,用户发起订单后,会记录该订单编号 - @Parameters({ - @Parameter(name = "id", description = "砍价记录编号", required = true, example = "1024"), - @Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"), - }) - CommonResult updateBargainRecordOrderId(@RequestParam("id") Long id, - @RequestParam("oderId") Long orderId); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainValidateJoinRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainValidateJoinRespDTO.java deleted file mode 100644 index a64e923f5..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainValidateJoinRespDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain.dto; - -import lombok.Data; - -/** - * 校验参与砍价 Response DTO - */ -@Data -public class BargainValidateJoinRespDTO { - - /** - * 砍价活动编号 - */ - private Long activityId; - /** - * 砍价活动名称 - */ - private String name; - - /** - * 砍价金额 - */ - private Integer bargainPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java deleted file mode 100644 index acd9d935f..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 拼团记录") -public interface CombinationRecordApi { - - String PREFIX = ApiConstants.PREFIX + "/combination-record"; - - @GetMapping(PREFIX + "/validate") - @Operation(summary = "校验是否满足拼团条件") - @Parameters({ - @Parameter(name = "userId", description = "用户编号", required = true, example = "1024"), - @Parameter(name = "activityId", description = "活动编号", required = true, example = "2048"), - @Parameter(name = "headId", description = "团长编号", required = true, example = "4096"), - @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "8192"), - @Parameter(name = "count", description = "数量", required = true, example = "1"), - }) - CommonResult validateCombinationRecord(@RequestParam("userId") Long userId, - @RequestParam("activityId") Long activityId, - @RequestParam("headId") Long headId, - @RequestParam("skuId") Long skuId, - @RequestParam("count") Integer count); - - @PostMapping(PREFIX + "/create") - @Operation(summary = "创建开团记录") - CommonResult createCombinationRecord( - @RequestBody @Valid CombinationRecordCreateReqDTO reqDTO); - - @GetMapping(PREFIX + "/is-success") - @Operation(summary = "查询拼团记录是否成功") - @Parameters({ - @Parameter(name = "userId", description = "用户编号", required = true, example = "1024"), - @Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"), - }) - CommonResult isCombinationRecordSuccess(@RequestParam("userId") Long userId, - @RequestParam("orderId") Long orderId); - - @GetMapping(PREFIX + "/validate-join") - @Operation(summary = "【下单前】校验是否满足拼团活动条件") // 如果校验失败,则抛出业务异常 - @Parameters({ - @Parameter(name = "userId", description = "用户编号", required = true, example = "1024"), - @Parameter(name = "activityId", description = "活动编号", required = true, example = "2048"), - @Parameter(name = "headId", description = "团长编号", example = "4096"), // 如果新发起的团,headId 不用传递 - @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "8192"), - @Parameter(name = "count", description = "数量", required = true, example = "1"), - }) - CommonResult validateJoinCombination(@RequestParam("userId") Long userId, - @RequestParam("activityId") Long activityId, - @RequestParam(value = "headId", required = false) Long headId, - @RequestParam("skuId") Long skuId, - @RequestParam("count") Integer count); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateReqDTO.java deleted file mode 100644 index ac86c45ea..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateReqDTO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination.dto; - -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 拼团记录的创建 Request DTO - * - * @author HUIHUI - */ -@Data -public class CombinationRecordCreateReqDTO { - - /** - * 拼团活动编号 - */ - @NotNull(message = "拼团活动编号不能为空") - private Long activityId; - /** - * spu 编号 - */ - @NotNull(message = "spu 编号不能为空") - private Long spuId; - /** - * sku 编号 - */ - @NotNull(message = "sku 编号不能为空") - private Long skuId; - /** - * 购买的商品数量 - */ - @NotNull(message = "购买数量不能为空") - private Integer count; - /** - * 订单编号 - */ - @NotNull(message = "订单编号不能为空") - private Long orderId; - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - /** - * 团长编号 - */ - private Long headId; - /** - * 拼团商品单价 - */ - @NotNull(message = "拼团商品单价不能为空") - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateRespDTO.java deleted file mode 100644 index 5f4ea2afd..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationRecordCreateRespDTO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination.dto; - -import lombok.Data; - -/** - * 拼团记录的创建 Response DTO - * - * @author HUIHUI - */ -@Data -public class CombinationRecordCreateRespDTO { - - /** - * 拼团活动编号 - * - * 关联 CombinationActivityDO 的 id 字段 - */ - private Long combinationActivityId; - /** - * 拼团团长编号 - * - * 关联 CombinationRecordDO 的 headId 字段 - */ - private Long combinationHeadId; - /** - * 拼团记录编号 - * - * 关联 CombinationRecordDO 的 id 字段 - */ - private Long combinationRecordId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationValidateJoinRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationValidateJoinRespDTO.java deleted file mode 100644 index 86fe00a5f..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/dto/CombinationValidateJoinRespDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination.dto; - -import lombok.Data; - -/** - * 校验参与拼团 Response DTO - * - * @author HUIHUI - */ -@Data -public class CombinationValidateJoinRespDTO { - - /** - * 砍价活动编号 - */ - private Long activityId; - /** - * 砍价活动名称 - */ - private String name; - - /** - * 拼团金额 - */ - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApi.java deleted file mode 100644 index a73991a3d..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApi.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.cloud.openfeign.SpringQueryMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 优惠劵") -public interface CouponApi { - - String PREFIX = ApiConstants.PREFIX + "/coupon"; - - @PutMapping(PREFIX + "/use") - @Operation(summary = "使用优惠劵") - CommonResult useCoupon(@RequestBody @Valid CouponUseReqDTO useReqDTO); - - @PutMapping(PREFIX + "/return-used") - @Parameter(name = "id", description = "优惠券编号", required = true, example = "1") - CommonResult returnUsedCoupon(@RequestParam("id") Long id); - - @GetMapping(PREFIX + "/validate") - @Operation(summary = "校验优惠劵") - CommonResult validateCoupon(@Valid @SpringQueryMap CouponValidReqDTO validReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponRespDTO.java deleted file mode 100644 index a404bf27d..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponRespDTO.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon.dto; - -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 优惠劵 Response DTO - * - * @author 芋道源码 - */ -@Data -public class CouponRespDTO { - - // ========== 基本信息 BEGIN ========== - /** - * 优惠劵编号 - */ - private Long id; - /** - * 优惠劵模板编号 - */ - private Integer templateId; - /** - * 优惠劵名 - */ - private String name; - /** - * 优惠码状态 - * - * 枚举 {@link CouponStatusEnum} - */ - private Integer status; - - // ========== 基本信息 END ========== - - // ========== 领取情况 BEGIN ========== - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 领取类型 - * - * 枚举 {@link CouponTakeTypeEnum} - */ - private Integer takeType; - // ========== 领取情况 END ========== - - // ========== 使用规则 BEGIN ========== - /** - * 是否设置满多少金额可用,单位:分 - */ - private Integer usePrice; - /** - * 生效开始时间 - */ - private LocalDateTime validStartTime; - /** - * 生效结束时间 - */ - private LocalDateTime validEndTime; - /** - * 商品范围 - */ - private Integer productScope; - /** - * 商品范围编号的数组 - */ - private List productScopeValues; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - /** - * 折扣类型 - */ - private Integer discountType; - /** - * 折扣百分比 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - */ - private Integer discountPrice; - /** - * 折扣上限,仅在 {@link #discountType} 等于 {@link PromotionDiscountTypeEnum#PERCENT} 时生效 - */ - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 使用情况 BEGIN ========== - /** - * 使用订单号 - */ - private Long useOrderId; - /** - * 使用时间 - */ - private LocalDateTime useTime; - - // ========== 使用情况 END ========== -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponTemplateRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponTemplateRespDTO.java deleted file mode 100644 index a54ccf2b0..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponTemplateRespDTO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon.dto; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import lombok.Data; - -/** - * 优惠券模版 Response DTO - * - * @author HUIHUI - */ -@Data -public class CouponTemplateRespDTO { - /** - * 模板编号,自增唯一 - */ - - private Long id; - /** - * 优惠劵名 - */ - private String name; - - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponUseReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponUseReqDTO.java deleted file mode 100644 index 9323ab553..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponUseReqDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon.dto; - -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 优惠劵使用 Request DTO - * - * @author 芋道源码 - */ -@Data -public class CouponUseReqDTO { - - /** - * 优惠劵编号 - */ - @NotNull(message = "优惠劵编号不能为空") - private Long id; - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - - /** - * 订单编号 - */ - @NotNull(message = "订单编号不能为空") - private Long orderId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponValidReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponValidReqDTO.java deleted file mode 100644 index dd25c6408..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponValidReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon.dto; - -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 优惠劵使用 Request DTO - * - * @author 芋道源码 - */ -@Data -public class CouponValidReqDTO { - - /** - * 优惠劵编号 - */ - @NotNull(message = "优惠劵编号不能为空") - private Long id; - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApi.java deleted file mode 100644 index e446f6414..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApi.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.discount; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.Collection; -import java.util.List; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 限时折扣") -public interface DiscountActivityApi { - - String PREFIX = ApiConstants.PREFIX + "/discount-activity"; - - @GetMapping(PREFIX + "/list-by-sku-id") - @Operation(summary = "获得商品匹配的的限时折扣信息") - @Parameter(name = "skuIds", description = "商品 SKU 编号数组", required = true, example = "[1, 2]") - CommonResult> getMatchDiscountProductList(@RequestParam("skuIds") Collection skuIds); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/dto/DiscountProductRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/dto/DiscountProductRespDTO.java deleted file mode 100644 index 52dfdbe27..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/dto/DiscountProductRespDTO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.discount.dto; - -import lombok.Data; - -/** - * 限时折扣活动商品 Response DTO - * - * @author 芋道源码 - */ -@Data -public class DiscountProductRespDTO { - - /** - * 编号,主键自增 - */ - private Long id; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 折扣类型 - */ - private Integer discountType; - /** - * 折扣百分比 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - */ - private Integer discountPrice; - - // ========== 活动字段 ========== - /** - * 限时折扣活动的编号 - */ - private Long activityId; - /** - * 活动标题 - */ - private String activityName; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApi.java deleted file mode 100644 index 1e81950d8..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApi.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.reward; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.Collection; -import java.util.List; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 满减送") -public interface RewardActivityApi { - - String PREFIX = ApiConstants.PREFIX + "/reward-activity"; - - @GetMapping(PREFIX + "/list-by-spu-id") - @Operation(summary = "获得商品匹配的的满减送活动信息") - @Parameter(name = "spuIds", description = "商品 SPU 编号数组", required = true, example = "[1, 2]") - CommonResult> getMatchRewardActivityList(@RequestParam("spuIds") Collection spuIds); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/dto/RewardActivityMatchRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/dto/RewardActivityMatchRespDTO.java deleted file mode 100644 index 6ae71a1d9..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/dto/RewardActivityMatchRespDTO.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.reward.dto; - -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import lombok.Data; - -import java.util.List; - -/** - * 满减送活动的匹配 Response DTO - * - * @author 芋道源码 - */ -@Data -public class RewardActivityMatchRespDTO { - - /** - * 活动编号,主键自增 - */ - private Long id; - /** - * 活动标题 - */ - private String name; - /** - * 条件类型 - * - * 枚举 {@link PromotionConditionTypeEnum} - */ - private Integer conditionType; - /** - * 优惠规则的数组 - */ - private List rules; - - /** - * 商品 SPU 编号的数组 - */ - private List spuIds; - - // TODO 芋艿:后面 RewardActivityRespDTO 有了之后,Rule 可以放过去 - /** - * 优惠规则 - */ - @Data - public static class Rule { - - /** - * 优惠门槛 - * - * 1. 满 N 元,单位:分 - * 2. 满 N 件 - */ - private Integer limit; - /** - * 优惠价格,单位:分 - */ - private Integer discountPrice; - /** - * 是否包邮 - */ - private Boolean freeDelivery; - /** - * 赠送的积分 - */ - private Integer point; - /** - * 赠送的优惠劵编号的数组 - */ - private List couponIds; - /** - * 赠送的优惠券数量的数组 - */ - private List couponCounts; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java deleted file mode 100644 index e077d0544..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.seckill; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 秒杀活动") -public interface SeckillActivityApi { - - String PREFIX = ApiConstants.PREFIX + "/discount-activity"; - - @PutMapping(PREFIX + "/update-stock-decr") - @Operation(summary = "更新秒杀库存(减少)") - @Parameters({ - @Parameter(name = "id", description = "活动编号", required = true, example = "1"), - @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"), - @Parameter(name = "count", description = "数量", required = true, example = "3"), - }) - CommonResult updateSeckillStockDecr(@RequestParam("id") Long id, - @RequestParam("skuId") Long skuId, - @RequestParam("count")Integer count); - - @PutMapping(PREFIX + "/update-stock-incr") - @Operation(summary = "更新秒杀库存(增加)") - @Parameters({ - @Parameter(name = "id", description = "活动编号", required = true, example = "1"), - @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"), - @Parameter(name = "count", description = "数量", required = true, example = "3"), - }) - CommonResult updateSeckillStockIncr(@RequestParam("id") Long id, - @RequestParam("skuId") Long skuId, - @RequestParam("count")Integer count); - - @GetMapping("/validate-join") - @Operation(summary = "【下单前】校验是否参与秒杀活动") // 如果校验失败,则抛出业务异常 - @Parameters({ - @Parameter(name = "activityId", description = "活动编号", required = true, example = "1"), - @Parameter(name = "skuId", description = "SKU 编号", required = true, example = "2"), - @Parameter(name = "count", description = "数量", required = true, example = "3"), - }) - CommonResult validateJoinSeckill(@RequestParam("activityId") Long activityId, - @RequestParam("skuId") Long skuId, - @RequestParam("count")Integer count); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/dto/SeckillValidateJoinRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/dto/SeckillValidateJoinRespDTO.java deleted file mode 100644 index aae89a415..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/dto/SeckillValidateJoinRespDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.seckill.dto; - -import lombok.Data; - -/** - * 校验参与秒杀 Response DTO - */ -@Data -public class SeckillValidateJoinRespDTO { - - /** - * 秒杀活动名称 - */ - private String name; - /** - * 总限购数量 - * - * 目的:目前只有 trade 有具体下单的数据,需要交给 trade 价格计算使用 - */ - private Integer totalLimitCount; - - /** - * 秒杀金额 - */ - private Integer seckillPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ApiConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ApiConstants.java deleted file mode 100644 index 2de4351cf..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "promotion-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/promotion"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/DictTypeConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/DictTypeConstants.java deleted file mode 100644 index f377ca239..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/DictTypeConstants.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums; - -/** - * promotion 字典类型的枚举类 - * - * @author HUIHUI - */ -public class DictTypeConstants { - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java deleted file mode 100644 index 3b19d616a..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,128 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Promotion 错误码枚举类 - *

- * promotion 系统,使用 1-013-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 促销活动相关 1-013-001-000 ============ - ErrorCode DISCOUNT_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_001_000, "限时折扣活动不存在"); - ErrorCode DISCOUNT_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_001_001, "存在商品参加了其它限时折扣活动"); - ErrorCode DISCOUNT_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_001_002, "限时折扣活动已关闭,不能修改"); - ErrorCode DISCOUNT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1_013_001_003, "限时折扣活动未关闭,不能删除"); - ErrorCode DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_001_004, "限时折扣活动已关闭,不能重复关闭"); - - // ========== Banner 相关 1-013-002-000 ============ - ErrorCode BANNER_NOT_EXISTS = new ErrorCode(1_013_002_000, "Banner 不存在"); - - // ========== Coupon 相关 1-013-003-000 ============ - ErrorCode COUPON_NO_MATCH_SPU = new ErrorCode(1_013_003_000, "优惠劵没有可使用的商品!"); - ErrorCode COUPON_NO_MATCH_MIN_PRICE = new ErrorCode(1_013_003_001, "所结算的商品中未满足使用的金额"); - - // ========== 优惠劵模板 1-013-004-000 ========== - ErrorCode COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1_013_004_000, "优惠劵模板不存在"); - ErrorCode COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL = new ErrorCode(1_013_004_001, "发放数量不能小于已领取数量({})"); - ErrorCode COUPON_TEMPLATE_NOT_ENOUGH = new ErrorCode(1_013_004_002, "当前剩余数量不够领取"); - ErrorCode COUPON_TEMPLATE_USER_ALREADY_TAKE = new ErrorCode(1_013_004_003, "用户已领取过此优惠券"); - ErrorCode COUPON_TEMPLATE_EXPIRED = new ErrorCode(1_013_004_004, "优惠券已过期"); - ErrorCode COUPON_TEMPLATE_CANNOT_TAKE = new ErrorCode(1_013_004_005, "领取方式不正确"); - - // ========== 优惠劵 1-013-005-000 ========== - ErrorCode COUPON_NOT_EXISTS = new ErrorCode(1_013_005_000, "优惠券不存在"); - ErrorCode COUPON_DELETE_FAIL_USED = new ErrorCode(1_013_005_001, "回收优惠劵失败,优惠劵已被使用"); - ErrorCode COUPON_STATUS_NOT_UNUSED = new ErrorCode(1_013_005_002, "优惠劵不处于待使用状态"); - ErrorCode COUPON_VALID_TIME_NOT_NOW = new ErrorCode(1_013_005_003, "优惠券不在使用时间范围内"); - ErrorCode COUPON_STATUS_NOT_USED = new ErrorCode(1_013_005_004, "优惠劵不是已使用状态"); - - // ========== 满减送活动 1-013-006-000 ========== - ErrorCode REWARD_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_006_000, "满减送活动不存在"); - ErrorCode REWARD_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_006_001, "存在商品参加了其它满减送活动"); - ErrorCode REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_002, "满减送活动已关闭,不能修改"); - ErrorCode REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1_013_006_003, "满减送活动未关闭,不能删除"); - ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_004, "满减送活动已关闭,不能重复关闭"); - ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_END = new ErrorCode(1_013_006_005, "满减送活动已结束,不能关闭"); - - // ========== TODO 空着 1-013-007-000 ============ - - // ========== 秒杀活动 1-013-008-000 ========== - ErrorCode SECKILL_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_008_000, "秒杀活动不存在"); - ErrorCode SECKILL_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_008_002, "存在商品参加了其它秒杀活动,秒杀时段冲突"); - ErrorCode SECKILL_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_008_003, "秒杀活动已关闭,不能修改"); - ErrorCode SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1_013_008_004, "秒杀活动未关闭或未结束,不能删除"); - ErrorCode SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_008_005, "秒杀活动已关闭,不能重复关闭"); - ErrorCode SECKILL_ACTIVITY_UPDATE_STOCK_FAIL = new ErrorCode(1_013_008_006, "秒杀失败,原因:秒杀库存不足"); - ErrorCode SECKILL_JOIN_ACTIVITY_TIME_ERROR = new ErrorCode(1_013_008_007, "秒杀失败,原因:不在活动时间范围内"); - ErrorCode SECKILL_JOIN_ACTIVITY_STATUS_CLOSED = new ErrorCode(1_013_008_008, "秒杀失败,原因:秒杀活动已关闭"); - ErrorCode SECKILL_JOIN_ACTIVITY_SINGLE_LIMIT_COUNT_EXCEED = new ErrorCode(1_013_008_009, "秒杀失败,原因:单次限购超出"); - ErrorCode SECKILL_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS = new ErrorCode(1_013_008_010, "秒杀失败,原因:商品不存在"); - - // ========== 秒杀时段 1-013-009-000 ========== - ErrorCode SECKILL_CONFIG_NOT_EXISTS = new ErrorCode(1_013_009_000, "秒杀时段不存在"); - ErrorCode SECKILL_CONFIG_TIME_CONFLICTS = new ErrorCode(1_013_009_001, "秒杀时段冲突"); - ErrorCode SECKILL_CONFIG_DISABLE = new ErrorCode(1_013_009_004, "秒杀时段已关闭"); - - // ========== 拼团活动 1-013-010-000 ========== - ErrorCode COMBINATION_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_010_000, "拼团活动不存在"); - ErrorCode COMBINATION_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_010_001, "存在商品参加了其它拼团活动"); - ErrorCode COMBINATION_ACTIVITY_STATUS_DISABLE_NOT_UPDATE = new ErrorCode(1_013_010_002, "拼团活动已关闭不能修改"); - ErrorCode COMBINATION_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1_013_010_003, "拼团活动未关闭或未结束,不能删除"); - ErrorCode COMBINATION_ACTIVITY_STATUS_DISABLE = new ErrorCode(1_013_010_004, "拼团失败,原因:拼团活动已关闭"); - ErrorCode COMBINATION_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS = new ErrorCode(1_013_010_005, "拼团失败,原因:拼团活动商品不存在"); - ErrorCode COMBINATION_ACTIVITY_UPDATE_STOCK_FAIL = new ErrorCode(1_013_010_006, "拼团失败,原因:拼团活动商品库存不足"); - - // ========== 拼团记录 1-013-011-000 ========== - ErrorCode COMBINATION_RECORD_NOT_EXISTS = new ErrorCode(1_013_011_000, "拼团不存在"); - ErrorCode COMBINATION_RECORD_EXISTS = new ErrorCode(1_013_011_001, "拼团失败,已参与过该拼团"); - ErrorCode COMBINATION_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1_013_011_002, "拼团失败,父拼团不存在"); - ErrorCode COMBINATION_RECORD_USER_FULL = new ErrorCode(1_013_011_003, "拼团失败,拼团人数已满"); - ErrorCode COMBINATION_RECORD_FAILED_HAVE_JOINED = new ErrorCode(1_013_011_004, "拼团失败,原因:存在该活动正在进行的拼团记录"); - ErrorCode COMBINATION_RECORD_FAILED_TIME_NOT_START = new ErrorCode(1_013_011_005, "拼团失败,活动未开始"); - ErrorCode COMBINATION_RECORD_FAILED_TIME_END = new ErrorCode(1_013_011_006, "拼团失败,活动已经结束"); - ErrorCode COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED = new ErrorCode(1_013_011_007, "拼团失败,原因:单次限购超出"); - ErrorCode COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED = new ErrorCode(1_013_011_008, "拼团失败,原因:超出总购买次数"); - ErrorCode COMBINATION_RECORD_FAILED_ORDER_STATUS_UNPAID = new ErrorCode(1_013_011_009, "拼团失败,原因:存在未支付订单,请先支付"); - - // ========== 砍价活动 1-013-012-000 ========== - ErrorCode BARGAIN_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_012_000, "砍价活动不存在"); - ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_012_001, "存在商品参加了其它砍价活动"); - ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1_013_012_002, "砍价活动已关闭,不能修改"); - ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1_013_012_003, "砍价活动未关闭或未结束,不能删除"); - ErrorCode BARGAIN_ACTIVITY_STOCK_NOT_ENOUGH = new ErrorCode(1_013_012_004, "砍价活动库存不足"); - ErrorCode BARGAIN_ACTIVITY_STATUS_CLOSED = new ErrorCode(1_013_012_005, "砍价活动已关闭"); - ErrorCode BARGAIN_ACTIVITY_TIME_END = new ErrorCode(1_013_012_006, "砍价活动已经结束"); - - // ========== 砍价记录 1-013-013-000 ========== - ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1_013_013_000, "砍价记录不存在"); - ErrorCode BARGAIN_RECORD_CREATE_FAIL_EXISTS = new ErrorCode(1_013_013_001, "参与失败,您已经参与当前砍价活动"); - ErrorCode BARGAIN_RECORD_CREATE_FAIL_LIMIT = new ErrorCode(1_013_013_002, "参与失败,您已达到当前砍价活动的参与上限"); - ErrorCode BARGAIN_JOIN_RECORD_NOT_SUCCESS = new ErrorCode(1_013_013_004, "下单失败,砍价未成功"); - ErrorCode BARGAIN_JOIN_RECORD_ALREADY_ORDER = new ErrorCode(1_013_013_005, "下单失败,该砍价已经下单"); - - // ========== 砍价助力 1-013-014-000 ========== - ErrorCode BARGAIN_HELP_CREATE_FAIL_RECORD_NOT_IN_PROCESS = new ErrorCode(1_013_014_000, "助力失败,砍价记录不处于进行中"); - ErrorCode BARGAIN_HELP_CREATE_FAIL_RECORD_SELF = new ErrorCode(1_013_014_001, "助力失败,不能助力自己"); - ErrorCode BARGAIN_HELP_CREATE_FAIL_LIMIT = new ErrorCode(1_013_014_002, "助力失败,您已达到当前砍价活动的助力上限"); - ErrorCode BARGAIN_HELP_CREATE_FAIL_CONFLICT = new ErrorCode(1_013_014_003, "助力失败,请重试"); - ErrorCode BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS = new ErrorCode(1_013_014_004, "助力失败,您已经助力过了"); - - // ========== 文章分类 1-013-015-000 ========== - ErrorCode ARTICLE_CATEGORY_NOT_EXISTS = new ErrorCode(1_013_015_000, "文章分类不存在"); - ErrorCode ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES = new ErrorCode(1_013_015_001, "文章分类删除失败,存在关联文章"); - - // ========== 文章管理 1-013-016-000 ========== - ErrorCode ARTICLE_NOT_EXISTS = new ErrorCode(1_013_016_000, "文章不存在"); - - // ========== 装修模板 1-013-017-000 ========== - ErrorCode DIY_TEMPLATE_NOT_EXISTS = new ErrorCode(1_013_017_000, "装修模板不存在"); - ErrorCode DIY_TEMPLATE_NAME_USED = new ErrorCode(1_013_017_001, "装修模板名称({})已经被使用"); - ErrorCode DIY_TEMPLATE_USED_CANNOT_DELETE = new ErrorCode(1_013_017_002, "不能删除正在使用的装修模板"); - - // ========== 装修页面 1-013-018-000 ========== - ErrorCode DIY_PAGE_NOT_EXISTS = new ErrorCode(1_013_018_000, "装修页面不存在"); - ErrorCode DIY_PAGE_NAME_USED = new ErrorCode(1_013_018_001, "装修页面名称({})已经被使用"); - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/banner/BannerPositionEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/banner/BannerPositionEnum.java deleted file mode 100644 index 8a8338c8a..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/banner/BannerPositionEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.banner; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * Banner Position 枚举 - * - * @author HUIHUI - */ -@AllArgsConstructor -@Getter -public enum BannerPositionEnum implements IntArrayValuable { - - HOME_POSITION(1, "首页"), - SECKILL_POSITION(2, "秒杀活动页"), - COMBINATION_POSITION(3, "砍价活动页"), - DISCOUNT_POSITION(4, "限时折扣页"), - REWARD_POSITION(5, "满减送页"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BannerPositionEnum::getPosition).toArray(); - - /** - * 值 - */ - private final Integer position; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/bargain/BargainRecordStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/bargain/BargainRecordStatusEnum.java deleted file mode 100644 index d5c22a7c5..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/bargain/BargainRecordStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.bargain; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 砍价记录的状态枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum BargainRecordStatusEnum implements IntArrayValuable { - - IN_PROGRESS(1, "砍价中"), - SUCCESS(2, "砍价成功"), - FAILED(3, "砍价失败"), // 活动到期时,会自动将到期的砍价全部设置为过期 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BargainRecordStatusEnum::getStatus).toArray(); - - /** - * 值 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/combination/CombinationRecordStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/combination/CombinationRecordStatusEnum.java deleted file mode 100644 index 627e13946..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/combination/CombinationRecordStatusEnum.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.combination; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 拼团状态枚举 - * - * @author HUIHUI - */ -@AllArgsConstructor -@Getter -public enum CombinationRecordStatusEnum implements IntArrayValuable { - - IN_PROGRESS(0, "进行中"), - SUCCESS(1, "拼团成功"), - FAILED(2, "拼团失败"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CombinationRecordStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - public static boolean isSuccess(Integer status) { - return ObjectUtil.equal(status, SUCCESS.getStatus()); - } - - public static boolean isInProgress(Integer status) { - return ObjectUtil.equal(status, IN_PROGRESS.getStatus()); - } - - public static boolean isFailed(Integer status) { - return ObjectUtil.equal(status, FAILED.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionActivityStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionActivityStatusEnum.java deleted file mode 100644 index e45e37beb..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionActivityStatusEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -// TODO 芋艿:弱化这个状态 -/** - * 促销活动的状态枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum PromotionActivityStatusEnum implements IntArrayValuable { - - WAIT(10, "未开始"), - RUN(20, "进行中"), - END(30, "已结束"), - CLOSE(40, "已关闭"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionActivityStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionConditionTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionConditionTypeEnum.java deleted file mode 100644 index 05e62e399..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionConditionTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 营销的条件类型枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum PromotionConditionTypeEnum implements IntArrayValuable { - - PRICE(10, "满 N 元"), - COUNT(20, "满 N 件"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionConditionTypeEnum::getType).toArray(); - - /** - * 类型值 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java deleted file mode 100644 index 7da6b4b08..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠类型枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PromotionDiscountTypeEnum implements IntArrayValuable { - - PRICE(1, "满减"), // 具体金额 - PERCENT(2, "折扣"), // 百分比 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionDiscountTypeEnum::getType).toArray(); - - /** - * 优惠类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java deleted file mode 100644 index 882dc4aee..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionProductScopeEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 营销的商品范围枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PromotionProductScopeEnum implements IntArrayValuable { - - ALL(1, "通用券"), // 全部商品 - SPU(2, "商品券"), // 指定商品 - CATEGORY(3, "品类券"), // 指定品类 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionProductScopeEnum::getScope).toArray(); - - /** - * 范围值 - */ - private final Integer scope; - /** - * 范围名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java deleted file mode 100644 index 4524c198d..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionTypeEnum.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.common; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 营销类型枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PromotionTypeEnum implements IntArrayValuable { - - SECKILL_ACTIVITY(1, "秒杀活动"), - BARGAIN_ACTIVITY(2, "砍价活动"), - COMBINATION_ACTIVITY(3, "拼团活动"), - - DISCOUNT_ACTIVITY(4, "限时折扣"), - REWARD_ACTIVITY(5, "满减送"), - - MEMBER_LEVEL(6, "会员折扣"), - COUPON(7, "优惠劵"), - POINT(8, "积分") - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionTypeEnum::getType).toArray(); - - /** - * 类型值 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponStatusEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponStatusEnum.java deleted file mode 100644 index 320345d85..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.coupon; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠劵状态枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum CouponStatusEnum implements IntArrayValuable { - - UNUSED(1, "未使用"), - USED(2, "已使用"), - EXPIRE(3, "已过期"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponStatusEnum::getStatus).toArray(); - - /** - * 值 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTakeTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTakeTypeEnum.java deleted file mode 100644 index 1513e62ea..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTakeTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.coupon; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠劵领取方式 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum CouponTakeTypeEnum implements IntArrayValuable { - - USER(1, "直接领取"), // 用户可在首页、每日领劵直接领取 - ADMIN(2, "指定发放"), // 后台指定会员赠送优惠劵 - REGISTER(3, "新人券"), // 注册时自动领取 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTakeTypeEnum::getValue).toArray(); - - /** - * 值 - */ - private final Integer value; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTemplateValidityTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTemplateValidityTypeEnum.java deleted file mode 100644 index 391515de3..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/coupon/CouponTemplateValidityTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.coupon; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 优惠劵模板的有限期类型的枚举 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum CouponTemplateValidityTypeEnum implements IntArrayValuable { - - DATE(1, "固定日期"), - TERM(2, "领取之后"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateValidityTypeEnum::getType).toArray(); - - /** - * 值 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecorateComponentEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecorateComponentEnum.java deleted file mode 100644 index 45bc1fe4d..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecorateComponentEnum.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.decorate; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 页面组件枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -@SuppressWarnings("JavadocLinkAsPlainText") -public enum DecorateComponentEnum { - - /** - * 格式:[{ - * "name": "标题" - * "picUrl": "https://www.iocoder.cn/xxx.png", - * "url": "/pages/users/index" - * }] - * - * 最多 10 个 - */ - MENU("menu", "菜单"), - /** - * 格式:[{ - * "name": "标题" - * "url": "/pages/users/index" - * }] - */ - ROLLING_NEWS("scrolling-news", "滚动新闻"), - /** - * 格式:[{ - * "picUrl": "https://www.iocoder.cn/xxx.png", - * "url": "/pages/users/index" - * }] - */ - SLIDE_SHOW("slide-show", "轮播图"), - /** - * 格式:[{ - * "name": "标题" - * "type": "类型", // best、hot、new、benefit、good - * "tag": "标签" // 例如说:多买多省 - * }] - * - * 最多 4 个 - */ - PRODUCT_RECOMMEND("product-recommend", "商品推荐"); - - /** - * 页面组件代码 - */ - private final String code; - - /** - * 页面组件说明 - */ - private final String desc; - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecoratePageEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecoratePageEnum.java deleted file mode 100644 index 3b662db7a..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/decorate/DecoratePageEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.decorate; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 装修页面枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum DecoratePageEnum implements IntArrayValuable { - - INDEX(1, "首页"), - MY(2, "个人中心"), - ; - - private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getPage).toArray(); - - /** - * 页面编号 - */ - private final Integer page; - - /** - * 页面名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/diy/DiyPageEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/diy/DiyPageEnum.java deleted file mode 100644 index fa00adaad..000000000 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/diy/DiyPageEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.enums.diy; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 装修页面枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum DiyPageEnum implements IntArrayValuable { - - INDEX(1, "首页"), - MY(2, "我的"), - ; - - private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DiyPageEnum::getPage).toArray(); - - /** - * 页面编号 - */ - private final Integer page; - - /** - * 页面名称 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/Dockerfile b/yudao-module-mall/yudao-module-promotion-biz/Dockerfile deleted file mode 100644 index e507655d9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-promotion-biz -WORKDIR /yudao-module-promotion-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-promotion-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48101 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-mall/yudao-module-promotion-biz/pom.xml b/yudao-module-mall/yudao-module-promotion-biz/pom.xml deleted file mode 100644 index 9996af44b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/pom.xml +++ /dev/null @@ -1,152 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - jar - yudao-module-promotion-biz - - ${project.artifactId} - - - promotion 模块,主要实现营销相关功能 - 例如:营销活动、banner 广告、优惠券、优惠码等功能。 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-promotion-api - ${revision} - - - cn.iocoder.cloud - yudao-module-product-api - ${revision} - - - cn.iocoder.cloud - yudao-module-trade-api - ${revision} - - - cn.iocoder.cloud - yudao-module-member-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-web - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-job - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mq - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - io.vavr - vavr - 0.10.2 - compile - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/PromotionServerApplication.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/PromotionServerApplication.java deleted file mode 100644 index e552de3ea..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/PromotionServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class PromotionServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(PromotionServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApiImpl.java deleted file mode 100644 index 97ff41d9a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainActivityApiImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 砍价活动 Api 接口实现类 - * - * @author HUIHUI - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class BargainActivityApiImpl implements BargainActivityApi { - - @Resource - private BargainActivityService bargainActivityService; - - @Override - public CommonResult updateBargainActivityStock(Long id, Integer count) { - bargainActivityService.updateBargainActivityStock(id, count); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApiImpl.java deleted file mode 100644 index b4412e96d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApiImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.bargain; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 砍价活动 API 实现类 - * - * @author HUIHUI - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class BargainRecordApiImpl implements BargainRecordApi { - - @Resource - private BargainRecordService bargainRecordService; - - @Override - public CommonResult validateJoinBargain(Long userId, Long bargainRecordId, Long skuId) { - return success(bargainRecordService.validateJoinBargain(userId, bargainRecordId, skuId)); - } - - @Override - public CommonResult updateBargainRecordOrderId(Long id, Long orderId) { - bargainRecordService.updateBargainRecordOrderId(id, orderId); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java deleted file mode 100644 index 5a55a7737..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.combination; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COMBINATION_RECORD_NOT_EXISTS; - -/** - * 拼团活动 API 实现类 - * - * @author HUIHUI - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class CombinationRecordApiImpl implements CombinationRecordApi { - - @Resource - private CombinationRecordService combinationRecordService; - - @Override - public CommonResult validateCombinationRecord(Long userId, Long activityId, Long headId, Long skuId, Integer count) { - combinationRecordService.validateCombinationRecord(userId, activityId, headId, skuId, count); - return success(true); - } - - @Override - public CommonResult createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { - return success(CombinationActivityConvert.INSTANCE.convert4(combinationRecordService.createCombinationRecord(reqDTO))); - } - - @Override - public CommonResult isCombinationRecordSuccess(Long userId, Long orderId) { - CombinationRecordDO record = combinationRecordService.getCombinationRecord(userId, orderId); - if (record == null) { - throw exception(COMBINATION_RECORD_NOT_EXISTS); - } - return success(CombinationRecordStatusEnum.isSuccess(record.getStatus())); - } - - @Override - public CommonResult validateJoinCombination( - Long userId, Long activityId, Long headId, Long skuId, Integer count) { - return success(combinationRecordService.validateJoinCombination(userId, activityId, headId, skuId, count)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApiImpl.java deleted file mode 100644 index e3d268985..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponApiImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.coupon; - - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 优惠劵 API 实现类 - * - * @author 芋道源码 - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class CouponApiImpl implements CouponApi { - - @Resource - private CouponService couponService; - - @Override - public CommonResult useCoupon(CouponUseReqDTO useReqDTO) { - couponService.useCoupon(useReqDTO.getId(), useReqDTO.getUserId(), useReqDTO.getOrderId()); - return success(true); - } - - @Override - public CommonResult returnUsedCoupon(Long id) { - couponService.returnUsedCoupon(id); - return success(true); - } - - @Override - public CommonResult validateCoupon(CouponValidReqDTO validReqDTO) { - CouponDO coupon = couponService.validCoupon(validReqDTO.getId(), validReqDTO.getUserId()); - return success(CouponConvert.INSTANCE.convert(coupon)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApiImpl.java deleted file mode 100644 index 232ab25ee..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/discount/DiscountActivityApiImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.discount; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; -import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; -import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 限时折扣 API 实现类 - * - * @author 芋道源码 - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class DiscountActivityApiImpl implements DiscountActivityApi { - - @Resource - private DiscountActivityService discountActivityService; - - @Override - public CommonResult> getMatchDiscountProductList(Collection skuIds) { - return success(DiscountActivityConvert.INSTANCE.convertList02(discountActivityService.getMatchDiscountProductList(skuIds))); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApiImpl.java deleted file mode 100644 index 45d33adae..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/reward/RewardActivityApiImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.reward; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 满减送活动 API 实现类 - * - * @author 芋道源码 - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class RewardActivityApiImpl implements RewardActivityApi { - - @Resource - private RewardActivityService rewardActivityService; - - @Override - public CommonResult> getMatchRewardActivityList(Collection spuIds) { - return success(rewardActivityService.getMatchRewardActivityList(spuIds)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java deleted file mode 100644 index f8dfb14d7..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApiImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.promotion.api.seckill; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 秒杀活动接口 Api 接口实现类 - * - * @author HUIHUI - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class SeckillActivityApiImpl implements SeckillActivityApi { - - @Resource - private SeckillActivityService activityService; - - @Override - public CommonResult updateSeckillStockDecr(Long id, Long skuId, Integer count) { - activityService.updateSeckillStockDecr(id, skuId, count); - return success(true); - } - - @Override - public CommonResult updateSeckillStockIncr(Long id, Long skuId, Integer count) { - activityService.updateSeckillStockIncr(id, skuId, count); - return success(true); - } - - @Override - public CommonResult validateJoinSeckill(Long activityId, Long skuId, Integer count) { - return success(activityService.validateJoinSeckill(activityId, skuId, count)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleCategoryController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleCategoryController.java deleted file mode 100644 index 245e6950c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleCategoryController.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import cn.iocoder.yudao.module.promotion.service.article.ArticleCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 文章分类") -@RestController -@RequestMapping("/promotion/article-category") -@Validated -public class ArticleCategoryController { - - @Resource - private ArticleCategoryService articleCategoryService; - - @PostMapping("/create") - @Operation(summary = "创建文章分类") - @PreAuthorize("@ss.hasPermission('promotion:article-category:create')") - public CommonResult createArticleCategory(@Valid @RequestBody ArticleCategoryCreateReqVO createReqVO) { - return success(articleCategoryService.createArticleCategory(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新文章分类") - @PreAuthorize("@ss.hasPermission('promotion:article-category:update')") - public CommonResult updateArticleCategory(@Valid @RequestBody ArticleCategoryUpdateReqVO updateReqVO) { - articleCategoryService.updateArticleCategory(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除文章分类") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:article-category:delete')") - public CommonResult deleteArticleCategory(@RequestParam("id") Long id) { - articleCategoryService.deleteArticleCategory(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得文章分类") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") - public CommonResult getArticleCategory(@RequestParam("id") Long id) { - ArticleCategoryDO category = articleCategoryService.getArticleCategory(id); - return success(ArticleCategoryConvert.INSTANCE.convert(category)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取文章分类精简信息列表", description = "只包含被开启的文章分类,主要用于前端的下拉选项") - public CommonResult> getSimpleDeptList() { - // 获得分类列表,只要开启状态的 - List list = articleCategoryService.getArticleCategoryListByStatus(CommonStatusEnum.ENABLE.getStatus()); - // 降序排序后,返回给前端 - list.sort(Comparator.comparing(ArticleCategoryDO::getSort).reversed()); - return success(ArticleCategoryConvert.INSTANCE.convertList03(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得文章分类分页") - @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") - public CommonResult> getArticleCategoryPage(@Valid ArticleCategoryPageReqVO pageVO) { - PageResult pageResult = articleCategoryService.getArticleCategoryPage(pageVO); - return success(ArticleCategoryConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java deleted file mode 100644 index f6dea04e3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import cn.iocoder.yudao.module.promotion.service.article.ArticleService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 文章管理") -@RestController -@RequestMapping("/promotion/article") -@Validated -public class ArticleController { - - @Resource - private ArticleService articleService; - - @PostMapping("/create") - @Operation(summary = "创建文章管理") - @PreAuthorize("@ss.hasPermission('promotion:article:create')") - public CommonResult createArticle(@Valid @RequestBody ArticleCreateReqVO createReqVO) { - return success(articleService.createArticle(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新文章管理") - @PreAuthorize("@ss.hasPermission('promotion:article:update')") - public CommonResult updateArticle(@Valid @RequestBody ArticleUpdateReqVO updateReqVO) { - articleService.updateArticle(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除文章管理") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:article:delete')") - public CommonResult deleteArticle(@RequestParam("id") Long id) { - articleService.deleteArticle(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得文章管理") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:article:query')") - public CommonResult getArticle(@RequestParam("id") Long id) { - ArticleDO article = articleService.getArticle(id); - return success(ArticleConvert.INSTANCE.convert(article)); - } - - @GetMapping("/page") - @Operation(summary = "获得文章管理分页") - @PreAuthorize("@ss.hasPermission('promotion:article:query')") - public CommonResult> getArticlePage(@Valid ArticlePageReqVO pageVO) { - PageResult pageResult = articleService.getArticlePage(pageVO); - return success(ArticleConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java deleted file mode 100644 index 4c07e86a9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 文章管理 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class ArticleBaseVO { - - @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15458") - @NotNull(message = "文章分类编号不能为空") - private Long categoryId; - - @Schema(description = "关联商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22378") - @NotNull(message = "关联商品不能为空") - private Long spuId; - - @Schema(description = "文章标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是一个标题") - @NotNull(message = "文章标题不能为空") - private String title; - - @Schema(description = "文章作者", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String author; - - @Schema(description = "文章封面图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") - @NotNull(message = "文章封面图片地址不能为空") - private String picUrl; - - @Schema(description = "文章简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是一个简介") - private String introduction; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "是否热门(小程序)", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否热门(小程序)不能为空") - private Boolean recommendHot; - - @Schema(description = "是否轮播图(小程序)", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否轮播图(小程序)不能为空") - private Boolean recommendBanner; - - @Schema(description = "文章内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是文章内容") - @NotNull(message = "文章内容不能为空") - private String content; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java deleted file mode 100644 index d598dd768..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 文章管理创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCreateReqVO extends ArticleBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java deleted file mode 100644 index 9c7539585..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 文章管理分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticlePageReqVO extends PageParam { - - @Schema(description = "文章分类编号", example = "15458") - private Long categoryId; - - @Schema(description = "关联商品编号", example = "22378") - private Long spuId; - - @Schema(description = "文章标题") - private String title; - - @Schema(description = "文章作者") - private String author; - - @Schema(description = "状态", example = "2") - private Integer status; - - @Schema(description = "是否热门(小程序)") - private Boolean recommendHot; - - @Schema(description = "是否轮播图(小程序)") - private Boolean recommendBanner; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java deleted file mode 100644 index 3f9281a17..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 文章管理 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleRespVO extends ArticleBaseVO { - - @Schema(description = "文章编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8606") - private Long id; - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "99999") - private Integer browseCount; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java deleted file mode 100644 index 3efd59334..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 文章管理更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleUpdateReqVO extends ArticleBaseVO { - - @Schema(description = "文章编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8606") - @NotNull(message = "文章编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryBaseVO.java deleted file mode 100644 index 42bf116c4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryBaseVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 文章分类 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class ArticleCategoryBaseVO { - - @Schema(description = "文章分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "秒杀") - @NotNull(message = "文章分类名称不能为空") - private String name; - - @Schema(description = "图标地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") - private String picUrl; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "排序不能为空") - private Integer sort; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryCreateReqVO.java deleted file mode 100644 index a8dc1f2e1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 文章分类创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCategoryCreateReqVO extends ArticleCategoryBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryPageReqVO.java deleted file mode 100644 index b161aae08..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 文章分类分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCategoryPageReqVO extends PageParam { - - @Schema(description = "文章分类名称", example = "秒杀") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryRespVO.java deleted file mode 100644 index af4b045a7..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 文章分类 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCategoryRespVO extends ArticleCategoryBaseVO { - - @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategorySimpleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategorySimpleRespVO.java deleted file mode 100644 index 4e43326c9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategorySimpleRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 文章分类精简信息 Response VO") -@Data -public class ArticleCategorySimpleRespVO { - - @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490") - private Long id; - - @Schema(description = "文章分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "秒杀") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryUpdateReqVO.java deleted file mode 100644 index 72a1b3506..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 文章分类更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class ArticleCategoryUpdateReqVO extends ArticleCategoryBaseVO { - - @Schema(description = "文章分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19490") - @NotNull(message = "文章分类编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java deleted file mode 100644 index 8b6dae9cf..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import cn.iocoder.yudao.module.promotion.service.banner.BannerService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - Banner 管理") -@RestController -@RequestMapping("/promotion/banner") -@Validated -public class BannerController { - - @Resource - private BannerService bannerService; - - @PostMapping("/create") - @Operation(summary = "创建 Banner") - @PreAuthorize("@ss.hasPermission('promotion:banner:create')") - public CommonResult createBanner(@Valid @RequestBody BannerCreateReqVO createReqVO) { - return success(bannerService.createBanner(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新 Banner") - @PreAuthorize("@ss.hasPermission('promotion:banner:update')") - public CommonResult updateBanner(@Valid @RequestBody BannerUpdateReqVO updateReqVO) { - bannerService.updateBanner(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除 Banner") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:banner:delete')") - public CommonResult deleteBanner(@RequestParam("id") Long id) { - bannerService.deleteBanner(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得 Banner") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:banner:query')") - public CommonResult getBanner(@RequestParam("id") Long id) { - BannerDO banner = bannerService.getBanner(id); - return success(BannerConvert.INSTANCE.convert(banner)); - } - - @GetMapping("/page") - @Operation(summary = "获得 Banner 分页") - @PreAuthorize("@ss.hasPermission('promotion:banner:query')") - public CommonResult> getBannerPage(@Valid BannerPageReqVO pageVO) { - PageResult pageResult = bannerService.getBannerPage(pageVO); - return success(BannerConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerBaseVO.java deleted file mode 100644 index 0818257ef..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerBaseVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.banner.BannerPositionEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * Banner Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * @author xia - */ -@Data -public class BannerBaseVO { - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "标题不能为空") - private String title; - - @Schema(description = "跳转链接", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "跳转链接不能为空") - private String url; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "图片地址不能为空") - private String picUrl; - - @Schema(description = "position", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "position 不能为空") - @InEnum(BannerPositionEnum.class) - private Integer position; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "备注") - private String memo; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerCreateReqVO.java deleted file mode 100644 index 180cdfe87..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerCreateReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -/** - * @author xia - */ -@Schema(description = "管理后台 - Banner 创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BannerCreateReqVO extends BannerBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java deleted file mode 100644 index c2ac49d71..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - Banner 分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BannerPageReqVO extends PageParam { - - @Schema(description = "标题", example = "这是一个标题") - private String title; - - @Schema(description = "状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerRespVO.java deleted file mode 100644 index 2eee606e1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - Banner Response VO") -@Data -@ToString(callSuper = true) -public class BannerRespVO extends BannerBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerUpdateReqVO.java deleted file mode 100644 index 266f28c1b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerUpdateReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -/** - * @author xia - */ -@Schema(description = "管理后台 - Banner更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BannerUpdateReqVO extends BannerBaseVO { - - @Schema(description = "banner 编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "banner 编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java deleted file mode 100644 index d76b90e9a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.*; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - 砍价活动") -@RestController -@RequestMapping("/promotion/bargain-activity") -@Validated -public class BargainActivityController { - - @Resource - private BargainActivityService bargainActivityService; - @Resource - private BargainRecordService bargainRecordService; - @Resource - private BargainHelpService bargainHelpService; - - @Resource - private ProductSpuApi spuApi; - - @PostMapping("/create") - @Operation(summary = "创建砍价活动") - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:create')") - public CommonResult createBargainActivity(@Valid @RequestBody BargainActivityCreateReqVO createReqVO) { - return success(bargainActivityService.createBargainActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新砍价活动") - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:update')") - public CommonResult updateBargainActivity(@Valid @RequestBody BargainActivityUpdateReqVO updateReqVO) { - bargainActivityService.updateBargainActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭砍价活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:close')") - public CommonResult closeSeckillActivity(@RequestParam("id") Long id) { - bargainActivityService.closeBargainActivityById(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除砍价活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:delete')") - public CommonResult deleteBargainActivity(@RequestParam("id") Long id) { - bargainActivityService.deleteBargainActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得砍价活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')") - public CommonResult getBargainActivity(@RequestParam("id") Long id) { - return success(BargainActivityConvert.INSTANCE.convert(bargainActivityService.getBargainActivity(id))); - } - - @GetMapping("/page") - @Operation(summary = "获得砍价活动分页") - @PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')") - public CommonResult> getBargainActivityPage( - @Valid BargainActivityPageReqVO pageVO) { - // 查询砍价活动 - PageResult pageResult = bargainActivityService.getBargainActivityPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - List spuList = spuApi.getSpuList(convertList(pageResult.getList(), BargainActivityDO::getSpuId)).getCheckedData(); - // 统计数据 - Collection activityIds = convertList(pageResult.getList(), BargainActivityDO::getId); - Map recordUserCountMap = bargainRecordService.getBargainRecordUserCountMap(activityIds, null); - Map recordSuccessUserCountMap = bargainRecordService.getBargainRecordUserCountMap(activityIds, - BargainRecordStatusEnum.SUCCESS.getStatus()); - Map helpUserCountMap = bargainHelpService.getBargainHelpUserCountMapByActivity(activityIds); - return success(BargainActivityConvert.INSTANCE.convertPage(pageResult, spuList, - recordUserCountMap, recordSuccessUserCountMap, helpUserCountMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainHelpController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainHelpController.java deleted file mode 100644 index 14265e0b3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainHelpController.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpRespVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainHelpConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 砍价助力") -@RestController -@RequestMapping("/promotion/bargain-help") -@Validated -public class BargainHelpController { - - @Resource - private BargainHelpService bargainHelpService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/page") - @Operation(summary = "获得砍价助力分页") - @PreAuthorize("@ss.hasPermission('promotion:bargain-help:query')") - public CommonResult> getBargainHelpPage(@Valid BargainHelpPageReqVO pageVO) { - PageResult pageResult = bargainHelpService.getBargainHelpPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - Map userMap = memberUserApi.getUserMap( - convertSet(pageResult.getList(), BargainHelpDO::getUserId)); - return success(BargainHelpConvert.INSTANCE.convertPage(pageResult, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainRecordController.java deleted file mode 100644 index 69781b3b5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainRecordController.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainRecordConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 砍价记录") -@RestController -@RequestMapping("/promotion/bargain-record") -@Validated -public class BargainRecordController { - - @Resource - private BargainRecordService bargainRecordService; - @Resource - private BargainActivityService bargainActivityService; - @Resource - private BargainHelpService bargainHelpService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/page") - @Operation(summary = "获得砍价记录分页") - @PreAuthorize("@ss.hasPermission('promotion:bargain-record:query')") - public CommonResult> getBargainRecordPage(@Valid BargainRecordPageReqVO pageVO) { - PageResult pageResult = bargainRecordService.getBargainRecordPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - Map userMap = memberUserApi.getUserMap( - convertSet(pageResult.getList(), BargainRecordDO::getUserId)); - List activityList = bargainActivityService.getBargainActivityList( - convertSet(pageResult.getList(), BargainRecordDO::getActivityId)); - Map helpCountMap = bargainHelpService.getBargainHelpUserCountMapByRecord( - convertSet(pageResult.getList(), BargainRecordDO::getId)); - return success(BargainRecordConvert.INSTANCE.convertPage(pageResult, helpCountMap, activityList, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityBaseVO.java deleted file mode 100644 index 9f7113fbb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityBaseVO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 砍价活动 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class BargainActivityBaseVO { - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "砍得越多省得越多,是兄弟就来砍我") - @NotNull(message = "砍价名称不能为空") - private String name; - - @Schema(description = "商品 SPU 编号", example = "1") - @NotNull(message = "砍价商品不能为空") - private Long spuId; - - @Schema(description = "商品 skuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - @NotNull(message = "商品 skuId 不能为空") - private Long skuId; - - @Schema(description = "砍价起始价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - @NotNull(message = "砍价起始价格不能为空") - private Integer bargainFirstPrice; - - @Schema(description = "砍价底价", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - @NotNull(message = "砍价底价不能为空") - private Integer bargainMinPrice; - - @Schema(description = "活动库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - @NotNull(message = "活动库存不能为空") - private Integer stock; - - @Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "16218") - @NotNull(message = "总限购数量不能为空") - private Integer totalLimitCount; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]") - @NotNull(message = "活动开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]") - @NotNull(message = "活动结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "最大助力次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "最大助力次数不能为空") - private Integer helpMaxCount; - - @Schema(description = "最大帮砍次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "最大帮砍次数不能为空") - private Integer bargainCount; - - @Schema(description = "用户每次砍价的最小金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "用户每次砍价的最小金额不能为空") - private Integer randomMinPrice; - - @Schema(description = "用户每次砍价的最大金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "用户每次砍价的最大金额不能为空") - private Integer randomMaxPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityCreateReqVO.java deleted file mode 100644 index 83cb5eaf9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 砍价活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityCreateReqVO extends BargainActivityBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageItemRespVO.java deleted file mode 100644 index 721a31ca6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageItemRespVO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 砍价活动的分页项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityPageItemRespVO extends BargainActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促") - private String spuName; - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "活动状态不能为空") - private Integer status; - - @Schema(description = "活动总库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - private Integer totalStock; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") - private LocalDateTime createTime; - - // ========== 统计字段 ========== - - @Schema(description = "总砍价的用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "999") - private Integer recordUserCount; - - @Schema(description = "成功砍价的用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "500") - private Integer recordSuccessUserCount; - - @Schema(description = "帮助砍价的用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Integer helpUserCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageReqVO.java deleted file mode 100644 index 66f23730f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 砍价活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityPageReqVO extends PageParam { - - @Schema(description = "砍价名称", example = "赵六") - private String name; - - @Schema(description = "活动状态", example = "0") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java deleted file mode 100644 index 0295fddc5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -@Schema(description = "管理后台 - 砍价活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityRespVO extends BargainActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityUpdateReqVO.java deleted file mode 100644 index b7470293f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 砍价活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainActivityUpdateReqVO extends BargainActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - @NotNull(message = "活动编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpBaseVO.java deleted file mode 100644 index 41dd1c246..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpBaseVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 砍价助力 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BargainHelpBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5402") - private Long userId; - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "16825") - private Long activityId; - - @Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1800") - private Long recordId; - - @Schema(description = "减少砍价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "32300") - private Integer reducePrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpPageReqVO.java deleted file mode 100644 index 8afbe3ff6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 砍价助力分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainHelpPageReqVO extends PageParam { - - @Schema(description = "砍价记录编号", example = "1800") - private Long recordId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpRespVO.java deleted file mode 100644 index 151594477..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/help/BargainHelpRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 砍价助力 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainHelpRespVO extends BargainHelpBaseVO { - - @Schema(description = "砍价助力编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25860") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 用户相关 ========== - - @Schema(description = "用户昵称", example = "老芋艿") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordBaseVO.java deleted file mode 100644 index 31650f10d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordBaseVO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 砍价记录 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BargainRecordBaseVO { - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "22690") - @NotNull(message = "砍价活动名称不能为空") - private Long activityId; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9430") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23622") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29950") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "31160") - @NotNull(message = "砍价起始价格,单位:分不能为空") - private Integer bargainFirstPrice; - - @Schema(description = "当前砍价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "22743") - @NotNull(message = "当前砍价,单位:分不能为空") - private Integer bargainPrice; - - @Schema(description = "砍价状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "砍价状态不能为空") - private Integer status; - - @Schema(description = "订单编号", example = "27845") - private Long orderId; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageItemRespVO.java deleted file mode 100644 index 608ed3090..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageItemRespVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod; - -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 砍价记录的分页项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainRecordPageItemRespVO extends BargainRecordBaseVO { - - @Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") - private LocalDateTime createTime; - - @Schema(description = "帮砍次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer helpCount; - - // ========== 用户相关 ========== - - @Schema(description = "用户昵称", example = "老芋艿") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - // ========== 活动相关 ========== - - private BargainActivityRespVO activity; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageReqVO.java deleted file mode 100644 index 47b671877..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 砍价记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BargainRecordPageReqVO extends PageParam { - - @Schema(description = "砍价状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationActivityController.java deleted file mode 100644 index 69e31099b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationActivityController.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.*; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.hutool.core.collection.CollectionUtil.newArrayList; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 拼团活动") -@RestController -@RequestMapping("/promotion/combination-activity") -@Validated -public class CombinationActivityController { - - @Resource - private CombinationActivityService combinationActivityService; - @Resource - private CombinationRecordService combinationRecordService; - - @Resource - private ProductSpuApi productSpuApi; - - @PostMapping("/create") - @Operation(summary = "创建拼团活动") - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:create')") - public CommonResult createCombinationActivity(@Valid @RequestBody CombinationActivityCreateReqVO createReqVO) { - return success(combinationActivityService.createCombinationActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新拼团活动") - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:update')") - public CommonResult updateCombinationActivity(@Valid @RequestBody CombinationActivityUpdateReqVO updateReqVO) { - combinationActivityService.updateCombinationActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭拼团活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:close')") - public CommonResult closeCombinationActivity(@RequestParam("id") Long id) { - combinationActivityService.closeCombinationActivityById(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除拼团活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:delete')") - public CommonResult deleteCombinationActivity(@RequestParam("id") Long id) { - combinationActivityService.deleteCombinationActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得拼团活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:query')") - public CommonResult getCombinationActivity(@RequestParam("id") Long id) { - CombinationActivityDO activity = combinationActivityService.getCombinationActivity(id); - List products = combinationActivityService.getCombinationProductListByActivityIds(newArrayList(id)); - return success(CombinationActivityConvert.INSTANCE.convert(activity, products)); - } - - @GetMapping("/page") - @Operation(summary = "获得拼团活动分页") - @PreAuthorize("@ss.hasPermission('promotion:combination-activity:query')") - public CommonResult> getCombinationActivityPage( - @Valid CombinationActivityPageReqVO pageVO) { - // 查询拼团活动 - PageResult pageResult = combinationActivityService.getCombinationActivityPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 统计数据 - Set activityIds = convertSet(pageResult.getList(), CombinationActivityDO::getId); - Map groupCountMap = combinationRecordService.getCombinationRecordCountMapByActivity( - activityIds, null, CombinationRecordDO.HEAD_ID_GROUP); - Map groupSuccessCountMap = combinationRecordService.getCombinationRecordCountMapByActivity( - activityIds, CombinationRecordStatusEnum.SUCCESS.getStatus(), CombinationRecordDO.HEAD_ID_GROUP); - Map recordCountMap = combinationRecordService.getCombinationRecordCountMapByActivity( - activityIds, null, null); - // 拼接数据 - List products = combinationActivityService.getCombinationProductListByActivityIds( - convertSet(pageResult.getList(), CombinationActivityDO::getId)); - List spus = productSpuApi.getSpuList( - convertSet(pageResult.getList(), CombinationActivityDO::getSpuId)).getCheckedData(); - return success(CombinationActivityConvert.INSTANCE.convertPage(pageResult, products, - groupCountMap, groupSuccessCountMap, recordCountMap, spus)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java deleted file mode 100644 index 45ad4e02d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordSummaryVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.context.annotation.Lazy; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 拼团记录") -@RestController -@RequestMapping("/promotion/combination-record") -@Validated -public class CombinationRecordController { - - @Resource - private CombinationActivityService combinationActivityService; - @Resource - @Lazy - private CombinationRecordService combinationRecordService; - - @GetMapping("/page") - @Operation(summary = "获得拼团记录分页") - @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") - public CommonResult> getCombinationRecordPage( - @Valid CombinationRecordReqPageVO pageVO) { - PageResult recordPage = combinationRecordService.getCombinationRecordPage(pageVO); - // 拼接数据 - List activities = combinationActivityService.getCombinationActivityListByIds( - convertSet(recordPage.getList(), CombinationRecordDO::getActivityId)); - List products = combinationActivityService.getCombinationProductListByActivityIds( - convertSet(recordPage.getList(), CombinationRecordDO::getActivityId)); - return success(CombinationActivityConvert.INSTANCE.convert(recordPage, activities, products)); - } - - @GetMapping("/get-summary") - @Operation(summary = "获得拼团记录的概要信息", description = "用于拼团记录页面展示") - @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") - public CommonResult getCombinationRecordSummary() { - CombinationRecordSummaryVO summaryVO = new CombinationRecordSummaryVO(); - summaryVO.setUserCount(combinationRecordService.getCombinationUserCount()); // 获取拼团用户参与数量 - summaryVO.setSuccessCount(combinationRecordService.getCombinationRecordCount( // 获取成团记录 - CombinationRecordStatusEnum.SUCCESS.getStatus(), null, CombinationRecordDO.HEAD_ID_GROUP)); - summaryVO.setVirtualGroupCount(combinationRecordService.getCombinationRecordCount(// 获取虚拟成团记录 - null, Boolean.TRUE, CombinationRecordDO.HEAD_ID_GROUP)); - return success(summaryVO); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityBaseVO.java deleted file mode 100644 index 4b3abeab4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityBaseVO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 拼团活动 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class CombinationActivityBaseVO { - - @Schema(description = "拼团名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "越拼越省钱") - @NotNull(message = "拼团名称不能为空") - private String name; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "拼团商品不能为空") - private Long spuId; - - @Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "16218") - @NotNull(message = "总限购数量不能为空") - private Integer totalLimitCount; - - @Schema(description = "单次限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "28265") - @NotNull(message = "单次限购数量不能为空") - private Integer singleLimitCount; - - @Schema(description = "活动时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]") - @NotNull(message = "活动时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "活动时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]") - @NotNull(message = "活动时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "开团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") - @NotNull(message = "开团人数不能为空") - private Integer userSize; - - @Schema(description = "虚拟成团", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - @NotNull(message = "虚拟成团不能为空") - private Boolean virtualGroup; - - @Schema(description = "限制时长(小时)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "限制时长不能为空") - private Integer limitDuration; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityCreateReqVO.java deleted file mode 100644 index dff1a6cdb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityCreateReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import java.util.List; - -@Schema(description = "管理后台 - 拼团活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityCreateReqVO extends CombinationActivityBaseVO { - - @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageItemRespVO.java deleted file mode 100644 index 0151adfb9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageItemRespVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 拼团活动的分页项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityPageItemRespVO extends CombinationActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - // ========== 商品字段 ========== - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 - example = "618大促") - private String spuName; - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - - // ========== 统计字段 ========== - - @Schema(description = "开团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "33") - private Integer groupCount; - - @Schema(description = "成团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer groupSuccessCount; - - @Schema(description = "购买次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer recordCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageReqVO.java deleted file mode 100644 index bfb54b730..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 拼团活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityPageReqVO extends PageParam { - - @Schema(description = "拼团名称", example = "赵六") - private String name; - - @Schema(description = "活动状态", example = "0") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityRespVO.java deleted file mode 100644 index 0ac77c559..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 拼团活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityRespVO extends CombinationActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "开团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") - private Integer userSize; - - @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityUpdateReqVO.java deleted file mode 100644 index f4483cee1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityUpdateReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 拼团活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationActivityUpdateReqVO extends CombinationActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - @NotNull(message = "活动编号不能为空") - private Long id; - - @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductBaseVO.java deleted file mode 100644 index 452fb38ff..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductBaseVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 拼团商品 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class CombinationProductBaseVO { - - @Schema(description = "商品 spuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "30563") - @NotNull(message = "商品 spuId 不能为空") - private Long spuId; - - @Schema(description = "商品 skuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "30563") - @NotNull(message = "商品 skuId 不能为空") - private Long skuId; - - @Schema(description = "拼团价格,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "27682") - @NotNull(message = "拼团价格不能为空") - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductPageReqVO.java deleted file mode 100644 index 02bcc070c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductPageReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 拼团商品分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationProductPageReqVO extends PageParam { - - @Schema(description = "拼团活动编号", example = "6829") - private Long activityId; - - @Schema(description = "商品 SPU 编号", example = "18731") - private Long spuId; - - @Schema(description = "商品 SKU 编号", example = "31675") - private Long skuId; - - @Schema(description = "拼团商品状态", example = "2") - private Integer activityStatus; - - @Schema(description = "活动开始时间点") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] activityStartTime; - - @Schema(description = "活动结束时间点") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] activityEndTime; - - @Schema(description = "拼团价格,单位分", example = "27682") - private Integer activePrice; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductRespVO.java deleted file mode 100644 index eeac5c3b5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/product/CombinationProductRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 拼团商品 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationProductRespVO extends CombinationProductBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28322") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordBaseVO.java deleted file mode 100644 index 18c754dc5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordBaseVO.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 拼团记录 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class CombinationRecordBaseVO { - - @Schema(description = "拼团记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "拼团活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long activityId; - - @Schema(description = "团长编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long headId; - - // ========== 用户相关 ========== - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9430") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "用户昵称", example = "老芋艿") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - // ========== 商品相关 ========== - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23622") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29950") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是大黄豆") - private String spuName; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime expireTime; - - @Schema(description = "可参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer userSize; - - @Schema(description = "已参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer userCount; - - @Schema(description = "拼团状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "是否虚拟成团", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") - private Boolean virtualGroup; - - @Schema(description = "开始时间 (订单付款后开始的时间)", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间(成团时间/失败时间)", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordPageItemRespVO.java deleted file mode 100644 index 7b1b10bac..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordPageItemRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 拼团记录的分页项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationRecordPageItemRespVO extends CombinationRecordBaseVO { - - // ========== 活动相关 ========== - - private CombinationActivityRespVO activity; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPage2VO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPage2VO.java deleted file mode 100644 index 9e6fe9159..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPage2VO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 拼团记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationRecordReqPage2VO extends PageParam { - - @Schema(description = "团长编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "团长编号不能为空") - private Long headId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java deleted file mode 100644 index a66795d64..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordReqPageVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 拼团记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CombinationRecordReqPageVO extends PageParam { - - @Schema(description = "活动状态", example = "1") - @InEnum(BargainRecordStatusEnum.class) - private Integer status; - - @Schema(description = "团长编号", example = "1024") - private Long headId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordSummaryVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordSummaryVO.java deleted file mode 100644 index 64d63afe0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/recrod/CombinationRecordSummaryVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 拼团记录信息统计 Response VO") -@Data -public class CombinationRecordSummaryVO { - - @Schema(description = "所有拼团记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userCount; - - @Schema(description = "成团记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long successCount; - - @Schema(description = "虚拟成团记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long virtualGroupCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java deleted file mode 100755 index 8e0a9bd2b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponSendReqVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 优惠劵") -@RestController -@RequestMapping("/promotion/coupon") -@Validated -public class CouponController { - - @Resource - private CouponService couponService; - @Resource - private MemberUserApi memberUserApi; - - @DeleteMapping("/delete") - @Operation(summary = "回收优惠劵") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:coupon:delete')") - public CommonResult deleteCoupon(@RequestParam("id") Long id) { - couponService.deleteCoupon(id); - return success(true); - } - - @GetMapping("/page") - @Operation(summary = "获得优惠劵分页") - @PreAuthorize("@ss.hasPermission('promotion:coupon:query')") - public CommonResult> getCouponPage(@Valid CouponPageReqVO pageVO) { - PageResult pageResult = couponService.getCouponPage(pageVO); - PageResult pageResulVO = CouponConvert.INSTANCE.convertPage(pageResult); - if (CollUtil.isEmpty(pageResulVO.getList())) { - return success(pageResulVO); - } - - // 读取用户信息,进行拼接 - Map userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), CouponDO::getUserId)); - pageResulVO.getList().forEach(itemRespVO -> MapUtils.findAndThen(userMap, itemRespVO.getUserId(), - userRespDTO -> itemRespVO.setNickname(userRespDTO.getNickname()))); - return success(pageResulVO); - } - - @PostMapping("/send") - @Operation(summary = "发送优惠劵") - @PreAuthorize("@ss.hasPermission('promotion:coupon:send')") - public CommonResult sendCoupon(@Valid @RequestBody CouponSendReqVO reqVO) { - couponService.takeCouponByAdmin(reqVO.getTemplateId(), reqVO.getUserIds()); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponTemplateController.java deleted file mode 100755 index c94756049..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/CouponTemplateController.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.*; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 优惠劵模板") -@RestController -@RequestMapping("/promotion/coupon-template") -@Validated -public class CouponTemplateController { - - @Resource - private CouponTemplateService couponTemplateService; - - @PostMapping("/create") - @Operation(summary = "创建优惠劵模板") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:create')") - public CommonResult createCouponTemplate(@Valid @RequestBody CouponTemplateCreateReqVO createReqVO) { - return success(couponTemplateService.createCouponTemplate(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新优惠劵模板") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:update')") - public CommonResult updateCouponTemplate(@Valid @RequestBody CouponTemplateUpdateReqVO updateReqVO) { - couponTemplateService.updateCouponTemplate(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新优惠劵模板状态") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:update')") - public CommonResult updateCouponTemplateStatus(@Valid @RequestBody CouponTemplateUpdateStatusReqVO reqVO) { - couponTemplateService.updateCouponTemplateStatus(reqVO.getId(), reqVO.getStatus()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除优惠劵模板") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:delete')") - public CommonResult deleteCouponTemplate(@RequestParam("id") Long id) { - couponTemplateService.deleteCouponTemplate(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得优惠劵模板") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')") - public CommonResult getCouponTemplate(@RequestParam("id") Long id) { - CouponTemplateDO couponTemplate = couponTemplateService.getCouponTemplate(id); - return success(CouponTemplateConvert.INSTANCE.convert(couponTemplate)); - } - - @GetMapping("/page") - @Operation(summary = "获得优惠劵模板分页") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')") - public CommonResult> getCouponTemplatePage(@Valid CouponTemplatePageReqVO pageVO) { - PageResult pageResult = couponTemplateService.getCouponTemplatePage(pageVO); - return success(CouponTemplateConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list") - @Operation(summary = "获得优惠劵模板列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')") - public CommonResult> getCouponTemplateList(@RequestParam("ids") Collection ids) { - List list = couponTemplateService.getCouponTemplateList(ids); - return success(CouponTemplateConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponBaseVO.java deleted file mode 100755 index 0d7459867..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponBaseVO.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** -* 优惠劵 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class CouponBaseVO { - - // ========== 基本信息 BEGIN ========== - @Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "优惠劵模板编号不能为空") - private Long templateId; - - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") - @NotNull(message = "优惠劵名不能为空") - private String name; - - @Schema(description = "优惠码状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - // ========== 基本信息 END ========== - - // ========== 领取情况 BEGIN ========== - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "领取方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "领取方式不能为空") - private Integer takeType; - // ========== 领取情况 END ========== - - // ========== 使用规则 BEGIN ========== - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 单位:分;0 - 不限制 - @NotNull(message = "是否设置满多少金额可用不能为空") - private Integer usePrice; - - @Schema(description = "固定日期 - 生效开始时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validEndTime; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品范围不能为空") - @InEnum(PromotionProductScopeEnum.class) - private Integer productScope; - - @Schema(description = "商品范围编号的数组", example = "1,3") - private List productScopeValues; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "优惠类型不能为空") - @InEnum(PromotionDiscountTypeEnum.class) - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 使用情况 BEGIN ========== - - @Schema(description = "使用订单号", example = "4096") - private Long useOrderId; - - @Schema(description = "使用时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime useTime; - - // ========== 使用情况 END ========== - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageItemRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageItemRespVO.java deleted file mode 100755 index 118736ef6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageItemRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 优惠劵分页的每一项 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponPageItemRespVO extends CouponRespVO { - - @Schema(description = "用户昵称", example = "老芋艿") - private String nickname; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageReqVO.java deleted file mode 100755 index 75aa2f74b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponPageReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.Collection; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 优惠劵分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponPageReqVO extends PageParam { - - @Schema(description = "优惠劵模板编号", example = "2048") - private Long templateId; - - @Schema(description = "优惠码状态", example = "1") - @InEnum(value = CouponStatusEnum.class, message = "优惠劵状态,必须是 {value}") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "用户昵称", example = "芋艿") - private String nickname; - - @Schema(description = "用户编号", example = "1") - private Collection userIds; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponRespVO.java deleted file mode 100755 index 7c0fa6c86..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 优惠劵 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponRespVO extends CouponBaseVO { - - @Schema(description = "优惠劵编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponSendReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponSendReqVO.java deleted file mode 100644 index bac879f9c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponSendReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Set; - -@Schema(description = "管理后台 - 优惠劵发放 Request VO") -@Data -@ToString(callSuper = true) -public class CouponSendReqVO { - - @Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "优惠劵模板编号不能为空") - private Long templateId; - - @Schema(description = "用户编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]") - @NotEmpty(message = "用户编号列表不能为空") - private Set userIds; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateBaseVO.java deleted file mode 100755 index 2529f79ac..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateBaseVO.java +++ /dev/null @@ -1,154 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** -* 优惠劵模板 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class CouponTemplateBaseVO { - - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") - @NotNull(message = "优惠劵名不能为空") - private String name; - - @Schema(description = "发行总量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") // -1 - 则表示不限制发放数量 - @NotNull(message = "发行总量不能为空") - private Integer totalCount; - - @Schema(description = "每人限领个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") // -1 - 则表示不限制 - @NotNull(message = "每人限领个数不能为空") - private Integer takeLimitCount; - - @Schema(description = "领取方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "领取方式不能为空") - private Integer takeType; - - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 单位:分;0 - 不限制 - @NotNull(message = "是否设置满多少金额可用不能为空") - private Integer usePrice; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品范围不能为空") - @InEnum(PromotionProductScopeEnum.class) - private Integer productScope; - - @Schema(description = "商品范围编号的数组", example = "[1, 3]") - private List productScopeValues; - - @Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "生效日期类型不能为空") - @InEnum(CouponTemplateValidityTypeEnum.class) - private Integer validityType; - - @Schema(description = "固定日期 - 生效开始时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime validEndTime; - - @Schema(description = "领取日期 - 开始天数") - @Min(value = 0L, message = "开始天数必须大于 0") - private Integer fixedStartTerm; - - @Schema(description = "领取日期 - 结束天数") - @Min(value = 1L, message = "开始天数必须大于 1") - private Integer fixedEndTerm; - - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "优惠类型不能为空") - @InEnum(PromotionDiscountTypeEnum.class) - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 - private Integer discountLimitPrice; - - @AssertTrue(message = "商品范围编号的数组不能为空") - @JsonIgnore - public boolean isProductScopeValuesValid() { - return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空 - || CollUtil.isNotEmpty(productScopeValues); - } - - @AssertTrue(message = "生效开始时间不能为空") - @JsonIgnore - public boolean isValidStartTimeValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.DATE.getType()) - || validStartTime != null; - } - - @AssertTrue(message = "生效结束时间不能为空") - @JsonIgnore - public boolean isValidEndTimeValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.DATE.getType()) - || validEndTime != null; - } - - @AssertTrue(message = "开始天数不能为空") - @JsonIgnore - public boolean isFixedStartTermValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.TERM.getType()) - || fixedStartTerm != null; - } - - @AssertTrue(message = "结束天数不能为空") - @JsonIgnore - public boolean isFixedEndTermValid() { - return ObjectUtil.notEqual(validityType, CouponTemplateValidityTypeEnum.TERM.getType()) - || fixedEndTerm != null; - } - - @AssertTrue(message = "折扣百分比需要大于等于 1,小于等于 99") - @JsonIgnore - public boolean isDiscountPercentValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) - || (discountPercent != null && discountPercent >= 1 && discountPercent<= 99); - } - - @AssertTrue(message = "优惠金额不能为空") - @JsonIgnore - public boolean isDiscountPriceValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PRICE.getType()) - || discountPrice != null; - } - - @AssertTrue(message = "折扣上限不能为空") - @JsonIgnore - public boolean isDiscountLimitPriceValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) - || discountLimitPrice != null; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateCreateReqVO.java deleted file mode 100755 index d9c5c326d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 优惠劵模板创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplateCreateReqVO extends CouponTemplateBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplatePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplatePageReqVO.java deleted file mode 100755 index 1dad778f5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplatePageReqVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 优惠劵模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplatePageReqVO extends PageParam { - - @Schema(description = "优惠劵名", example = "你好") - private String name; - - @Schema(description = "状态", example = "1") - private Integer status; - - @Schema(description = "优惠类型", example = "1") - private Integer discountType; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "可以领取的类型", example = "[1, 2, 3]") - @InEnum(value = CouponTakeTypeEnum.class, message = "可以领取的类型,必须是 {value}") - private List canTakeTypes; - - @Schema(description = "商品范围", example = "1") - @InEnum(value = PromotionProductScopeEnum.class, message = "商品范围,必须是 {value}") - private Integer productScope; - - @Schema(description = "商品范围编号", example = "1") - private Long productScopeValue; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateRespVO.java deleted file mode 100755 index d2c9d710a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 优惠劵模板 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplateRespVO extends CouponTemplateBaseVO { - - @Schema(description = "模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "领取优惠券的数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer takeCount; - - @Schema(description = "使用优惠券的次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Integer useCount; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateReqVO.java deleted file mode 100755 index e57bf6209..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 优惠劵模板更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CouponTemplateUpdateReqVO extends CouponTemplateBaseVO { - - @Schema(description = "模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "模板编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateStatusReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateStatusReqVO.java deleted file mode 100644 index a2234e3c5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateUpdateStatusReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 优惠劵模板更新状态 Request VO") -@Data -public class CouponTemplateUpdateStatusReqVO { - - @Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "优惠劵模板编号不能为空") - private Long id; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/DiscountActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/DiscountActivityController.java deleted file mode 100755 index 620e54c2b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/DiscountActivityController.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.*; -import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 限时折扣活动") -@RestController -@RequestMapping("/promotion/discount-activity") -@Validated -public class DiscountActivityController { - - @Resource - private DiscountActivityService discountActivityService; - - @Resource - private ProductSpuApi productSpuApi; - - @PostMapping("/create") - @Operation(summary = "创建限时折扣活动") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:create')") - public CommonResult createDiscountActivity(@Valid @RequestBody DiscountActivityCreateReqVO createReqVO) { - return success(discountActivityService.createDiscountActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新限时折扣活动") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:update')") - public CommonResult updateDiscountActivity(@Valid @RequestBody DiscountActivityUpdateReqVO updateReqVO) { - discountActivityService.updateDiscountActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭限时折扣活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:close')") - public CommonResult closeRewardActivity(@RequestParam("id") Long id) { - discountActivityService.closeDiscountActivity(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除限时折扣活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:delete')") - public CommonResult deleteDiscountActivity(@RequestParam("id") Long id) { - discountActivityService.deleteDiscountActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得限时折扣活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:query')") - public CommonResult getDiscountActivity(@RequestParam("id") Long id) { - DiscountActivityDO discountActivity = discountActivityService.getDiscountActivity(id); - if (discountActivity == null) { - return success(null); - } - // 拼接结果 - List discountProducts = discountActivityService.getDiscountProductsByActivityId(id); - return success(DiscountActivityConvert.INSTANCE.convert(discountActivity, discountProducts)); - } - - @GetMapping("/page") - @Operation(summary = "获得限时折扣活动分页") - @PreAuthorize("@ss.hasPermission('promotion:discount-activity:query')") - public CommonResult> getDiscountActivityPage(@Valid DiscountActivityPageReqVO pageVO) { - PageResult pageResult = discountActivityService.getDiscountActivityPage(pageVO); - - if (CollUtil.isEmpty(pageResult.getList())) { // TODO @zhangshuai:方法里的空行,目的是让代码分块,可以更清晰;所以上面这个空格可以不要,而下面判断之后的,空格,其实加下比较好;类似的还有 spuList、以及后面的 convert - return success(PageResult.empty(pageResult.getTotal())); - } - // 拼接数据 - List products = discountActivityService.getDiscountProductsByActivityId( - convertSet(pageResult.getList(), DiscountActivityDO::getId)); - - List spuList = productSpuApi.getSpuList( - convertSet(products, DiscountProductDO::getSpuId)).getCheckedData(); - - return success(DiscountActivityConvert.INSTANCE.convertPage(pageResult, products, spuList)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityBaseVO.java deleted file mode 100755 index a72990531..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityBaseVO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** -* 限时折扣活动 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class DiscountActivityBaseVO { - - @Schema(description = "活动标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "一个标题") - @NotNull(message = "活动标题不能为空") - private String name; - - @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "备注", example = "我是备注") - private String remark; - - @Schema(description = "商品") - @Data - public static class Product { - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "优惠类型不能为空") - @InEnum(PromotionDiscountTypeEnum.class) - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @AssertTrue(message = "折扣百分比需要大于等于 1,小于等于 99") - @JsonIgnore - public boolean isDiscountPercentValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType()) - || (discountPercent != null && discountPercent >= 1 && discountPercent<= 99); - } - - @AssertTrue(message = "优惠金额不能为空") - @JsonIgnore - public boolean isDiscountPriceValid() { - return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PRICE.getType()) - || discountPrice != null; - } - - } -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityCreateReqVO.java deleted file mode 100755 index 4da80a1b9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityCreateReqVO extends DiscountActivityBaseVO { - - /** - * 商品列表 - */ - @NotEmpty(message = "商品列表不能为空") - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityDetailRespVO.java deleted file mode 100755 index 85a989c05..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityDetailRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动的详细 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityDetailRespVO extends DiscountActivityRespVO { - - /** - * 商品列表 - */ - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityPageReqVO.java deleted file mode 100755 index 4463555ea..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 限时折扣活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityPageReqVO extends PageParam { - - @Schema(description = "活动标题", example = "一个标题") - private String name; - - @Schema(description = "活动状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityRespVO.java deleted file mode 100755 index 232454a98..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityRespVO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityRespVO extends DiscountActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "活动状态不能为空") - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") // TODO @zhangshuai:属性和属性之间,最多空一行噢; - private Long spuId; - - @Schema(description = "限时折扣商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - // ========== 商品字段 ========== - - // TODO @zhangshuai:一个优惠活动,会关联多个商品,所以它不用返回 spuName 哈; - // TODO 最终界面展示字段就:编号、活动名称、参与商品数、活动状态、开始时间、结束时间、操作 - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 - example = "618大促") - private String spuName; - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityUpdateReqVO.java deleted file mode 100755 index 83ff6d1e1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityUpdateReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 限时折扣活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiscountActivityUpdateReqVO extends DiscountActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "活动编号不能为空") - private Long id; - - /** - * 商品列表 - */ - @NotEmpty(message = "商品列表不能为空") - @Valid - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyPageController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyPageController.java deleted file mode 100644 index 4da7064d0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyPageController.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.*; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 装修页面") -@RestController -@RequestMapping("/promotion/diy-page") -@Validated -public class DiyPageController { - - @Resource - private DiyPageService diyPageService; - - @PostMapping("/create") - @Operation(summary = "创建装修页面") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:create')") - public CommonResult createDiyPage(@Valid @RequestBody DiyPageCreateReqVO createReqVO) { - return success(diyPageService.createDiyPage(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新装修页面") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:update')") - public CommonResult updateDiyPage(@Valid @RequestBody DiyPageUpdateReqVO updateReqVO) { - diyPageService.updateDiyPage(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除装修页面") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:diy-page:delete')") - public CommonResult deleteDiyPage(@RequestParam("id") Long id) { - diyPageService.deleteDiyPage(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得装修页面") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") - public CommonResult getDiyPage(@RequestParam("id") Long id) { - DiyPageDO diyPage = diyPageService.getDiyPage(id); - return success(DiyPageConvert.INSTANCE.convert(diyPage)); - } - - @GetMapping("/list") - @Operation(summary = "获得装修页面列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") - public CommonResult> getDiyPageList(@RequestParam("ids") Collection ids) { - List list = diyPageService.getDiyPageList(ids); - return success(DiyPageConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得装修页面分页") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") - public CommonResult> getDiyPagePage(@Valid DiyPagePageReqVO pageVO) { - PageResult pageResult = diyPageService.getDiyPagePage(pageVO); - return success(DiyPageConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/get-property") - @Operation(summary = "获得装修页面属性") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:query')") - public CommonResult getDiyPageProperty(@RequestParam("id") Long id) { - DiyPageDO diyPage = diyPageService.getDiyPage(id); - return success(DiyPageConvert.INSTANCE.convertPropertyVo(diyPage)); - } - - @PutMapping("/update-property") - @Operation(summary = "更新装修页面属性") - @PreAuthorize("@ss.hasPermission('promotion:diy-page:update')") - public CommonResult updateDiyPageProperty(@Valid @RequestBody DiyPagePropertyUpdateRequestVO updateReqVO) { - diyPageService.updateDiyPageProperty(updateReqVO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyTemplateController.java deleted file mode 100644 index 2ec8f2ea0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/DiyTemplateController.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.*; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; -import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 装修模板") -@RestController -@RequestMapping("/promotion/diy-template") -@Validated -public class DiyTemplateController { - - @Resource - private DiyTemplateService diyTemplateService; - @Resource - private DiyPageService diyPageService; - - @PostMapping("/create") - @Operation(summary = "创建装修模板") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:create')") - public CommonResult createDiyTemplate(@Valid @RequestBody DiyTemplateCreateReqVO createReqVO) { - return success(diyTemplateService.createDiyTemplate(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新装修模板") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:update')") - public CommonResult updateDiyTemplate(@Valid @RequestBody DiyTemplateUpdateReqVO updateReqVO) { - diyTemplateService.updateDiyTemplate(updateReqVO); - return success(true); - } - - @PutMapping("/use") - @Operation(summary = "使用装修模板") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:use')") - public CommonResult useDiyTemplate(@RequestParam("id") Long id) { - diyTemplateService.useDiyTemplate(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除装修模板") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:diy-template:delete')") - public CommonResult deleteDiyTemplate(@RequestParam("id") Long id) { - diyTemplateService.deleteDiyTemplate(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得装修模板") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:query')") - public CommonResult getDiyTemplate(@RequestParam("id") Long id) { - DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id); - return success(DiyTemplateConvert.INSTANCE.convert(diyTemplate)); - } - - @GetMapping("/page") - @Operation(summary = "获得装修模板分页") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:query')") - public CommonResult> getDiyTemplatePage(@Valid DiyTemplatePageReqVO pageVO) { - PageResult pageResult = diyTemplateService.getDiyTemplatePage(pageVO); - return success(DiyTemplateConvert.INSTANCE.convertPage(pageResult)); - } - - // TODO @疯狂:这个要不和 getDiyTemplate 合并,然后 DiyTemplateRespVO 里面直接把 DiyPagePropertyRespVO 也加上。减少 VO 好了,管理后台 get 多返回点数据,也问题不大的。目的,还是想尽可能降低大家的理解成本哈; - @GetMapping("/get-property") - @Operation(summary = "获得装修模板属性") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:query')") - public CommonResult getDiyTemplateProperty(@RequestParam("id") Long id) { - DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id); - List pages = diyPageService.getDiyPageByTemplateId(id); - return success(DiyTemplateConvert.INSTANCE.convertPropertyVo(diyTemplate, pages)); - } - - // TODO @疯狂:这个接口,要不和 useDiyTemplate 合并成一个,然后 VO 改成我们新的 VO 规范。不改的字段,就不传递。 - @PutMapping("/update-property") - @Operation(summary = "更新装修模板属性") - @PreAuthorize("@ss.hasPermission('promotion:diy-template:update')") - public CommonResult updateDiyTemplateProperty(@Valid @RequestBody DiyTemplatePropertyUpdateRequestVO updateReqVO) { - diyTemplateService.updateDiyTemplateProperty(updateReqVO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageBaseVO.java deleted file mode 100644 index 66186b1eb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageBaseVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 装修页面 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class DiyPageBaseVO { - - @Schema(description = "装修模板编号", example = "26179") - private Long templateId; - - @Schema(description = "页面名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotNull(message = "页面名称不能为空") - private String name; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "预览图") - private List previewPicUrls; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageCreateReqVO.java deleted file mode 100644 index 17d3b35cb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 装修页面创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPageCreateReqVO extends DiyPageBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePageReqVO.java deleted file mode 100644 index 5c81b9f93..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 装修页面分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPagePageReqVO extends PageParam { - - @Schema(description = "页面名称", example = "王五") - private String name; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyRespVO.java deleted file mode 100644 index 2fdd54682..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 装修页面属性 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPagePropertyRespVO extends DiyPageBaseVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "页面属性", example = "[]") - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyUpdateRequestVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyUpdateRequestVO.java deleted file mode 100644 index ebfa36420..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPagePropertyUpdateRequestVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 装修页面属性更新 Request VO") -@Data -@ToString(callSuper = true) -public class DiyPagePropertyUpdateRequestVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - @NotNull(message = "装修页面编号不能为空") - private Long id; - - @Schema(description = "页面属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @NotBlank(message = "页面属性不能为空") - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageRespVO.java deleted file mode 100644 index 9e2d9af86..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 装修页面 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPageRespVO extends DiyPageBaseVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12082") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageUpdateReqVO.java deleted file mode 100644 index 9909b57f9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/page/DiyPageUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 装修页面更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyPageUpdateReqVO extends DiyPageBaseVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12082") - @NotNull(message = "装修页面编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java deleted file mode 100644 index 2f7769cbe..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateBaseVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.List; - -/** - * 装修模板 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class DiyTemplateBaseVO { - - @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题") - @NotEmpty(message = "模板名称不能为空") - private String name; - - @Schema(description = "备注", example = "默认主题") - private String remark; - - @Schema(description = "预览图", example = "[https://www.iocoder.cn/1.jpg]") - private List previewPicUrls; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqVO.java deleted file mode 100644 index 659f9c590..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 装修模板创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplateCreateReqVO extends DiyTemplateBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePageReqVO.java deleted file mode 100644 index 1099226f9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePageReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 装修模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplatePageReqVO extends PageParam { - - @Schema(description = "模板名称", example = "默认主题") - private String name; - - @Schema(description = "是否使用", example = "true") - private Boolean used; - - @Schema(description = "使用时间", example = "使用时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] usedTime; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyRespVO.java deleted file mode 100644 index 21dd46f3f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 装修模板属性 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplatePropertyRespVO extends DiyTemplateBaseVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "模板属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - private String property; - - @Schema(description = "模板页面", requiredMode = Schema.RequiredMode.REQUIRED, example = "[]") - private List pages; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyUpdateRequestVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyUpdateRequestVO.java deleted file mode 100644 index 84b80f227..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplatePropertyUpdateRequestVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 装修模板属性更新 Request VO") -@Data -@ToString(callSuper = true) -public class DiyTemplatePropertyUpdateRequestVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - @NotNull(message = "装修模板编号不能为空") - private Long id; - - @Schema(description = "模板属性,JSON 格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @NotBlank(message = "模板属性不能为空") - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateRespVO.java deleted file mode 100644 index e19089e6a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 装修模板 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplateRespVO extends DiyTemplateBaseVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "是否使用", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean used; - - @Schema(description = "使用时间", example = "使用时间") - private LocalDateTime usedTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateUpdateReqVO.java deleted file mode 100644 index 887f2f9dd..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/diy/vo/template/DiyTemplateUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 装修模板更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DiyTemplateUpdateReqVO extends DiyTemplateBaseVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - @NotNull(message = "装修模板编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/RewardActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/RewardActivityController.java deleted file mode 100755 index 7827fd114..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/RewardActivityController.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.reward.RewardActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 满减送活动") -@RestController -@RequestMapping("/promotion/reward-activity") -@Validated -public class RewardActivityController { - - @Resource - private RewardActivityService rewardActivityService; - - @PostMapping("/create") - @Operation(summary = "创建满减送活动") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:create')") - public CommonResult createRewardActivity(@Valid @RequestBody RewardActivityCreateReqVO createReqVO) { - return success(rewardActivityService.createRewardActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新满减送活动") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:update')") - public CommonResult updateRewardActivity(@Valid @RequestBody RewardActivityUpdateReqVO updateReqVO) { - rewardActivityService.updateRewardActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭满减送活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:close')") - public CommonResult closeRewardActivity(@RequestParam("id") Long id) { - rewardActivityService.closeRewardActivity(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除满减送活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:delete')") - public CommonResult deleteRewardActivity(@RequestParam("id") Long id) { - rewardActivityService.deleteRewardActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得满减送活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:query')") - public CommonResult getRewardActivity(@RequestParam("id") Long id) { - RewardActivityDO rewardActivity = rewardActivityService.getRewardActivity(id); - return success(RewardActivityConvert.INSTANCE.convert(rewardActivity)); - } - - @GetMapping("/page") - @Operation(summary = "获得满减送活动分页") - @PreAuthorize("@ss.hasPermission('promotion:reward-activity:query')") - public CommonResult> getRewardActivityPage(@Valid RewardActivityPageReqVO pageVO) { - PageResult pageResult = rewardActivityService.getRewardActivityPage(pageVO); - return success(RewardActivityConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityBaseVO.java deleted file mode 100755 index 01d1c80b3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityBaseVO.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.Valid; -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Future; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** -* 满减送活动 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class RewardActivityBaseVO { - - @Schema(description = "活动标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "满啦满啦") - @NotNull(message = "活动标题不能为空") - private String name; - - @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Future(message = "结束时间必须大于当前时间") - private LocalDateTime endTime; - - @Schema(description = "备注", example = "biubiubiu") - private String remark; - - @Schema(description = "条件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "条件类型不能为空") - @InEnum(value = PromotionConditionTypeEnum.class, message = "条件类型必须是 {value}") - private Integer conditionType; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品范围不能为空") - @InEnum(value = PromotionProductScopeEnum.class, message = "商品范围必须是 {value}") - private Integer productScope; - - @Schema(description = "商品 SPU 编号的数组", example = "1,2,3") - private List productSpuIds; - - /** - * 优惠规则的数组 - */ - @Valid // 校验下子对象 - private List rules; - - @Schema(description = "优惠规则") - @Data - public static class Rule { - - @Schema(description = "优惠门槛", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 1. 满 N 元,单位:分; 2. 满 N 件 - @Min(value = 1L, message = "优惠门槛必须大于等于 1") - private Integer limit; - - @Schema(description = "优惠价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @Min(value = 1L, message = "优惠价格必须大于等于 1") - private Integer discountPrice; - - @Schema(description = "是否包邮", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean freeDelivery; - - @Schema(description = "赠送的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @Min(value = 1L, message = "赠送的积分必须大于等于 1") - private Integer point; - - @Schema(description = "赠送的优惠劵编号的数组", example = "1,2,3") - private List couponIds; - - @Schema(description = "赠送的优惠券数量的数组", example = "1,2,3") - private List couponCounts; - - @AssertTrue(message = "优惠劵和数量必须一一对应") - @JsonIgnore - public boolean isCouponCountsValid() { - return CollUtil.size(couponCounts) == CollUtil.size(couponCounts); - } - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityCreateReqVO.java deleted file mode 100755 index 0710e46a4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 满减送活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityCreateReqVO extends RewardActivityBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityPageReqVO.java deleted file mode 100755 index 7052c9c66..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 满减送活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityPageReqVO extends PageParam { - - @Schema(description = "活动标题", example = "满啦满啦") - private String name; - - @Schema(description = "活动状态", example = "1") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityRespVO.java deleted file mode 100755 index 67bf12153..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 满减送活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityRespVO extends RewardActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer id; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityUpdateReqVO.java deleted file mode 100755 index 3185ec81d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/reward/vo/RewardActivityUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 满减送活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class RewardActivityUpdateReqVO extends RewardActivityBaseVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "活动编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java deleted file mode 100644 index 623697fba..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.*; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 秒杀活动") -@RestController -@RequestMapping("/promotion/seckill-activity") -@Validated -public class SeckillActivityController { - - @Resource - private SeckillActivityService seckillActivityService; - @Resource - private ProductSpuApi productSpuApi; - - @PostMapping("/create") - @Operation(summary = "创建秒杀活动") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:create')") - public CommonResult createSeckillActivity(@Valid @RequestBody SeckillActivityCreateReqVO createReqVO) { - return success(seckillActivityService.createSeckillActivity(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新秒杀活动") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:update')") - public CommonResult updateSeckillActivity(@Valid @RequestBody SeckillActivityUpdateReqVO updateReqVO) { - seckillActivityService.updateSeckillActivity(updateReqVO); - return success(true); - } - - @PutMapping("/close") - @Operation(summary = "关闭秒杀活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:close')") - public CommonResult closeSeckillActivity(@RequestParam("id") Long id) { - seckillActivityService.closeSeckillActivity(id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除秒杀活动") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:delete')") - public CommonResult deleteSeckillActivity(@RequestParam("id") Long id) { - seckillActivityService.deleteSeckillActivity(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得秒杀活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:query')") - public CommonResult getSeckillActivity(@RequestParam("id") Long id) { - SeckillActivityDO activity = seckillActivityService.getSeckillActivity(id); - List products = seckillActivityService.getSeckillProductListByActivityId(id); - return success(SeckillActivityConvert.INSTANCE.convert(activity, products)); - } - - @GetMapping("/page") - @Operation(summary = "获得秒杀活动分页") - @PreAuthorize("@ss.hasPermission('promotion:seckill-activity:query')") - public CommonResult> getSeckillActivityPage(@Valid SeckillActivityPageReqVO pageVO) { - // 查询活动列表 - PageResult pageResult = seckillActivityService.getSeckillActivityPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - List products = seckillActivityService.getSeckillProductListByActivityId( - convertSet(pageResult.getList(), SeckillActivityDO::getId)); - List spuList = productSpuApi.getSpuList( - convertSet(pageResult.getList(), SeckillActivityDO::getSpuId)).getCheckedData(); - return success(SeckillActivityConvert.INSTANCE.convertPage(pageResult, products, spuList)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillConfigController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillConfigController.java deleted file mode 100644 index 56d6db2e8..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillConfigController.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.*; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 秒杀时段") -@RestController -@RequestMapping("/promotion/seckill-config") -@Validated -public class SeckillConfigController { - - @Resource - private SeckillConfigService seckillConfigService; - - @PostMapping("/create") - @Operation(summary = "创建秒杀时段") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:create')") - public CommonResult createSeckillConfig(@Valid @RequestBody SeckillConfigCreateReqVO createReqVO) { - return success(seckillConfigService.createSeckillConfig(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新秒杀时段") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:update')") - public CommonResult updateSeckillConfig(@Valid @RequestBody SeckillConfigUpdateReqVO updateReqVO) { - seckillConfigService.updateSeckillConfig(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "修改时段配置状态") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:update')") - public CommonResult updateSeckillConfigStatus(@Valid @RequestBody SeckillConfigUpdateStatusReqVo reqVO) { - seckillConfigService.updateSeckillConfigStatus(reqVO.getId(), reqVO.getStatus()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除秒杀时段") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:delete')") - public CommonResult deleteSeckillConfig(@RequestParam("id") Long id) { - seckillConfigService.deleteSeckillConfig(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得秒杀时段") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:query')") - public CommonResult getSeckillConfig(@RequestParam("id") Long id) { - SeckillConfigDO seckillConfig = seckillConfigService.getSeckillConfig(id); - return success(SeckillConfigConvert.INSTANCE.convert(seckillConfig)); - } - - @GetMapping("/list") - @Operation(summary = "获得所有秒杀时段列表") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:query')") - public CommonResult> getSeckillConfigList() { - List list = seckillConfigService.getSeckillConfigList(); - return success(SeckillConfigConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获得所有开启状态的秒杀时段精简列表", description = "主要用于前端的下拉选项") - public CommonResult> getListAllSimple() { - List list = seckillConfigService.getSeckillConfigListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - return success(SeckillConfigConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得秒杀时间段分页") - @PreAuthorize("@ss.hasPermission('promotion:seckill-config:query')") - public CommonResult> getSeckillActivityPage(@Valid SeckillConfigPageReqVO pageVO) { - PageResult pageResult = seckillConfigService.getSeckillConfigPage(pageVO); - return success(SeckillConfigConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java deleted file mode 100644 index 8aada5a1f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 秒杀活动基地签证官 - * 秒杀活动 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class SeckillActivityBaseVO { - - @Schema(description = "秒杀活动商品 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "[121,1212]") - @NotNull(message = "秒杀活动商品不能为空") - private Long spuId; - - @Schema(description = "秒杀活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促") - @NotNull(message = "秒杀活动名称不能为空") - private String name; - - @Schema(description = "备注", example = "清仓大甩卖割韭菜") - private String remark; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "活动开始时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "活动结束时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endTime; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "秒杀时段 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,2,3]") - @NotNull(message = "秒杀时段不能为空") - private List configIds; - - @Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "12877") - private Integer totalLimitCount; - - @Schema(description = "单次限够数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "31683") - private Integer singleLimitCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java deleted file mode 100644 index 9b6e7291a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 秒杀活动创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityCreateReqVO extends SeckillActivityBaseVO { - - @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java deleted file mode 100644 index c3cc2ebf0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 秒杀活动的详细 Response VO") -@Data -@ToString(callSuper = true) -public class SeckillActivityDetailRespVO extends SeckillActivityBaseVO{ - - @Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java deleted file mode 100644 index ac634a7b2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -@Schema(description = "管理后台 - 秒杀活动分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityPageReqVO extends PageParam { - - @Schema(description = "秒杀活动名称", example = "晚九点限时秒杀") - private String name; - - @Schema(description = "活动状态", example = "进行中") - private Integer status; - - @Schema(description = "秒杀时段id", example = "1") - private Long configId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java deleted file mode 100644 index 742c73ba6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 秒杀活动 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityRespVO extends SeckillActivityBaseVO { - - @Schema(description = "秒杀活动 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "订单实付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "22354") - private Integer totalPrice; - - @Schema(description = "秒杀库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer stock; - - @Schema(description = "秒杀总库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer totalStock; - - @Schema(description = "新增订单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer orderCount; - - @Schema(description = "付款人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer userCount; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 商品字段 ========== - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 - example = "618大促") - private String spuName; - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java deleted file mode 100644 index bf2ca35bb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 秒杀活动更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityUpdateReqVO extends SeckillActivityBaseVO { - - @Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigBaseVO.java deleted file mode 100644 index 78a1c51df..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigBaseVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotNull; -import java.time.LocalTime; -import java.util.List; - -/** - * 秒杀时段 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class SeckillConfigBaseVO { - - @Schema(description = "秒杀时段名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "早上场") - @NotNull(message = "秒杀时段名称不能为空") - private String name; - - @Schema(description = "开始时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:00:00") - @NotNull(message = "开始时间点不能为空") - private String startTime; - - @Schema(description = "结束时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "16:00:00") - @NotNull(message = "结束时间点不能为空") - private String endTime; - - @Schema(description = "秒杀轮播图", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]") - @NotNull(message = "秒杀轮播图不能为空") - private List sliderPicUrls; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "状态不能为空") - private Integer status; - - @AssertTrue(message = "秒杀时段开始时间和结束时间不能相等") - @JsonIgnore - public boolean isValidStartTimeValid() { - return !LocalTime.parse(startTime).equals(LocalTime.parse(endTime)); - } - - @AssertTrue(message = "秒杀时段开始时间不能在结束时间之后") - @JsonIgnore - public boolean isValidEndTimeValid() { - return !LocalTime.parse(startTime).isAfter(LocalTime.parse(endTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigCreateReqVO.java deleted file mode 100644 index 979ee699d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 秒杀时段创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillConfigCreateReqVO extends SeckillConfigBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigPageReqVO.java deleted file mode 100644 index 92211385a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 秒杀时段分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillConfigPageReqVO extends PageParam { - - @Schema(description = "秒杀时段名称", example = "上午场") - private String name; - - @Schema(description = "状态", example = "0") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigRespVO.java deleted file mode 100644 index 5411536c9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 秒杀时段 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillConfigRespVO extends SeckillConfigBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "秒杀活动数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer seckillActivityCount; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigSimpleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigSimpleRespVO.java deleted file mode 100644 index 069f39e31..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigSimpleRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 秒杀时段配置精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class SeckillConfigSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "秒杀时段名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "早上场") - @NotNull(message = "秒杀时段名称不能为空") - private String name; - - @Schema(description = "开始时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:00:00") - private String startTime; - - @Schema(description = "结束时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "16:00:00") - private String endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateReqVO.java deleted file mode 100644 index 5b11dc4fc..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 秒杀时段更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillConfigUpdateReqVO extends SeckillConfigBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateStatusReqVo.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateStatusReqVo.java deleted file mode 100644 index 0547cb1de..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateStatusReqVo.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 修改时段配置状态 Request VO") -@Data -public class SeckillConfigUpdateStatusReqVo { - - @Schema(description = "时段配置编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "时段配置编号不能为空") - private Long id; - - @Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductBaseVO.java deleted file mode 100644 index 6584b79cb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductBaseVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 秒杀参与商品 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author HUIHUI - */ -@Data -public class SeckillProductBaseVO { - - @Schema(description = "商品sku_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30563") - @NotNull(message = "商品sku_id不能为空") - private Long skuId; - - @Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "6689") - @NotNull(message = "秒杀金额,单位:分不能为空") - private Integer seckillPrice; - - @Schema(description = "秒杀库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "秒杀库存不能为空") - private Integer stock; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductRespVO.java deleted file mode 100644 index 96b7eec4c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 秒杀参与商品 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillProductRespVO extends SeckillProductBaseVO { - - @Schema(description = "秒杀参与商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "256") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.http b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.http deleted file mode 100644 index 0dda88c7d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.http +++ /dev/null @@ -1,5 +0,0 @@ -### /promotion/activity/list-by-spu-ids 获得多个商品,近期参与的每个活动 -GET {{appApi}}/promotion/activity/list-by-spu-ids?spuIds=222&spuIds=633 -Authorization: Bearer {{appToken}} -Content-Type: application/json -tenant-id: {{appTenentId}} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java deleted file mode 100644 index 38dd72ba3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java +++ /dev/null @@ -1,172 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.activity; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.activity.vo.AppActivityRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; -import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; -import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; - -@Tag(name = "用户 APP - 营销活动") // 用于提供跨多个活动的 HTTP 接口 -@RestController -@RequestMapping("/promotion/activity") -@Validated -public class AppActivityController { - - @Resource - private CombinationActivityService combinationActivityService; - @Resource - private SeckillActivityService seckillActivityService; - @Resource - private BargainActivityService bargainActivityService; - @Resource - private DiscountActivityService discountActivityService; - @Resource - private RewardActivityService rewardActivityService; - - @GetMapping("/list-by-spu-id") - @Operation(summary = "获得单个商品,近期参与的每个活动") - @Parameter(name = "spuId", description = "商品编号", required = true) - public CommonResult> getActivityListBySpuId(@RequestParam("spuId") Long spuId) { - // 每种活动,只返回一个 - return success(getAppActivityList(Collections.singletonList(spuId))); - } - - @GetMapping("/list-by-spu-ids") - @Operation(summary = "获得多个商品,近期参与的每个活动") - @Parameter(name = "spuIds", description = "商品编号数组", required = true) - public CommonResult>> getActivityListBySpuIds(@RequestParam("spuIds") List spuIds) { - if (CollUtil.isEmpty(spuIds)) { - return success(MapUtil.empty()); - } - // 每种活动,只返回一个;key 为 SPU 编号 - return success(convertMultiMap(getAppActivityList(spuIds), AppActivityRespVO::getSpuId)); - } - - private List getAppActivityList(Collection spuIds) { - if (CollUtil.isEmpty(spuIds)) { - return new ArrayList<>(); - } - // 获取开启的且开始的且没有结束的活动 - List activityList = new ArrayList<>(); - LocalDateTime now = LocalDateTime.now(); - // 1. 拼团活动 - getCombinationActivities(spuIds, now, activityList); - // 2. 秒杀活动 - getSeckillActivities(spuIds, now, activityList); - // 3. 砍价活动 - getBargainActivities(spuIds, now, activityList); - // 4. 限时折扣活动 - getDiscountActivities(spuIds, now, activityList); - // 5. 满减送活动 - getRewardActivities(spuIds, now, activityList); - return activityList; - } - - private void getCombinationActivities(Collection spuIds, LocalDateTime now, List activityList) { - List combinationActivities = combinationActivityService.getCombinationActivityBySpuIdsAndStatusAndDateTimeLt( - spuIds, CommonStatusEnum.ENABLE.getStatus(), now); - if (CollUtil.isEmpty(combinationActivities)) { - return; - } - - combinationActivities.forEach(item -> { - activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.COMBINATION_ACTIVITY.getType(), - item.getName(), item.getSpuId(), item.getStartTime(), item.getEndTime())); - }); - } - - private void getSeckillActivities(Collection spuIds, LocalDateTime now, List activityList) { - List seckillActivities = seckillActivityService.getSeckillActivityBySpuIdsAndStatusAndDateTimeLt( - spuIds, CommonStatusEnum.ENABLE.getStatus(), now); - if (CollUtil.isEmpty(seckillActivities)) { - return; - } - - seckillActivities.forEach(item -> { - activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.SECKILL_ACTIVITY.getType(), - item.getName(), item.getSpuId(), item.getStartTime(), item.getEndTime())); - }); - } - - private void getBargainActivities(Collection spuIds, LocalDateTime now, List activityList) { - List bargainActivities = bargainActivityService.getBargainActivityBySpuIdsAndStatusAndDateTimeLt( - spuIds, CommonStatusEnum.ENABLE.getStatus(), now); - if (CollUtil.isNotEmpty(bargainActivities)) { - return; - } - - bargainActivities.forEach(item -> { - activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.BARGAIN_ACTIVITY.getType(), - item.getName(), item.getSpuId(), item.getStartTime(), item.getEndTime())); - }); - } - - private void getDiscountActivities(Collection spuIds, LocalDateTime now, List activityList) { - List discountActivities = discountActivityService.getDiscountActivityBySpuIdsAndStatusAndDateTimeLt( - spuIds, CommonStatusEnum.ENABLE.getStatus(), now); - if (CollUtil.isEmpty(discountActivities)) { - return; - } - - List products = discountActivityService.getDiscountProductsByActivityId( - convertSet(discountActivities, DiscountActivityDO::getId)); - Map productMap = convertMap(products, DiscountProductDO::getActivityId, DiscountProductDO::getSpuId); - discountActivities.forEach(item -> activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType(), - item.getName(), productMap.get(item.getId()), item.getStartTime(), item.getEndTime()))); - } - - private void getRewardActivities(Collection spuIds, LocalDateTime now, List activityList) { - // TODO @puhui999:有 3 范围,不只 spuId,还有 categoryId,全部 - List rewardActivityList = rewardActivityService.getRewardActivityBySpuIdsAndStatusAndDateTimeLt( - spuIds, PromotionActivityStatusEnum.RUN.getStatus(), now); - if (CollUtil.isEmpty(rewardActivityList)) { - return; - } - - Map> spuIdAndActivityMap = spuIds.stream() - .collect(Collectors.toMap( - spuId -> spuId, - spuId -> rewardActivityList.stream() - .filter(activity -> activity.getProductSpuIds().contains(spuId)) - .max(Comparator.comparing(RewardActivityDO::getCreateTime)))); - for (Long supId : spuIdAndActivityMap.keySet()) { - if (!spuIdAndActivityMap.get(supId).isPresent()) { - continue; - } - - RewardActivityDO rewardActivityDO = spuIdAndActivityMap.get(supId).get(); - activityList.add(new AppActivityRespVO(rewardActivityDO.getId(), PromotionTypeEnum.REWARD_ACTIVITY.getType(), - rewardActivityDO.getName(), supId, rewardActivityDO.getStartTime(), rewardActivityDO.getEndTime())); - } - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/vo/AppActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/vo/AppActivityRespVO.java deleted file mode 100644 index 6a67a669d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/vo/AppActivityRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.activity.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 营销活动 Response VO") -@AllArgsConstructor -@NoArgsConstructor -@Data -public class AppActivityRespVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "活动类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; // 对应 PromotionTypeEnum 枚举 - - @Schema(description = "活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大促") - private String name; - - @Schema(description = "spu 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "618") - private Long spuId; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java deleted file mode 100644 index 482b497d9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import cn.iocoder.yudao.module.promotion.service.article.ArticleCategoryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 文章分类") -@RestController -@RequestMapping("/promotion/article-category") -@Validated -public class AppArticleCategoryController { - - @Resource - private ArticleCategoryService articleCategoryService; - - @RequestMapping("/list") - @Operation(summary = "获得文章分类列表") - public CommonResult> getArticleCategoryList() { - List categoryList = articleCategoryService.getArticleCategoryListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - categoryList.sort(Comparator.comparing(ArticleCategoryDO::getSort)); // 按 sort 降序排列 - return success(ArticleCategoryConvert.INSTANCE.convertList04(categoryList)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java deleted file mode 100644 index a318bfd8a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import cn.iocoder.yudao.module.promotion.service.article.ArticleService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 文章") -@RestController -@RequestMapping("/promotion/article") -@Validated -public class AppArticleController { - - @Resource - private ArticleService articleService; - - @RequestMapping("/list") - @Operation(summary = "获得文章详情列表") - @Parameters({ - @Parameter(name = "recommendHot", description = "是否热门", example = "false"), // 场景一:查看指定的文章 - @Parameter(name = "recommendBanner", description = "是否轮播图", example = "false") // 场景二:查看指定的文章 - }) - public CommonResult> getArticleList( - @RequestParam(value = "recommendHot", required = false) Boolean recommendHot, - @RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) { - return success(ArticleConvert.INSTANCE.convertList03( - articleService.getArticleCategoryListByRecommend(recommendHot, recommendBanner))); - } - - @RequestMapping("/page") - @Operation(summary = "获得文章详情分页") - public CommonResult> getArticlePage(AppArticlePageReqVO pageReqVO) { - return success(ArticleConvert.INSTANCE.convertPage02(articleService.getArticlePage(pageReqVO))); - } - - @RequestMapping("/get") - @Operation(summary = "获得文章详情") - @Parameters({ - @Parameter(name = "id", description = "文章编号", example = "1024"), - @Parameter(name = "title", description = "文章标题", example = "1024"), - }) - public CommonResult getArticle(@RequestParam(value = "id", required = false) Long id, - @RequestParam(value = "title", required = false) String title) { - ArticleDO article = id != null ? articleService.getArticle(id) - : articleService.getLastArticleByTitle(title); - return success(BeanUtils.toBean(article, AppArticleRespVO.class)); - } - - @PutMapping("/add-browse-count") - @Operation(summary = "增加文章浏览量") - @Parameter(name = "id", description = "文章编号", example = "1024") - public CommonResult addBrowseCount(@RequestParam("id") Long id) { - articleService.addArticleBrowseCount(id); - return success(true); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticlePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticlePageReqVO.java deleted file mode 100644 index f548ae9bd..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticlePageReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article.vo.article; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "应用 App - 文章的分页 Request VO") -@Data -public class AppArticlePageReqVO extends PageParam { - - @Schema(description = "分类编号", example = "2048") - private Long categoryId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java deleted file mode 100644 index 2c77fdc34..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article.vo.article; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "应用 App - 文章 Response VO") -@Data -public class AppArticleRespVO { - - @Schema(description = "文章编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "文章标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码 - 促销模块") - private String title; - - @Schema(description = "文章作者", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String author; - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long categoryId; - - @Schema(description = "图文封面", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "文章简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是简介") - private String introduction; - - @Schema(description = "文章内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是详细") - private String content; - - @Schema(description = "发布时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer browseCount; - - @Schema(description = "关联的商品 SPU 编号", example = "1024") - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java deleted file mode 100644 index e0f34e95d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.article.vo.category; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "应用 App - 文章分类 Response VO") -@Data -public class AppArticleCategoryRespVO { - - @Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "技术") - private String name; - - @Schema(description = "分类图标", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java deleted file mode 100644 index 4ccaa2c12..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.banner; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.banner.vo.AppBannerRespVO; -import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import cn.iocoder.yudao.module.promotion.service.banner.BannerService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@RestController -@RequestMapping("/promotion/banner") -@Tag(name = "用户 APP - 首页 Banner") -@Validated -public class AppBannerController { - - @Resource - private BannerService bannerService; - - @GetMapping("/list") - @Operation(summary = "获得 banner 列表") - @Parameter(name = "position", description = "Banner position", example = "1") - public CommonResult> getBannerList(@RequestParam("position") Integer position) { - List bannerList = bannerService.getBannerListByPosition(position); - return success(BannerConvert.INSTANCE.convertList01(bannerList)); - } - - @PutMapping("/add-browse-count") - @Operation(summary = "增加 Banner 点击量") - @Parameter(name = "id", description = "Banner 编号", example = "1024") - public CommonResult addBrowseCount(@RequestParam("id") Long id) { - bannerService.addBannerBrowseCount(id); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/vo/AppBannerRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/vo/AppBannerRespVO.java deleted file mode 100644 index cc36d87d4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/vo/AppBannerRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.banner.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - Banner Response VO") -@Data -public class AppBannerRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "标题不能为空") - private String title; - - @Schema(description = "跳转链接", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "跳转链接不能为空") - private String url; - - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "图片地址不能为空") - private String picUrl; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java deleted file mode 100644 index 47a7fdcc4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.Duration; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildCache; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "用户 App - 砍价活动") -@RestController -@RequestMapping("/promotion/bargain-activity") -@Validated -public class AppBargainActivityController { - - /** - * {@link AppBargainActivityRespVO} 缓存,通过它异步刷新 {@link #getBargainActivityList0(Integer)} 所要的首页数据 - */ - private final LoadingCache> bargainActivityListCache = buildCache(Duration.ofSeconds(10L), - new CacheLoader>() { - - @Override - public List load(Integer count) { - return getBargainActivityList0(count); - } - - }); - - @Resource - private BargainActivityService bargainActivityService; - @Resource - private BargainRecordService bargainRecordService; - - @Resource - private ProductSpuApi spuApi; - - @GetMapping("/list") - @Operation(summary = "获得砍价活动列表", description = "用于小程序首页") - @Parameter(name = "count", description = "需要展示的数量", example = "6") - public CommonResult> getBargainActivityList( - @RequestParam(name = "count", defaultValue = "6") Integer count) { - return success(bargainActivityListCache.getUnchecked(count)); - } - - private ListgetBargainActivityList0(Integer count) { - List list = bargainActivityService.getBargainActivityListByCount(count); - if (CollUtil.isEmpty(list)) { - return Collections.emptyList(); - } - // 拼接数据 - List spuList = spuApi.getSpuList(convertList(list, BargainActivityDO::getSpuId)).getCheckedData(); - return BargainActivityConvert.INSTANCE.convertAppList(list, spuList); - } - - @GetMapping("/page") - @Operation(summary = "获得砍价活动分页") - public CommonResult> getBargainActivityPage(PageParam pageReqVO) { - PageResult result = bargainActivityService.getBargainActivityPage(pageReqVO); - if (CollUtil.isEmpty(result.getList())) { - return success(PageResult.empty(result.getTotal())); - } - // 拼接数据 - List spuList = spuApi.getSpuList(convertList(result.getList(), BargainActivityDO::getSpuId)).getCheckedData(); - return success(BargainActivityConvert.INSTANCE.convertAppPage(result, spuList)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得砍价活动详情") - @Parameter(name = "id", description = "活动编号", example = "1") - public CommonResult getBargainActivityDetail(@RequestParam("id") Long id) { - BargainActivityDO activity = bargainActivityService.getBargainActivity(id); - if (activity == null) { - return success(null); - } - // 拼接数据 - Integer successUserCount = bargainRecordService.getBargainRecordUserCount(id, BargainRecordStatusEnum.SUCCESS.getStatus()); - ProductSpuRespDTO spu = spuApi.getSpu(activity.getSpuId()).getCheckedData(); - return success(BargainActivityConvert.INSTANCE.convert(activity, successUserCount, spu)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.http b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.http deleted file mode 100644 index 2e401e9d6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.http +++ /dev/null @@ -1,9 +0,0 @@ -### /promotion/bargain-record/create 创建砍价助力 -POST {{appApi}}/promotion/bargain-help/create -Authorization: Bearer test248 -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "recordId": 26 -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.java deleted file mode 100644 index 48d19ff7f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainHelpController.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpRespVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainHelpConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 砍价助力") -@RestController -@RequestMapping("/promotion/bargain-help") -@Validated -public class AppBargainHelpController { - - @Resource - private BargainHelpService bargainHelpService; - - @Resource - private MemberUserApi memberUserApi; - - @PostMapping("/create") - @Operation(summary = "创建砍价助力", description = "给拼团记录砍一刀") // 返回结果为砍价金额,单位:分 - public CommonResult createBargainHelp(@RequestBody AppBargainHelpCreateReqVO reqVO) { - BargainHelpDO help = bargainHelpService.createBargainHelp(getLoginUserId(), reqVO); - return success(help.getReducePrice()); - } - - @GetMapping("/list") - @Operation(summary = "获得砍价助力列表") - @Parameter(name = "recordId", description = "砍价记录编号", required = true, example = "111") - public CommonResult> getBargainHelpList(@RequestParam("recordId") Long recordId) { - List helps = bargainHelpService.getBargainHelpListByRecordId(recordId); - if (CollUtil.isEmpty(helps)) { - return success(Collections.emptyList()); - } - helps.sort((o1, o2) -> o2.getCreateTime().compareTo(o1.getCreateTime())); // 倒序展示 - - // 拼接数据 - Map userMap = memberUserApi.getUserMap( - convertSet(helps, BargainHelpDO::getUserId)); - return success(BargainHelpConvert.INSTANCE.convertList(helps, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.http b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.http deleted file mode 100644 index 46cbe3c8e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.http +++ /dev/null @@ -1,9 +0,0 @@ -### /promotion/bargain-record/create 创建砍价记录 -POST {{appApi}}/promotion/bargain-record/create -Authorization: Bearer {{appToken}} -Content-Type: application/json -tenant-id: {{appTenentId}} - -{ - "activityId": 1 -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java deleted file mode 100644 index 5cf3a38df..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java +++ /dev/null @@ -1,162 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordSummaryRespVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainRecordConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; -import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; -import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 砍价记录") -@RestController -@RequestMapping("/promotion/bargain-record") -@Validated -public class AppBargainRecordController { - - @Resource - private BargainHelpService bargainHelpService; - @Resource - private BargainRecordService bargainRecordService; - @Resource - private BargainActivityService bargainActivityService; - - @Resource - private TradeOrderApi tradeOrderApi; - @Resource - private MemberUserApi memberUserApi; - @Resource - private ProductSpuApi productSpuApi; - - @GetMapping("/get-summary") - @Operation(summary = "获得砍价记录的概要信息", description = "用于小程序首页") - public CommonResult getBargainRecordSummary() { - // 砍价成功的用户数量 - Integer successUserCount = bargainRecordService.getBargainRecordUserCount( - BargainRecordStatusEnum.SUCCESS.getStatus()); - if (successUserCount == 0) { - return success(new AppBargainRecordSummaryRespVO().setSuccessUserCount(0) - .setSuccessList(Collections.emptyList())); - } - // 砍价成功的用户列表 - List successList = bargainRecordService.getBargainRecordList( - BargainRecordStatusEnum.SUCCESS.getStatus(), 7); - List activityList = bargainActivityService.getBargainActivityList( - convertSet(successList, BargainRecordDO::getActivityId)); - Map userMap = memberUserApi.getUserMap( - convertSet(successList, BargainRecordDO::getUserId)); - // 拼接返回 - return success(BargainRecordConvert.INSTANCE.convert(successUserCount, successList, activityList, userMap)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得砍价记录的明细") - @Parameters({ - @Parameter(name = "id", description = "砍价记录编号", example = "111"), // 场景一:查看指定的砍价记录 - @Parameter(name = "activityId", description = "砍价活动编号", example = "222") // 场景二:查看指定的砍价活动 - }) - public CommonResult getBargainRecordDetail( - @RequestParam(value = "id", required = false) Long id, - @RequestParam(value = "activityId", required = false) Long activityId) { - // 1. 查询砍价记录 + 砍价活动 - Assert.isTrue(id != null || activityId != null, "砍价记录编号和活动编号不能同时为空"); - BargainRecordDO record = id != null ? bargainRecordService.getBargainRecord(id) - : bargainRecordService.getLastBargainRecord(getLoginUserId(), activityId); - if (activityId == null || record != null) { - activityId = record.getActivityId(); - } - // 2. 查询助力记录 - Long userId = getLoginUserId(); - Integer helpAction = getHelpAction(userId, record, activityId); - // 3. 如果是自己的订单,则查询订单信息 - TradeOrderRespDTO order = record != null && record.getOrderId() != null && record.getUserId().equals(getLoginUserId()) - ? tradeOrderApi.getOrder(record.getOrderId()).getCheckedData() : null; - // TODO 继续查询别的字段 - - // 拼接返回 - return success(BargainRecordConvert.INSTANCE.convert02(record, helpAction, order)); - } - - private Integer getHelpAction(Long userId, BargainRecordDO record, Long activityId) { - // 0.1 如果没有活动,无法帮砍 - if (activityId == null) { - return null; - } - // 0.2 如果是自己的砍价记录,无法帮砍 - if (record != null && record.getUserId().equals(userId)) { - return null; - } - - // 1. 判断是否已经助力 - if (record != null - && bargainHelpService.getBargainHelp(record.getId(), userId) != null) { - return AppBargainRecordDetailRespVO.HELP_ACTION_SUCCESS; - } - // 2. 判断是否满助力 - BargainActivityDO activity = bargainActivityService.getBargainActivity(activityId); - if (activity != null - && bargainHelpService.getBargainHelpCountByActivity(activityId, userId) >= activity.getBargainCount()) { - return AppBargainRecordDetailRespVO.HELP_ACTION_FULL; - } - // 3. 允许助力 - return AppBargainRecordDetailRespVO.HELP_ACTION_NONE; - } - - @GetMapping("/page") - @Operation(summary = "获得砍价记录的分页") - public CommonResult> getBargainRecordPage(PageParam pageParam) { - PageResult pageResult = bargainRecordService.getBargainRecordPage(getLoginUserId(), pageParam); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - - // 拼接数据 - List activityList = bargainActivityService.getBargainActivityList( - convertSet(pageResult.getList(), BargainRecordDO::getActivityId)); - List spuList = productSpuApi.getSpuList( - convertSet(pageResult.getList(), BargainRecordDO::getSpuId)).getCheckedData(); - List orderList = tradeOrderApi.getOrderList( - convertSet(pageResult.getList(), BargainRecordDO::getOrderId)).getCheckedData(); - return success(BargainRecordConvert.INSTANCE.convertPage02(pageResult, activityList, spuList, orderList)); - } - - @PostMapping("/create") - @Operation(summary = "创建砍价记录", description = "参与砍价活动") - @PreAuthenticated - public CommonResult createBargainRecord(@RequestBody AppBargainRecordCreateReqVO reqVO) { - Long recordId = bargainRecordService.createBargainRecord(getLoginUserId(), reqVO); - return success(recordId); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityDetailRespVO.java deleted file mode 100644 index 78322f49e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityDetailRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 砍价活动的明细 Response VO") -@Data -public class AppBargainActivityDetailRespVO { - - @Schema(description = "砍价活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大砍价") - private String name; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long skuId; - - @Schema(description = "商品价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - - @Schema(description = "商品描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "我要吃西红柿") - private String description; - - @Schema(description = "砍价库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") - private Integer stock; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") // 从 SPU 的 picUrl 读取 - private String picUrl; - - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") // 从 SPU 的 marketPrice 读取 - private Integer marketPrice; - - @Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer bargainFirstPrice; - - @Schema(description = "砍价最低金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer bargainMinPrice; - - @Schema(description = "砍价成功数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer successUserCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java deleted file mode 100644 index f6e0193a5..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 砍价活动 Response VO") -@Data -public class AppBargainActivityRespVO { - - @Schema(description = "砍价活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大砍价") - private String name; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long skuId; - - @Schema(description = "砍价库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") - private Integer stock; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "4096") - private String picUrl; - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - - @Schema(description = "砍价最低金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer bargainMinPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpCreateReqVO.java deleted file mode 100644 index 369926677..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpCreateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 砍价助力的创建 Request VO") -@Data -public class AppBargainHelpCreateReqVO { - - @Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "砍价记录编号不能为空") - private Long recordId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpRespVO.java deleted file mode 100644 index c7bb20fea..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/help/AppBargainHelpRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 砍价助力 Response VO") -@Data -public class AppBargainHelpRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userId; - - @Schema(description = "助力用户的昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String nickname; - - @Schema(description = "助力用户的头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String avatar; - - @Schema(description = "助力用户的砍价金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer reducePrice; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordCreateReqVO.java deleted file mode 100644 index cc1e448dd..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordCreateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 砍价记录的创建 Request VO") -@Data -public class AppBargainRecordCreateReqVO { - - @Schema(description = "砍价活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "砍价活动编号不能为空") - private Long activityId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordDetailRespVO.java deleted file mode 100644 index 2f408b2c4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordDetailRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 砍价记录的明细 Response VO") -@Data -public class AppBargainRecordDetailRespVO { - - public static final int HELP_ACTION_NONE = 1; // 帮砍动作 - 未帮砍,可以帮砍 - public static final int HELP_ACTION_FULL = 2; // 帮砍动作 - 未帮砍,无法帮砍(可帮砍次数已满) - public static final int HELP_ACTION_SUCCESS = 3; // 帮砍动作 - 已帮砍 - - // ========== 砍价记录 ========== - - @Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") - private Long userId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long skuId; - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private Long activityId; - - @Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - private Integer bargainFirstPrice; - - @Schema(description = "当前砍价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "23") - private Integer bargainPrice; - - @Schema(description = "砍价记录状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - // ========== 订单相关 ========== 注意:只有是自己的砍价记录,才会返回,保证隐私性 - - @Schema(description = "订单编号", example = "1024") - private Long orderId; - - @Schema(description = "支付状态", example = "true") - private Boolean payStatus; - - @Schema(description = "支付订单编号", example = "1024") - private Long payOrderId; - - // ========== 助力记录 ========== - - private Integer helpAction; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordRespVO.java deleted file mode 100644 index 6aa6cd909..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordRespVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 砍价记录的 Response VO") -@Data -public class AppBargainRecordRespVO { - - @Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long skuId; - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") - private Long activityId; - - @Schema(description = "砍价记录状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "当前价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "102") - private Integer bargainPrice; - - // ========== 活动相关 ========== - - @Schema(description = "活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") - private String activityName; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - // ========== 订单相关 ========== - - @Schema(description = "订单编号", example = "1024") - private Long orderId; - - @Schema(description = "支付状态", example = "true") - private Boolean payStatus; - - @Schema(description = "支付订单编号", example = "1024") - private Long payOrderId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java deleted file mode 100644 index 8523e00a0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 砍价记录的简要概括 Response VO") -@Data -public class AppBargainRecordSummaryRespVO { - - @Schema(description = "砍价用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer successUserCount; - - @Schema(description = "成功砍价的记录", requiredMode = Schema.RequiredMode.REQUIRED) // 只返回最近的 7 个 - private List successList; - - @Schema(description = "成功砍价记录") - @Data - public static class Record { - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王**") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - @Schema(description = "活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "天蚕土豆") - private String activityName; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java deleted file mode 100644 index b311f05c0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java +++ /dev/null @@ -1,113 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.Duration; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildCache; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "用户 APP - 拼团活动") -@RestController -@RequestMapping("/promotion/combination-activity") -@Validated -public class AppCombinationActivityController { - - /** - * {@link AppCombinationActivityRespVO} 缓存,通过它异步刷新 {@link #getCombinationActivityList0(Integer)} 所要的首页数据 - */ - private final LoadingCache> combinationActivityListCache = buildCache(Duration.ofSeconds(10L), - new CacheLoader>() { - - @Override - public List load(Integer count) { - return getCombinationActivityList0(count); - } - - }); - - @Resource - private CombinationActivityService activityService; - - @Resource - private ProductSpuApi spuApi; - - @GetMapping("/list") - @Operation(summary = "获得拼团活动列表", description = "用于小程序首页") - @Parameter(name = "count", description = "需要展示的数量", example = "6") - public CommonResult> getCombinationActivityList( - @RequestParam(name = "count", defaultValue = "6") Integer count) { - return success(combinationActivityListCache.getUnchecked(count)); - } - - private List getCombinationActivityList0(Integer count) { - List activityList = activityService.getCombinationActivityListByCount(count); - if (CollUtil.isEmpty(activityList)) { - return Collections.emptyList(); - } - // 拼接返回 - List productList = activityService.getCombinationProductListByActivityIds( - convertList(activityList, CombinationActivityDO::getId)); - List spuList = spuApi.getSpuList(convertList(activityList, CombinationActivityDO::getSpuId)).getCheckedData(); - return CombinationActivityConvert.INSTANCE.convertAppList(activityList, productList, spuList); - } - - @GetMapping("/page") - @Operation(summary = "获得拼团活动分页") - public CommonResult> getCombinationActivityPage(PageParam pageParam) { - PageResult pageResult = activityService.getCombinationActivityPage(pageParam); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - // 拼接返回 - List productList = activityService.getCombinationProductListByActivityIds( - convertList(pageResult.getList(), CombinationActivityDO::getId)); - List spuList = spuApi.getSpuList(convertList(pageResult.getList(), CombinationActivityDO::getSpuId)).getCheckedData(); - return success(CombinationActivityConvert.INSTANCE.convertAppPage(pageResult, productList, spuList)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得拼团活动明细") - @Parameter(name = "id", description = "活动编号", required = true, example = "1024") - public CommonResult getCombinationActivityDetail(@RequestParam("id") Long id) { - // 1. 获取活动 - CombinationActivityDO activity = activityService.getCombinationActivity(id); - if (activity == null - || ObjectUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - return success(null); - } - - // 2. 获取活动商品 - List products = activityService.getCombinationProductsByActivityId(activity.getId()); - return success(CombinationActivityConvert.INSTANCE.convert3(activity, products)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java deleted file mode 100644 index 7901eb1db..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordSummaryRespVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.context.annotation.Lazy; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import javax.validation.constraints.Max; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 拼团活动") -@RestController -@RequestMapping("/promotion/combination-record") -@Validated -public class AppCombinationRecordController { - - @Resource - private CombinationRecordService combinationRecordService; - @Resource - @Lazy - private TradeOrderApi tradeOrderApi; - - @GetMapping("/get-summary") - @Operation(summary = "获得拼团记录的概要信息", description = "用于小程序首页") - public CommonResult getCombinationRecordSummary() { - AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO(); - // 1. 获得拼团参与用户数量 - Long userCount = combinationRecordService.getCombinationUserCount(); - if (userCount == 0) { - summary.setAvatars(Collections.emptyList()); - summary.setUserCount(userCount); - return success(summary); - } - summary.setUserCount(userCount); - - // 2. 获得拼团记录头像 - List records = combinationRecordService.getLatestCombinationRecordList( - AppCombinationRecordSummaryRespVO.AVATAR_COUNT); - summary.setAvatars(convertList(records, CombinationRecordDO::getAvatar)); - return success(summary); - } - - @GetMapping("/get-head-list") - @Operation(summary = "获得最近 n 条拼团记录(团长发起的)") - @Parameters({ - @Parameter(name = "activityId", description = "拼团活动编号"), - @Parameter(name = "status", description = "拼团状态"), // 对应 CombinationRecordStatusEnum 枚举 - @Parameter(name = "count", description = "数量") - }) - public CommonResult> getHeadCombinationRecordList( - @RequestParam(value = "activityId", required = false) Long activityId, - @RequestParam("status") Integer status, - @RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) { - List list = combinationRecordService.getHeadCombinationRecordList(activityId, status, count); - return success(BeanUtils.toBean(list, AppCombinationRecordRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得我的拼团记录分页") - @PreAuthenticated - public CommonResult> getCombinationRecordPage( - @Valid AppCombinationRecordPageReqVO pageReqVO) { - PageResult pageResult = combinationRecordService.getCombinationRecordPage( - getLoginUserId(), pageReqVO); - return success(BeanUtils.toBean(pageResult, AppCombinationRecordRespVO.class)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得拼团记录明细") - @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024") - public CommonResult getCombinationRecordDetail(@RequestParam("id") Long id) { - // 1. 查找这条拼团记录 - CombinationRecordDO record = combinationRecordService.getCombinationRecordById(id); - if (record == null) { - return success(null); - } - - // 2. 查找该拼团的参团记录 - CombinationRecordDO headRecord; - List memberRecords; - if (Objects.equals(record.getHeadId(), CombinationRecordDO.HEAD_ID_GROUP)) { // 情况一:团长 - headRecord = record; - memberRecords = combinationRecordService.getCombinationRecordListByHeadId(record.getId()); - } else { // 情况二:团员 - headRecord = combinationRecordService.getCombinationRecordById(record.getHeadId()); - memberRecords = combinationRecordService.getCombinationRecordListByHeadId(headRecord.getId()); - } - - // 3. 拼接数据 - return success(CombinationActivityConvert.INSTANCE.convert(getLoginUserId(), headRecord, memberRecords)); - } - - @GetMapping("/cancel") - @Operation(summary = "取消拼团") - @Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024") - public CommonResult cancelCombinationRecord(@RequestParam("id") Long id) { - Long userId = getLoginUserId(); - // 1、查找这条拼团记录 - CombinationRecordDO record = combinationRecordService.getCombinationRecordByIdAndUser(userId, id); - if (record == null) { - return success(Boolean.FALSE); - } - // 1.1、需要先校验拼团记录未完成; - if (!CombinationRecordStatusEnum.isInProgress(record.getStatus())) { - return success(Boolean.FALSE); - } - - // 2. 取消已支付的订单 - tradeOrderApi.cancelPaidOrder(userId, record.getOrderId()); - // 3. 取消拼团记录 - combinationRecordService.cancelCombinationRecord(userId, record.getId(), record.getHeadId()); - return success(Boolean.TRUE); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityDetailRespVO.java deleted file mode 100644 index e2996b89b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityDetailRespVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 拼团活动明细 Response VO") -@Data -public class AppCombinationActivityDetailRespVO { - - @Schema(description = "拼团活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "拼团活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大拼团") - private String name; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "拼团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "3") - private Integer userSize; - - @Schema(description = "成功的拼团数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer successCount; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "总共限购数量", example = "10") - private Integer totalLimitCount; - - @Schema(description = "单次限购数量", example = "5") - private Integer singleLimitCount; - - @Schema(description = "商品信息数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - @Schema(description = "商品信息") - @Data - public static class Product { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") - private Long skuId; - - @Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer combinationPrice; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java deleted file mode 100644 index 64462a377..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 拼团活动 Response VO") -@Data -public class AppCombinationActivityRespVO { - - @Schema(description = "拼团活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "拼团活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大拼团") - private String name; - - @Schema(description = "拼团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "3") - private Integer userSize; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") - // 从 SPU 的 picUrl 读取 - private String picUrl; - - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - // 从 SPU 的 marketPrice 读取 - private Integer marketPrice; - - @Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordDetailRespVO.java deleted file mode 100644 index 7c310a670..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordDetailRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 拼团记录详细 Response VO") -@Data -public class AppCombinationRecordDetailRespVO { - - @Schema(description = "团长的拼团记录", requiredMode = Schema.RequiredMode.REQUIRED) - private AppCombinationRecordRespVO headRecord; - - @Schema(description = "成员的拼团记录", requiredMode = Schema.RequiredMode.REQUIRED) - private List memberRecords; - - @Schema(description = "当前用户参团记录对应的订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordPageReqVO.java deleted file mode 100644 index 7f7169bb9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "用户 App - 拼团记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppCombinationRecordPageReqVO extends PageParam { - - @Schema(description = "拼团状态", example = "1") - @InEnum(value = CombinationRecordStatusEnum.class, message = "拼团状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordRespVO.java deleted file mode 100644 index 8e4496a66..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordRespVO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 拼团记录 Response VO") -@Data -public class AppCombinationRecordRespVO { - - @Schema(description = "拼团记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "拼团活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long activityId; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String avatar; - - @Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime expireTime; - - @Schema(description = "可参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer userSize; - - @Schema(description = "已参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Integer userCount; - - @Schema(description = "拼团状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long orderId; - - @Schema(description = "商品名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是大黄豆") - private String spuName; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer count; - - @Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer combinationPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordSummaryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordSummaryRespVO.java deleted file mode 100644 index d9ea03d6f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordSummaryRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 拼团记录的简要概括 Response VO") -@Data -public class AppCombinationRecordSummaryRespVO { - - /** - * 加载 {@link #avatars} 的数量 - */ - public static final Integer AVATAR_COUNT = 7; - - @Schema(description = "拼团用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userCount; - - @Schema(description = "拼团用户头像列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List avatars; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java deleted file mode 100755 index 5320c4ae6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.*; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 优惠劵") -@RestController -@RequestMapping("/promotion/coupon") -@Validated -public class AppCouponController { - - @Resource - private CouponService couponService; - @Resource - private CouponTemplateService couponTemplateService; - - @PostMapping("/take") - @Operation(summary = "领取优惠劵") - @Parameter(name = "templateId", description = "优惠券模板编号", required = true, example = "1024") - @PreAuthenticated - public CommonResult takeCoupon(@Valid @RequestBody AppCouponTakeReqVO reqVO) { - // 1. 领取优惠劵 - Long userId = getLoginUserId(); - couponService.takeCoupon(reqVO.getTemplateId(), CollUtil.newHashSet(userId), CouponTakeTypeEnum.USER); - - // 2. 检查是否可以继续领取 - CouponTemplateDO couponTemplate = couponTemplateService.getCouponTemplate(reqVO.getTemplateId()); - boolean canTakeAgain = true; - if (couponTemplate.getTakeLimitCount() != null && couponTemplate.getTakeLimitCount() > 0) { - Integer takeCount = couponService.getTakeCount(reqVO.getTemplateId(), userId); - canTakeAgain = takeCount < couponTemplate.getTakeLimitCount(); - } - return success(canTakeAgain); - } - - @GetMapping("/match-list") - @Operation(summary = "获得匹配指定商品的优惠劵列表", description = "用于下单页,展示优惠劵列表") - public CommonResult> getMatchCouponList(AppCouponMatchReqVO matchReqVO) { - // todo: 优化:优惠金额倒序 - List list = couponService.getMatchCouponList(getLoginUserId(), matchReqVO); - return success(BeanUtils.toBean(list, AppCouponMatchRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "我的优惠劵列表") - @PreAuthenticated - public CommonResult> getCouponPage(AppCouponPageReqVO pageReqVO) { - PageResult pageResult = couponService.getCouponPage( - CouponConvert.INSTANCE.convert(pageReqVO, Collections.singleton(getLoginUserId()))); - return success(BeanUtils.toBean(pageResult, AppCouponRespVO.class)); - } - - @GetMapping("/get") - @Operation(summary = "获得优惠劵") - @Parameter(name = "id", description = "优惠劵编号", required = true, example = "1024") - @PreAuthenticated - public CommonResult getCoupon(@RequestParam("id") Long id) { - CouponDO coupon = couponService.getCoupon(getLoginUserId(), id); - return success(BeanUtils.toBean(coupon, AppCouponRespVO.class)); - } - - @GetMapping(value = "/get-unused-count") - @Operation(summary = "获得未使用的优惠劵数量") - @PreAuthenticated - public CommonResult getUnusedCouponCount() { - return success(couponService.getUnusedCouponCount(getLoginUserId())); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java deleted file mode 100755 index 5aa9db97e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java +++ /dev/null @@ -1,144 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplateRespVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static java.util.Collections.singletonList; - -@Tag(name = "用户 App - 优惠劵模板") -@RestController -@RequestMapping("/promotion/coupon-template") -@Validated -public class AppCouponTemplateController { - - @Resource - private CouponTemplateService couponTemplateService; - @Resource - private CouponService couponService; - - @Resource - private ProductSpuApi productSpuApi; - - @GetMapping("/get") - @Operation(summary = "获得优惠劵模版") - @Parameter(name = "id", description = "优惠券模板编号", required = true, example = "1024") - public CommonResult getCouponTemplate(Long id) { - CouponTemplateDO template = couponTemplateService.getCouponTemplate(id); - if (template == null) { - return success(null); - } - // 处理是否可领取 - Map canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), singletonList(template)); - return success(BeanUtils.toBean(template, AppCouponTemplateRespVO.class) - .setCanTake(canCanTakeMap.get(template.getId()))); - } - - @GetMapping("/list") - @Operation(summary = "获得优惠劵模版列表") - @Parameters({ - @Parameter(name = "spuId", description = "商品 SPU 编号"), // 目前主要给商品详情使用 - @Parameter(name = "productScope", description = "使用类型"), - @Parameter(name = "count", description = "数量", required = true) - }) - public CommonResult> getCouponTemplateList( - @RequestParam(value = "spuId", required = false) Long spuId, - @RequestParam(value = "productScope", required = false) Integer productScope, - @RequestParam(value = "count", required = false, defaultValue = "10") Integer count) { - // 1.1 处理查询条件:商品范围编号 - Long productScopeValue = getProductScopeValue(productScope, spuId); - // 1.2 处理查询条件:领取方式 = 直接领取 - List canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getValue()); - - // 2. 查询 - List list = couponTemplateService.getCouponTemplateList(canTakeTypes, productScope, - productScopeValue, count); - - // 3.1 领取数量 - Map canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), list); - // 3.2 拼接返回 - return success(CouponTemplateConvert.INSTANCE.convertAppList(list, canCanTakeMap)); - } - - @GetMapping("/list-by-ids") - @Operation(summary = "获得优惠劵模版列表") - @Parameter(name = "ids", description = "优惠券模板编号列表") - public CommonResult> getCouponTemplateList( - @RequestParam(value = "ids", required = false) Set ids) { - // 1. 查询 - List list = couponTemplateService.getCouponTemplateList(ids); - - // 2.1 领取数量 - Map canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), list); - // 2.2 拼接返回 - return success(CouponTemplateConvert.INSTANCE.convertAppList(list, canCanTakeMap)); - } - - @GetMapping("/page") - @Operation(summary = "获得优惠劵模版分页") - public CommonResult> getCouponTemplatePage(AppCouponTemplatePageReqVO pageReqVO) { - // 1.1 处理查询条件:商品范围编号 - Long productScopeValue = getProductScopeValue(pageReqVO.getProductScope(), pageReqVO.getSpuId()); - // 1.2 处理查询条件:领取方式 = 直接领取 - List canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getValue()); - - // 2. 分页查询 - PageResult pageResult = couponTemplateService.getCouponTemplatePage( - CouponTemplateConvert.INSTANCE.convert(pageReqVO, canTakeTypes, pageReqVO.getProductScope(), productScopeValue)); - - // 3.1 领取数量 - Map canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), pageResult.getList()); - // 3.2 拼接返回 - return success(CouponTemplateConvert.INSTANCE.convertAppPage(pageResult, canCanTakeMap)); - } - - /** - * 获得商品的使用范围编号 - * - * @param productScope 商品范围 - * @param spuId 商品 SPU 编号 - * @return 商品范围编号 - */ - private Long getProductScopeValue(Integer productScope, Long spuId) { - // 通用券:没有商品范围 - if (ObjectUtils.equalsAny(productScope, PromotionProductScopeEnum.ALL.getScope(), null)) { - return null; - } - // 品类券:查询商品的品类编号 - if (Objects.equals(productScope, PromotionProductScopeEnum.CATEGORY.getScope()) && spuId != null) { - ProductSpuRespDTO spu = productSpuApi.getSpu(spuId).getCheckedData(); - return spu != null ? spu.getCategoryId() : null; - } - // 商品卷:直接返回 - return spuId; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchReqVO.java deleted file mode 100755 index 9d36e3a4e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 优惠劵的匹配 Request VO") -@Data -public class AppCouponMatchReqVO { - - @Schema(description = "商品金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "商品金额不能为空") - private Integer price; - - @Schema(description = "商品 SPU 编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]") - @NotEmpty(message = "商品 SPU 编号不能为空") - private List spuIds; - - @Schema(description = "商品 SKU 编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]") - @NotEmpty(message = "商品 SKU 编号不能为空") - private List skuIds; - - @Schema(description = "分类编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[10, 20]") - @NotEmpty(message = "分类编号不能为空") - private List categoryIds; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchRespVO.java deleted file mode 100755 index da60390fe..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 优惠劵 Response VO") -@Data -public class AppCouponMatchRespVO extends AppCouponRespVO { - - @Schema(description = "是否匹配", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean match; - - @Schema(description = "匹配条件的提示", example = "所结算商品没有符合条件的商品") - private String description; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponPageReqVO.java deleted file mode 100644 index 0c423959b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "用户 App - 优惠劵分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppCouponPageReqVO extends PageParam { - - @Schema(description = "优惠劵状态", example = "1") - @InEnum(value = CouponStatusEnum.class, message = "优惠劵状态,必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponRespVO.java deleted file mode 100755 index 7a5f249e4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponRespVO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 优惠劵 Response VO") -@Data -public class AppCouponRespVO { - - @Schema(description = "优惠劵编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") - private String name; - - @Schema(description = "优惠劵状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 参见 CouponStatusEnum 枚举 - private Integer status; - - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 单位:分;0 - 不限制 - private Integer usePrice; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer productScope; - - @Schema(description = "商品范围编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private List productScopeValues; - - @Schema(description = "固定日期 - 生效开始时间") - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - private LocalDateTime validEndTime; - - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 - private Integer discountLimitPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponTakeReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponTakeReqVO.java deleted file mode 100644 index 0f71fe2bf..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponTakeReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 优惠劵领取 Request VO") -@Data -public class AppCouponTakeReqVO { - - @Schema(description = "优惠劵模板编号", example = "1") - @NotNull(message = "优惠劵模板编号不能为空") - private Long templateId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplatePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplatePageReqVO.java deleted file mode 100644 index d98b2f161..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplatePageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "用户 App - 优惠劵模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppCouponTemplatePageReqVO extends PageParam { - - @Schema(description = "商品范围", example = "1") - @InEnum(value = PromotionProductScopeEnum.class, message = "商品范围,必须是 {value}") - private Integer productScope; - - @Schema(description = "商品标号", example = "1") - private Long spuId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplateRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplateRespVO.java deleted file mode 100755 index bb3a26eb9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplateRespVO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 优惠劵模板 Response VO") -@Data -public class AppCouponTemplateRespVO { - - @Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") - private String name; - - @Schema(description = "每人限领个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") // -1 - 则表示不限制 - private Integer takeLimitCount; - - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 单位:分;0 - 不限制 - private Integer usePrice; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer productScope; - - @Schema(description = "商品范围编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private List productScopeValues; - - @Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer validityType; - - @Schema(description = "固定日期 - 生效开始时间") - private LocalDateTime validStartTime; - - @Schema(description = "固定日期 - 生效结束时间") - private LocalDateTime validEndTime; - - @Schema(description = "领取日期 - 开始天数") - @Min(value = 0L, message = "开始天数必须大于 0") - private Integer fixedStartTerm; - - @Schema(description = "领取日期 - 结束天数") - @Min(value = 1L, message = "开始天数必须大于 1") - private Integer fixedEndTerm; - - @Schema(description = "优惠类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer discountType; - - @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 - private Integer discountPercent; - - @Schema(description = "优惠金额", example = "10") - @Min(value = 0, message = "优惠金额需要大于等于 0") - private Integer discountPrice; - - @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 - private Integer discountLimitPrice; - - // ========== 用户相关字段 ========== - - @Schema(description = "是否可以领取", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean canTake; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyPageController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyPageController.java deleted file mode 100644 index 384dea400..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyPageController.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.diy; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyPagePropertyRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 装修页面") -@RestController -@RequestMapping("/promotion/diy-page") -@Validated -public class AppDiyPageController { - - @Resource - private DiyPageService diyPageService; - - @GetMapping("/get") - @Operation(summary = "获得装修页面") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getDiyPage(@RequestParam("id") Long id) { - DiyPageDO diyPage = diyPageService.getDiyPage(id); - return success(BeanUtils.toBean(diyPage, AppDiyPagePropertyRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyTemplateController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyTemplateController.java deleted file mode 100644 index 0bf37c9e6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyTemplateController.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.diy; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyTemplatePropertyRespVO; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.diy.DiyPageEnum; -import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService; -import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; - -@Tag(name = "用户 APP - 装修模板") -@RestController -@RequestMapping("/promotion/diy-template") -@Validated -public class AppDiyTemplateController { - - @Resource - private DiyTemplateService diyTemplateService; - @Resource - private DiyPageService diyPageService; - - // TODO @疯狂:要不要把 used 和 get 接口合并哈;不传递 id,直接拿默认; - @GetMapping("/used") - @Operation(summary = "使用中的装修模板") - public CommonResult getUsedDiyTemplate() { - DiyTemplateDO diyTemplate = diyTemplateService.getUsedDiyTemplate(); - return success(buildVo(diyTemplate)); - } - - @GetMapping("/get") - @Operation(summary = "获得装修模板") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getDiyTemplate(@RequestParam("id") Long id) { - DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id); - return success(buildVo(diyTemplate)); - } - - private AppDiyTemplatePropertyRespVO buildVo(DiyTemplateDO diyTemplate) { - if (diyTemplate == null) { - return null; - } - // 查询模板下的页面 - List pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId()); - String home = findFirst(pages, page -> DiyPageEnum.INDEX.getName().equals(page.getName()), DiyPageDO::getProperty); - String user = findFirst(pages, page -> DiyPageEnum.MY.getName().equals(page.getName()), DiyPageDO::getProperty); - // 拼接返回 - return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, home, user); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyPagePropertyRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyPagePropertyRespVO.java deleted file mode 100644 index fb896d797..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyPagePropertyRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.diy.vo; - -import com.fasterxml.jackson.annotation.JsonRawValue; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "用户 App - 装修页面属性 Response VO") -@Data -@ToString(callSuper = true) -public class AppDiyPagePropertyRespVO { - - @Schema(description = "装修页面编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "页面名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - @Schema(description = "页面属性", example = "[]") - @JsonRawValue - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyTemplatePropertyRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyTemplatePropertyRespVO.java deleted file mode 100644 index aa237e088..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/vo/AppDiyTemplatePropertyRespVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.diy.vo; - -import com.fasterxml.jackson.annotation.JsonRawValue; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -@Schema(description = "用户 App - 装修模板属性 Response VO") -@Data -@ToString(callSuper = true) -public class AppDiyTemplatePropertyRespVO { - - @Schema(description = "装修模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31209") - private Long id; - - @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "默认主题") - private String name; - - @Schema(description = "模板属性", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @JsonRawValue - private String property; - - @Schema(description = "首页", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @JsonRawValue - private String home; - - @Schema(description = "我的", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") - @JsonRawValue - private String user; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/AppRewardActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/AppRewardActivityController.java deleted file mode 100755 index 1607a4b3c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/AppRewardActivityController.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.reward; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.promotion.controller.app.reward.vo.AppRewardActivityRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 满减送活动") -@RestController -@RequestMapping("/promotion/reward-activity") -@Validated -public class AppRewardActivityController { - - @Resource - private RewardActivityService rewardActivityService; - - @GetMapping("/get") - @Operation(summary = "获得满减送活动") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getRewardActivity(@RequestParam("id") Long id) { - RewardActivityDO rewardActivity = rewardActivityService.getRewardActivity(id); - return success(BeanUtils.toBean(rewardActivity, AppRewardActivityRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/vo/AppRewardActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/vo/AppRewardActivityRespVO.java deleted file mode 100755 index acaa5225d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/reward/vo/AppRewardActivityRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.reward.vo; - -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 满减送活动 Response VO") -@Data -public class AppRewardActivityRespVO { - - @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer id; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "活动标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "满啦满啦") - private String name; - - @Schema(description = "条件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer conditionType; - - @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer productScope; - - @Schema(description = "商品 SPU 编号的数组", example = "1,2,3") - private List productSpuIds; - - @Schema(description = "优惠规则的数组") - private List rules; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java deleted file mode 100644 index a51a50da4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java +++ /dev/null @@ -1,153 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityNowRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityRespVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.context.annotation.Lazy; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildCache; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween; - -@Tag(name = "用户 App - 秒杀活动") -@RestController -@RequestMapping("/promotion/seckill-activity") -@Validated -public class AppSeckillActivityController { - - /** - * {@link AppSeckillActivityNowRespVO} 缓存,通过它异步刷新 {@link #getNowSeckillActivity()} 所要的首页数据 - */ - private final LoadingCache nowSeckillActivityCache = buildCache(Duration.ofSeconds(10L), - new CacheLoader() { - - @Override - public AppSeckillActivityNowRespVO load(String key) { - return getNowSeckillActivity0(); - } - - }); - - @Resource - private SeckillActivityService activityService; - @Resource - @Lazy - private SeckillConfigService configService; - - @Resource - private ProductSpuApi spuApi; - - @GetMapping("/get-now") - @Operation(summary = "获得当前秒杀活动", description = "获取当前正在进行的活动,提供给首页使用") - public CommonResult getNowSeckillActivity() { - return success(nowSeckillActivityCache.getUnchecked("")); // 缓存 - } - - private AppSeckillActivityNowRespVO getNowSeckillActivity0() { - // 1. 获取当前时间处在哪个秒杀阶段 - SeckillConfigDO config = configService.getCurrentSeckillConfig(); - if (config == null) { // 时段不存在直接返回 null - return new AppSeckillActivityNowRespVO(); - } - - // 2.1 查询满足当前阶段的活动 - List activityList = activityService.getSeckillActivityListByConfigIdAndStatus(config.getId(), CommonStatusEnum.ENABLE.getStatus()); - List productList = activityService.getSeckillProductListByActivityId( - convertList(activityList, SeckillActivityDO::getId)); - // 2.2 获取 spu 信息 - List spuList = spuApi.getSpuList(convertList(activityList, SeckillActivityDO::getSpuId)).getCheckedData(); - return SeckillActivityConvert.INSTANCE.convert(config, activityList, productList, spuList); - } - - @GetMapping("/page") - @Operation(summary = "获得秒杀活动分页") - public CommonResult> getSeckillActivityPage(AppSeckillActivityPageReqVO pageReqVO) { - // 1. 查询满足当前阶段的活动 - PageResult pageResult = activityService.getSeckillActivityAppPageByConfigId(pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty(pageResult.getTotal())); - } - List productList = activityService.getSeckillProductListByActivityId( - convertList(pageResult.getList(), SeckillActivityDO::getId)); - - // 2. 拼接数据 - List spuList = spuApi.getSpuList(convertList(pageResult.getList(), SeckillActivityDO::getSpuId)).getCheckedData(); - return success(SeckillActivityConvert.INSTANCE.convertPage02(pageResult, productList, spuList)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得秒杀活动明细") - @Parameter(name = "id", description = "活动编号", required = true, example = "1024") - public CommonResult getSeckillActivity(@RequestParam("id") Long id) { - // 1. 获取活动 - SeckillActivityDO activity = activityService.getSeckillActivity(id); - if (activity == null - || ObjectUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - return success(null); - } - - // 2. 获取时间段 - List configs = configService.getSeckillConfigListByStatus(CommonStatusEnum.ENABLE.getStatus()); - configs.removeIf(config -> !CollUtil.contains(activity.getConfigIds(), config.getId())); - // 2.1 优先使用当前时间段 - SeckillConfigDO config = findFirst(configs, config0 -> isBetween(config0.getStartTime(), config0.getEndTime())); - // 2.2 如果没有,则获取最后一个,因为倾向优先展示“未开始” > “已结束” - if (config == null) { - config = CollUtil.getLast(configs); - } - if (config == null) { - return null; - } - // 3. 计算开始时间、结束时间 - LocalDate nowDate; - // 3.1 如果在活动日期范围内,则以今天为 nowDate - if (LocalDateTimeUtils.isBetween(activity.getStartTime(), activity.getEndTime())) { - nowDate = LocalDate.now(); - } else { - // 3.2 如果不在活动时间范围内,则直接以活动的 endTime 作为 nowDate,因为还是倾向优先展示“未开始” > “已结束” - nowDate = activity.getEndTime().toLocalDate(); - } - LocalDateTime startTime = LocalDateTime.of(nowDate, LocalTime.parse(config.getStartTime())); - LocalDateTime endTime = LocalDateTime.of(nowDate, LocalTime.parse(config.getEndTime())); - - // 4. 拼接数据 - List productList = activityService.getSeckillProductListByActivityId(activity.getId()); - return success(SeckillActivityConvert.INSTANCE.convert3(activity, productList, startTime, endTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java deleted file mode 100644 index 12ff30944..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config.AppSeckillConfigRespVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 秒杀时间段") -@RestController -@RequestMapping("/promotion/seckill-config") -@Validated -public class AppSeckillConfigController { - @Resource - private SeckillConfigService configService; - - @GetMapping("/list") - @Operation(summary = "获得秒杀时间段列表") - public CommonResult> getSeckillConfigList() { - List list = configService.getSeckillConfigListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(SeckillConfigConvert.INSTANCE.convertList2(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityDetailRespVO.java deleted file mode 100644 index ebb5ac54d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityDetailRespVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 秒杀活动的详细 Response VO") -@Data -public class AppSeckillActivityDetailRespVO { - - @Schema(description = "秒杀活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "秒杀活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晚九点限时秒杀") - private String name; - - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime startTime; - - @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime endTime; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "总共限购数量", example = "10") - private Integer totalLimitCount; - - @Schema(description = "单次限购数量", example = "5") - private Integer singleLimitCount; - - @Schema(description = "秒杀库存(剩余)", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer stock; - - @Schema(description = "秒杀库存(总计)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer totalStock; - - @Schema(description = "商品信息数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List products; - - @Schema(description = "商品信息") - @Data - public static class Product { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") - private Long skuId; - - @Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer seckillPrice; - - @Schema(description = "秒杀限量库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer stock; - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityNowRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityNowRespVO.java deleted file mode 100644 index 5dad12904..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityNowRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity; - -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config.AppSeckillConfigRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 当前秒杀活动 Response VO") -@Data -public class AppSeckillActivityNowRespVO { - - @Schema(description = "秒杀时间段", requiredMode = Schema.RequiredMode.REQUIRED) - private AppSeckillConfigRespVO config; - - @Schema(description = "秒杀活动数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List activities; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityPageReqVO.java deleted file mode 100644 index 158f11fd3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityPageReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "用户 App - 商品评价分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AppSeckillActivityPageReqVO extends PageParam { - - @Schema(description = "秒杀配置编号", example = "1024") - private Long configId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java deleted file mode 100644 index 68e7ff829..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/activity/AppSeckillActivityRespVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 秒杀活动 Response VO") -@Data -public class AppSeckillActivityRespVO { - - @Schema(description = "秒杀活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "秒杀活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晚九点限时秒杀") - private String name; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 - example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 - example = "50") - private Integer marketPrice; - - @Schema(description = "秒杀活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "秒杀库存(剩余)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer stock; - @Schema(description = "秒杀库存(总共)", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer totalStock; - - @Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer seckillPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/config/AppSeckillConfigRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/config/AppSeckillConfigRespVO.java deleted file mode 100644 index c981f8429..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/vo/config/AppSeckillConfigRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 秒杀时间段 Response VO") -@Data -public class AppSeckillConfigRespVO { - - @Schema(description = "秒杀时间段编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "开始时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:00") - private String startTime; - @Schema(description = "结束时间点", requiredMode = Schema.RequiredMode.REQUIRED, example = "09:59") - private String endTime; - - @Schema(description = "轮播图", requiredMode = Schema.RequiredMode.REQUIRED) - private List sliderPicUrls; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java deleted file mode 100644 index 05ad935f7..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategorySimpleRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 文章分类 Convert - * - * @author HUIHUI - */ -@Mapper -public interface ArticleCategoryConvert { - - ArticleCategoryConvert INSTANCE = Mappers.getMapper(ArticleCategoryConvert.class); - - ArticleCategoryDO convert(ArticleCategoryCreateReqVO bean); - - ArticleCategoryDO convert(ArticleCategoryUpdateReqVO bean); - - ArticleCategoryRespVO convert(ArticleCategoryDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList03(List list); - - List convertList04(List categoryList); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java deleted file mode 100644 index 7f4867f5d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 文章管理 Convert - * - * @author HUIHUI - */ -@Mapper -public interface ArticleConvert { - - ArticleConvert INSTANCE = Mappers.getMapper(ArticleConvert.class); - - ArticleDO convert(ArticleCreateReqVO bean); - - ArticleDO convert(ArticleUpdateReqVO bean); - - ArticleRespVO convert(ArticleDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - AppArticleRespVO convert01(ArticleDO article); - - PageResult convertPage02(PageResult articlePage); - - List convertList03(List articleCategoryListByRecommendHotAndRecommendBanner); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/banner/BannerConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/banner/BannerConvert.java deleted file mode 100644 index d2d75362e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/banner/BannerConvert.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.banner.vo.AppBannerRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface BannerConvert { - - BannerConvert INSTANCE = Mappers.getMapper(BannerConvert.class); - - List convertList(List list); - - PageResult convertPage(PageResult pageResult); - - BannerRespVO convert(BannerDO banner); - - BannerDO convert(BannerCreateReqVO createReqVO); - - BannerDO convert(BannerUpdateReqVO updateReqVO); - - List convertList01(List bannerList); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java deleted file mode 100644 index 69f1ce2ea..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 拼团活动 Convert - * - * @author HUIHUI - */ -@Mapper -public interface BargainActivityConvert { - - BargainActivityConvert INSTANCE = Mappers.getMapper(BargainActivityConvert.class); - - BargainActivityDO convert(BargainActivityBaseVO bean); - - BargainActivityDO convert(BargainActivityUpdateReqVO bean); - - BargainActivityRespVO convert(BargainActivityDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult page, List spuList, - Map recordUserCountMap, Map recordSuccessUserCountMap, - Map helpUserCountMap) { - PageResult result = convertPage(page); - // 拼接关联属性 - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - result.getList().forEach(item -> { - findAndThen(spuMap, item.getSpuId(), spu -> { - item.setPicUrl(spu.getPicUrl()).setSpuName(spu.getName()); - }); - // 设置统计字段 - item.setRecordUserCount(recordUserCountMap.getOrDefault(item.getId(), 0)) - .setRecordSuccessUserCount(recordSuccessUserCountMap.getOrDefault(item.getId(), 0)) - .setHelpUserCount(helpUserCountMap.getOrDefault(item.getId(), 0)); - }); - return result; - } - - AppBargainActivityDetailRespVO convert1(BargainActivityDO bean); - - default AppBargainActivityDetailRespVO convert(BargainActivityDO bean, Integer successUserCount, ProductSpuRespDTO spu) { - AppBargainActivityDetailRespVO detail = convert1(bean).setSuccessUserCount(successUserCount); - if (spu != null) { - detail.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()); - } - return detail; - } - - PageResult convertAppPage(PageResult page); - - default PageResult convertAppPage(PageResult page, List spuList) { - PageResult result = convertAppPage(page); - // 拼接关联属性 - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - List list = CollectionUtils.convertList(result.getList(), item -> { - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - result.setList(list); - return result; - } - - List convertAppList(List list); - - default List convertAppList(List list, List spuList) { - List activityList = convertAppList(list); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - return CollectionUtils.convertList(activityList, item -> { - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainHelpConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainHelpConvert.java deleted file mode 100644 index 6ec71ce7c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainHelpConvert.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 砍价助力 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BargainHelpConvert { - - BargainHelpConvert INSTANCE = Mappers.getMapper(BargainHelpConvert.class); - - default PageResult convertPage(PageResult page, - Map userMap) { - PageResult pageResult = convertPage(page); - // 拼接数据 - pageResult.getList().forEach(record -> - MapUtils.findAndThen(userMap, record.getUserId(), - user -> record.setNickname(user.getNickname()).setAvatar(user.getAvatar()))); - return pageResult; - } - PageResult convertPage(PageResult page); - - default List convertList(List helps, - Map userMap) { - List helpVOs = convertList02(helps); - helpVOs.forEach(help -> - MapUtils.findAndThen(userMap, help.getUserId(), - user -> help.setNickname(user.getNickname()).setAvatar(user.getAvatar()))); - return helpVOs; - } - List convertList02(List helps); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java deleted file mode 100644 index 5c1bf75a3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordSummaryRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 砍价记录 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BargainRecordConvert { - - BargainRecordConvert INSTANCE = Mappers.getMapper(BargainRecordConvert.class); - - default PageResult convertPage(PageResult page, - Map helpCountMap, - List activityList, - Map userMap) { - PageResult pageResult = convertPage(page); - // 拼接数据 - Map activityMap = convertMap(activityList, BargainActivityDO::getId); - pageResult.getList().forEach(record -> { - MapUtils.findAndThen(userMap, record.getUserId(), - user -> record.setNickname(user.getNickname()).setAvatar(user.getAvatar())); - record.setActivity(BargainActivityConvert.INSTANCE.convert(activityMap.get(record.getActivityId()))) - .setHelpCount(helpCountMap.getOrDefault(record.getId(), 0)); - }); - return pageResult; - } - PageResult convertPage(PageResult page); - - default PageResult convertPage02(PageResult page, - List activityList, - List spuList, - List orderList) { - PageResult pageResult = convertPage02(page); - // 拼接数据 - Map activityMap = convertMap(activityList, BargainActivityDO::getId); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map orderMap = convertMap(orderList, TradeOrderRespDTO::getId); - pageResult.getList().forEach(record -> { - MapUtils.findAndThen(activityMap, record.getActivityId(), - activity -> record.setActivityName(activity.getName()).setEndTime(activity.getEndTime())); - MapUtils.findAndThen(spuMap, record.getSpuId(), - spu -> record.setPicUrl(record.getPicUrl())); - MapUtils.findAndThen(orderMap, record.getOrderId(), - order -> record.setPayStatus(order.getPayStatus()).setPayOrderId(order.getPayOrderId())); - }); - return pageResult; - } - PageResult convertPage02(PageResult page); - - default AppBargainRecordSummaryRespVO convert(Integer successUserCount, List successList, - List activityList, Map userMap) { - AppBargainRecordSummaryRespVO summary = new AppBargainRecordSummaryRespVO().setSuccessUserCount(successUserCount); - Map activityMap = convertMap(activityList, BargainActivityDO::getId); - summary.setSuccessList(CollectionUtils.convertList(successList, record -> { - AppBargainRecordSummaryRespVO.Record recordVO = new AppBargainRecordSummaryRespVO.Record(); - MapUtils.findAndThen(userMap, record.getUserId(), - user -> recordVO.setNickname(user.getNickname()).setAvatar(user.getAvatar())); - MapUtils.findAndThen(activityMap, record.getActivityId(), - activity -> recordVO.setActivityName(activity.getName())); - return recordVO; - })); - return summary; - } - - @Mapping(source = "record.id", target = "id") - @Mapping(source = "record.userId", target = "userId") - @Mapping(source = "record.status", target = "status") - AppBargainRecordDetailRespVO convert02(BargainRecordDO record, Integer helpAction, TradeOrderRespDTO order); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java deleted file mode 100644 index 965459b77..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java +++ /dev/null @@ -1,227 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.combination; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 拼团活动 Convert - * - * @author HUIHUI - */ -@Mapper -public interface CombinationActivityConvert { - - CombinationActivityConvert INSTANCE = Mappers.getMapper(CombinationActivityConvert.class); - - CombinationActivityDO convert(CombinationActivityCreateReqVO bean); - - CombinationActivityDO convert(CombinationActivityUpdateReqVO bean); - - CombinationActivityRespVO convert(CombinationActivityDO bean); - - CombinationProductRespVO convert(CombinationProductDO bean); - - default CombinationActivityRespVO convert(CombinationActivityDO activity, List products) { - return convert(activity).setProducts(convertList2(products)); - } - - List convertList(List list); - - default PageResult convertPage(PageResult page, - List productList, - Map groupCountMap, - Map groupSuccessCountMap, - Map recordCountMap, - List spuList) { - PageResult pageResult = convertPage(page); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - pageResult.getList().forEach(item -> { - MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()) - .setMarketPrice(spu.getMarketPrice())); - item.setProducts(convertList2(productList)); - // 设置统计字段 - item.setGroupCount(groupCountMap.getOrDefault(item.getId(), 0)) - .setGroupSuccessCount(groupSuccessCountMap.getOrDefault(item.getId(), 0)) - .setRecordCount(recordCountMap.getOrDefault(item.getId(), 0)); - }); - return pageResult; - } - - PageResult convertPage(PageResult page); - - List convertList2(List productDOs); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(target = "activityId", source = "activity.id"), - @Mapping(target = "spuId", source = "activity.spuId"), - @Mapping(target = "skuId", source = "product.skuId"), - @Mapping(target = "combinationPrice", source = "product.combinationPrice"), - @Mapping(target = "activityStartTime", source = "activity.startTime"), - @Mapping(target = "activityEndTime", source = "activity.endTime") - }) - CombinationProductDO convert(CombinationActivityDO activity, CombinationProductBaseVO product); - - default List convertList(List products, CombinationActivityDO activity) { - return CollectionUtils.convertList(products, item -> convert(activity, item).setActivityStatus(activity.getStatus())); - } - - default List convertList(List updateProductVOs, - List products, CombinationActivityDO activity) { - Map productMap = convertMap(products, CombinationProductDO::getSkuId, CombinationProductDO::getId); - return CollectionUtils.convertList(updateProductVOs, updateProductVO -> convert(activity, updateProductVO) - .setId(productMap.get(updateProductVO.getSkuId())) - .setActivityStatus(activity.getStatus())); - } - - CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO); - - default CombinationRecordCreateRespDTO convert4(CombinationRecordDO combinationRecord) { - return new CombinationRecordCreateRespDTO().setCombinationActivityId(combinationRecord.getActivityId()) - .setCombinationRecordId(combinationRecord.getId()).setCombinationHeadId(combinationRecord.getHeadId()); - } - - default CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO, - CombinationActivityDO activity, MemberUserRespDTO user, - ProductSpuRespDTO spu, ProductSkuRespDTO sku) { - return convert(reqDTO).setVirtualGroup(false) - .setStatus(CombinationRecordStatusEnum.IN_PROGRESS.getStatus()) // 创建后默认状态为进行中 - .setUserSize(activity.getUserSize()).setUserCount(1) // 默认就是 1 插入后会接着更新一次所有的拼团记录 - // 用户信息 - .setNickname(user.getNickname()).setAvatar(user.getAvatar()) - // 商品信息 - .setSpuName(spu.getName()).setPicUrl(sku.getPicUrl()); - } - - List convertAppList(List list); - - default List convertAppList(List list, - List productList, - List spuList) { - List activityList = convertAppList(list); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map> productMap = convertMultiMap(productList, CombinationProductDO::getActivityId); - return CollectionUtils.convertList(activityList, item -> { - // 设置 product 信息 - item.setCombinationPrice(getMinValue(productMap.get(item.getId()), CombinationProductDO::getCombinationPrice)); - // 设置 SPU 信息 - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - } - - PageResult convertAppPage(PageResult result); - - default PageResult convertAppPage(PageResult result, - List productList, - List spuList) { - PageResult appPage = convertAppPage(result); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map> productMap = convertMultiMap(productList, CombinationProductDO::getActivityId); - List list = CollectionUtils.convertList(appPage.getList(), item -> { - // 设置 product 信息 - item.setCombinationPrice(getMinValue(productMap.get(item.getId()), CombinationProductDO::getCombinationPrice)); - // 设置 SPU 信息 - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - appPage.setList(list); - return appPage; - } - - AppCombinationActivityDetailRespVO convert2(CombinationActivityDO combinationActivity); - - List convertList1(List products); - - default AppCombinationActivityDetailRespVO convert3(CombinationActivityDO combinationActivity, List products) { - return convert2(combinationActivity).setProducts(convertList1(products)); - } - - List convertList3(List records); - - AppCombinationRecordRespVO convert(CombinationRecordDO record); - - PageResult convert(PageResult result); - - default PageResult convert(PageResult recordPage, List activities, List products) { - PageResult result = convert(recordPage); - // 拼接关联属性 - Map activityMap = convertMap(activities, CombinationActivityDO::getId); - Map> productsMap = convertMultiMap(products, CombinationProductDO::getActivityId); - result.setList(CollectionUtils.convertList(result.getList(), item -> { - findAndThen(activityMap, item.getActivityId(), activity -> { - item.setActivity(convert(activity).setProducts(convertList2(productsMap.get(item.getActivityId())))); - }); - return item; - })); - return result; - } - - default AppCombinationRecordDetailRespVO convert(Long userId, CombinationRecordDO headRecord, List memberRecords) { - AppCombinationRecordDetailRespVO respVO = new AppCombinationRecordDetailRespVO() - .setHeadRecord(convert(headRecord)).setMemberRecords(convertList3(memberRecords)); - // 处理自己参与拼团的 orderId - CombinationRecordDO userRecord = CollectionUtils.findFirst(memberRecords, r -> ObjectUtil.equal(r.getUserId(), userId)); - if (userRecord == null && ObjectUtil.equal(headRecord.getUserId(), userId)) { - userRecord = headRecord; - } - respVO.setOrderId(userRecord == null ? null : userRecord.getOrderId()); - return respVO; - } - - /** - * 转换生成虚拟成团虚拟记录 - * - * @param headRecord 虚拟成团团长记录 - * @return 虚拟记录列表 - */ - default List convertVirtualRecordList(CombinationRecordDO headRecord) { - int count = headRecord.getUserSize() - headRecord.getUserCount(); - List createRecords = new ArrayList<>(count); - for (int i = 0; i < count; i++) { - // 基础信息和团长保持一致 - CombinationRecordDO newRecord = convert5(headRecord); - // 虚拟信息 - newRecord.setCount(0) // 会单独更新下,在后续的 Service 逻辑里 - .setUserId(0L).setNickname("").setAvatar("").setOrderId(0L); - createRecords.add(newRecord); - } - return createRecords; - } - @Mapping(target = "id", ignore = true) - CombinationRecordDO convert5(CombinationRecordDO headRecord); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java deleted file mode 100755 index 0ac9c58da..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageItemRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDateTime; -import java.util.Collection; - -/** - * 优惠劵 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface CouponConvert { - - CouponConvert INSTANCE = Mappers.getMapper(CouponConvert.class); - - PageResult convertPage(PageResult page); - - CouponRespDTO convert(CouponDO bean); - - default CouponDO convert(CouponTemplateDO template, Long userId) { - CouponDO couponDO = new CouponDO() - .setTemplateId(template.getId()) - .setName(template.getName()) - .setTakeType(template.getTakeType()) - .setUsePrice(template.getUsePrice()) - .setProductScope(template.getProductScope()) - .setProductScopeValues(template.getProductScopeValues()) - .setDiscountType(template.getDiscountType()) - .setDiscountPercent(template.getDiscountPercent()) - .setDiscountPrice(template.getDiscountPrice()) - .setDiscountLimitPrice(template.getDiscountLimitPrice()) - .setStatus(CouponStatusEnum.UNUSED.getStatus()) - .setUserId(userId); - if (CouponTemplateValidityTypeEnum.DATE.getType().equals(template.getValidityType())) { - couponDO.setValidStartTime(template.getValidStartTime()); - couponDO.setValidEndTime(template.getValidEndTime()); - } else if (CouponTemplateValidityTypeEnum.TERM.getType().equals(template.getValidityType())) { - couponDO.setValidStartTime(LocalDateTime.now().plusDays(template.getFixedStartTerm())); - couponDO.setValidEndTime(LocalDateTime.now().plusDays(template.getFixedEndTerm())); - } - return couponDO; - } - - CouponPageReqVO convert(AppCouponPageReqVO pageReqVO, Collection userIds); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java deleted file mode 100755 index c6b86da38..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.coupon; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplateRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 优惠劵模板 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface CouponTemplateConvert { - - CouponTemplateConvert INSTANCE = Mappers.getMapper(CouponTemplateConvert.class); - - CouponTemplateDO convert(CouponTemplateCreateReqVO bean); - - CouponTemplateDO convert(CouponTemplateUpdateReqVO bean); - - CouponTemplateRespVO convert(CouponTemplateDO bean); - - PageResult convertPage(PageResult page); - - CouponTemplatePageReqVO convert(AppCouponTemplatePageReqVO pageReqVO, List canTakeTypes, Integer productScope, Long productScopeValue); - - PageResult convertAppPage(PageResult pageResult); - - List convertAppList(List list); - - default PageResult convertAppPage(PageResult pageResult, Map userCanTakeMap) { - PageResult result = convertAppPage(pageResult); - copyTo(result.getList(), userCanTakeMap); - return result; - } - - default List convertAppList(List list, Map userCanTakeMap) { - List result = convertAppList(list); - copyTo(result, userCanTakeMap); - return result; - } - - default void copyTo(List list, Map userCanTakeMap) { - for (AppCouponTemplateRespVO template : list) { - // 检查已领取数量是否超过限领数量 - template.setCanTake(MapUtil.getBool(userCanTakeMap, template.getId(), false)); - } - } - - List convertList(List list); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/DiscountActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/DiscountActivityConvert.java deleted file mode 100755 index 0ecbd92ef..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/DiscountActivityConvert.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.discount; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.*; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 限时折扣活动 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface DiscountActivityConvert { - - DiscountActivityConvert INSTANCE = Mappers.getMapper(DiscountActivityConvert.class); - - DiscountActivityDO convert(DiscountActivityCreateReqVO bean); - - DiscountActivityDO convert(DiscountActivityUpdateReqVO bean); - - DiscountActivityRespVO convert(DiscountActivityDO bean); - - List convertList(List list); - List convertList2(List list); - - List convertList02(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult page, - List discountProductDOList, - List spuList) { - PageResult pageResult = convertPage(page); - - // 拼接商品 TODO @zhangshuai:类似空行的问题,也可以看看 - Map discountActivityMap = CollectionUtils.convertMap(discountProductDOList, DiscountProductDO::getActivityId); - Map spuMap = CollectionUtils.convertMap(spuList, ProductSpuRespDTO::getId); - pageResult.getList().forEach(item -> { - item.setProducts(convertList2(discountProductDOList)); - item.setSpuId(discountActivityMap.get(item.getId())==null?null: discountActivityMap.get(item.getId()).getSpuId()); - if (item.getSpuId() != null) { - MapUtils.findAndThen(spuMap, item.getSpuId(), - spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - } - - }); - return pageResult; - } - - DiscountProductDO convert(DiscountActivityBaseVO.Product bean); - - default DiscountActivityDetailRespVO convert(DiscountActivityDO activity, List products){ - if ( activity == null && products == null ) { - return null; - } - - DiscountActivityDetailRespVO discountActivityDetailRespVO = new DiscountActivityDetailRespVO(); - - if ( activity != null ) { - discountActivityDetailRespVO.setName( activity.getName() ); - discountActivityDetailRespVO.setStartTime( activity.getStartTime() ); - discountActivityDetailRespVO.setEndTime( activity.getEndTime() ); - discountActivityDetailRespVO.setRemark( activity.getRemark() ); - discountActivityDetailRespVO.setId( activity.getId() ); - discountActivityDetailRespVO.setStatus( activity.getStatus() ); - discountActivityDetailRespVO.setCreateTime( activity.getCreateTime() ); - } - if (!products.isEmpty()) { - discountActivityDetailRespVO.setSpuId(products.get(0).getSpuId()); - } - discountActivityDetailRespVO.setProducts( convertList2( products ) ); - - return discountActivityDetailRespVO; - } - - // =========== 比较是否相等 ========== - /** - * 比较两个限时折扣商品是否相等 - * - * @param productDO 数据库中的商品 - * @param productVO 前端传入的商品 - * @return 是否匹配 - */ - @SuppressWarnings("DuplicatedCode") - default boolean isEquals(DiscountProductDO productDO, DiscountActivityBaseVO.Product productVO) { - if (ObjectUtil.notEqual(productDO.getSpuId(), productVO.getSpuId()) - || ObjectUtil.notEqual(productDO.getSkuId(), productVO.getSkuId()) - || ObjectUtil.notEqual(productDO.getDiscountType(), productVO.getDiscountType())) { - return false; - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PRICE.getType())) { - return ObjectUtil.equal(productDO.getDiscountPrice(), productVO.getDiscountPrice()); - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PERCENT.getType())) { - return ObjectUtil.equal(productDO.getDiscountPercent(), productVO.getDiscountPercent()); - } - return true; - } - - /** - * 比较两个限时折扣商品是否相等 - * 注意,比较时忽略 id 编号 - * - * @param productDO 商品 1 - * @param productVO 商品 2 - * @return 是否匹配 - */ - @SuppressWarnings("DuplicatedCode") - default boolean isEquals(DiscountProductDO productDO, DiscountProductDO productVO) { - if (ObjectUtil.notEqual(productDO.getSpuId(), productVO.getSpuId()) - || ObjectUtil.notEqual(productDO.getSkuId(), productVO.getSkuId()) - || ObjectUtil.notEqual(productDO.getDiscountType(), productVO.getDiscountType())) { - return false; - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PRICE.getType())) { - return ObjectUtil.equal(productDO.getDiscountPrice(), productVO.getDiscountPrice()); - } - if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PERCENT.getType())) { - return ObjectUtil.equal(productDO.getDiscountPercent(), productVO.getDiscountPercent()); - } - return true; - } - - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyPageConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyPageConvert.java deleted file mode 100644 index 3443fd862..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyPageConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.*; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 装修页面 Convert - * - * @author owen - */ -@Mapper -public interface DiyPageConvert { - - DiyPageConvert INSTANCE = Mappers.getMapper(DiyPageConvert.class); - - DiyPageDO convert(DiyPageCreateReqVO bean); - - DiyPageDO convert(DiyPageUpdateReqVO bean); - - DiyPageRespVO convert(DiyPageDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - DiyPageCreateReqVO convertCreateVo(Long templateId, String name, String remark); - - DiyPagePropertyRespVO convertPropertyVo(DiyPageDO diyPage); - - DiyPageDO convert(DiyPagePropertyUpdateRequestVO updateReqVO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyTemplateConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyTemplateConvert.java deleted file mode 100644 index a579c6087..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/diy/DiyTemplateConvert.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.*; -import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyTemplatePropertyRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 装修模板 Convert - * - * @author owen - */ -@Mapper -public interface DiyTemplateConvert { - - DiyTemplateConvert INSTANCE = Mappers.getMapper(DiyTemplateConvert.class); - - DiyTemplateDO convert(DiyTemplateCreateReqVO bean); - - DiyTemplateDO convert(DiyTemplateUpdateReqVO bean); - - DiyTemplateRespVO convert(DiyTemplateDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - DiyTemplatePropertyRespVO convertPropertyVo(DiyTemplateDO diyTemplate, List pages); - - AppDiyTemplatePropertyRespVO convertPropertyVo2(DiyTemplateDO diyTemplate, String home, String user); - - DiyTemplateDO convert(DiyTemplatePropertyUpdateRequestVO updateReqVO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/reward/RewardActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/reward/RewardActivityConvert.java deleted file mode 100755 index 5343656ed..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/reward/RewardActivityConvert.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.reward; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 满减送活动 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface RewardActivityConvert { - - RewardActivityConvert INSTANCE = Mappers.getMapper(RewardActivityConvert.class); - - RewardActivityDO convert(RewardActivityCreateReqVO bean); - - RewardActivityDO convert(RewardActivityUpdateReqVO bean); - - RewardActivityRespVO convert(RewardActivityDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java deleted file mode 100644 index 4f53cf3dc..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java +++ /dev/null @@ -1,141 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityDetailRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityNowRespVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityRespVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; - -/** - * 秒杀活动 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface SeckillActivityConvert { - - SeckillActivityConvert INSTANCE = Mappers.getMapper(SeckillActivityConvert.class); - - SeckillActivityDO convert(SeckillActivityCreateReqVO bean); - - SeckillActivityDO convert(SeckillActivityUpdateReqVO bean); - - SeckillActivityRespVO convert(SeckillActivityDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult page, - List seckillProducts, - List spuList) { - PageResult pageResult = convertPage(page); - // 拼接商品 - Map spuMap = CollectionUtils.convertMap(spuList, ProductSpuRespDTO::getId); - pageResult.getList().forEach(item -> { - item.setProducts(convertList2(seckillProducts)); - MapUtils.findAndThen(spuMap, item.getSpuId(), - spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - }); - return pageResult; - } - - SeckillActivityDetailRespVO convert1(SeckillActivityDO activity); - - default SeckillActivityDetailRespVO convert(SeckillActivityDO activity, List products) { - return convert1(activity).setProducts(convertList2(products)); - } - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(target = "activityId", source = "activity.id"), - @Mapping(target = "configIds", source = "activity.configIds"), - @Mapping(target = "spuId", source = "activity.spuId"), - @Mapping(target = "skuId", source = "product.skuId"), - @Mapping(target = "seckillPrice", source = "product.seckillPrice"), - @Mapping(target = "stock", source = "product.stock"), - @Mapping(target = "activityStartTime", source = "activity.startTime"), - @Mapping(target = "activityEndTime", source = "activity.endTime") - }) - SeckillProductDO convert(SeckillActivityDO activity, SeckillProductBaseVO product); - - default List convertList(List products, SeckillActivityDO activity) { - return CollectionUtils.convertList(products, item -> convert(activity, item).setActivityStatus(activity.getStatus())); - } - - List convertList2(List list); - - List convertList3(List activityList); - - default AppSeckillActivityNowRespVO convert(SeckillConfigDO filteredConfig, List activityList, - List productList, List spuList) { - AppSeckillActivityNowRespVO respVO = new AppSeckillActivityNowRespVO(); - respVO.setConfig(SeckillConfigConvert.INSTANCE.convert1(filteredConfig)); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map> productMap = convertMultiMap(productList, SeckillProductDO::getActivityId); - respVO.setActivities(CollectionUtils.convertList(convertList3(activityList), item -> { - // product 信息 - item.setSeckillPrice(getMinValue(productMap.get(item.getId()), SeckillProductDO::getSeckillPrice)); - // spu 信息 - findAndThen(spuMap, item.getSpuId(), spu -> - item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - })); - return respVO; - } - - PageResult convertPage1(PageResult pageResult); - - default PageResult convertPage02(PageResult pageResult, List productList, List spuList) { - PageResult result = convertPage1(pageResult); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map> productMap = convertMultiMap(productList, SeckillProductDO::getActivityId); - List list = CollectionUtils.convertList(result.getList(), item -> { - // product 信息 - item.setSeckillPrice(getMinValue(productMap.get(item.getId()), SeckillProductDO::getSeckillPrice)); - // spu 信息 - findAndThen(spuMap, item.getSpuId(), spu -> item.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - return item; - }); - result.setList(list); - return result; - } - - AppSeckillActivityDetailRespVO convert2(SeckillActivityDO seckillActivity); - - List convertList1(List products); - - default AppSeckillActivityDetailRespVO convert3(SeckillActivityDO activity, List products, - LocalDateTime startTime, LocalDateTime endTime) { - return convert2(activity) - .setProducts(convertList1(products)) - .setStartTime(startTime).setEndTime(endTime); - } - - SeckillValidateJoinRespDTO convert02(SeckillActivityDO activity, SeckillProductDO product); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillconfig/SeckillConfigConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillconfig/SeckillConfigConvert.java deleted file mode 100644 index f8dd77440..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillconfig/SeckillConfigConvert.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigSimpleRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.config.AppSeckillConfigRespVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 秒杀时段 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface SeckillConfigConvert { - - SeckillConfigConvert INSTANCE = Mappers.getMapper(SeckillConfigConvert.class); - - SeckillConfigDO convert(SeckillConfigCreateReqVO bean); - - SeckillConfigDO convert(SeckillConfigUpdateReqVO bean); - - SeckillConfigRespVO convert(SeckillConfigDO bean); - - List convertList(List list); - - List convertList1(List list); - - PageResult convertPage(PageResult page); - - List convertList2(List list); - - AppSeckillConfigRespVO convert1(SeckillConfigDO filteredConfig); -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleCategoryDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleCategoryDO.java deleted file mode 100644 index c79b86d66..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleCategoryDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.article; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 文章分类 DO - * - * @author HUIHUI - */ -@TableName("promotion_article_category") -@KeySequence("promotion_article_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ArticleCategoryDO extends BaseDO { - - /** - * 文章分类编号 - */ - @TableId - private Long id; - /** - * 文章分类名称 - */ - private String name; - /** - * 图标地址 - */ - private String picUrl; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 排序 - */ - private Integer sort; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleDO.java deleted file mode 100644 index 426d9d9c7..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/article/ArticleDO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.article; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 文章管理 DO - * - * @author HUIHUI - */ -@TableName("promotion_article") -@KeySequence("promotion_article_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ArticleDO extends BaseDO { - - /** - * 文章管理编号 - */ - @TableId - private Long id; - /** - * 分类编号 ArticleCategoryDO#id - */ - private Long categoryId; - /** - * 关联商品编号 ProductSpuDO#id - */ - private Long spuId; - /** - * 文章标题 - */ - private String title; - /** - * 文章作者 - */ - private String author; - /** - * 文章封面图片地址 - */ - private String picUrl; - /** - * 文章简介 - */ - private String introduction; - /** - * 浏览次数 - */ - private Integer browseCount; - /** - * 排序 - */ - private Integer sort; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 是否热门(小程序) - */ - private Boolean recommendHot; - /** - * 是否轮播图(小程序) - */ - private Boolean recommendBanner; - /** - * 文章内容 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java deleted file mode 100644 index fad9385b2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.banner; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.banner.BannerPositionEnum; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * banner DO - * - * @author xia - */ -@TableName("promotion_banner") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BannerDO extends BaseDO { - - /** - * 编号 - */ - private Long id; - /** - * 标题 - */ - private String title; - /** - * 跳转链接 - */ - private String url; - /** - * 图片链接 - */ - private String picUrl; - /** - * 排序 - */ - private Integer sort; - - /** - * 状态 {@link CommonStatusEnum} - */ - private Integer status; - - /** - * 定位 {@link BannerPositionEnum} - */ - private Integer position; - - /** - * 备注 - */ - private String memo; - - /** - * 点击次数 - */ - private Integer browseCount; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainActivityDO.java deleted file mode 100644 index 37259ebe6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainActivityDO.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 砍价活动 DO - * - * @author HUIHUI - */ -@TableName("promotion_bargain_activity") -@KeySequence("promotion_bargain_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BargainActivityDO extends BaseDO { - - /** - * 砍价活动编号 - */ - @TableId - private Long id; - - /** - * 砍价活动名称 - */ - private String name; - - /** - * 活动开始时间 - */ - private LocalDateTime startTime; - /** - * 活动结束时间 - */ - private LocalDateTime endTime; - - /** - * 活动状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 砍价起始价格,单位:分 - */ - private Integer bargainFirstPrice; - /** - * 砍价底价,单位:分 - */ - private Integer bargainMinPrice; - - /** - * 砍价库存(剩余库存砍价时扣减) - */ - private Integer stock; - /** - * 砍价总库存 - */ - private Integer totalStock; - - /** - * 砍价人数 - * - * 需要多少人,砍价才能成功,即 {@link BargainRecordDO#getStatus()} 更新为 {@link BargainRecordDO#getStatus()} 成功状态 - */ - private Integer helpMaxCount; - /** - * 帮砍次数 - * - * 单个活动,用户可以帮砍的次数。 - * 例如说:帮砍次数为 1 时,A 和 B 同时将该活动链接发给 C,C 只能帮其中一个人砍价。 - */ - private Integer bargainCount; - - /** - * 总限购数量 - */ - private Integer totalLimitCount; - /** - * 用户每次砍价的最小金额,单位:分 - */ - private Integer randomMinPrice; - /** - * 用户每次砍价的最大金额,单位:分 - */ - private Integer randomMaxPrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainHelpDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainHelpDO.java deleted file mode 100644 index 8419f3436..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainHelpDO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 砍价助力 DO - * - * @author HUIHUI - */ -@TableName("promotion_bargain_help") -@KeySequence("promotion_bargain_help_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BargainHelpDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 砍价活动编号 - * - * 关联 {@link BargainActivityDO#getId()} 字段 - */ - private Long activityId; - /** - * 砍价记录编号 - * - * 关联 {@link BargainRecordDO#getId()} 字段 - */ - private Long recordId; - - /** - * 用户编号 - */ - private Long userId; - /** - * 减少价格,单位:分 - */ - private Integer reducePrice; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainRecordDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainRecordDO.java deleted file mode 100644 index e5f574dd6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainRecordDO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 砍价记录 DO TODO - * - * @author HUIHUI - */ -@TableName("promotion_bargain_record") -@KeySequence("promotion_bargain_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BargainRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - */ - private Long userId; - - /** - * 砍价活动编号 - * - * 关联 {@link BargainActivityDO#getId()} 字段 - */ - private Long activityId; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - - /** - * 砍价起始价格,单位:分 - */ - private Integer bargainFirstPrice; - /** - * 当前砍价,单位:分 - */ - private Integer bargainPrice; - - /** - * 砍价状态 - * - * 砍价成功的条件是:(2 选 1) - * 1. 砍价到 {@link BargainActivityDO#getBargainMinPrice()} 底价 - * 2. 助力人数到达 {@link BargainActivityDO#getHelpMaxCount()} 人 - * - * 枚举 {@link BargainRecordStatusEnum} - */ - private Integer status; - /** - * 结束时间 - */ - private LocalDateTime endTime; - - /** - * 订单编号 - */ - private Long orderId; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationActivityDO.java deleted file mode 100644 index 5236b303a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationActivityDO.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.combination; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 拼团活动 DO - * - * @author HUIHUI - */ -@TableName("promotion_combination_activity") -@KeySequence("promotion_combination_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CombinationActivityDO extends BaseDO { - - /** - * 活动编号 - */ - @TableId - private Long id; - /** - * 拼团名称 - */ - private String name; - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id - */ - private Long spuId; - /** - * 总限购数量 - */ - private Integer totalLimitCount; - /** - * 单次限购数量 - */ - private Integer singleLimitCount; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 几人团 - */ - private Integer userSize; - /** - * 虚拟成团 - */ - private Boolean virtualGroup; - /** - * 活动状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 限制时长(小时) - */ - private Integer limitDuration; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationProductDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationProductDO.java deleted file mode 100644 index d793bb63e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationProductDO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.combination; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 拼团商品 DO - * - * @author HUIHUI - */ -@TableName("promotion_combination_product") -@KeySequence("promotion_combination_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CombinationProductDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 拼团活动编号 - */ - private Long activityId; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 拼团价格,单位分 - */ - private Integer combinationPrice; - - /** - * 拼团商品状态 - * - * 关联 {@link CombinationActivityDO#getStatus()} - */ - private Integer activityStatus; - /** - * 活动开始时间点 - * - * 冗余 {@link CombinationActivityDO#getStartTime()} - */ - private LocalDateTime activityStartTime; - /** - * 活动结束时间点 - * - * 冗余 {@link CombinationActivityDO#getEndTime()} - */ - private LocalDateTime activityEndTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationRecordDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationRecordDO.java deleted file mode 100644 index e1ba90bf1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationRecordDO.java +++ /dev/null @@ -1,140 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.combination; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -// TODO 芋艿:把字段的顺序,和 do 顺序对齐下 -/** - * 拼团记录 DO - * - * 1. 用户参与拼团时,会创建一条记录 - * 2. 团长的拼团记录,和参团人的拼团记录,通过 {@link #headId} 关联 - * - * @author HUIHUI - */ -@TableName("promotion_combination_record") -@KeySequence("promotion_combination_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CombinationRecordDO extends BaseDO { - - /** - * 团长编号 - 团长 - */ - public static final Long HEAD_ID_GROUP = 0L; - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 拼团活动编号 - * - * 关联 {@link CombinationActivityDO#getId()} - */ - private Long activityId; - /** - * 拼团商品单价 - * - * 冗余 {@link CombinationProductDO#getCombinationPrice()} - */ - private Integer combinationPrice; - /** - * SPU 编号 - */ - private Long spuId; - /** - * 商品名字 - */ - private String spuName; - /** - * 商品图片 - */ - private String picUrl; - /** - * SKU 编号 - */ - private Long skuId; - /** - * 购买的商品数量 - */ - private Integer count; - - /** - * 用户编号 - */ - private Long userId; - - /** - * 用户昵称 - */ - private String nickname; - /** - * 用户头像 - */ - private String avatar; - - /** - * 团长编号 - * - * 关联 {@link CombinationRecordDO#getId()} - * - * 如果是团长,则它的值是 {@link #HEAD_ID_GROUP} - */ - private Long headId; - /** - * 开团状态 - * - * 关联 {@link CombinationRecordStatusEnum} - */ - private Integer status; - /** - * 订单编号 - */ - private Long orderId; - /** - * 开团需要人数 - * - * 关联 {@link CombinationActivityDO#getUserSize()} - */ - private Integer userSize; - /** - * 已加入拼团人数 - */ - private Integer userCount; - /** - * 是否虚拟成团 - * - * 默认为 false。 - * 拼团过期都还没有成功,如果 {@link CombinationActivityDO#getVirtualGroup()} 为 true,则执行虚拟成团的逻辑,才会更新该字段为 true - */ - private Boolean virtualGroup; - - /** - * 过期时间 - * - * 基于 {@link CombinationRecordDO#getStartTime()} + {@link CombinationActivityDO#getLimitDuration()} 计算 - */ - private LocalDateTime expireTime; - /** - * 开始时间 (订单付款后开始的时间) - */ - private LocalDateTime startTime; - /** - * 结束时间(成团时间/失败时间) - */ - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java deleted file mode 100644 index 31cef2e78..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.coupon; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 优惠劵 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_coupon", autoResultMap = true) -@KeySequence("promotion_coupon_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class CouponDO extends BaseDO { - - // ========== 基本信息 BEGIN ========== - /** - * 优惠劵编号 - */ - private Long id; - /** - * 优惠劵模板编号 - * - * 关联 {@link CouponTemplateDO#getId()} - */ - private Long templateId; - /** - * 优惠劵名 - * - * 冗余 {@link CouponTemplateDO#getName()} - */ - private String name; - /** - * 优惠码状态 - * - * 枚举 {@link CouponStatusEnum} - */ - // TODO 芋艿:已作废? - private Integer status; - - // TODO 芋艿:发放 adminid? - - // ========== 基本信息 END ========== - - // ========== 领取情况 BEGIN ========== - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 领取类型 - * - * 枚举 {@link CouponTakeTypeEnum} - */ - private Integer takeType; - // ========== 领取情况 END ========== - - // ========== 使用规则 BEGIN ========== - /** - * 是否设置满多少金额可用,单位:分 - * - * 冗余 {@link CouponTemplateDO#getUsePrice()} - */ - private Integer usePrice; - /** - * 生效开始时间 - */ - private LocalDateTime validStartTime; - /** - * 生效结束时间 - */ - private LocalDateTime validEndTime; - /** - * 商品范围 - * - * 枚举 {@link PromotionProductScopeEnum} - */ - private Integer productScope; - /** - * 商品范围编号的数组 - * - * 冗余 {@link CouponTemplateDO#getProductScopeValues()} - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List productScopeValues; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - /** - * 折扣类型 - * - * 冗余 {@link CouponTemplateDO#getDiscountType()} - */ - private Integer discountType; - /** - * 折扣百分比 - * - * 冗余 {@link CouponTemplateDO#getDiscountPercent()} - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - * - * 冗余 {@link CouponTemplateDO#getDiscountPrice()} - */ - private Integer discountPrice; - /** - * 折扣上限,仅在 {@link #discountType} 等于 {@link PromotionDiscountTypeEnum#PERCENT} 时生效 - * - * 冗余 {@link CouponTemplateDO#getDiscountLimitPrice()} - */ - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 使用情况 BEGIN ========== - /** - * 使用订单号 - */ - private Long useOrderId; - /** - * 使用时间 - */ - private LocalDateTime useTime; - - // ========== 使用情况 END ========== - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java deleted file mode 100644 index ad4ebab9b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java +++ /dev/null @@ -1,166 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.coupon; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 优惠劵模板 DO - * - * 当用户领取时,会生成 {@link CouponDO} 优惠劵 - * - * @author 芋道源码 - */ -@TableName(value = "promotion_coupon_template", autoResultMap = true) -@KeySequence("promotion_coupon_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class CouponTemplateDO extends BaseDO { - - // ========== 基本信息 BEGIN ========== - /** - * 模板编号,自增唯一 - */ - @TableId - private Long id; - /** - * 优惠劵名 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - // TODO 芋艿:要不要改成 3 个状态?? - private Integer status; - - // ========== 基本信息 END ========== - - // ========== 领取规则 BEGIN ========== - /** - * 发放数量 - * - * -1 - 则表示不限制发放数量 - */ - private Integer totalCount; - /** - * 每人限领个数 - * - * -1 - 则表示不限制 - */ - private Integer takeLimitCount; - /** - * 领取方式 - * - * 枚举 {@link CouponTakeTypeEnum} - */ - private Integer takeType; - // ========== 领取规则 END ========== - - // ========== 使用规则 BEGIN ========== - /** - * 是否设置满多少金额可用,单位:分 - * - * 0 - 不限制 - * 大于 0 - 多少金额可用 - */ - private Integer usePrice; - /** - * 商品范围 - * - * 枚举 {@link PromotionProductScopeEnum} - */ - private Integer productScope; - /** - * 商品范围编号的数组 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List productScopeValues; - /** - * 生效日期类型 - * - * 枚举 {@link CouponTemplateValidityTypeEnum} - */ - private Integer validityType; - /** - * 固定日期 - 生效开始时间 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#DATE} - */ - private LocalDateTime validStartTime; - /** - * 固定日期 - 生效结束时间 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#DATE} - */ - private LocalDateTime validEndTime; - /** - * 领取日期 - 开始天数 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#TERM} - */ - private Integer fixedStartTerm; - /** - * 领取日期 - 结束天数 - * - * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#TERM} - */ - private Integer fixedEndTerm; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - /** - * 折扣类型 - * - * 枚举 {@link PromotionDiscountTypeEnum} - */ - private Integer discountType; - /** - * 折扣百分比 - * - * 例如,80% 为 80 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - * - * 当 {@link #discountType} 为 {@link PromotionDiscountTypeEnum#PRICE} 生效 - */ - private Integer discountPrice; - /** - * 折扣上限,仅在 {@link #discountType} 等于 {@link PromotionDiscountTypeEnum#PERCENT} 时生效 - * - * 例如,折扣上限为 20 元,当使用 8 折优惠券,订单金额为 1000 元时,最高只可折扣 20 元,而非 80 元。 - */ - private Integer discountLimitPrice; - // ========== 使用效果 END ========== - - // ========== 统计信息 BEGIN ========== - /** - * 领取优惠券的数量 - */ - private Integer takeCount; - /** - * 使用优惠券的次数 - */ - private Integer useCount; - // ========== 统计信息 END ========== - - // TODO 芋艿:领取开始时间、领取结束时间 - - // TODO 芋艿:要不要加描述 -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountActivityDO.java deleted file mode 100644 index 956a223be..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountActivityDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.discount; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; - -/** - * 限时折扣活动 DO - * - * 一个活动下,可以有 {@link DiscountProductDO} 商品; - * 一个商品,在指定时间段内,只能属于一个活动; - * - * @author 芋道源码 - */ -@TableName(value = "promotion_discount_activity", autoResultMap = true) -@KeySequence("promotion_discount_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class DiscountActivityDO extends BaseDO { - - /** - * 活动编号,主键自增 - */ - @TableId - private Long id; - /** - * 活动标题 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - * - * 活动被关闭后,不允许再次开启。 - */ - private Integer status; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountProductDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountProductDO.java deleted file mode 100644 index 12b6822d6..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountProductDO.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.discount; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; - -/** - * 限时折扣商品 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_discount_product", autoResultMap = true) -@KeySequence("promotion_discount_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class DiscountProductDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 限时折扣活动的编号 - * - * 关联 {@link DiscountActivityDO#getId()} - */ - private Long activityId; - - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的 id 编号 - */ - private Long skuId; - - /** - * 折扣类型 - * - * 枚举 {@link PromotionDiscountTypeEnum} - */ - private Integer discountType; - /** - * 折扣百分比 - * - * 例如,80% 为 80 - */ - private Integer discountPercent; - /** - * 优惠金额,单位:分 - * - * 当 {@link #discountType} 为 {@link PromotionDiscountTypeEnum#PRICE} 生效 - */ - private Integer discountPrice; - - /** - * 活动状态 - * - * 关联 {@link DiscountActivityDO#getStatus()} - */ - private Integer activityStatus; - /** - * 活动开始时间点 - * - * 冗余 {@link DiscountActivityDO#getStartTime()} - */ - private LocalDateTime activityStartTime; - /** - * 活动结束时间点 - * - * 冗余 {@link DiscountActivityDO#getEndTime()} - */ - private LocalDateTime activityEndTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java deleted file mode 100644 index e1c0dd376..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyPageDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.diy; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.StringListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.util.List; - -/** - * 装修页面 DO - * - * @author owen - */ -@TableName(value = "promotion_diy_page", autoResultMap = true) -@KeySequence("promotion_diy_page_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class DiyPageDO extends BaseDO { - - /** - * 装修页面编号 - */ - @TableId - private Long id; - /** - * 装修模板编号 - * - * 关联 {@link DiyTemplateDO#getId()} - */ - private Long templateId; - /** - * 页面名称 - */ - private String name; - /** - * 备注 - */ - private String remark; - /** - * 预览图,多个逗号分隔 - */ - @TableField(typeHandler = StringListTypeHandler.class) - private List previewPicUrls; - /** - * 页面属性,JSON 格式 - */ - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java deleted file mode 100644 index 1b7e1d592..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/diy/DiyTemplateDO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.diy; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.StringListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 装修模板 DO - * - * 1. 新建一个模版,下面可以包含多个 {@link DiyPageDO} 页面,例如说首页、我的 - * 2. 如果需要使用某个模版,则将 {@link #used} 设置为 true,表示已使用,有且仅有一个 - * - * @author owen - */ -@TableName(value = "promotion_diy_template", autoResultMap = true) -@KeySequence("promotion_diy_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class DiyTemplateDO extends BaseDO { - - /** - * 装修模板编号 - */ - @TableId - private Long id; - /** - * 模板名称 - */ - private String name; - /** - * 是否使用 - */ - private Boolean used; - /** - * 使用时间 - */ - private LocalDateTime usedTime; - /** - * 备注 - */ - private String remark; - - /** - * 预览图 - */ - @TableField(typeHandler = StringListTypeHandler.class) - private List previewPicUrls; - /** - * uni-app 底部导航属性,JSON 格式 - */ - private String property; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java deleted file mode 100644 index 0c0b477ef..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.reward; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; -import java.time.LocalDateTime; -import java.util.List; - -/** - * 满减送活动 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_reward_activity", autoResultMap = true) -@KeySequence("promotion_reward_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -public class RewardActivityDO extends BaseDO { - - /** - * 活动编号,主键自增 - */ - @TableId - private Long id; - /** - * 活动标题 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link PromotionActivityStatusEnum} - */ - private Integer status; - /** - * 开始时间 - */ - private LocalDateTime startTime; - /** - * 结束时间 - */ - private LocalDateTime endTime; - /** - * 备注 - */ - private String remark; - /** - * 条件类型 - * - * 枚举 {@link PromotionConditionTypeEnum} - */ - private Integer conditionType; - /** - * 商品范围 - * - * 枚举 {@link PromotionProductScopeEnum} - */ - private Integer productScope; - /** - * 商品 SPU 编号的数组 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List productSpuIds; - /** - * 优惠规则的数组 - */ - @TableField(typeHandler = RuleTypeHandler.class) - private List rules; - - /** - * 优惠规则 - */ - @Data - public static class Rule implements Serializable { - - /** - * 优惠门槛 - * - * 1. 满 N 元,单位:分 - * 2. 满 N 件 - */ - private Integer limit; - /** - * 优惠价格,单位:分 - */ - private Integer discountPrice; - /** - * 是否包邮 - */ - private Boolean freeDelivery; - /** - * 赠送的积分 - */ - private Integer point; - /** - * 赠送的优惠劵编号的数组 - */ - private List couponIds; - /** - * 赠送的优惠券数量的数组 - */ - private List couponCounts; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class RuleTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List parse(String json) { - return JsonUtils.parseArray(json, Rule.class); - } - - @Override - protected String toJson(List obj) { - return JsonUtils.toJsonString(obj); - } - - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillActivityDO.java deleted file mode 100644 index 76a08ac70..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillActivityDO.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 秒杀活动 DO - * - * @author halfninety - */ -@TableName(value = "promotion_seckill_activity", autoResultMap = true) -@KeySequence("promotion_seckill_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class SeckillActivityDO extends BaseDO { - - /** - * 秒杀活动编号 - */ - @TableId - private Long id; - /** - * 秒杀活动商品 - */ - private Long spuId; - /** - * 秒杀活动名称 - */ - private String name; - /** - * 活动状态 - * - * 枚举 {@link CommonStatusEnum 对应的类} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 活动开始时间 - */ - private LocalDateTime startTime; - /** - * 活动结束时间 - */ - private LocalDateTime endTime; - /** - * 排序 - */ - private Integer sort; - /** - * 秒杀时段 id - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List configIds; - - /** - * 总限购数量 - */ - private Integer totalLimitCount; - /** - * 单次限够数量 - */ - private Integer singleLimitCount; - - /** - * 秒杀库存(剩余库存秒杀时扣减) - */ - private Integer stock; - /** - * 秒杀总库存 - */ - private Integer totalStock; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillConfigDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillConfigDO.java deleted file mode 100644 index 73efb7ad4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillConfigDO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 秒杀时段 DO - * - * @author 芋道源码 - */ -@TableName(value = "promotion_seckill_config", autoResultMap = true) -@KeySequence("promotion_seckill_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SeckillConfigDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 秒杀时段名称 - */ - private String name; - /** - * 开始时间点 - */ - private String startTime; - /** - * 结束时间点 - */ - private String endTime; - /** - * 秒杀轮播图 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List sliderPicUrls; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum 对应的类} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillProductDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillProductDO.java deleted file mode 100644 index 45a2d9e93..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/SeckillProductDO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 秒杀参与商品 DO - * - * @author HUIHUI - */ -@TableName("promotion_seckill_product") -@KeySequence("promotion_seckill_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SeckillProductDO extends BaseDO { - - /** - * 秒杀参与商品编号 - */ - @TableId - private Long id; - /** - * 秒杀活动 id - * - * 关联 {@link SeckillActivityDO#getId()} - */ - private Long activityId; - /** - * 秒杀时段 id - * - * 关联 {@link SeckillConfigDO#getId()} - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List configIds; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 秒杀金额,单位:分 - */ - private Integer seckillPrice; - /** - * 秒杀库存 - */ - private Integer stock; - - /** - * 秒杀商品状态 - * - * 枚举 {@link CommonStatusEnum 对应的类} - */ - private Integer activityStatus; - /** - * 活动开始时间点 - */ - private LocalDateTime activityStartTime; - /** - * 活动结束时间点 - */ - private LocalDateTime activityEndTime; - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleCategoryMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleCategoryMapper.java deleted file mode 100644 index d39264b6a..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleCategoryMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 文章分类 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface ArticleCategoryMapper extends BaseMapperX { - - default PageResult selectPage(ArticleCategoryPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ArticleCategoryDO::getName, reqVO.getName()) - .eqIfPresent(ArticleCategoryDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(ArticleCategoryDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ArticleCategoryDO::getSort)); - } - - default List selectListByStatus(Integer status) { - return selectList(ArticleCategoryDO::getStatus, status); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java deleted file mode 100644 index 4ee82471e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 文章管理 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface ArticleMapper extends BaseMapperX { - - default PageResult selectPage(ArticlePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ArticleDO::getCategoryId, reqVO.getCategoryId()) - .eqIfPresent(ArticleDO::getTitle, reqVO.getTitle()) - .eqIfPresent(ArticleDO::getAuthor, reqVO.getAuthor()) - .eqIfPresent(ArticleDO::getStatus, reqVO.getStatus()) - .eqIfPresent(ArticleDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(ArticleDO::getRecommendHot, reqVO.getRecommendHot()) - .eqIfPresent(ArticleDO::getRecommendBanner, reqVO.getRecommendBanner()) - .betweenIfPresent(ArticleDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ArticleDO::getId)); - } - - default List selectList(Boolean recommendHot, Boolean recommendBanner) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(ArticleDO::getRecommendHot, recommendHot) - .eqIfPresent(ArticleDO::getRecommendBanner, recommendBanner)); - } - - default List selectListByTitle(String title) { - return selectList(ArticleDO::getTitle, title); - } - - default PageResult selectPage(AppArticlePageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eqIfPresent(ArticleDO::getCategoryId, pageReqVO.getCategoryId())); - } - - default void updateBrowseCount(Long id) { - update(null, new LambdaUpdateWrapper() - .eq(ArticleDO::getId, id) - .setSql("browse_count = browse_count + 1")); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/banner/BannerMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/banner/BannerMapper.java deleted file mode 100644 index 74bd3c7da..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/banner/BannerMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * Banner Mapper - * - * @author xia - */ -@Mapper -public interface BannerMapper extends BaseMapperX { - - default PageResult selectPage(BannerPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BannerDO::getTitle, reqVO.getTitle()) - .eqIfPresent(BannerDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BannerDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BannerDO::getSort)); - } - - default void updateBrowseCount(Long id) { - update(null, new LambdaUpdateWrapper() - .eq(BannerDO::getId, id) - .setSql("browse_count = browse_count + 1")); - } - - default List selectBannerListByPosition(Integer position) { - return selectList(new LambdaQueryWrapperX().eq(BannerDO::getPosition, position)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java deleted file mode 100644 index 72d604e77..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java +++ /dev/null @@ -1,120 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 砍价活动 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface BargainActivityMapper extends BaseMapperX { - - default PageResult selectPage(BargainActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(BargainActivityDO::getName, reqVO.getName()) - .eqIfPresent(BargainActivityDO::getStatus, reqVO.getStatus()) - .orderByDesc(BargainActivityDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(BargainActivityDO::getStatus, status); - } - - /** - * 更新活动库存 - * - * @param id 活动编号 - * @param count 扣减的库存数量 - * @return 影响的行数 - */ - default int updateStock(Long id, int count) { - // 情况一:增加库存 - if (count > 0) { - return update(null, new LambdaUpdateWrapper() - .eq(BargainActivityDO::getId, id) - .setSql("stock = stock + " + count)); - } - // 情况二:扣减库存 - count = -count; // 取正 - return update(null, new LambdaUpdateWrapper() - .eq(BargainActivityDO::getId, id) - .ge(BargainActivityDO::getStock, count) - .setSql("stock = stock - " + count)); - } - - /** - * 查询处在 now 日期时间且是 status 状态的活动分页 - * - * @param pageReqVO 分页参数 - * @param status 状态 - * @param now 当前日期时间 - * @return 活动分页 - */ - default PageResult selectPage(PageParam pageReqVO, Integer status, LocalDateTime now) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eq(BargainActivityDO::getStatus, status) - .le(BargainActivityDO::getStartTime, now) - .ge(BargainActivityDO::getEndTime, now)); - } - - /** - * 查询处在 now 日期时间且是 status 状态的活动分页 - * - * @param status 状态 - * @param now 当前日期时间 - * @return 活动分页 - */ - default List selectList(Integer count, Integer status, LocalDateTime now) { - return selectList(new LambdaQueryWrapperX() - .eq(BargainActivityDO::getStatus, status) - .le(BargainActivityDO::getStartTime, now) - .ge(BargainActivityDO::getEndTime, now) - .last("LIMIT " + count)); - } - - /** - * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - * - * @param spuIds spu 编号 - * @param status 状态 - * @return 包含 spuId 和 activityId 的 map 对象列表 - */ - default List> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(Collection spuIds, Integer status) { - return selectMaps(new QueryWrapper() - .select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id - .in("spu_id", spuIds) - .eq("status", status) - .groupBy("spu_id")); - } - - /** - * 获取指定活动编号的活动列表且 - * 开始时间和结束时间小于给定时间 dateTime 的活动列表 - * - * @param ids 活动编号 - * @param dateTime 指定日期 - * @return 活动列表 - */ - default List selectListByIdsAndDateTimeLt(Collection ids, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .in(BargainActivityDO::getId, ids) - .lt(BargainActivityDO::getStartTime, dateTime) - .gt(BargainActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动 - .orderByDesc(BargainActivityDO::getCreateTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java deleted file mode 100644 index 8d01ba361..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -@Mapper -public interface BargainHelpMapper extends BaseMapperX { - - default Long selectCountByUserIdAndActivityId(Long userId, Long activityId) { - return selectCount(new LambdaQueryWrapper<>(BargainHelpDO.class) - .eq(BargainHelpDO::getUserId, userId) - .eq(BargainHelpDO::getActivityId, activityId)); - } - - default Long selectUserCountMapByRecordId(Long recordId) { - return selectCount(BargainHelpDO::getRecordId, recordId); - } - - default BargainHelpDO selectByUserIdAndRecordId(Long userId, Long recordId) { - return selectOne(new LambdaQueryWrapper<>(BargainHelpDO.class) - .eq(BargainHelpDO::getUserId, userId) - .eq(BargainHelpDO::getRecordId, recordId)); - } - - default Map selectUserCountMapByActivityId(Collection activityIds) { - // SQL count 查询 - List> result = selectMaps(new QueryWrapper() - .select("COUNT(DISTINCT(user_id)) AS userCount, activity_id AS activityId") - .in("activity_id", activityIds) - .groupBy("activity_id")); - if (CollUtil.isEmpty(result)) { - return Collections.emptyMap(); - } - // 转换数据 - return CollectionUtils.convertMap(result, - record -> MapUtil.getLong(record, "activityId"), - record -> MapUtil.getInt(record, "userCount" )); - } - - default Map selectUserCountMapByRecordId(Collection recordIds) { - // SQL count 查询 - List> result = selectMaps(new QueryWrapper() - .select("COUNT(1) AS userCount, record_id AS recordId") - .in("record_id", recordIds) - .groupBy("record_id")); - if (CollUtil.isEmpty(result)) { - return Collections.emptyMap(); - } - // 转换数据 - return CollectionUtils.convertMap(result, - record -> MapUtil.getLong(record, "recordId"), - record -> MapUtil.getInt(record, "userCount" )); - } - - default PageResult selectPage(BargainHelpPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BargainHelpDO::getRecordId, reqVO.getRecordId()) - .orderByDesc(BargainHelpDO::getId)); - } - - default List selectListByRecordId(Long recordId) { - return selectList(new LambdaQueryWrapperX() - .eq(BargainHelpDO::getRecordId, recordId)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java deleted file mode 100644 index 17560db82..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * 砍价记录 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface BargainRecordMapper extends BaseMapperX { - - default BargainRecordDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(BargainRecordDO::getId, id, - BargainRecordDO::getUserId, userId); - } - - default List selectListByUserIdAndActivityIdAndStatus( - Long userId, Long activityId, Integer status) { - return selectList(new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getUserId, userId) - .eq(BargainRecordDO::getActivityId, activityId) - .eq(BargainRecordDO::getStatus, status)); - } - - default BargainRecordDO selectLastByUserIdAndActivityId(Long userId, Long activityId) { - return selectOne(new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getUserId, userId) - .eq(BargainRecordDO::getActivityId, activityId) - .orderByDesc(BargainRecordDO::getId) - .last("LIMIT 1")); - } - - default Long selectCountByUserIdAndActivityIdAndStatus( - Long userId, Long activityId, Integer status) { - return selectCount(new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getUserId, userId) - .eq(BargainRecordDO::getActivityId, activityId) - .eq(BargainRecordDO::getStatus, status)); - } - - default int updateByIdAndBargainPrice(Long id, Integer whereBargainPrice, BargainRecordDO updateObj) { - return update(updateObj, new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getId, id) - .eq(BargainRecordDO::getBargainPrice, whereBargainPrice)); - } - - default Map selectUserCountByActivityIdsAndStatus(Collection activityIds, Integer status) { - // SQL count 查询 - List> result = selectMaps(new QueryWrapper() - .select("COUNT(DISTINCT(user_id)) AS userCount, activity_id AS activityId") - .in("activity_id", activityIds) - .eq(status != null, "status", status) - .groupBy("activity_id")); - if (CollUtil.isEmpty(result)) { - return Collections.emptyMap(); - } - // 转换数据 - return CollectionUtils.convertMap(result, - record -> MapUtil.getLong(record, "activityId"), - record -> MapUtil.getInt(record, "userCount" )); - } - - @Select("SELECT COUNT(DISTINCT(user_id)) FROM promotion_bargain_record " + - "WHERE status = #{status}") - Integer selectUserCountByStatus(@Param("status") Integer status); - - @Select("SELECT COUNT(DISTINCT(user_id)) FROM promotion_bargain_record " + - "WHERE activity_id = #{activityId} " + - "AND status = #{status}") - Integer selectUserCountByActivityIdAndStatus(@Param("activityId") Long activityId, - @Param("status") Integer status); - - default PageResult selectPage(BargainRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BargainRecordDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BargainRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BargainRecordDO::getId)); - } - - default PageResult selectBargainRecordPage(Long userId, PageParam pageParam) { - return selectPage(pageParam, new LambdaQueryWrapperX() - .eq(BargainRecordDO::getUserId, userId) - .orderByDesc(BargainRecordDO::getId)); - } - - default List selectListByStatusAndCount(Integer status, Integer count) { - return selectList(new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getStatus, status) - .last("LIMIT " + count)); - } - - /** - * 更新砍价的订单编号,前提是 orderId 原本是空的 - * - * @param id 砍价记录编号 - * @param orderId 订单编号 - * @return 更新数量 - */ - default int updateOrderIdById(Long id, Long orderId) { - return update(new BargainRecordDO().setOrderId(orderId).setEndTime(LocalDateTime.now()), - new LambdaQueryWrapper<>(BargainRecordDO.class) - .eq(BargainRecordDO::getId, id) - .isNull(BargainRecordDO::getOrderId)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java deleted file mode 100644 index 55e975c45..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.combination; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 拼团活动 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CombinationActivityMapper extends BaseMapperX { - - default PageResult selectPage(CombinationActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(CombinationActivityDO::getName, reqVO.getName()) - .eqIfPresent(CombinationActivityDO::getStatus, reqVO.getStatus()) - .orderByDesc(CombinationActivityDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(CombinationActivityDO::getStatus, status); - } - - default PageResult selectPage(PageParam pageParam, Integer status) { - return selectPage(pageParam, new LambdaQueryWrapperX() - .eq(CombinationActivityDO::getStatus, status)); - } - - default List selectListByStatus(Integer status, Integer count) { - return selectList(new LambdaQueryWrapperX() - .eq(CombinationActivityDO::getStatus, status) - .last("LIMIT " + count)); - } - - /** - * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - * @param spuIds spu 编号 - * @param status 状态 - * @return 包含 spuId 和 activityId 的 map 对象列表 - */ - default List> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(@Param("spuIds") Collection spuIds, @Param("status") Integer status) { - return selectMaps(new QueryWrapper() - .select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id - .in("spu_id", spuIds) - .eq("status", status) - .groupBy("spu_id")); - } - - /** - * 获取指定活动编号的活动列表且 - * 开始时间和结束时间小于给定时间 dateTime 的活动列表 - * - * @param ids 活动编号 - * @param dateTime 指定日期 - * @return 活动列表 - */ - default List selectListByIdsAndDateTimeLt(Collection ids, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .in(CombinationActivityDO::getId, ids) - .lt(CombinationActivityDO::getStartTime, dateTime) - .gt(CombinationActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动 - .orderByDesc(CombinationActivityDO::getCreateTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationProductMapper.java deleted file mode 100644 index 5d80b6d09..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationProductMapper.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.combination; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 拼团商品 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CombinationProductMapper extends BaseMapperX { - - default PageResult selectPage(CombinationProductPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CombinationProductDO::getActivityId, reqVO.getActivityId()) - .eqIfPresent(CombinationProductDO::getSpuId, reqVO.getSpuId()) - .eqIfPresent(CombinationProductDO::getSkuId, reqVO.getSkuId()) - .eqIfPresent(CombinationProductDO::getActivityStatus, reqVO.getActivityStatus()) - .betweenIfPresent(CombinationProductDO::getActivityStartTime, reqVO.getActivityStartTime()) - .betweenIfPresent(CombinationProductDO::getActivityEndTime, reqVO.getActivityEndTime()) - .eqIfPresent(CombinationProductDO::getCombinationPrice, reqVO.getActivePrice()) - .betweenIfPresent(CombinationProductDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(CombinationProductDO::getId)); - } - - default List selectListByActivityIds(Collection ids) { - return selectList(CombinationProductDO::getActivityId, ids); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java deleted file mode 100644 index 04c1c6157..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java +++ /dev/null @@ -1,154 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * 拼团记录 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CombinationRecordMapper extends BaseMapperX { - - default CombinationRecordDO selectByUserIdAndOrderId(Long userId, Long orderId) { - return selectOne(CombinationRecordDO::getUserId, userId, - CombinationRecordDO::getOrderId, orderId); - } - - /** - * 查询拼团记录 - * - * @param headId 团长编号 - * @return 拼团记录 - */ - default CombinationRecordDO selectByHeadId(Long headId, Integer status) { - return selectOne(new LambdaQueryWrapperX() - .eq(CombinationRecordDO::getId, headId) - .eq(CombinationRecordDO::getStatus, status)); - } - - /** - * 查询拼团记录 - * - * @param userId 用户 id - * @param activityId 活动 id - * @return 拼团记录 - */ - default List selectListByUserIdAndActivityId(Long userId, Long activityId) { - return selectList(new LambdaQueryWrapperX() - .eq(CombinationRecordDO::getUserId, userId) - .eq(CombinationRecordDO::getActivityId, activityId)); - } - - /** - * 获取最近的 count 条数据 - * - * @param count 数量 - * @return 拼团记录列表 - */ - default List selectLatestList(int count) { - return selectList(new LambdaQueryWrapperX() - .orderByDesc(CombinationRecordDO::getId) - .last("LIMIT " + count)); - } - - default List selectListByActivityIdAndStatusAndHeadId(Long activityId, Integer status, - Long headId, Integer count) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(CombinationRecordDO::getActivityId, activityId) - .eqIfPresent(CombinationRecordDO::getStatus, status) - .eq(CombinationRecordDO::getHeadId, headId) - .orderByDesc(CombinationRecordDO::getId) - .last("LIMIT " + count)); - } - - default Map selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(Collection activityIds, - Integer status, Long headId) { - // SQL count 查询 - List> result = selectMaps(new QueryWrapper() - .select("COUNT(DISTINCT(user_id)) AS recordCount, activity_id AS activityId") - .in("activity_id", activityIds) - .eq(status != null, "status", status) - .eq(headId != null, "head_id", headId) - .groupBy("activity_id")); - if (CollUtil.isEmpty(result)) { - return Collections.emptyMap(); - } - // 转换数据 - return CollectionUtils.convertMap(result, - record -> MapUtil.getLong(record, "activityId"), - record -> MapUtil.getInt(record, "recordCount")); - } - - default PageResult selectPage(CombinationRecordReqPageVO pageVO) { - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX() - .eqIfPresent(CombinationRecordDO::getStatus, pageVO.getStatus()) - .betweenIfPresent(CombinationRecordDO::getCreateTime, pageVO.getCreateTime()); - // 如果 headId 非空,说明查询指定团的团长 + 团员的拼团记录 - if (pageVO.getHeadId() != null) { - queryWrapper.eq(CombinationRecordDO::getId, pageVO.getHeadId()) // 团长 - .or().eq(CombinationRecordDO::getHeadId, pageVO.getHeadId()); // 团员 - } - return selectPage(pageVO, queryWrapper); - } - - /** - * 查询指定条件的记录数 - * - * @param status 状态,可为 null - * @param virtualGroup 是否虚拟成团,可为 null - * @param headId 团长编号,可为 null - * @return 记录数 - */ - default Long selectCountByHeadAndStatusAndVirtualGroup(Integer status, Boolean virtualGroup, Long headId) { - return selectCount(new LambdaQueryWrapperX() - .eqIfPresent(CombinationRecordDO::getStatus, status) - .eqIfPresent(CombinationRecordDO::getVirtualGroup, virtualGroup) - .eqIfPresent(CombinationRecordDO::getHeadId, headId)); - } - - /** - * 查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次 - * - * @return 参加过拼团的用户数 - */ - default Long selectUserCount() { - return selectCount(new QueryWrapper() - .select("DISTINCT (user_id)")); - } - - default List selectListByHeadIdAndStatusAndExpireTimeLt(Long headId, Integer status, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .eq(CombinationRecordDO::getHeadId, headId) - .eq(CombinationRecordDO::getStatus, status) - .lt(CombinationRecordDO::getExpireTime, dateTime)); - } - - default List selectListByHeadId(Long headId) { - return selectList(CombinationRecordDO::getHeadId, headId); - } - - default PageResult selectPage(Long userId, AppCombinationRecordPageReqVO pageReqVO) { - LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX() - .eq(CombinationRecordDO::getUserId, userId) - .eqIfPresent(CombinationRecordDO::getStatus, pageReqVO.getStatus()); - return selectPage(pageReqVO, queryWrapper); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java deleted file mode 100755 index e5f1daf6c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponMapper.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.coupon; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.github.yulichang.toolkit.MPJWrappers; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 优惠劵 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CouponMapper extends BaseMapperX { - - default PageResult selectPage(CouponPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CouponDO::getTemplateId, reqVO.getTemplateId()) - .eqIfPresent(CouponDO::getStatus, reqVO.getStatus()) - .inIfPresent(CouponDO::getUserId, reqVO.getUserIds()) - .betweenIfPresent(CouponDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(CouponDO::getId)); - } - - default List selectListByUserIdAndStatus(Long userId, Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(CouponDO::getUserId, userId).eq(CouponDO::getStatus, status)); - } - - default CouponDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(new LambdaQueryWrapperX() - .eq(CouponDO::getId, id).eq(CouponDO::getUserId, userId)); - } - - default int delete(Long id, Collection whereStatuses) { - return update(null, new LambdaUpdateWrapper() - .eq(CouponDO::getId, id).in(CouponDO::getStatus, whereStatuses) - .set(CouponDO::getDeleted, 1)); - } - - default int updateByIdAndStatus(Long id, Integer status, CouponDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(CouponDO::getId, id).eq(CouponDO::getStatus, status)); - } - - default Long selectCountByUserIdAndStatus(Long userId, Integer status) { - return selectCount(new LambdaQueryWrapperX() - .eq(CouponDO::getUserId, userId) - .eq(CouponDO::getStatus, status)); - } - - default List selectListByTemplateIdAndUserId(Long templateId, Collection userIds) { - return selectList(new LambdaQueryWrapperX() - .eq(CouponDO::getTemplateId, templateId) - .in(CouponDO::getUserId, userIds) - ); - } - - default Map selectCountByUserIdAndTemplateIdIn(Long userId, Collection templateIds) { - String templateIdAlias = "templateId"; - String countAlias = "count"; - List> list = selectMaps(MPJWrappers.lambdaJoin(CouponDO.class) - .selectAs(CouponDO::getTemplateId, templateIdAlias) - .selectCount(CouponDO::getId, countAlias) - .eq(CouponDO::getUserId, userId) - .in(CouponDO::getTemplateId, templateIds) - .groupBy(CouponDO::getTemplateId)); - return convertMap(list, map -> MapUtil.getLong(map, templateIdAlias), map -> MapUtil.getInt(map, countAlias)); - } - - default List selectListByUserIdAndStatusAndUsePriceLeAndProductScope( - Long userId, Integer status, Integer usePrice, List spuIds, List categoryIds) { - Function, String> productScopeValuesFindInSetFunc = ids -> ids.stream() - .map(id -> StrUtil.format("FIND_IN_SET({}, product_scope_values) ", id)) - .collect(Collectors.joining(" OR ")); - return selectList(new LambdaQueryWrapperX() - .eq(CouponDO::getUserId, userId) - .eq(CouponDO::getStatus, status) - .le(CouponDO::getUsePrice, usePrice) // 价格小于等于,满足价格使用条件 - .and(w -> w.eq(CouponDO::getProductScope, PromotionProductScopeEnum.ALL.getScope()) // 商品范围一:全部 - .or(ww -> ww.eq(CouponDO::getProductScope, PromotionProductScopeEnum.SPU.getScope()) // 商品范围二:满足指定商品 - .apply(productScopeValuesFindInSetFunc.apply(spuIds))) - .or(ww -> ww.eq(CouponDO::getProductScope, PromotionProductScopeEnum.CATEGORY.getScope()) // 商品范围三:满足指定分类 - .apply(productScopeValuesFindInSetFunc.apply(categoryIds))))); - } - - default List selectListByStatusAndValidEndTimeLe(Integer status, LocalDateTime validEndTime) { - return selectList(new LambdaQueryWrapperX() - .eq(CouponDO::getStatus, status) - .le(CouponDO::getValidEndTime, validEndTime) - ); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java deleted file mode 100755 index 50e3c0315..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.function.Consumer; - -/** - * 优惠劵模板 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface CouponTemplateMapper extends BaseMapperX { - - default PageResult selectPage(CouponTemplatePageReqVO reqVO) { - // 构建可领取的查询条件 - Consumer> canTakeConsumer = buildCanTakeQueryConsumer(reqVO.getCanTakeTypes()); - // 执行分页查询 - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(CouponTemplateDO::getName, reqVO.getName()) - .eqIfPresent(CouponTemplateDO::getStatus, reqVO.getStatus()) - .eqIfPresent(CouponTemplateDO::getDiscountType, reqVO.getDiscountType()) - .betweenIfPresent(CouponTemplateDO::getCreateTime, reqVO.getCreateTime()) - .eqIfPresent(CouponTemplateDO::getProductScope, reqVO.getProductScope()) - .and(reqVO.getProductScopeValue() != null, w -> w.apply("FIND_IN_SET({0}, product_scope_values)", - reqVO.getProductScopeValue())) - .and(canTakeConsumer != null, canTakeConsumer) - .orderByDesc(CouponTemplateDO::getId)); - } - - default void updateTakeCount(Long id, Integer incrCount) { - update(null, new LambdaUpdateWrapper() - .eq(CouponTemplateDO::getId, id) - .setSql("take_count = take_count + " + incrCount)); - } - - default List selectListByTakeType(Integer takeType) { - return selectList(CouponTemplateDO::getTakeType, takeType); - } - - default List selectList(List canTakeTypes, Integer productScope, Long productScopeValue, Integer count) { - // 构建可领取的查询条件 - Consumer> canTakeConsumer = buildCanTakeQueryConsumer(canTakeTypes); - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(CouponTemplateDO::getProductScope, productScope) - .and(productScopeValue != null, w -> w.apply("FIND_IN_SET({0}, product_scope_values)", - productScopeValue)) - .and(canTakeConsumer != null, canTakeConsumer) - .last(" LIMIT " + count) - .orderByDesc(CouponTemplateDO::getId)); - } - - static Consumer> buildCanTakeQueryConsumer(List canTakeTypes) { - Consumer> canTakeConsumer = null; - if (CollUtil.isNotEmpty(canTakeTypes)) { - canTakeConsumer = w -> - w.eq(CouponTemplateDO::getStatus, CommonStatusEnum.ENABLE.getStatus()) // 1. 状态为可用的 - .in(CouponTemplateDO::getTakeType, canTakeTypes) // 2. 领取方式一致 - .and(ww -> ww.gt(CouponTemplateDO::getValidEndTime, LocalDateTime.now()) // 3.1 未过期 - .or().eq(CouponTemplateDO::getValidityType, CouponTemplateValidityTypeEnum.TERM.getType())) // 3.2 领取之后 - .apply(" (take_count < total_count OR total_count = -1 )"); // 4. 剩余数量大于 0,或者无限领取 - } - return canTakeConsumer; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountActivityMapper.java deleted file mode 100755 index efd4e4d25..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountActivityMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.discount; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 限时折扣活动 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface DiscountActivityMapper extends BaseMapperX { - - default PageResult selectPage(DiscountActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DiscountActivityDO::getName, reqVO.getName()) - .eqIfPresent(DiscountActivityDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DiscountActivityDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(DiscountActivityDO::getId)); - } - - /** - * 获取指定活动编号的活动列表且 - * 开始时间和结束时间小于给定时间 dateTime 的活动列表 - * - * @param ids 活动编号 - * @param dateTime 指定日期 - * @return 活动列表 - */ - default List selectListByIdsAndDateTimeLt(Collection ids, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .in(DiscountActivityDO::getId, ids) - .lt(DiscountActivityDO::getStartTime, dateTime) - .gt(DiscountActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动 - .orderByDesc(DiscountActivityDO::getCreateTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountProductMapper.java deleted file mode 100755 index 5257b836d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountProductMapper.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.discount; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 限时折扣商城 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface DiscountProductMapper extends BaseMapperX { - - default List selectListBySkuId(Collection skuIds) { - return selectList(DiscountProductDO::getSkuId, skuIds); - } - - default List selectListByActivityId(Long activityId) { - return selectList(DiscountProductDO::getActivityId, activityId); - } - - default List selectListByActivityId(Collection activityIds) { - return selectList(DiscountProductDO::getActivityId, activityIds); - } - - // TODO @zhangshuai:逻辑里,尽量避免写 join 语句哈,你可以看看这个查询,有什么办法优化?目前的一个思路,是分 2 次查询,性能也是 ok 的 - List getMatchDiscountProductList(@Param("skuIds") Collection skuIds); - - /** - * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - * - * @param spuIds spu 编号 - * @param status 状态 - * @return 包含 spuId 和 activityId 的 map 对象列表 - */ - default List> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(Collection spuIds, Integer status) { - return selectMaps(new QueryWrapper() - .select("spu_id AS spuId, MAX(DISTINCT(activity_id)) AS activityId") - .in("spu_id", spuIds) - .eq("activity_status", status) - .groupBy("spu_id")); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyPageMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyPageMapper.java deleted file mode 100644 index 979b93f25..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyPageMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 装修页面 Mapper - * - * @author owen - */ -@Mapper -public interface DiyPageMapper extends BaseMapperX { - - default PageResult selectPage(DiyPagePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DiyPageDO::getName, reqVO.getName()) - .betweenIfPresent(DiyPageDO::getCreateTime, reqVO.getCreateTime()) - // 模板下面的页面,在模板中管理 - .isNull(DiyPageDO::getTemplateId) - .orderByDesc(DiyPageDO::getId)); - } - - default List selectListByTemplateId(Long templateId) { - return selectList(DiyPageDO::getTemplateId, templateId); - } - - default DiyPageDO selectByNameAndTemplateIdIsNull(String name) { - return selectOne(new LambdaQueryWrapperX() - .eq(DiyPageDO::getName, name) - .isNull(DiyPageDO::getTemplateId)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyTemplateMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyTemplateMapper.java deleted file mode 100644 index ca3c6284e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/diy/DiyTemplateMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 装修模板 Mapper - * - * @author owen - */ -@Mapper -public interface DiyTemplateMapper extends BaseMapperX { - - default PageResult selectPage(DiyTemplatePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DiyTemplateDO::getName, reqVO.getName()) - .eqIfPresent(DiyTemplateDO::getUsed, reqVO.getUsed()) - .betweenIfPresent(DiyTemplateDO::getUsedTime, reqVO.getUsedTime()) - .betweenIfPresent(DiyTemplateDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(DiyTemplateDO::getUsed) // 排序规则1:已使用的排到最前面 - .orderByDesc(DiyTemplateDO::getId)); // 排序规则2:新创建的排到前面 - } - - default DiyTemplateDO selectByUsed(boolean used) { - return selectOne(DiyTemplateDO::getUsed, used); - } - - default DiyTemplateDO selectByName(String name) { - return selectOne(DiyTemplateDO::getName, name); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/reward/RewardActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/reward/RewardActivityMapper.java deleted file mode 100755 index ca9e9668f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/reward/RewardActivityMapper.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.reward; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * 满减送活动 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface RewardActivityMapper extends BaseMapperX { - - default PageResult selectPage(RewardActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(RewardActivityDO::getName, reqVO.getName()) - .eqIfPresent(RewardActivityDO::getStatus, reqVO.getStatus()) - .orderByDesc(RewardActivityDO::getId)); - } - - default List selectListByStatus(Collection statuses) { - return selectList(RewardActivityDO::getStatus, statuses); - } - - default List selectListByProductScopeAndStatus(Integer productScope, Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(RewardActivityDO::getProductScope, productScope) - .eq(RewardActivityDO::getStatus, status)); - } - - default List selectListBySpuIdsAndStatus(Collection spuIds, Integer status) { - Function, String> productScopeValuesFindInSetFunc = ids -> ids.stream() - .map(id -> StrUtil.format("FIND_IN_SET({}, product_spu_ids) ", id)) - .collect(Collectors.joining(" OR ")); - return selectList(new QueryWrapper() - .eq("status", status) - .apply(productScopeValuesFindInSetFunc.apply(spuIds))); - } - - /** - * 获取指定活动编号的活动列表且 - * 开始时间和结束时间小于给定时间 dateTime 的活动列表 - * - * @param ids 活动编号 - * @param dateTime 指定日期 - * @return 活动列表 - */ - default List selectListByIdsAndDateTimeLt(Collection ids, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .in(RewardActivityDO::getId, ids) - .lt(RewardActivityDO::getStartTime, dateTime) - .gt(RewardActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动 - .orderByDesc(RewardActivityDO::getCreateTime) - ); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java deleted file mode 100644 index ca40e7602..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 秒杀活动 Mapper - * - * @author halfninety - */ -@Mapper -public interface SeckillActivityMapper extends BaseMapperX { - - default PageResult selectPage(SeckillActivityPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(SeckillActivityDO::getName, reqVO.getName()) - .eqIfPresent(SeckillActivityDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(SeckillActivityDO::getCreateTime, reqVO.getCreateTime()) - .apply(ObjectUtil.isNotNull(reqVO.getConfigId()), "FIND_IN_SET(" + reqVO.getConfigId() + ", config_ids) > 0") - .orderByDesc(SeckillActivityDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(SeckillActivityDO::getStatus, status)); - } - - /** - * 更新活动库存(减少) - * - * @param id 活动编号 - * @param count 扣减的库存数量(正数) - * @return 影响的行数 - */ - default int updateStockDecr(Long id, int count) { - Assert.isTrue(count > 0); - return update(null, new LambdaUpdateWrapper() - .eq(SeckillActivityDO::getId, id) - .gt(SeckillActivityDO::getStock, count) - .setSql("stock = stock - " + count)); - } - - /** - * 更新活动库存(增加) - * - * @param id 活动编号 - * @param count 增加的库存数量(正数) - * @return 影响的行数 - */ - default int updateStockIncr(Long id, int count) { - Assert.isTrue(count > 0); - return update(null, new LambdaUpdateWrapper() - .eq(SeckillActivityDO::getId, id) - .setSql("stock = stock + " + count)); - } - - default PageResult selectPage(AppSeckillActivityPageReqVO pageReqVO, Integer status) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eqIfPresent(SeckillActivityDO::getStatus, status) - // TODO 芋艿:对 find in set 的想法; - .apply(ObjectUtil.isNotNull(pageReqVO.getConfigId()), "FIND_IN_SET(" + pageReqVO.getConfigId() + ",config_ids) > 0")); - } - - /** - * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - * - * @param spuIds spu 编号 - * @param status 状态 - * @return 包含 spuId 和 activityId 的 map 对象列表 - */ - default List> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(@Param("spuIds") Collection spuIds, @Param("status") Integer status) { - return selectMaps(new QueryWrapper() - .select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id - .in("spu_id", spuIds) - .eq("status", status) - .groupBy("spu_id")); - } - - /** - * 获取指定活动编号的活动列表且 - * 开始时间和结束时间小于给定时间 dateTime 的活动列表 - * - * @param ids 活动编号 - * @param dateTime 指定日期 - * @return 活动列表 - */ - default List selectListByIdsAndDateTimeLt(Collection ids, LocalDateTime dateTime) { - return selectList(new LambdaQueryWrapperX() - .in(SeckillActivityDO::getId, ids) - .lt(SeckillActivityDO::getStartTime, dateTime) - .gt(SeckillActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动 - .orderByDesc(SeckillActivityDO::getCreateTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java deleted file mode 100644 index 8fb140179..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -/** - * 秒杀活动商品 Mapper - * - * @author halfninety - */ -@Mapper -public interface SeckillProductMapper extends BaseMapperX { - - default List selectListByActivityId(Long activityId) { - return selectList(SeckillProductDO::getActivityId, activityId); - } - - default SeckillProductDO selectByActivityIdAndSkuId(Long activityId, Long skuId) { - return selectOne(SeckillProductDO::getActivityId, activityId, - SeckillProductDO::getSkuId, skuId); - } - - default List selectListByActivityId(Collection ids) { - return selectList(SeckillProductDO::getActivityId, ids); - } - - /** - * 更新活动库存(减少) - * - * @param id 活动编号 - * @param count 扣减的库存数量(减少库存) - * @return 影响的行数 - */ - default int updateStockDecr(Long id, int count) { - Assert.isTrue(count > 0); - return update(null, new LambdaUpdateWrapper() - .eq(SeckillProductDO::getId, id) - .ge(SeckillProductDO::getStock, count) - .setSql("stock = stock - " + count)); - } - - /** - * 更新活动库存(增加) - * - * @param id 活动编号 - * @param count 需要增加的库存(增加库存) - * @return 影响的行数 - */ - default int updateStockIncr(Long id, int count) { - Assert.isTrue(count > 0); - return update(null, new LambdaUpdateWrapper() - .eq(SeckillProductDO::getId, id) - .setSql("stock = stock + " + count)); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillconfig/SeckillConfigMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillconfig/SeckillConfigMapper.java deleted file mode 100644 index f1dcaca32..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillconfig/SeckillConfigMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillconfig; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface SeckillConfigMapper extends BaseMapperX { - - default PageResult selectPage(SeckillConfigPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(SeckillConfigDO::getName, reqVO.getName()) - .eqIfPresent(SeckillConfigDO::getStatus, reqVO.getStatus()) - .orderByAsc(SeckillConfigDO::getStartTime)); - } - - default List selectListByStatus(Integer status) { - return selectList(SeckillConfigDO::getStatus, status); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/package-info.java deleted file mode 100644 index b2131910d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 promotion 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.promotion.framework; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/config/RpcConfiguration.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index 33c4be85b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.promotion.framework.rpc.config; - -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.product.api.category.ProductCategoryApi; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {ProductSkuApi.class, ProductSpuApi.class, ProductCategoryApi.class, - MemberUserApi.class, TradeOrderApi.class}) -public class RpcConfiguration { -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/package-info.java deleted file mode 100644 index 2484c83e1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.promotion.framework.rpc; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/config/SecurityConfiguration.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 99f1ef547..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.promotion.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.promotion.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Promotion 模块的 Security 配置 - */ -@Configuration("promotionSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("promotionAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/core/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/core/package-info.java deleted file mode 100644 index 72b196292..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.promotion.framework.security.core; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/combination/CombinationRecordExpireJob.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/combination/CombinationRecordExpireJob.java deleted file mode 100644 index 9e86dfc7b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/combination/CombinationRecordExpireJob.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.promotion.job.combination; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -// TODO 芋艿:配置一个 Job -/** - * 拼团过期 Job - * - * @author HUIHUI - */ -@Component -public class CombinationRecordExpireJob { - - @Resource - private CombinationRecordService combinationRecordService; - - @XxlJob("combinationRecordExpireJob") - @TenantJob // 多租户 - public String execute() { - KeyValue keyValue = combinationRecordService.expireCombinationRecord(); - return StrUtil.format("过期拼团 {} 个, 虚拟成团 {} 个", keyValue.getKey(), keyValue.getValue()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/coupon/CouponExpireJob.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/coupon/CouponExpireJob.java deleted file mode 100644 index dc0f9c3a4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/coupon/CouponExpireJob.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.promotion.job.coupon; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -// TODO 芋艿:配置一个 Job -/** - * 优惠券过期 Job - * - * @author owen - */ -@Component -public class CouponExpireJob { - - @Resource - private CouponService couponService; - - @XxlJob("couponExpireJob") - @TenantJob // 多租户 - public String execute() { - int count = couponService.expireCoupon(); - return StrUtil.format("过期优惠券 {} 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/package-info.java deleted file mode 100644 index 320b98aa2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/job/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位,无具体含义 - */ -package cn.iocoder.yudao.module.promotion.job; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/coupon/CouponTakeByRegisterConsumer.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/coupon/CouponTakeByRegisterConsumer.java deleted file mode 100644 index 4d7a092c4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/coupon/CouponTakeByRegisterConsumer.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.promotion.mq.consumer.coupon; - -import cn.iocoder.yudao.module.member.message.user.MemberUserCreateMessage; -import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.event.EventListener; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 用户注册时,发送优惠劵的消费者,基 {@link MemberUserCreateMessage} 消息 - * - * @author owen - */ -@Component -@Slf4j -public class CouponTakeByRegisterConsumer { - - @Resource - private CouponService couponService; - - @EventListener - @Async // Spring Event 默认在 Producer 发送的线程,通过 @Async 实现异步 - public void onMessage(MemberUserCreateMessage message) { - log.info("[onMessage][消息内容({})]", message); - couponService.takeCouponByRegister(message.getUserId()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/package-info.java deleted file mode 100644 index 95c23df74..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/consumer/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的消费者 - */ -package cn.iocoder.yudao.module.promotion.mq.consumer; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/message/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/message/package-info.java deleted file mode 100644 index 912504e76..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/message/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的消息 - */ -package cn.iocoder.yudao.module.promotion.mq.message; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/producer/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/producer/package-info.java deleted file mode 100644 index e7b8d1b4c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/mq/producer/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 消息队列的生产者 - */ -package cn.iocoder.yudao.module.promotion.mq.producer; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/package-info.java deleted file mode 100644 index c022c6276..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * promotion 模块,我们放营销业务。 - * 例如说:营销活动、banner、优惠券等等 - * - * 1. Controller URL:以 /promotion/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 promotion_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.promotion; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryService.java deleted file mode 100644 index 7ce7c0aa0..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryService.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 文章分类 Service 接口 - * - * @author HUIHUI - */ -public interface ArticleCategoryService { - - /** - * 创建文章分类 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createArticleCategory(@Valid ArticleCategoryCreateReqVO createReqVO); - - /** - * 更新文章分类 - * - * @param updateReqVO 更新信息 - */ - void updateArticleCategory(@Valid ArticleCategoryUpdateReqVO updateReqVO); - - /** - * 删除文章分类 - * - * @param id 编号 - */ - void deleteArticleCategory(Long id); - - /** - * 获得文章分类 - * - * @param id 编号 - * @return 文章分类 - */ - ArticleCategoryDO getArticleCategory(Long id); - - /** - * 获得文章分类分页 - * - * @param pageReqVO 分页查询 - * @return 文章分类分页 - */ - PageResult getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO); - - /** - * 获得指定状态的文章分类列表 - * - * @param status 状态 - * @return 文章分类列表 - */ - List getArticleCategoryListByStatus(Integer status); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java deleted file mode 100644 index 9375f498c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleCategoryMapper; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; - -/** - * 文章分类 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class ArticleCategoryServiceImpl implements ArticleCategoryService { - - @Resource - private ArticleCategoryMapper articleCategoryMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖问题 - private ArticleService articleService; - - @Override - public Long createArticleCategory(ArticleCategoryCreateReqVO createReqVO) { - // 插入 - ArticleCategoryDO category = ArticleCategoryConvert.INSTANCE.convert(createReqVO); - articleCategoryMapper.insert(category); - // 返回 - return category.getId(); - } - - @Override - public void updateArticleCategory(ArticleCategoryUpdateReqVO updateReqVO) { - // 校验存在 - validateArticleCategoryExists(updateReqVO.getId()); - // 更新 - ArticleCategoryDO updateObj = ArticleCategoryConvert.INSTANCE.convert(updateReqVO); - articleCategoryMapper.updateById(updateObj); - } - - @Override - public void deleteArticleCategory(Long id) { - // 校验存在 - validateArticleCategoryExists(id); - // 校验是不是存在关联文章 - Long count = articleService.getArticleCountByCategoryId(id); - if (count > 0) { - throw exception(ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES); - } - - // 删除 - articleCategoryMapper.deleteById(id); - } - - private void validateArticleCategoryExists(Long id) { - if (articleCategoryMapper.selectById(id) == null) { - throw exception(ARTICLE_CATEGORY_NOT_EXISTS); - } - } - - @Override - public ArticleCategoryDO getArticleCategory(Long id) { - return articleCategoryMapper.selectById(id); - } - - @Override - public PageResult getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO) { - return articleCategoryMapper.selectPage(pageReqVO); - } - - @Override - public List getArticleCategoryListByStatus(Integer status) { - return articleCategoryMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java deleted file mode 100644 index 24b0fc9fb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 文章 Service 接口 - * - * @author HUIHUI - */ -public interface ArticleService { - - /** - * 创建文章 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createArticle(@Valid ArticleCreateReqVO createReqVO); - - /** - * 更新文章 - * - * @param updateReqVO 更新信息 - */ - void updateArticle(@Valid ArticleUpdateReqVO updateReqVO); - - /** - * 删除文章 - * - * @param id 编号 - */ - void deleteArticle(Long id); - - /** - * 获得文章 - * - * @param id 编号 - * @return 文章 - */ - ArticleDO getArticle(Long id); - - /** - * 基于标题,获得文章 - * - * 如果有重名的文章,获取最后发布的 - * - * @param title 标题 - * @return 文章 - */ - ArticleDO getLastArticleByTitle(String title); - - /** - * 获得文章分页 - * - * @param pageReqVO 分页查询 - * @return 文章分页 - */ - PageResult getArticlePage(ArticlePageReqVO pageReqVO); - - /** - * 获得文章列表 - * - * @param recommendHot 是否热门 - * @param recommendBanner 是否轮播图 - * @return 文章列表 - */ - List getArticleCategoryListByRecommend(Boolean recommendHot, Boolean recommendBanner); - - /** - * 获得文章分页 - * - * @param pageReqVO 分页查询 - * @return 文章分页 - */ - PageResult getArticlePage(AppArticlePageReqVO pageReqVO); - - /** - * 获得指定分类的文章数量 - * - * @param categoryId 文章分类编号 - * @return 文章数量 - */ - Long getArticleCountByCategoryId(Long categoryId); - - /** - * 增加文章浏览量 - * - * @param id 文章编号 - */ - void addArticleBrowseCount(Long id); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java deleted file mode 100644 index 24883657e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java +++ /dev/null @@ -1,123 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.article; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS; - -/** - * 文章管理 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class ArticleServiceImpl implements ArticleService { - - @Resource - private ArticleMapper articleMapper; - - @Resource - private ArticleCategoryService articleCategoryService; - - @Override - public Long createArticle(ArticleCreateReqVO createReqVO) { - // 校验分类存在 - validateArticleCategoryExists(createReqVO.getCategoryId()); - - // 插入 - ArticleDO article = ArticleConvert.INSTANCE.convert(createReqVO); - article.setBrowseCount(0); // 初始浏览量 - articleMapper.insert(article); - // 返回 - return article.getId(); - } - - @Override - public void updateArticle(ArticleUpdateReqVO updateReqVO) { - // 校验存在 - validateArticleExists(updateReqVO.getId()); - // 校验分类存在 - validateArticleCategoryExists(updateReqVO.getCategoryId()); - - // 更新 - ArticleDO updateObj = ArticleConvert.INSTANCE.convert(updateReqVO); - articleMapper.updateById(updateObj); - } - - @Override - public void deleteArticle(Long id) { - // 校验存在 - validateArticleExists(id); - // 删除 - articleMapper.deleteById(id); - } - - private void validateArticleExists(Long id) { - if (articleMapper.selectById(id) == null) { - throw exception(ARTICLE_NOT_EXISTS); - } - } - - private void validateArticleCategoryExists(Long categoryId) { - ArticleCategoryDO articleCategory = articleCategoryService.getArticleCategory(categoryId); - if (articleCategory == null) { - throw exception(ARTICLE_CATEGORY_NOT_EXISTS); - } - } - - @Override - public ArticleDO getArticle(Long id) { - return articleMapper.selectById(id); - } - - @Override - public ArticleDO getLastArticleByTitle(String title) { - List articles = articleMapper.selectListByTitle(title); - return CollUtil.getLast(articles); - } - - @Override - public PageResult getArticlePage(ArticlePageReqVO pageReqVO) { - return articleMapper.selectPage(pageReqVO); - } - - @Override - public List getArticleCategoryListByRecommend(Boolean recommendHot, Boolean recommendBanner) { - return articleMapper.selectList(recommendHot, recommendBanner); - } - - @Override - public PageResult getArticlePage(AppArticlePageReqVO pageReqVO) { - return articleMapper.selectPage(pageReqVO); - } - - @Override - public Long getArticleCountByCategoryId(Long categoryId) { - return articleMapper.selectCount(ArticleDO::getCategoryId, categoryId); - } - - @Override - public void addArticleBrowseCount(Long id) { - // 校验文章是否存在 - validateArticleExists(id); - // 增加浏览次数 - articleMapper.updateBrowseCount(id); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerService.java deleted file mode 100644 index 404f7f5b2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerService.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 首页 Banner Service 接口 - * - * @author xia - */ -public interface BannerService { - - /** - * 创建 Banner - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBanner(@Valid BannerCreateReqVO createReqVO); - - /** - * 更新 Banner - * - * @param updateReqVO 更新信息 - */ - void updateBanner(@Valid BannerUpdateReqVO updateReqVO); - - /** - * 删除 Banner - * - * @param id 编号 - */ - void deleteBanner(Long id); - - /** - * 获得 Banner - * - * @param id 编号 - * @return Banner - */ - BannerDO getBanner(Long id); - - /** - * 获得 Banner 分页 - * - * @param pageReqVO 分页查询 - * @return Banner分页 - */ - PageResult getBannerPage(BannerPageReqVO pageReqVO); - - /** - * 增加 Banner 点击量 - * - * @param id Banner编号 - */ - void addBannerBrowseCount(Long id); - - /** - * 获得 Banner 列表 - * - * @param position 定位 - * @return Banner 列表 - */ - List getBannerListByPosition(Integer position); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerServiceImpl.java deleted file mode 100644 index 46c22f0e2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/banner/BannerServiceImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.banner; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.banner.BannerMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.BANNER_NOT_EXISTS; - -/** - * 首页 banner 实现类 - * - * @author xia - */ -@Service -@Validated -public class BannerServiceImpl implements BannerService { - - @Resource - private BannerMapper bannerMapper; - - @Override - public Long createBanner(BannerCreateReqVO createReqVO) { - // 插入 - BannerDO banner = BannerConvert.INSTANCE.convert(createReqVO); - bannerMapper.insert(banner); - // 返回 - return banner.getId(); - } - - @Override - public void updateBanner(BannerUpdateReqVO updateReqVO) { - // 校验存在 - this.validateBannerExists(updateReqVO.getId()); - // 更新 - BannerDO updateObj = BannerConvert.INSTANCE.convert(updateReqVO); - bannerMapper.updateById(updateObj); - } - - @Override - public void deleteBanner(Long id) { - // 校验存在 - this.validateBannerExists(id); - // 删除 - bannerMapper.deleteById(id); - } - - private void validateBannerExists(Long id) { - if (bannerMapper.selectById(id) == null) { - throw exception(BANNER_NOT_EXISTS); - } - } - - @Override - public BannerDO getBanner(Long id) { - return bannerMapper.selectById(id); - } - - @Override - public PageResult getBannerPage(BannerPageReqVO pageReqVO) { - return bannerMapper.selectPage(pageReqVO); - } - - @Override - public void addBannerBrowseCount(Long id) { - // 校验 Banner 是否存在 - validateBannerExists(id); - // 增加点击次数 - bannerMapper.updateBrowseCount(id); - } - - @Override - public List getBannerListByPosition(Integer position) { - return bannerMapper.selectBannerListByPosition(position); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java deleted file mode 100644 index e1d2702b1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java +++ /dev/null @@ -1,120 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -/** - * 砍价活动 Service 接口 - * - * @author HUIHUI - */ -public interface BargainActivityService { - - /** - * 创建砍价活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createBargainActivity(@Valid BargainActivityCreateReqVO createReqVO); - - /** - * 更新砍价活动 - * - * @param updateReqVO 更新信息 - */ - void updateBargainActivity(@Valid BargainActivityUpdateReqVO updateReqVO); - - /** - * 更新砍价活动库存 - * - * 如果更新失败(库存不足),则抛出业务异常 - * - * @param id 砍价活动编号 - * @param count 购买数量 - */ - void updateBargainActivityStock(Long id, Integer count); - - /** - * 关闭砍价活动 - * - * @param id 砍价活动编号 - */ - void closeBargainActivityById(Long id); - - /** - * 删除砍价活动 - * - * @param id 编号 - */ - void deleteBargainActivity(Long id); - - /** - * 获得砍价活动 - * - * @param id 编号 - * @return 砍价活动 - */ - BargainActivityDO getBargainActivity(Long id); - - /** - * 获得砍价活动列表 - * - * @param ids 编号数组 - * @return 砍价活动列表 - */ - List getBargainActivityList(Set ids); - - /** - * 校验砍价活动,是否可以参与(发起砍价、下单、帮好友砍价) - * - * @param id 编号 - * @return 砍价活动 - */ - BargainActivityDO validateBargainActivityCanJoin(Long id); - - /** - * 获得砍价活动分页 - * - * @param pageReqVO 分页查询 - * @return 砍价活动分页 - */ - PageResult getBargainActivityPage(BargainActivityPageReqVO pageReqVO); - - /** - * 获取正在进行的活动分页数据 - * - * @param pageReqVO 分页请求 - * @return 砍价活动分页 - */ - PageResult getBargainActivityPage(PageParam pageReqVO); - - /** - * 获取正在进行的活动分页数据 - * - * @param count 需要的数量 - * @return 砍价活动分页 - */ - List getBargainActivityListByCount(Integer count); - - /** - * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 - * - * @param spuIds spu 编号 - * @param status 状态 - * @param dateTime 日期时间 - * @return 砍价活动列表 - */ - List getBargainActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java deleted file mode 100644 index 4e30536a8..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java +++ /dev/null @@ -1,208 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 砍价活动 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class BargainActivityServiceImpl implements BargainActivityService { - - @Resource - private BargainActivityMapper bargainActivityMapper; - - @Resource - private ProductSkuApi productSkuApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createBargainActivity(BargainActivityCreateReqVO createReqVO) { - // 校验商品 SPU 是否存在是否参加的别的活动 - validateBargainConflict(createReqVO.getSpuId(), null); - // 校验商品 sku 是否存在 - validateSku(createReqVO.getSkuId()); - - // 插入砍价活动 - BargainActivityDO activityDO = BargainActivityConvert.INSTANCE.convert(createReqVO) - .setTotalStock(createReqVO.getStock()) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - bargainActivityMapper.insert(activityDO); - return activityDO.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateBargainActivity(BargainActivityUpdateReqVO updateReqVO) { - // 校验存在 - BargainActivityDO activity = validateBargainActivityExists(updateReqVO.getId()); - // 校验状态 - if (ObjectUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(BARGAIN_ACTIVITY_STATUS_DISABLE); - } - // 校验商品冲突 - validateBargainConflict(updateReqVO.getSpuId(), updateReqVO.getId()); - // 校验商品 sku 是否存在 - validateSku(updateReqVO.getSkuId()); - - // 更新 - BargainActivityDO updateObj = BargainActivityConvert.INSTANCE.convert(updateReqVO); - if (updateObj.getStock() > activity.getTotalStock()) { // 如果更新的库存大于原来的库存,则更新总库存 - updateObj.setTotalStock(updateObj.getStock()); - } - bargainActivityMapper.updateById(updateObj); - } - - @Override - public void updateBargainActivityStock(Long id, Integer count) { - if (count < 0) { - // 更新库存。如果更新失败,则抛出异常 - int updateCount = bargainActivityMapper.updateStock(id, count); - if (updateCount == 0) { - throw exception(BARGAIN_ACTIVITY_STOCK_NOT_ENOUGH); - } - } else if (count > 0) { - bargainActivityMapper.updateStock(id, count); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void closeBargainActivityById(Long id) { - // 校验砍价活动是否存在 - BargainActivityDO activity = validateBargainActivityExists(id); - if (CommonStatusEnum.isDisable(activity.getStatus())) { - throw exception(BARGAIN_ACTIVITY_STATUS_DISABLE); - } - - bargainActivityMapper.updateById(new BargainActivityDO().setId(id) - .setStatus(CommonStatusEnum.DISABLE.getStatus())); - } - - private void validateBargainConflict(Long spuId, Long activityId) { - // 查询所有开启的砍价活动 - List activityList = bargainActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); - if (activityId != null) { // 更新时排除自己 - activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId)); - } - // 校验商品 spu 是否参加了其它活动 - if (anyMatch(activityList, activity -> ObjectUtil.equal(activity.getSpuId(), spuId))) { - throw exception(BARGAIN_ACTIVITY_SPU_CONFLICTS); - } - } - - private void validateSku(Long skuId) { - ProductSkuRespDTO sku = productSkuApi.getSku(skuId).getCheckedData(); - if (sku == null) { - throw exception(SKU_NOT_EXISTS); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteBargainActivity(Long id) { - // 校验存在 - BargainActivityDO activityDO = validateBargainActivityExists(id); - // 校验状态 - if (CommonStatusEnum.isEnable(activityDO.getStatus())) { - throw exception(BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END); - } - - // 删除 - bargainActivityMapper.deleteById(id); - } - - private BargainActivityDO validateBargainActivityExists(Long id) { - BargainActivityDO activityDO = bargainActivityMapper.selectById(id); - if (activityDO == null) { - throw exception(BARGAIN_ACTIVITY_NOT_EXISTS); - } - return activityDO; - } - - @Override - public BargainActivityDO getBargainActivity(Long id) { - return bargainActivityMapper.selectById(id); - } - - @Override - public List getBargainActivityList(Set ids) { - return bargainActivityMapper.selectBatchIds(ids); - } - - @Override - public BargainActivityDO validateBargainActivityCanJoin(Long id) { - BargainActivityDO activity = bargainActivityMapper.selectById(id); - if (activity == null) { - throw exception(BARGAIN_ACTIVITY_NOT_EXISTS); - } - if (CommonStatusEnum.isDisable(activity.getStatus())) { - throw exception(BARGAIN_ACTIVITY_STATUS_CLOSED); - } - if (activity.getStock() <= 0) { - throw exception(BARGAIN_ACTIVITY_STOCK_NOT_ENOUGH); - } - if (!LocalDateTimeUtils.isBetween(activity.getStartTime(), activity.getEndTime())) { - throw exception(BARGAIN_ACTIVITY_TIME_END); - } - return activity; - } - - @Override - public PageResult getBargainActivityPage(BargainActivityPageReqVO pageReqVO) { - return bargainActivityMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getBargainActivityPage(PageParam pageReqVO) { - // 只查询进行中,且在时间范围内的 - return bargainActivityMapper.selectPage(pageReqVO, CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now()); - } - - @Override - public List getBargainActivityListByCount(Integer count) { - return bargainActivityMapper.selectList(count, CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now()); - } - - @Override - public List getBargainActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime) { - // 1. 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - List> spuIdAndActivityIdMaps = bargainActivityMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status); - if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) { - return Collections.emptyList(); - } - // 2. 查询活动详情 - return bargainActivityMapper.selectListByIdsAndDateTimeLt( - convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")), dateTime); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpService.java deleted file mode 100644 index 8aec48597..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpService.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpCreateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 砍价助力 Service 接口 - * - * @author 芋道源码 - */ -public interface BargainHelpService { - - /** - * 创建砍价助力(帮人砍价) - * - * @param userId 用户编号 - * @param reqVO 请求信息 - * @return 砍价助力记录 - */ - BargainHelpDO createBargainHelp(Long userId, AppBargainHelpCreateReqVO reqVO); - - /** - * 【砍价活动】获得助力人数 Map - * - * @param activityIds 活动编号 - * @return 助力人数 Map - */ - Map getBargainHelpUserCountMapByActivity(Collection activityIds); - - /** - * 【砍价记录】获得助力人数 Map - * - * @param recordIds 记录编号 - * @return 助力人数 Map - */ - Map getBargainHelpUserCountMapByRecord(Collection recordIds); - - /** - * 【砍价活动】获得用户的助力次数 - * - * @param activityId 活动编号 - * @param userId 用户编号 - * @return 助力次数 - */ - Long getBargainHelpCountByActivity(Long activityId, Long userId); - - /** - * 获得砍价助力分页 - * - * @param pageReqVO 分页查询 - * @return 砍价助力分页 - */ - PageResult getBargainHelpPage(BargainHelpPageReqVO pageReqVO); - - /** - * 获得指定砍价记录编号,对应的砍价助力列表 - * - * @param recordId 砍价记录编号 - * @return 砍价助力列表 - */ - List getBargainHelpListByRecordId(Long recordId); - - /** - * 获得助力记录 - * - * @param recordId 砍价记录编号 - * @param userId 用户编号 - * @return 助力记录 - */ - BargainHelpDO getBargainHelp(Long recordId, Long userId); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java deleted file mode 100644 index f60ed5c0d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpCreateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainHelpMapper; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import jodd.util.MathUtil; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 砍价助力 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BargainHelpServiceImpl implements BargainHelpService { - - @Resource - private BargainHelpMapper bargainHelpMapper; - - @Resource - private BargainRecordService bargainRecordService; - @Resource - private BargainActivityService bargainActivityService; - - @Override - @Transactional(rollbackFor = Exception.class) - public BargainHelpDO createBargainHelp(Long userId, AppBargainHelpCreateReqVO reqVO) { - // 1.1 校验砍价记录存在,并且处于进行中 - BargainRecordDO record = bargainRecordService.getBargainRecord(reqVO.getRecordId()); - if (record == null) { - throw exception(BARGAIN_RECORD_NOT_EXISTS); - } - if (ObjUtil.notEqual(record.getStatus(), BargainRecordStatusEnum.IN_PROGRESS.getStatus())) { - throw exception(BARGAIN_HELP_CREATE_FAIL_RECORD_NOT_IN_PROCESS); - } - // 1.2 不能自己给自己砍价 - if (ObjUtil.equal(record.getUserId(), userId)) { - throw exception(BARGAIN_HELP_CREATE_FAIL_RECORD_SELF); - } - - // 2.1 校验砍价活动 - BargainActivityDO activity = bargainActivityService.getBargainActivity(record.getActivityId()); - // 2.2 校验自己是否助力次数上限 - if (bargainHelpMapper.selectCountByUserIdAndActivityId(userId, activity.getId()) - >= activity.getBargainCount()) { - throw exception(BARGAIN_HELP_CREATE_FAIL_LIMIT); - } - // 2.3 特殊情况:砍价已经砍到最低价,不能再砍了 - if (record.getBargainPrice() <= activity.getBargainMinPrice()) { - throw exception(BARGAIN_HELP_CREATE_FAIL_RECORD_NOT_IN_PROCESS); - } - - // 3. 已经助力 - if (bargainHelpMapper.selectByUserIdAndRecordId(userId, record.getId()) != null) { - throw exception(BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS); - } - - // 4.1 计算砍价金额 - Integer reducePrice = calculateReducePrice(activity, record); - Assert.isTrue(reducePrice > 0, "砍价金额必须大于 0 元"); - // 4.2 创建助力记录 - BargainHelpDO help = BargainHelpDO.builder().userId(userId).activityId(activity.getId()) - .recordId(record.getId()).reducePrice(reducePrice).build(); - bargainHelpMapper.insert(help); - - // 5. 判断砍价记录是否完成 - Boolean success = record.getBargainPrice() - reducePrice <= activity.getBargainMinPrice() // 情况一:砍价已经砍到最低价 - || bargainHelpMapper.selectUserCountMapByRecordId(reqVO.getRecordId()) >= activity.getHelpMaxCount(); // 情况二:砍价助力已经达到上限 - if (!bargainRecordService.updateBargainRecordBargainPrice( - record.getId(), record.getBargainPrice(), reducePrice, success)) { - // 多人一起砍价,需要重试 - throw exception(BARGAIN_HELP_CREATE_FAIL_CONFLICT); - } - return help; - } - - // TODO 芋艿:优化点:实现一个更随机的逻辑,可以按照你自己的业务; - private Integer calculateReducePrice(BargainActivityDO activity, BargainRecordDO record) { - // 1. 随机金额 - Integer reducePrice = MathUtil.randomInt(activity.getBargainMinPrice(), - activity.getRandomMaxPrice() + 1); // + 1 的原因是,randomInt 默认不包含第二个参数 - // 2. 校验是否超过砍价上限 - if (record.getBargainPrice() - reducePrice < activity.getBargainMinPrice()) { - reducePrice = record.getBargainPrice() - activity.getBargainMinPrice(); - } - return reducePrice; - } - - @Override - public Map getBargainHelpUserCountMapByActivity(Collection activityIds) { - return bargainHelpMapper.selectUserCountMapByActivityId(activityIds); - } - - @Override - public Map getBargainHelpUserCountMapByRecord(Collection recordIds) { - return bargainHelpMapper.selectUserCountMapByRecordId(recordIds); - } - - @Override - public Long getBargainHelpCountByActivity(Long activityId, Long userId) { - return bargainHelpMapper.selectCountByUserIdAndActivityId(userId, activityId); - } - - @Override - public PageResult getBargainHelpPage(BargainHelpPageReqVO pageReqVO) { - return bargainHelpMapper.selectPage(pageReqVO); - } - - @Override - public List getBargainHelpListByRecordId(Long recordId) { - return bargainHelpMapper.selectListByRecordId(recordId); - } - - @Override - public BargainHelpDO getBargainHelp(Long recordId, Long userId) { - return bargainHelpMapper.selectByUserIdAndRecordId(userId, recordId); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java deleted file mode 100644 index e3ba206a1..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; - -import javax.annotation.Nullable; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 砍价记录 service 接口 - * - * @author HUIHUI - */ -public interface BargainRecordService { - - /** - * 【会员】创建砍价记录(参与参加活动) - * - * @param userId 用户编号 - * @param reqVO 创建信息 - * @return 砍价记录编号 - */ - Long createBargainRecord(Long userId, AppBargainRecordCreateReqVO reqVO); - - /** - * 更新砍价记录的砍价金额 - * - * 如果满足砍价成功的条件,则更新砍价记录的状态为成功 - * - * @param id 砍价记录编号 - * @param whereBargainPrice 当前的砍价金额 - * @param reducePrice 减少的砍价金额 - * @param success 是否砍价成功 - * @return 是否更新成功。注意,如果并发更新时,会更新失败 - */ - Boolean updateBargainRecordBargainPrice(Long id, Integer whereBargainPrice, - Integer reducePrice, Boolean success); - - /** - * 【下单前】校验是否参与砍价活动 - *

- * 如果校验失败,则抛出业务异常 - * - * @param userId 用户编号 - * @param bargainRecordId 砍价活动编号 - * @param skuId SKU 编号 - * @return 砍价信息 - */ - BargainValidateJoinRespDTO validateJoinBargain(Long userId, Long bargainRecordId, Long skuId); - - /** - * 更新砍价记录的订单编号 - * - * 在砍价成功后,用户发起订单后,会记录该订单编号 - * - * @param id 砍价记录编号 - * @param orderId 订单编号 - */ - void updateBargainRecordOrderId(Long id, Long orderId); - - /** - * 获得砍价记录 - * - * @param id 砍价记录编号 - * @return 砍价记录 - */ - BargainRecordDO getBargainRecord(Long id); - - /** - * 获得用户在当前砍价活动中的最后一条砍价记录 - * - * @param userId 用户编号 - * @param activityId 砍价记录编号 - * @return 砍价记录 - */ - BargainRecordDO getLastBargainRecord(Long userId, Long activityId); - - /** - * 获得砍价人数 Map - * - * @param activityIds 活动编号 - * @param status 砍价记录状态 - * @return 砍价人数 Map - */ - Map getBargainRecordUserCountMap(Collection activityIds, @Nullable Integer status); - - /** - * 获得砍价人数 - * - * @param status 砍价记录状态 - * @return 砍价人数 - */ - Integer getBargainRecordUserCount(Integer status); - - /** - * 获得砍价人数 - * - * @param activityId 砍价活动编号 - * @param status 砍价记录状态 - * @return 砍价人数 - */ - Integer getBargainRecordUserCount(Long activityId, Integer status); - - /** - * 【管理员】获得砍价记录分页 - * - * @param pageReqVO 分页查询 - * @return 砍价记录分页 - */ - PageResult getBargainRecordPage(BargainRecordPageReqVO pageReqVO); - - /** - * 【会员】获得砍价记录分页 - * - * @param userId 用户编号 - * @param pageParam 分页查询 - * @return 砍价记录分页 - */ - PageResult getBargainRecordPage(Long userId, PageParam pageParam); - - /** - * 获得砍价记录列表 - * - * @param status 砍价记录状态 - * @param count 条数 - * @return 砍价记录列表 - */ - List getBargainRecordList(Integer status, Integer count); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java deleted file mode 100644 index aa6db4a74..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java +++ /dev/null @@ -1,152 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.bargain; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainRecordMapper; -import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Nullable; -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 砍价记录 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class BargainRecordServiceImpl implements BargainRecordService { - - @Resource - private BargainActivityService bargainActivityService; - - @Resource - private BargainRecordMapper bargainRecordMapper; - - @Override - public Long createBargainRecord(Long userId, AppBargainRecordCreateReqVO reqVO) { - // 1. 校验砍价活动(包括库存) - BargainActivityDO activity = bargainActivityService.validateBargainActivityCanJoin(reqVO.getActivityId()); - - // 2.1 校验当前是否已经有参与中的砍价活动 - if (CollUtil.isNotEmpty(bargainRecordMapper.selectListByUserIdAndActivityIdAndStatus( - userId, reqVO.getActivityId(), BargainRecordStatusEnum.IN_PROGRESS.getStatus()))) { - throw exception(BARGAIN_RECORD_CREATE_FAIL_EXISTS); - } - // 2.2 是否超过参与的上限 - if (bargainRecordMapper.selectCountByUserIdAndActivityIdAndStatus( - userId, reqVO.getActivityId(), BargainRecordStatusEnum.SUCCESS.getStatus()) >= activity.getTotalLimitCount()) { - throw exception(BARGAIN_RECORD_CREATE_FAIL_LIMIT); - } - - // 3. 创建砍价记录 - BargainRecordDO record = BargainRecordDO.builder().userId(userId) - .activityId(reqVO.getActivityId()).spuId(activity.getSpuId()).skuId(activity.getSkuId()) - .bargainFirstPrice(activity.getBargainFirstPrice()).bargainPrice(activity.getBargainFirstPrice()) - .status(BargainRecordStatusEnum.IN_PROGRESS.getStatus()).build(); - bargainRecordMapper.insert(record); - return record.getId(); - } - - @Override - public Boolean updateBargainRecordBargainPrice(Long id, Integer whereBargainPrice, - Integer reducePrice, Boolean success) { - BargainRecordDO updateObj = new BargainRecordDO().setBargainPrice(whereBargainPrice - reducePrice); - if (success) { - updateObj.setStatus(BargainRecordStatusEnum.SUCCESS.getStatus()); - } - return bargainRecordMapper.updateByIdAndBargainPrice(id, whereBargainPrice, updateObj) > 0; - } - - @Override - public BargainValidateJoinRespDTO validateJoinBargain(Long userId, Long bargainRecordId, Long skuId) { - // 1.1 砍价记录不存在 - BargainRecordDO record = bargainRecordMapper.selectByIdAndUserId(bargainRecordId, userId); - if (record == null) { - throw exception(BARGAIN_RECORD_NOT_EXISTS); - } - // 1.2 砍价记录未在进行中 - if (ObjUtil.notEqual(record.getStatus(), BargainRecordStatusEnum.SUCCESS.getStatus())) { - throw exception(BARGAIN_JOIN_RECORD_NOT_SUCCESS); - } - // 1.3 砍价记录已经下单 - if (record.getOrderId() != null) { - throw exception(BARGAIN_JOIN_RECORD_ALREADY_ORDER); - } - - // 2.1 校验砍价活动(包括库存) - BargainActivityDO activity = bargainActivityService.validateBargainActivityCanJoin(record.getActivityId()); - Assert.isTrue(Objects.equals(skuId, activity.getSkuId()), "砍价商品不匹配"); // 防御性校验 - return new BargainValidateJoinRespDTO().setActivityId(activity.getId()).setName(activity.getName()) - .setBargainPrice(record.getBargainPrice()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateBargainRecordOrderId(Long id, Long orderId) { - // 更新失败,说明已经下单 - int updateCount = bargainRecordMapper.updateOrderIdById(id, orderId); - if (updateCount == 0) { - throw exception(BARGAIN_JOIN_RECORD_ALREADY_ORDER); - } - } - - @Override - public BargainRecordDO getBargainRecord(Long id) { - return bargainRecordMapper.selectById(id); - } - - @Override - public BargainRecordDO getLastBargainRecord(Long userId, Long activityId) { - return bargainRecordMapper.selectLastByUserIdAndActivityId(userId, activityId); - } - - @Override - public Map getBargainRecordUserCountMap(Collection activityIds, @Nullable Integer status) { - return bargainRecordMapper.selectUserCountByActivityIdsAndStatus(activityIds, status); - } - - @Override - public Integer getBargainRecordUserCount(Integer status) { - return bargainRecordMapper.selectUserCountByStatus(status); - } - - @Override - public Integer getBargainRecordUserCount(Long activityId, Integer status) { - return bargainRecordMapper.selectUserCountByActivityIdAndStatus(activityId, status); - } - - @Override - public PageResult getBargainRecordPage(BargainRecordPageReqVO pageReqVO) { - return bargainRecordMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getBargainRecordPage(Long userId, PageParam pageParam) { - return bargainRecordMapper.selectBargainRecordPage(userId, pageParam); - } - - @Override - public List getBargainRecordList(Integer status, Integer count) { - return bargainRecordMapper.selectListByStatusAndCount(status, count); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java deleted file mode 100644 index 23adc738e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.combination; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * 拼团活动 Service 接口 - * - * @author HUIHUI - */ -public interface CombinationActivityService { - - /** - * 创建拼团活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCombinationActivity(@Valid CombinationActivityCreateReqVO createReqVO); - - /** - * 更新拼团活动 - * - * @param updateReqVO 更新信息 - */ - void updateCombinationActivity(@Valid CombinationActivityUpdateReqVO updateReqVO); - - /** - * 关闭拼团活动 - * - * @param id 拼团活动编号 - */ - void closeCombinationActivityById(Long id); - - /** - * 删除拼团活动 - * - * @param id 编号 - */ - void deleteCombinationActivity(Long id); - - /** - * 校验拼团活动是否存在 - * - * @param id 编号 - * @return 拼团活动 - */ - CombinationActivityDO validateCombinationActivityExists(Long id); - - /** - * 获得拼团活动 - * - * @param id 编号 - * @return 拼团活动 - */ - CombinationActivityDO getCombinationActivity(Long id); - - /** - * 获得拼团活动分页 - * - * @param pageReqVO 分页查询 - * @return 拼团活动分页 - */ - PageResult getCombinationActivityPage(CombinationActivityPageReqVO pageReqVO); - - /** - * 获得拼团活动商品列表 - * - * @param activityId 拼团活动 id - * @return 拼团活动的商品列表 - */ - default List getCombinationProductsByActivityId(Long activityId) { - return getCombinationProductListByActivityIds(Collections.singletonList(activityId)); - } - - /** - * 获得拼团活动商品列表 - * - * @param activityIds 拼团活动 ids - * @return 拼团活动的商品列表 - */ - List getCombinationProductListByActivityIds(Collection activityIds); - - /** - * 获得拼团活动列表 - * - * @param ids 拼团活动 ids - * @return 拼团活动的列表 - */ - List getCombinationActivityListByIds(Collection ids); - - /** - * 获取正在进行的活动分页数据 - * - * @param count 需要的数量 - * @return 拼团活动分页 - */ - List getCombinationActivityListByCount(Integer count); - - /** - * 获取正在进行的活动分页数据 - * - * @param pageParam 分页请求 - * @return 拼团活动分页 - */ - PageResult getCombinationActivityPage(PageParam pageParam); - - /** - * 获取指定活动、指定 sku 编号的商品 - * - * @param activityId 活动编号 - * @param skuId sku 编号 - * @return 活动商品信息 - */ - CombinationProductDO selectByActivityIdAndSkuId(Long activityId, Long skuId); - - /** - * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 - * - * @param spuIds spu 编号 - * @param status 状态 - * @param dateTime 日期时间 - * @return 拼团活动列表 - */ - List getCombinationActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java deleted file mode 100644 index 24f8c323e..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java +++ /dev/null @@ -1,257 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationActivityMapper; -import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationProductMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; - -/** - * 拼团活动 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class CombinationActivityServiceImpl implements CombinationActivityService { - - @Resource - private CombinationActivityMapper combinationActivityMapper; - @Resource - private CombinationProductMapper combinationProductMapper; - - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createCombinationActivity(CombinationActivityCreateReqVO createReqVO) { - // 校验商品 SPU 是否存在是否参加的别的活动 - validateProductConflict(createReqVO.getSpuId(), null); - // 校验商品是否存在 - validateProductExists(createReqVO.getSpuId(), createReqVO.getProducts()); - - // 插入拼团活动 - CombinationActivityDO activity = CombinationActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - combinationActivityMapper.insert(activity); - // 插入商品 - List products = CombinationActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), activity); - combinationProductMapper.insertBatch(products); - return activity.getId(); - } - - /** - * 校验拼团商品参与的活动是否存在冲突 - * - * @param spuId 商品 SPU 编号 - * @param activityId 拼团活动编号 - */ - private void validateProductConflict(Long spuId, Long activityId) { - // 查询所有开启的拼团活动 - List activityList = combinationActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); - if (activityId != null) { // 时排除自己 - activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId)); - } - // 查找是否有其它活动,选择了该产品 - List matchActivityList = filterList(activityList, activity -> ObjectUtil.equal(activity.getId(), spuId)); - if (CollUtil.isNotEmpty(matchActivityList)) { - throw exception(COMBINATION_ACTIVITY_SPU_CONFLICTS); - } - } - - /** - * 校验拼团商品是否都存在 - * - * @param spuId 商品 SPU 编号 - * @param products 拼团商品 - */ - private void validateProductExists(Long spuId, List products) { - // 1. 校验商品 spu 是否存在 - ProductSpuRespDTO spu = productSpuApi.getSpu(spuId).getCheckedData(); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - - // 2. 校验商品 sku 都存在 - List skus = productSkuApi.getSkuListBySpuId(singletonList(spuId)).getCheckedData(); - Map skuMap = convertMap(skus, ProductSkuRespDTO::getId); - products.forEach(product -> { - if (!skuMap.containsKey(product.getSkuId())) { - throw exception(SKU_NOT_EXISTS); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateCombinationActivity(CombinationActivityUpdateReqVO updateReqVO) { - // 校验存在 - CombinationActivityDO activityDO = validateCombinationActivityExists(updateReqVO.getId()); - // 校验状态 - if (ObjectUtil.equal(activityDO.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE_NOT_UPDATE); - } - // 校验商品冲突 - validateProductConflict(updateReqVO.getSpuId(), updateReqVO.getId()); - // 校验商品是否存在 - validateProductExists(updateReqVO.getSpuId(), updateReqVO.getProducts()); - - // 更新活动 - CombinationActivityDO updateObj = CombinationActivityConvert.INSTANCE.convert(updateReqVO); - combinationActivityMapper.updateById(updateObj); - // 更新商品 - updateCombinationProduct(updateObj, updateReqVO.getProducts()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void closeCombinationActivityById(Long id) { - // 校验活动是否存在 - CombinationActivityDO activity = validateCombinationActivityExists(id); - if (CommonStatusEnum.isDisable(activity.getStatus())) { - throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE_NOT_UPDATE); - } - - // 关闭活动 - combinationActivityMapper.updateById(new CombinationActivityDO().setId(id) - .setStatus(CommonStatusEnum.DISABLE.getStatus())); - } - - /** - * 更新拼团商品 - * - * @param activity 拼团活动 - * @param products 该活动的最新商品配置 - */ - private void updateCombinationProduct(CombinationActivityDO activity, List products) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List newList = CombinationActivityConvert.INSTANCE.convertList(products, activity); - List oldList = combinationProductMapper.selectListByActivityIds(CollUtil.newArrayList(activity.getId())); - List> diffList = CollectionUtils.diffList(oldList, newList, (oldVal, newVal) -> { - boolean same = ObjectUtil.equal(oldVal.getSkuId(), newVal.getSkuId()); - if (same) { - newVal.setId(oldVal.getId()); - } - return same; - }); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - combinationProductMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - combinationProductMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - combinationProductMapper.deleteBatchIds(CollectionUtils.convertList(diffList.get(2), CombinationProductDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteCombinationActivity(Long id) { - // 校验存在 - CombinationActivityDO activity = validateCombinationActivityExists(id); - // 校验状态 - if (CommonStatusEnum.isEnable(activity.getStatus())) { - throw exception(COMBINATION_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END); - } - - // 删除 - combinationActivityMapper.deleteById(id); - } - - @Override - public CombinationActivityDO validateCombinationActivityExists(Long id) { - CombinationActivityDO activityDO = combinationActivityMapper.selectById(id); - if (activityDO == null) { - throw exception(COMBINATION_ACTIVITY_NOT_EXISTS); - } - return activityDO; - } - - @Override - public CombinationActivityDO getCombinationActivity(Long id) { - return validateCombinationActivityExists(id); - } - - @Override - public PageResult getCombinationActivityPage(CombinationActivityPageReqVO pageReqVO) { - return combinationActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getCombinationProductListByActivityIds(Collection activityIds) { - return combinationProductMapper.selectListByActivityIds(activityIds); - } - - @Override - public List getCombinationActivityListByIds(Collection ids) { - return combinationActivityMapper.selectList(CombinationActivityDO::getId, ids); - } - - @Override - public List getCombinationActivityListByCount(Integer count) { - return combinationActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus(), count); - } - - @Override - public PageResult getCombinationActivityPage(PageParam pageParam) { - return combinationActivityMapper.selectPage(pageParam, CommonStatusEnum.ENABLE.getStatus()); - } - - @Override - public CombinationProductDO selectByActivityIdAndSkuId(Long activityId, Long skuId) { - return combinationProductMapper.selectOne( - CombinationProductDO::getActivityId, activityId, - CombinationProductDO::getSkuId, skuId); - } - - @Override - public List getCombinationActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime) { - // 1.查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - List> spuIdAndActivityIdMaps = combinationActivityMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status); - if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) { - return Collections.emptyList(); - } - // 2.查询活动详情 - return combinationActivityMapper.selectListByIdsAndDateTimeLt( - convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")), dateTime); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java deleted file mode 100644 index 55f5b2ebc..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java +++ /dev/null @@ -1,176 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.combination; - -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; - -import javax.annotation.Nullable; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 拼团记录 Service 接口 - * - * @author HUIHUI - */ -public interface CombinationRecordService { - - /** - * 【下单前】校验是否满足拼团活动条件 - * - * 如果校验失败,则抛出业务异常 - * - * @param userId 用户编号 - * @param activityId 活动编号 - * @param headId 团长编号 - * @param skuId sku 编号 - * @param count 数量 - * @return 拼团信息 - */ - KeyValue validateCombinationRecord(Long userId, Long activityId, Long headId, - Long skuId, Integer count); - - /** - * 创建拼团记录 - * - * @param reqDTO 创建信息 - * @return 团信息 - */ - CombinationRecordDO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO); - - /** - * 获得拼团记录 - * - * @param userId 用户编号 - * @param orderId 订单编号 - * @return 拼团记录 - */ - CombinationRecordDO getCombinationRecord(Long userId, Long orderId); - - /** - * 【下单前】校验是否满足拼团活动条件 - * - * 如果校验失败,则抛出业务异常 - * - * @param userId 用户编号 - * @param activityId 活动编号 - * @param headId 团长编号 - * @param skuId sku 编号 - * @param count 数量 - * @return 拼团信息 - */ - CombinationValidateJoinRespDTO validateJoinCombination(Long userId, Long activityId, Long headId, Long skuId, Integer count); - - /** - * 获取拼团记录数 - * - * @param status 状态-允许为空 - * @param virtualGroup 是否虚拟成团-允许为空 - * @param headId 团长编号,允许空。目的 headId 设置为 {@link CombinationRecordDO#HEAD_ID_GROUP} 时,可以设置 - * @return 记录数 - */ - Long getCombinationRecordCount(@Nullable Integer status, @Nullable Boolean virtualGroup, Long headId); - - /** - * 查询用户拼团记录(DISTINCT 去重),也就是说查询会员表中的用户有多少人参与过拼团活动每个人只统计一次 - * - * @return 参加过拼团的用户数 - */ - Long getCombinationUserCount(); - - /** - * 获取最近的 count 条拼团记录 - * - * @param count 限制数量 - * @return 拼团记录列表 - */ - List getLatestCombinationRecordList(int count); - - /** - * 获得最近 n 条拼团记录(团长发起的) - * - * @param activityId 拼团活动编号 - * @param status 状态 - * @param count 数量 - * @return 拼团记录列表 - */ - List getHeadCombinationRecordList(Long activityId, Integer status, Integer count); - - /** - * 获取指定编号的拼团记录 - * - * @param id 拼团记录编号 - * @return 拼团记录 - */ - CombinationRecordDO getCombinationRecordById(Long id); - - /** - * 获取指定团长编号的拼团记录 - * - * @param headId 团长编号 - * @return 拼团记录列表 - */ - List getCombinationRecordListByHeadId(Long headId); - - /** - * 获取拼团记录分页数据 - * - * @param pageVO 分页请求 - * @return 拼团记录分页数据 - */ - PageResult getCombinationRecordPage(CombinationRecordReqPageVO pageVO); - - /** - * 【拼团活动】获得拼团记录数量 Map - * - * @param activityIds 活动记录编号数组 - * @param status 拼团状态,允许空 - * @param headId 团长编号,允许空。目的 headId 设置为 {@link CombinationRecordDO#HEAD_ID_GROUP} 时,可以设置 - * @return 拼团记录数量 Map - */ - Map getCombinationRecordCountMapByActivity(Collection activityIds, - @Nullable Integer status, - @Nullable Long headId); - - /** - * 获取拼团记录 - * - * @param userId 用户编号 - * @param id 拼团记录编号 - * @return 拼团记录 - */ - CombinationRecordDO getCombinationRecordByIdAndUser(Long userId, Long id); - - /** - * 取消拼团 - * - * @param userId 用户编号 - * @param id 拼团记录编号 - * @param headId 团长编号 - */ - void cancelCombinationRecord(Long userId, Long id, Long headId); - - /** - * 处理过期拼团 - * - * @return key 过期拼团数量, value 虚拟成团数量 - */ - KeyValue expireCombinationRecord(); - - /** - * 获得拼团记录分页数据 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 拼团记录分页数据 - */ - PageResult getCombinationRecordPage(Long userId, AppCombinationRecordPageReqVO pageReqVO); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java deleted file mode 100644 index dca15c233..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java +++ /dev/null @@ -1,426 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.combination; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; -import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO; -import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationRecordMapper; -import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; -import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Nullable; -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.afterNow; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.beforeNow; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -// TODO 芋艿:等拼团记录做完,完整 review 下 - -/** - * 拼团记录 Service 实现类 - * - * @author HUIHUI - */ -@Service -@Slf4j -@Validated -public class CombinationRecordServiceImpl implements CombinationRecordService { - - @Resource - private CombinationActivityService combinationActivityService; - @Resource - private CombinationRecordMapper combinationRecordMapper; - - @Resource - private MemberUserApi memberUserApi; - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Resource - @Lazy - private TradeOrderApi tradeOrderApi; - - // TODO @芋艿:在详细预览下; - @Override - public KeyValue validateCombinationRecord( - Long userId, Long activityId, Long headId, Long skuId, Integer count) { - // 1. 校验拼团活动是否存在 - CombinationActivityDO activity = combinationActivityService.validateCombinationActivityExists(activityId); - // 1.1 校验活动是否开启 - if (ObjUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE); - } - // 1.2. 校验活动开始时间 - if (afterNow(activity.getStartTime())) { - throw exception(COMBINATION_RECORD_FAILED_TIME_NOT_START); - } - // 1.3 校验是否超出单次限购数量 - if (count > activity.getSingleLimitCount()) { - throw exception(COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED); - } - - // 2. 父拼团是否存在,是否已经满了 - if (headId != null) { - // 2.1. 查询进行中的父拼团 - CombinationRecordDO record = combinationRecordMapper.selectByHeadId(headId, CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); - if (record == null) { - throw exception(COMBINATION_RECORD_HEAD_NOT_EXISTS); - } - // 2.2. 校验拼团是否已满 - if (ObjUtil.equal(record.getUserCount(), record.getUserSize())) { - throw exception(COMBINATION_RECORD_USER_FULL); - } - // 2.3 校验拼团是否过期(有父拼团的时候只校验父拼团的过期时间) - if (beforeNow(record.getExpireTime())) { - throw exception(COMBINATION_RECORD_FAILED_TIME_END); - } - } else { - // 3. 校验当前活动是否结束(自己是父拼团的时候才校验活动是否结束) - if (beforeNow(activity.getEndTime())) { - throw exception(COMBINATION_RECORD_FAILED_TIME_END); - } - } - - // 4.1 校验活动商品是否存在 - CombinationProductDO product = combinationActivityService.selectByActivityIdAndSkuId(activityId, skuId); - if (product == null) { - throw exception(COMBINATION_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS); - } - // 4.2 校验 sku 是否存在 - ProductSkuRespDTO sku = productSkuApi.getSku(skuId).getCheckedData(); - if (sku == null) { - throw exception(COMBINATION_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS); - } - // 4.3 校验库存是否充足 - if (count > sku.getStock()) { - throw exception(COMBINATION_ACTIVITY_UPDATE_STOCK_FAIL); - } - - // 6.1 校验是否有拼团记录 - List recordList = combinationRecordMapper.selectListByUserIdAndActivityId(userId, activityId); - recordList.removeIf(record -> CombinationRecordStatusEnum.isFailed(record.getStatus())); // 取消的订单,不算数 - if (CollUtil.isEmpty(recordList)) { // 如果为空,说明可以参与,直接返回 - return new KeyValue<>(activity, product); - } - // 6.2 校验用户是否有该活动正在进行的拼团 - CombinationRecordDO inProgressRecord = findFirst(recordList, - record -> CombinationRecordStatusEnum.isInProgress(record.getStatus())); - if (inProgressRecord != null) { - throw exception(COMBINATION_RECORD_FAILED_HAVE_JOINED); - } - // 6.3 校验是否超出总限购数量 - Integer sumValue = getSumValue(recordList, CombinationRecordDO::getCount, Integer::sum); - if (sumValue != null && sumValue + count > activity.getTotalLimitCount()) { - throw exception(COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED); - } - return new KeyValue<>(activity, product); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public CombinationRecordDO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { - // 1. 校验拼团活动 - KeyValue keyValue = validateCombinationRecord(reqDTO.getUserId(), - reqDTO.getActivityId(), reqDTO.getHeadId(), reqDTO.getSkuId(), reqDTO.getCount()); - - // 2. 组合数据创建拼团记录 - MemberUserRespDTO user = memberUserApi.getUser(reqDTO.getUserId()).getCheckedData(); - ProductSpuRespDTO spu = productSpuApi.getSpu(reqDTO.getSpuId()).getCheckedData(); - ProductSkuRespDTO sku = productSkuApi.getSku(reqDTO.getSkuId()).getCheckedData(); - CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO, keyValue.getKey(), user, spu, sku); - // 2.1. 如果是团长需要设置 headId 为 CombinationRecordDO#HEAD_ID_GROUP - if (record.getHeadId() == null) { - record.setStartTime(LocalDateTime.now()) - .setExpireTime(LocalDateTime.now().plusHours(keyValue.getKey().getLimitDuration())) - .setHeadId(CombinationRecordDO.HEAD_ID_GROUP); - } else { - // 2.2.有团长的情况下需要设置开始时间和过期时间为团长的 - CombinationRecordDO headRecord = combinationRecordMapper.selectByHeadId(record.getHeadId(), - CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); // 查询进行中的父拼团 - record.setStartTime(headRecord.getStartTime()).setExpireTime(headRecord.getExpireTime()); - } - combinationRecordMapper.insert(record); - - // 3. 更新拼团记录 - if (ObjUtil.notEqual(CombinationRecordDO.HEAD_ID_GROUP, record.getHeadId())) { - updateCombinationRecordWhenCreate(reqDTO.getHeadId(), keyValue.getKey()); - } - return record; - } - - /** - * 当新增拼团时,更新拼团记录的进展 - * - * @param headId 团长编号 - * @param activity 活动 - */ - private void updateCombinationRecordWhenCreate(Long headId, CombinationActivityDO activity) { - // 1. 团长 + 团员 - List records = getCombinationRecordListByHeadId(headId); - if (CollUtil.isEmpty(records)) { - return; - } - CombinationRecordDO headRecord = combinationRecordMapper.selectById(headId); - - // 2. 批量更新记录 - List updateRecords = new ArrayList<>(); - records.add(headRecord); // 加入团长,团长也需要更新 - boolean isFull = records.size() >= activity.getUserSize(); - LocalDateTime now = LocalDateTime.now(); - records.forEach(item -> { - CombinationRecordDO updateRecord = new CombinationRecordDO(); - updateRecord.setId(item.getId()).setUserCount(records.size()); - if (isFull) { - updateRecord.setStatus(CombinationRecordStatusEnum.SUCCESS.getStatus()); - updateRecord.setEndTime(now); - } - updateRecords.add(updateRecord); - }); - combinationRecordMapper.updateBatch(updateRecords); - } - - @Override - public CombinationRecordDO getCombinationRecord(Long userId, Long orderId) { - return combinationRecordMapper.selectByUserIdAndOrderId(userId, orderId); - } - - @Override - public CombinationValidateJoinRespDTO validateJoinCombination(Long userId, Long activityId, Long headId, - Long skuId, Integer count) { - KeyValue keyValue = validateCombinationRecord(userId, activityId, - headId, skuId, count); - return new CombinationValidateJoinRespDTO().setActivityId(keyValue.getKey().getId()) - .setName(keyValue.getKey().getName()).setCombinationPrice(keyValue.getValue().getCombinationPrice()); - } - - @Override - public Long getCombinationRecordCount(@Nullable Integer status, @Nullable Boolean virtualGroup, @Nullable Long headId) { - return combinationRecordMapper.selectCountByHeadAndStatusAndVirtualGroup(status, virtualGroup, headId); - } - - @Override - public Long getCombinationUserCount() { - return combinationRecordMapper.selectUserCount(); - } - - @Override - public List getLatestCombinationRecordList(int count) { - return combinationRecordMapper.selectLatestList(count); - } - - @Override - public List getHeadCombinationRecordList(Long activityId, Integer status, Integer count) { - return combinationRecordMapper.selectListByActivityIdAndStatusAndHeadId(activityId, status, - CombinationRecordDO.HEAD_ID_GROUP, count); - } - - @Override - public CombinationRecordDO getCombinationRecordById(Long id) { - return combinationRecordMapper.selectById(id); - } - - @Override - public List getCombinationRecordListByHeadId(Long headId) { - return combinationRecordMapper.selectList(CombinationRecordDO::getHeadId, headId); - } - - @Override - public PageResult getCombinationRecordPage(CombinationRecordReqPageVO pageVO) { - return combinationRecordMapper.selectPage(pageVO); - } - - @Override - public Map getCombinationRecordCountMapByActivity(Collection activityIds, - @Nullable Integer status, @Nullable Long headId) { - return combinationRecordMapper.selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(activityIds, status, headId); - } - - @Override - public CombinationRecordDO getCombinationRecordByIdAndUser(Long userId, Long id) { - return combinationRecordMapper.selectOne(CombinationRecordDO::getUserId, userId, CombinationRecordDO::getId, id); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void cancelCombinationRecord(Long userId, Long id, Long headId) { - // 删除记录 - combinationRecordMapper.deleteById(id); - - // 需要更新的记录 - List updateRecords = new ArrayList<>(); - // 如果它是团长,则顺序(下单时间)继承 - if (Objects.equals(headId, CombinationRecordDO.HEAD_ID_GROUP)) { // 情况一:团长 - // 团员 - List list = getCombinationRecordListByHeadId(id); - if (CollUtil.isEmpty(list)) { - return; - } - // 按照创建时间升序排序 - list.sort(Comparator.comparing(CombinationRecordDO::getCreateTime)); // 影响原 list - CombinationRecordDO newHead = list.get(0); // 新团长继位 - list.forEach(item -> { - CombinationRecordDO recordDO = new CombinationRecordDO(); - recordDO.setId(item.getId()); - if (ObjUtil.equal(item.getId(), newHead.getId())) { // 新团长 - recordDO.setHeadId(CombinationRecordDO.HEAD_ID_GROUP); - } else { - recordDO.setHeadId(newHead.getId()); - } - recordDO.setUserCount(list.size()); - updateRecords.add(recordDO); - }); - } else { // 情况二:团员 - // 团长 - CombinationRecordDO recordHead = combinationRecordMapper.selectById(headId); - // 团员 - List records = getCombinationRecordListByHeadId(headId); - if (CollUtil.isEmpty(records)) { - return; - } - records.add(recordHead); // 加入团长,团长数据也需要更新 - records.forEach(item -> { - CombinationRecordDO recordDO = new CombinationRecordDO(); - recordDO.setId(item.getId()); - recordDO.setUserCount(records.size()); - updateRecords.add(recordDO); - }); - } - - // 更新拼团记录 - combinationRecordMapper.updateBatch(updateRecords); - } - - @Override - public KeyValue expireCombinationRecord() { - // 1. 获取所有正在进行中的过期的父拼团 - List headExpireRecords = combinationRecordMapper.selectListByHeadIdAndStatusAndExpireTimeLt( - CombinationRecordDO.HEAD_ID_GROUP, CombinationRecordStatusEnum.IN_PROGRESS.getStatus(), LocalDateTime.now()); - if (CollUtil.isEmpty(headExpireRecords)) { - return new KeyValue<>(0, 0); - } - - // 2. 获取拼团活动 - List activities = combinationActivityService.getCombinationActivityListByIds( - convertSet(headExpireRecords, CombinationRecordDO::getActivityId)); - Map activityMap = convertMap(activities, CombinationActivityDO::getId); - - // 3. 逐个处理拼团,过期 or 虚拟成团 - KeyValue keyValue = new KeyValue<>(0, 0); // 统计过期拼团和虚拟成团 - for (CombinationRecordDO record : headExpireRecords) { - try { - CombinationActivityDO activity = activityMap.get(record.getActivityId()); - if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 - // 3.1. 处理过期的拼团 - getSelf().handleExpireRecord(record); - keyValue.setKey(keyValue.getKey() + 1); - } else { - // 3.2. 处理虚拟成团 - getSelf().handleVirtualGroupRecord(record); - keyValue.setValue(keyValue.getValue() + 1); - } - } catch (Exception ignored) { // 处理异常继续循环 - log.error("[expireCombinationRecord][record({}) 处理异常,请进行处理!record 数据是:{}]", - record.getId(), JsonUtils.toJsonString(record)); - } - } - return keyValue; - } - - /** - * 处理过期拼团 - * - * @param headRecord 过期拼团团长记录 - */ - @Transactional(rollbackFor = Exception.class) - public void handleExpireRecord(CombinationRecordDO headRecord) { - // 1. 更新拼团记录 - List headAndRecords = updateBatchCombinationRecords(headRecord, - CombinationRecordStatusEnum.FAILED); - // 2. 订单取消 - headAndRecords.forEach(item -> tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId())); - } - - /** - * 处理虚拟拼团 - * - * @param headRecord 虚拟成团团长记录 - */ - @Transactional(rollbackFor = Exception.class) - public void handleVirtualGroupRecord(CombinationRecordDO headRecord) { - // 1. 团员补齐 - combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualRecordList(headRecord)); - // 2. 更新拼团记录 - updateBatchCombinationRecords(headRecord, CombinationRecordStatusEnum.SUCCESS); - } - - /** - * 更新拼团记录 - * - * @param headRecord 团长记录 - * @param status 状态-拼团失败 FAILED 成功 SUCCESS - * @return 整团记录(包含团长和团成员) - */ - private List updateBatchCombinationRecords(CombinationRecordDO headRecord, CombinationRecordStatusEnum status) { - // 1. 查询团成员(包含团长) - List records = combinationRecordMapper.selectListByHeadId(headRecord.getId()); - records.add(headRecord);// 把团长加进去 - - // 2. 批量更新拼团记录 status 和 endTime - List updateRecords = new ArrayList<>(records.size()); - LocalDateTime now = LocalDateTime.now(); - records.forEach(item -> { - CombinationRecordDO updateRecord = new CombinationRecordDO().setId(item.getId()) - .setStatus(status.getStatus()).setEndTime(now); - if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数 - updateRecord.setUserCount(updateRecord.getUserSize()); - } - updateRecords.add(updateRecord); - }); - combinationRecordMapper.updateBatch(updateRecords); - return records; - } - - @Override - public PageResult getCombinationRecordPage(Long userId, AppCombinationRecordPageReqVO pageReqVO) { - return combinationRecordMapper.selectPage(userId, pageReqVO); - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private CombinationRecordServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java deleted file mode 100644 index edd654275..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java +++ /dev/null @@ -1,180 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; - -import java.util.*; - -/** - * 优惠劵 Service 接口 - * - * @author 芋道源码 - */ -public interface CouponService { - - /** - * 校验优惠劵,包括状态、有限期 - *

- * 1. 如果校验通过,则返回优惠劵信息 - * 2. 如果校验不通过,则直接抛出业务异常 - * - * @param id 优惠劵编号 - * @param userId 用户编号 - * @return 优惠劵信息 - */ - CouponDO validCoupon(Long id, Long userId); - - /** - * 校验优惠劵,包括状态、有限期 - * - * @param coupon 优惠劵 - * @see #validCoupon(Long, Long) 逻辑相同,只是入参不同 - */ - void validCoupon(CouponDO coupon); - - /** - * 获得优惠劵分页 - * - * @param pageReqVO 分页查询 - * @return 优惠劵分页 - */ - PageResult getCouponPage(CouponPageReqVO pageReqVO); - - /** - * 使用优惠劵 - * - * @param id 优惠劵编号 - * @param userId 用户编号 - * @param orderId 订单编号 - */ - void useCoupon(Long id, Long userId, Long orderId); - - /** - * 退还已使用的优惠券 - * - * @param id 优惠券编号 - */ - void returnUsedCoupon(Long id); - - /** - * 回收优惠劵 - * - * @param id 优惠劵编号 - */ - void deleteCoupon(Long id); - - /** - * 获得用户的优惠劵列表 - * - * @param userId 用户编号 - * @param status 优惠劵状态 - * @return 优惠劵列表 - */ - List getCouponList(Long userId, Integer status); - - /** - * 获得未使用的优惠劵数量 - * - * @param userId 用户编号 - * @return 未使用的优惠劵数量 - */ - Long getUnusedCouponCount(Long userId); - - /** - * 领取优惠券 - * - * @param templateId 优惠券模板编号 - * @param userIds 用户编号列表 - * @param takeType 领取方式 - */ - void takeCoupon(Long templateId, Set userIds, CouponTakeTypeEnum takeType); - - /** - * 【管理员】给用户发送优惠券 - * - * @param templateId 优惠券模板编号 - * @param userIds 用户编号列表 - */ - default void takeCouponByAdmin(Long templateId, Set userIds) { - takeCoupon(templateId, userIds, CouponTakeTypeEnum.ADMIN); - } - - /** - * 【会员】领取优惠券 - * - * @param templateId 优惠券模板编号 - * @param userId 用户编号 - */ - default void takeCouponByUser(Long templateId, Long userId) { - takeCoupon(templateId, CollUtil.newHashSet(userId), CouponTakeTypeEnum.USER); - } - - /** - * 【系统】给用户发送新人券 - * - * @param userId 用户编号 - */ - void takeCouponByRegister(Long userId); - - /** - * 获取会员领取指定优惠券的数量 - * - * @param templateId 优惠券模板编号 - * @param userId 用户编号 - * @return 领取优惠券的数量 - */ - default Integer getTakeCount(Long templateId, Long userId) { - Map map = getTakeCountMapByTemplateIds(Collections.singleton(templateId), userId); - return MapUtil.getInt(map, templateId, 0); - } - - /** - * 统计会员领取优惠券的数量 - * - * @param templateIds 优惠券模板编号列表 - * @param userId 用户编号 - * @return 领取优惠券的数量 - */ - Map getTakeCountMapByTemplateIds(Collection templateIds, Long userId); - - /** - * 获取用户匹配的优惠券列表 - * - * @param userId 用户编号 - * @param matchReqVO 匹配参数 - * @return 优惠券列表 - */ - List getMatchCouponList(Long userId, AppCouponMatchReqVO matchReqVO); - - /** - * 过期优惠券 - * - * @return 过期数量 - */ - int expireCoupon(); - - /** - * 获取用户是否可以领取优惠券 - * - * @param userId 用户编号 - * @param templates 优惠券列表 - * @return 是否可以领取 - */ - Map getUserCanCanTakeMap(Long userId, List templates); - - /** - * 获得优惠劵 - * - * @param userId 用户编号 - * @param id 编号 - * @return 优惠劵 - */ - CouponDO getCoupon(Long userId, Long id); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java deleted file mode 100644 index aa1f34fe3..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java +++ /dev/null @@ -1,334 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.hutool.core.collection.CollStreamUtil; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchReqVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponMapper; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; - -/** - * 优惠劵 Service 实现类 - * - * @author 芋道源码 - */ -@Slf4j -@Service -@Validated -public class CouponServiceImpl implements CouponService { - - @Resource - private CouponTemplateService couponTemplateService; - - @Resource - private CouponMapper couponMapper; - - @Resource - private MemberUserApi memberUserApi; - - @Override - public CouponDO validCoupon(Long id, Long userId) { - CouponDO coupon = couponMapper.selectByIdAndUserId(id, userId); - if (coupon == null) { - throw exception(COUPON_NOT_EXISTS); - } - validCoupon(coupon); - return coupon; - } - - @Override - public void validCoupon(CouponDO coupon) { - // 校验状态 - if (ObjectUtil.notEqual(coupon.getStatus(), CouponStatusEnum.UNUSED.getStatus())) { - throw exception(COUPON_STATUS_NOT_UNUSED); - } - // 校验有效期;为避免定时器没跑,实际优惠劵已经过期 - if (!LocalDateTimeUtils.isBetween(coupon.getValidStartTime(), coupon.getValidEndTime())) { - throw exception(COUPON_VALID_TIME_NOT_NOW); - } - } - - @Override - public PageResult getCouponPage(CouponPageReqVO pageReqVO) { - // 获得用户编号 - if (StrUtil.isNotEmpty(pageReqVO.getNickname())) { - List users = memberUserApi.getUserListByNickname(pageReqVO.getNickname()).getCheckedData(); - if (CollUtil.isEmpty(users)) { - return PageResult.empty(); - } - pageReqVO.setUserIds(convertSet(users, MemberUserRespDTO::getId)); - } - // 分页查询 - return couponMapper.selectPage(pageReqVO); - } - - @Override - public void useCoupon(Long id, Long userId, Long orderId) { - // 校验优惠劵 - validCoupon(id, userId); - - // 更新状态 - int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(), - new CouponDO().setStatus(CouponStatusEnum.USED.getStatus()) - .setUseOrderId(orderId).setUseTime(LocalDateTime.now())); - if (updateCount == 0) { - throw exception(COUPON_STATUS_NOT_UNUSED); - } - } - - @Override - public void returnUsedCoupon(Long id) { - // 校验存在 - CouponDO coupon = couponMapper.selectById(id); - if (coupon == null) { - throw exception(COUPON_NOT_EXISTS); - } - // 校验状态 - if (ObjectUtil.notEqual(coupon.getStatus(), CouponStatusEnum.USED.getStatus())) { - throw exception(COUPON_STATUS_NOT_USED); - } - - // 退还 - Integer status = LocalDateTimeUtils.beforeNow(coupon.getValidEndTime()) - ? CouponStatusEnum.EXPIRE.getStatus() // 退还时可能已经过期了 - : CouponStatusEnum.UNUSED.getStatus(); - int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.USED.getStatus(), - new CouponDO().setStatus(status)); - if (updateCount == 0) { - throw exception(COUPON_STATUS_NOT_USED); - } - - // TODO 增加优惠券变动记录? - } - - @Override - @Transactional - public void deleteCoupon(Long id) { - // 校验存在 - validateCouponExists(id); - - // 更新优惠劵 - int deleteCount = couponMapper.delete(id, - asList(CouponStatusEnum.UNUSED.getStatus(), CouponStatusEnum.EXPIRE.getStatus())); - if (deleteCount == 0) { - throw exception(COUPON_DELETE_FAIL_USED); - } - // 减少优惠劵模板的领取数量 -1 - couponTemplateService.updateCouponTemplateTakeCount(id, -1); - } - - @Override - public List getCouponList(Long userId, Integer status) { - return couponMapper.selectListByUserIdAndStatus(userId, status); - } - - private void validateCouponExists(Long id) { - if (couponMapper.selectById(id) == null) { - throw exception(COUPON_NOT_EXISTS); - } - } - - @Override - public Long getUnusedCouponCount(Long userId) { - return couponMapper.selectCountByUserIdAndStatus(userId, CouponStatusEnum.UNUSED.getStatus()); - } - - @Override - public void takeCoupon(Long templateId, Set userIds, CouponTakeTypeEnum takeType) { - CouponTemplateDO template = couponTemplateService.getCouponTemplate(templateId); - // 1. 过滤掉达到领取限制的用户 - removeTakeLimitUser(userIds, template); - // 2. 校验优惠劵是否可以领取 - validateCouponTemplateCanTake(template, userIds, takeType); - - // 3. 批量保存优惠劵 - couponMapper.insertBatch(convertList(userIds, userId -> CouponConvert.INSTANCE.convert(template, userId))); - - // 3. 增加优惠劵模板的领取数量 - couponTemplateService.updateCouponTemplateTakeCount(templateId, userIds.size()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void takeCouponByRegister(Long userId) { - List templates = couponTemplateService.getCouponTemplateListByTakeType(CouponTakeTypeEnum.REGISTER); - for (CouponTemplateDO template : templates) { - takeCoupon(template.getId(), CollUtil.newHashSet(userId), CouponTakeTypeEnum.REGISTER); - } - } - - @Override - public Map getTakeCountMapByTemplateIds(Collection templateIds, Long userId) { - if (CollUtil.isEmpty(templateIds)) { - return Collections.emptyMap(); - } - return couponMapper.selectCountByUserIdAndTemplateIdIn(userId, templateIds); - } - - @Override - public List getMatchCouponList(Long userId, AppCouponMatchReqVO matchReqVO) { - List list = couponMapper.selectListByUserIdAndStatusAndUsePriceLeAndProductScope(userId, - CouponStatusEnum.UNUSED.getStatus(), - matchReqVO.getPrice(), matchReqVO.getSpuIds(), matchReqVO.getCategoryIds()); - // 兜底逻辑:如果 CouponExpireJob 未执行,status 未变成 EXPIRE ,但是 validEndTime 已经过期了,需要进行过滤 - list.removeIf(coupon -> !LocalDateTimeUtils.isBetween(coupon.getValidStartTime(), coupon.getValidEndTime())); - return list; - } - - @Override - public int expireCoupon() { - // 1. 查询待过期的优惠券 - List list = couponMapper.selectListByStatusAndValidEndTimeLe( - CouponStatusEnum.UNUSED.getStatus(), LocalDateTime.now()); - if (CollUtil.isEmpty(list)) { - return 0; - } - - // 2. 遍历执行 - int count = 0; - for (CouponDO coupon : list) { - try { - boolean success = getSelf().expireCoupon(coupon); - if (success) { - count++; - } - } catch (Exception e) { - log.error("[expireCoupon][coupon({}) 更新为已过期失败]", coupon.getId(), e); - } - } - return count; - } - - @Override - public Map getUserCanCanTakeMap(Long userId, List templates) { - // 1. 未登录时,都显示可以领取 - Map userCanTakeMap = convertMap(templates, CouponTemplateDO::getId, templateId -> true); - if (userId == null) { - return userCanTakeMap; - } - - // 2.1 过滤领取数量无限制的 - Set templateIds = convertSet(templates, CouponTemplateDO::getId, template -> template.getTakeLimitCount() != -1); - // 2.2 检查用户领取的数量是否超过限制 - if (CollUtil.isNotEmpty(templateIds)) { - Map couponTakeCountMap = this.getTakeCountMapByTemplateIds(templateIds, userId); - for (CouponTemplateDO template : templates) { - Integer takeCount = couponTakeCountMap.get(template.getId()); - userCanTakeMap.put(template.getId(), takeCount == null || takeCount < template.getTakeLimitCount()); - } - } - return userCanTakeMap; - } - - /** - * 过期单个优惠劵 - * - * @param coupon 优惠劵 - * @return 是否过期成功 - */ - private boolean expireCoupon(CouponDO coupon) { - // 更新记录状态 - int updateRows = couponMapper.updateByIdAndStatus(coupon.getId(), CouponStatusEnum.UNUSED.getStatus(), - new CouponDO().setStatus(CouponStatusEnum.EXPIRE.getStatus())); - if (updateRows == 0) { - log.error("[expireCoupon][coupon({}) 更新为已过期失败]", coupon.getId()); - return false; - } - log.info("[expireCoupon][coupon({}) 更新为已过期成功]", coupon.getId()); - return true; - } - - /** - * 校验优惠券是否可以领取 - * - * @param couponTemplate 优惠券模板 - * @param userIds 领取人列表 - * @param takeType 领取方式 - */ - private void validateCouponTemplateCanTake(CouponTemplateDO couponTemplate, Set userIds, CouponTakeTypeEnum takeType) { - // 如果所有用户都领取过,则抛出异常 - if (CollUtil.isEmpty(userIds)) { - throw exception(COUPON_TEMPLATE_USER_ALREADY_TAKE); - } - - // 校验模板 - if (couponTemplate == null) { - throw exception(COUPON_TEMPLATE_NOT_EXISTS); - } - // 校验剩余数量 - if (couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) { - throw exception(COUPON_TEMPLATE_NOT_ENOUGH); - } - // 校验"固定日期"的有效期类型是否过期 - if (CouponTemplateValidityTypeEnum.DATE.getType().equals(couponTemplate.getValidityType())) { - if (LocalDateTimeUtils.beforeNow(couponTemplate.getValidEndTime())) { - throw exception(COUPON_TEMPLATE_EXPIRED); - } - } - // 校验领取方式 - if (ObjectUtil.notEqual(couponTemplate.getTakeType(), takeType.getValue())) { - throw exception(COUPON_TEMPLATE_CANNOT_TAKE); - } - } - - /** - * 过滤掉达到领取上线的用户 - * - * @param userIds 用户编号数组 - * @param couponTemplate 优惠劵模版 - */ - private void removeTakeLimitUser(Set userIds, CouponTemplateDO couponTemplate) { - if (couponTemplate.getTakeLimitCount() <= 0) { - return; - } - // 查询已领过券的用户 - List alreadyTakeCoupons = couponMapper.selectListByTemplateIdAndUserId(couponTemplate.getId(), userIds); - if (CollUtil.isEmpty(alreadyTakeCoupons)) { - return; - } - // 移除达到领取限制的用户 - Map userTakeCountMap = CollStreamUtil.groupBy(alreadyTakeCoupons, CouponDO::getUserId, Collectors.summingInt(c -> 1)); - userIds.removeIf(userId -> MapUtil.getInt(userTakeCountMap, userId, 0) >= couponTemplate.getTakeLimitCount()); - } - - @Override - public CouponDO getCoupon(Long userId, Long id) { - return couponMapper.selectByIdAndUserId(id, userId); - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private CouponServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java deleted file mode 100755 index 02ed7585b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 优惠劵模板 Service 接口 - * - * @author 芋道源码 - */ -public interface CouponTemplateService { - - /** - * 创建优惠劵模板 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createCouponTemplate(@Valid CouponTemplateCreateReqVO createReqVO); - - /** - * 更新优惠劵模板 - * - * @param updateReqVO 更新信息 - */ - void updateCouponTemplate(@Valid CouponTemplateUpdateReqVO updateReqVO); - - /** - * 更新优惠劵模板的状态 - * - * @param id 编号 - * @param status 状态 - */ - void updateCouponTemplateStatus(Long id, Integer status); - - /** - * 删除优惠劵模板 - * - * @param id 编号 - */ - void deleteCouponTemplate(Long id); - - /** - * 获得优惠劵模板 - * - * @param id 编号 - * @return 优惠劵模板 - */ - CouponTemplateDO getCouponTemplate(Long id); - - /** - * 获得优惠劵模板分页 - * - * @param pageReqVO 分页查询 - * @return 优惠劵模板分页 - */ - PageResult getCouponTemplatePage(CouponTemplatePageReqVO pageReqVO); - - /** - * 更新优惠劵模板的领取数量 - * - * @param id 优惠劵模板编号 - * @param incrCount 增加数量 - */ - void updateCouponTemplateTakeCount(Long id, int incrCount); - - /** - * 获得指定领取方式的优惠券模板 - * - * @param takeType 领取方式 - * @return 优惠券模板列表 - */ - List getCouponTemplateListByTakeType(CouponTakeTypeEnum takeType); - - /** - * 获得优惠券模板列表 - * - * @param canTakeTypes 可领取的类型列表 - * @param productScope 商品使用范围类型 - * @param productScopeValue 商品使用范围编号 - * @param count 查询数量 - * @return 优惠券模板列表 - */ - List getCouponTemplateList(List canTakeTypes, Integer productScope, - Long productScopeValue, Integer count); - - /** - * 获得优惠券模版列表 - * - * @param ids 优惠券模版编号 - * @return 优惠券模版列表 - */ - List getCouponTemplateList(Collection ids); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java deleted file mode 100755 index deaa42638..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.coupon; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.api.category.ProductCategoryApi; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponTemplateMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL; - -/** - * 优惠劵模板 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class CouponTemplateServiceImpl implements CouponTemplateService { - - @Resource - private CouponTemplateMapper couponTemplateMapper; - - @Resource - private ProductCategoryApi productCategoryApi; - @Resource - private ProductSpuApi productSpuApi; - - @Override - public Long createCouponTemplate(CouponTemplateCreateReqVO createReqVO) { - // 校验商品范围 - validateProductScope(createReqVO.getProductScope(), createReqVO.getProductScopeValues()); - // 插入 - CouponTemplateDO couponTemplate = CouponTemplateConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - couponTemplateMapper.insert(couponTemplate); - // 返回 - return couponTemplate.getId(); - } - - @Override - public void updateCouponTemplate(CouponTemplateUpdateReqVO updateReqVO) { - // 校验存在 - CouponTemplateDO couponTemplate = validateCouponTemplateExists(updateReqVO.getId()); - // 校验发放数量不能过小 - if (updateReqVO.getTotalCount() < couponTemplate.getTakeCount()) { - throw exception(COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL, couponTemplate.getTakeCount()); - } - // 校验商品范围 - validateProductScope(updateReqVO.getProductScope(), updateReqVO.getProductScopeValues()); - - // 更新 - CouponTemplateDO updateObj = CouponTemplateConvert.INSTANCE.convert(updateReqVO); - couponTemplateMapper.updateById(updateObj); - } - - @Override - public void updateCouponTemplateStatus(Long id, Integer status) { - // 校验存在 - validateCouponTemplateExists(id); - // 更新 - couponTemplateMapper.updateById(new CouponTemplateDO().setId(id).setStatus(status)); - } - - @Override - public void deleteCouponTemplate(Long id) { - // 校验存在 - validateCouponTemplateExists(id); - // 删除 - couponTemplateMapper.deleteById(id); - } - - private CouponTemplateDO validateCouponTemplateExists(Long id) { - CouponTemplateDO couponTemplate = couponTemplateMapper.selectById(id); - if (couponTemplate == null) { - throw exception(COUPON_TEMPLATE_NOT_EXISTS); - } - return couponTemplate; - } - - private void validateProductScope(Integer productScope, List productScopeValues) { - if (Objects.equals(PromotionProductScopeEnum.SPU.getScope(), productScope)) { - productSpuApi.validateSpuList(productScopeValues); - } else if (Objects.equals(PromotionProductScopeEnum.CATEGORY.getScope(), productScope)) { - productCategoryApi.validateCategoryList(productScopeValues); - } - } - - @Override - public CouponTemplateDO getCouponTemplate(Long id) { - return couponTemplateMapper.selectById(id); - } - - @Override - public PageResult getCouponTemplatePage(CouponTemplatePageReqVO pageReqVO) { - return couponTemplateMapper.selectPage(pageReqVO); - } - - @Override - public void updateCouponTemplateTakeCount(Long id, int incrCount) { - couponTemplateMapper.updateTakeCount(id, incrCount); - } - - @Override - public List getCouponTemplateListByTakeType(CouponTakeTypeEnum takeType) { - return couponTemplateMapper.selectListByTakeType(takeType.getValue()); - } - - @Override - public List getCouponTemplateList(List canTakeTypes, Integer productScope, - Long productScopeValue, Integer count) { - return couponTemplateMapper.selectList(canTakeTypes, productScope, productScopeValue, count); - } - - @Override - public List getCouponTemplateList(Collection ids) { - return couponTemplateMapper.selectBatchIds(ids); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java deleted file mode 100644 index af8b757bd..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.discount; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 限时折扣 Service 接口 - * - * @author 芋道源码 - */ -public interface DiscountActivityService { - - /** - * 基于指定 SKU 编号数组,获得匹配的限时折扣商品 - * - * 注意,匹配的条件,仅仅是日期符合,并且处于开启状态 - * - * @param skuIds SKU 编号数组 - * @return 匹配的限时折扣商品 - */ - List getMatchDiscountProductList(Collection skuIds); - - /** - * 创建限时折扣活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDiscountActivity(@Valid DiscountActivityCreateReqVO createReqVO); - - /** - * 更新限时折扣活动 - * - * @param updateReqVO 更新信息 - */ - void updateDiscountActivity(@Valid DiscountActivityUpdateReqVO updateReqVO); - - /** - * 关闭限时折扣活动 - * - * @param id 编号 - */ - void closeDiscountActivity(Long id); - - /** - * 删除限时折扣活动 - * - * @param id 编号 - */ - void deleteDiscountActivity(Long id); - - /** - * 获得限时折扣活动 - * - * @param id 编号 - * @return 限时折扣活动 - */ - DiscountActivityDO getDiscountActivity(Long id); - - /** - * 获得限时折扣活动分页 - * - * @param pageReqVO 分页查询 - * @return 限时折扣活动分页 - */ - PageResult getDiscountActivityPage(DiscountActivityPageReqVO pageReqVO); - - /** - * 获得活动编号,对应对应的商品列表 - * - * @param activityId 活动编号 - * @return 活动的商品列表 - */ - List getDiscountProductsByActivityId(Long activityId); - - /** - * 获得活动编号,对应对应的商品列表 - * - * @param activityIds 活动编号 - * @return 活动的商品列表 - */ - List getDiscountProductsByActivityId(Collection activityIds); - - /** - * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 - * - * @param spuIds spu 编号 - * @param status 状态 - * @param dateTime 当前日期时间 - * @return 折扣活动列表 - */ - List getDiscountActivityBySpuIdsAndStatusAndDateTimeLt( - Collection spuIds, Integer status, LocalDateTime dateTime); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java deleted file mode 100644 index 507d0e1f9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java +++ /dev/null @@ -1,206 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.discount; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountActivityMapper; -import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountProductMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.util.PromotionUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 限时折扣 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class DiscountActivityServiceImpl implements DiscountActivityService { - - @Resource - private DiscountActivityMapper discountActivityMapper; - @Resource - private DiscountProductMapper discountProductMapper; - - @Override - public List getMatchDiscountProductList(Collection skuIds) { - return discountProductMapper.getMatchDiscountProductList(skuIds); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createDiscountActivity(DiscountActivityCreateReqVO createReqVO) { - // 校验商品是否冲突 - validateDiscountActivityProductConflicts(null, createReqVO.getProducts()); - - // 插入活动 - DiscountActivityDO discountActivity = DiscountActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.ENABLE.getStatus()); - discountActivityMapper.insert(discountActivity); - // 插入商品 - List discountProducts = BeanUtils.toBean(createReqVO.getProducts(), DiscountProductDO.class, - product -> product.setActivityId(discountActivity.getId()).setActivityStatus(discountActivity.getStatus()) - .setActivityStartTime(createReqVO.getStartTime()).setActivityEndTime(createReqVO.getEndTime())); - discountProductMapper.insertBatch(discountProducts); - // 返回 - return discountActivity.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateDiscountActivity(DiscountActivityUpdateReqVO updateReqVO) { - // 校验存在 - DiscountActivityDO discountActivity = validateDiscountActivityExists(updateReqVO.getId()); - if (discountActivity.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { // 已关闭的活动,不能修改噢 - throw exception(DISCOUNT_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); - } - // 校验商品是否冲突 - validateDiscountActivityProductConflicts(updateReqVO.getId(), updateReqVO.getProducts()); - - // 更新活动 - DiscountActivityDO updateObj = DiscountActivityConvert.INSTANCE.convert(updateReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getEndTime())); - discountActivityMapper.updateById(updateObj); - // 更新商品 - updateDiscountProduct(updateReqVO); - } - - private void updateDiscountProduct(DiscountActivityUpdateReqVO updateReqVO) { - // TODO @zhangshuai:这里的逻辑,可以优化下哈;参考 CombinationActivityServiceImpl 的 updateCombinationProduct,主要是 CollectionUtils.diffList 的使用哈; - // 然后原先是使用 DiscountActivityConvert.INSTANCE.isEquals 对比,现在看看是不是简化就基于 skuId 对比就完事了;之前写的太精细,意义不大; - List dbDiscountProducts = discountProductMapper.selectListByActivityId(updateReqVO.getId()); - // 计算要删除的记录 - List deleteIds = convertList(dbDiscountProducts, DiscountProductDO::getId, - discountProductDO -> updateReqVO.getProducts().stream() - .noneMatch(product -> DiscountActivityConvert.INSTANCE.isEquals(discountProductDO, product))); - if (CollUtil.isNotEmpty(deleteIds)) { - discountProductMapper.deleteBatchIds(deleteIds); - } - // 计算新增的记录 - List newDiscountProducts = convertList(updateReqVO.getProducts(), - product -> DiscountActivityConvert.INSTANCE.convert(product).setActivityId(updateReqVO.getId())); - newDiscountProducts.removeIf(product -> dbDiscountProducts.stream().anyMatch( - dbProduct -> DiscountActivityConvert.INSTANCE.isEquals(dbProduct, product))); // 如果匹配到,说明是更新的 - if (CollectionUtil.isNotEmpty(newDiscountProducts)) { - discountProductMapper.insertBatch(newDiscountProducts); - } - } - - /** - * 校验商品是否冲突 - * - * @param id 编号 - * @param products 商品列表 - */ - private void validateDiscountActivityProductConflicts(Long id, List products) { - if (CollUtil.isEmpty(products)) { - return; - } - // 查询商品参加的活动 - // TODO @zhangshuai:下面 121 这个查询,是不是不用做呀;直接 convert 出 skuId 集合就 ok 啦; - List list = discountProductMapper.selectListByActivityId(id); - // TODO @zhangshuai:一般简单的 stream 方法,建议是使用 CollectionUtils,例如说这里是 convertList 对把。 - List skuIds = list.stream().map(item -> item.getSkuId()).collect(Collectors.toList()); - List matchDiscountProductList = getMatchDiscountProductList(skuIds); - if (id != null) { // 排除自己这个活动 - matchDiscountProductList.removeIf(product -> id.equals(product.getActivityId())); - } - // 如果非空,则说明冲突 - if (CollUtil.isNotEmpty(matchDiscountProductList)) { - throw exception(DISCOUNT_ACTIVITY_SPU_CONFLICTS); - } - } - - @Override - public void closeDiscountActivity(Long id) { - // 校验存在 - DiscountActivityDO activity = validateDiscountActivityExists(id); - if (activity.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { // 已关闭的活动,不能关闭噢 - throw exception(DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); - } - - // 更新 - DiscountActivityDO updateObj = new DiscountActivityDO().setId(id).setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); - discountActivityMapper.updateById(updateObj); - } - - @Override - public void deleteDiscountActivity(Long id) { - // 校验存在 - DiscountActivityDO activity = validateDiscountActivityExists(id); - if (CommonStatusEnum.isEnable(activity.getStatus())) { // 未关闭的活动,不能删除噢 - throw exception(DISCOUNT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED); - } - - // 删除 - discountActivityMapper.deleteById(id); - } - - private DiscountActivityDO validateDiscountActivityExists(Long id) { - DiscountActivityDO discountActivity = discountActivityMapper.selectById(id); - if (discountActivity == null) { - throw exception(DISCOUNT_ACTIVITY_NOT_EXISTS); - } - return discountActivity; - } - - @Override - public DiscountActivityDO getDiscountActivity(Long id) { - return discountActivityMapper.selectById(id); - } - - @Override - public PageResult getDiscountActivityPage(DiscountActivityPageReqVO pageReqVO) { - return discountActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getDiscountProductsByActivityId(Long activityId) { - return discountProductMapper.selectListByActivityId(activityId); - } - - @Override - public List getDiscountProductsByActivityId(Collection activityIds) { - return discountProductMapper.selectList("activity_id", activityIds); - } - - @Override - public List getDiscountActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime) { - // 1. 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - List> spuIdAndActivityIdMaps = discountProductMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status); - if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) { - return Collections.emptyList(); - } - - // 2. 查询活动详情 - return discountActivityMapper.selectListByIdsAndDateTimeLt( - convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")), dateTime); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageService.java deleted file mode 100644 index 31900e7a4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageService.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyUpdateRequestVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 装修页面 Service 接口 - * - * @author owen - */ -public interface DiyPageService { - - /** - * 创建装修页面 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDiyPage(@Valid DiyPageCreateReqVO createReqVO); - - /** - * 更新装修页面 - * - * @param updateReqVO 更新信息 - */ - void updateDiyPage(@Valid DiyPageUpdateReqVO updateReqVO); - - /** - * 删除装修页面 - * - * @param id 编号 - */ - void deleteDiyPage(Long id); - - /** - * 获得装修页面 - * - * @param id 编号 - * @return 装修页面 - */ - DiyPageDO getDiyPage(Long id); - - /** - * 获得装修页面列表 - * - * @param ids 编号 - * @return 装修页面列表 - */ - List getDiyPageList(Collection ids); - - /** - * 获得装修页面分页 - * - * @param pageReqVO 分页查询 - * @return 装修页面分页 - */ - PageResult getDiyPagePage(DiyPagePageReqVO pageReqVO); - - /** - * 更新装修页面属性 - * - * @param updateReqVO 更新信息 - */ - void updateDiyPageProperty(DiyPagePropertyUpdateRequestVO updateReqVO); - - /** - * 获得模板所属的页面列表 - * - * @param templateId 模板编号 - * @return 装修页面列表 - */ - List getDiyPageByTemplateId(Long templateId); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java deleted file mode 100644 index 69f96ad8f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyPageServiceImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyUpdateRequestVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.page.DiyPageUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyPageMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_PAGE_NAME_USED; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DIY_PAGE_NOT_EXISTS; - -/** - * 装修页面 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class DiyPageServiceImpl implements DiyPageService { - - @Resource - private DiyPageMapper diyPageMapper; - - @Override - public Long createDiyPage(DiyPageCreateReqVO createReqVO) { - // 校验名称唯一 - validateNameUnique(null, createReqVO.getTemplateId(), createReqVO.getName()); - // 插入 - DiyPageDO diyPage = DiyPageConvert.INSTANCE.convert(createReqVO); - diyPage.setProperty("{}"); - diyPageMapper.insert(diyPage); - return diyPage.getId(); - } - - @Override - public void updateDiyPage(DiyPageUpdateReqVO updateReqVO) { - // 校验存在 - validateDiyPageExists(updateReqVO.getId()); - // 校验名称唯一 - validateNameUnique(updateReqVO.getId(), updateReqVO.getTemplateId(), updateReqVO.getName()); - // 更新 - DiyPageDO updateObj = DiyPageConvert.INSTANCE.convert(updateReqVO); - diyPageMapper.updateById(updateObj); - } - - /** - * 校验 Page 页面,在一个 template 模版下的名字是唯一的 - * - * @param id Page 编号 - * @param templateId 模版编号 - * @param name Page 名字 - */ - void validateNameUnique(Long id, Long templateId, String name) { - if (templateId != null || StrUtil.isBlank(name)) { - return; - } - DiyPageDO page = diyPageMapper.selectByNameAndTemplateIdIsNull(name); - if (page == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的页面 - if (id == null) { - throw exception(DIY_PAGE_NAME_USED, name); - } - if (!page.getId().equals(id)) { - throw exception(DIY_PAGE_NAME_USED, name); - } - } - - @Override - public void deleteDiyPage(Long id) { - // 校验存在 - validateDiyPageExists(id); - // 删除 - diyPageMapper.deleteById(id); - } - - private void validateDiyPageExists(Long id) { - if (diyPageMapper.selectById(id) == null) { - throw exception(DIY_PAGE_NOT_EXISTS); - } - } - - @Override - public DiyPageDO getDiyPage(Long id) { - return diyPageMapper.selectById(id); - } - - @Override - public List getDiyPageList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return ListUtil.empty(); - } - return diyPageMapper.selectBatchIds(ids); - } - - @Override - public PageResult getDiyPagePage(DiyPagePageReqVO pageReqVO) { - return diyPageMapper.selectPage(pageReqVO); - } - - @Override - public List getDiyPageByTemplateId(Long templateId) { - return diyPageMapper.selectListByTemplateId(templateId); - } - - @Override - public void updateDiyPageProperty(DiyPagePropertyUpdateRequestVO updateReqVO) { - // 校验存在 - validateDiyPageExists(updateReqVO.getId()); - // 更新 - DiyPageDO updateObj = DiyPageConvert.INSTANCE.convert(updateReqVO); - diyPageMapper.updateById(updateObj); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateService.java deleted file mode 100644 index 4f0c0c7aa..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateService.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePropertyUpdateRequestVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; - -import javax.validation.Valid; - -/** - * 装修模板 Service 接口 - * - * @author owen - */ -public interface DiyTemplateService { - - /** - * 创建装修模板 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDiyTemplate(@Valid DiyTemplateCreateReqVO createReqVO); - - /** - * 更新装修模板 - * - * @param updateReqVO 更新信息 - */ - void updateDiyTemplate(@Valid DiyTemplateUpdateReqVO updateReqVO); - - /** - * 删除装修模板 - * - * @param id 编号 - */ - void deleteDiyTemplate(Long id); - - /** - * 获得装修模板 - * - * @param id 编号 - * @return 装修模板 - */ - DiyTemplateDO getDiyTemplate(Long id); - - /** - * 获得装修模板分页 - * - * @param pageReqVO 分页查询 - * @return 装修模板分页 - */ - PageResult getDiyTemplatePage(DiyTemplatePageReqVO pageReqVO); - - /** - * 使用装修模板 - * - * @param id 编号 - */ - void useDiyTemplate(Long id); - - /** - * 更新装修模板属性 - * - * @param updateReqVO 更新信息 - */ - void updateDiyTemplateProperty(DiyTemplatePropertyUpdateRequestVO updateReqVO); - - /** - * 获取使用中的装修模板 - * - * @return 装修模板 - */ - DiyTemplateDO getUsedDiyTemplate(); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java deleted file mode 100644 index f6d5e7240..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java +++ /dev/null @@ -1,171 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.diy; - -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplatePropertyUpdateRequestVO; -import cn.iocoder.yudao.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyPageConvert; -import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.diy.DiyTemplateMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 装修模板 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class DiyTemplateServiceImpl implements DiyTemplateService { - - @Resource - private DiyTemplateMapper diyTemplateMapper; - - @Resource - private DiyPageService diyPageService; - - @Transactional(rollbackFor = Exception.class) - @Override - public Long createDiyTemplate(DiyTemplateCreateReqVO createReqVO) { - // 校验名称唯一 - validateNameUnique(null, createReqVO.getName()); - // 插入 - DiyTemplateDO diyTemplate = DiyTemplateConvert.INSTANCE.convert(createReqVO); - diyTemplate.setProperty("{}"); - diyTemplateMapper.insert(diyTemplate); - // 创建默认页面 - createDefaultPage(diyTemplate); - // 返回 - return diyTemplate.getId(); - } - - /** - * 创建模板下面的默认页面 - * 默认创建两个页面:首页、我的 - * - * @param diyTemplate 模板对象 - */ - private void createDefaultPage(DiyTemplateDO diyTemplate) { - String remark = String.format("模板【%s】自动创建", diyTemplate.getName()); - diyPageService.createDiyPage(DiyPageConvert.INSTANCE.convertCreateVo(diyTemplate.getId(), "首页", remark)); - diyPageService.createDiyPage(DiyPageConvert.INSTANCE.convertCreateVo(diyTemplate.getId(), "我的", remark)); - } - - @Override - public void updateDiyTemplate(DiyTemplateUpdateReqVO updateReqVO) { - // 校验存在 - validateDiyTemplateExists(updateReqVO.getId()); - // 校验名称唯一 - validateNameUnique(updateReqVO.getId(), updateReqVO.getName()); - // 更新 - DiyTemplateDO updateObj = DiyTemplateConvert.INSTANCE.convert(updateReqVO); - diyTemplateMapper.updateById(updateObj); - } - - void validateNameUnique(Long id, String name) { - if (StrUtil.isBlank(name)) { - return; - } - DiyTemplateDO template = diyTemplateMapper.selectByName(name); - if (template == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的模板 - if (id == null) { - throw exception(DIY_TEMPLATE_NAME_USED, name); - } - if (!template.getId().equals(id)) { - throw exception(DIY_TEMPLATE_NAME_USED, name); - } - } - - @Override - public void deleteDiyTemplate(Long id) { - // 校验存在 - DiyTemplateDO diyTemplateDO = validateDiyTemplateExists(id); - // 校验使用中 - if (BooleanUtil.isTrue(diyTemplateDO.getUsed())) { - throw exception(DIY_TEMPLATE_USED_CANNOT_DELETE); - } - // 删除 - diyTemplateMapper.deleteById(id); - } - - private DiyTemplateDO validateDiyTemplateExists(Long id) { - DiyTemplateDO diyTemplateDO = diyTemplateMapper.selectById(id); - if (diyTemplateDO == null) { - throw exception(DIY_TEMPLATE_NOT_EXISTS); - } - return diyTemplateDO; - } - - @Override - public DiyTemplateDO getDiyTemplate(Long id) { - return diyTemplateMapper.selectById(id); - } - - @Override - public PageResult getDiyTemplatePage(DiyTemplatePageReqVO pageReqVO) { - return diyTemplateMapper.selectPage(pageReqVO); - } - - @Transactional(rollbackFor = Exception.class) - @Override - public void useDiyTemplate(Long id) { - // 校验存在 - validateDiyTemplateExists(id); - // TODO @疯狂:要不已使用的情况,抛个业务异常? - // 已使用的更新为未使用 - DiyTemplateDO used = diyTemplateMapper.selectByUsed(true); - if (used != null) { - // 如果 id 相同,说明未发生变化 - if (used.getId().equals(id)) { - return; - } - this.updateTemplateUsed(used.getId(), false, null); - } - // 更新为已使用 - this.updateTemplateUsed(id, true, LocalDateTime.now()); - } - - /** - * 更新模板是否使用 - * - * @param id 模板编号 - * @param used 是否使用 - * @param usedTime 使用时间 - */ - private void updateTemplateUsed(Long id, Boolean used, LocalDateTime usedTime) { - DiyTemplateDO updateObj = new DiyTemplateDO().setId(id) - .setUsed(used).setUsedTime(usedTime); - diyTemplateMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateDiyTemplateProperty(DiyTemplatePropertyUpdateRequestVO updateReqVO) { - // 校验存在 - validateDiyTemplateExists(updateReqVO.getId()); - // 更新模板属性 - DiyTemplateDO updateObj = DiyTemplateConvert.INSTANCE.convert(updateReqVO); - diyTemplateMapper.updateById(updateObj); - } - - @Override - public DiyTemplateDO getUsedDiyTemplate() { - return diyTemplateMapper.selectByUsed(true); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java deleted file mode 100755 index f08e74014..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.reward; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 满减送活动 Service 接口 - * - * @author 芋道源码 - */ -public interface RewardActivityService { - - /** - * 创建满减送活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createRewardActivity(@Valid RewardActivityCreateReqVO createReqVO); - - /** - * 更新满减送活动 - * - * @param updateReqVO 更新信息 - */ - void updateRewardActivity(@Valid RewardActivityUpdateReqVO updateReqVO); - - /** - * 关闭满减送活动 - * - * @param id 活动编号 - */ - void closeRewardActivity(Long id); - - /** - * 删除满减送活动 - * - * @param id 编号 - */ - void deleteRewardActivity(Long id); - - /** - * 获得满减送活动 - * - * @param id 编号 - * @return 满减送活动 - */ - RewardActivityDO getRewardActivity(Long id); - - /** - * 获得满减送活动分页 - * - * @param pageReqVO 分页查询 - * @return 满减送活动分页 - */ - PageResult getRewardActivityPage(RewardActivityPageReqVO pageReqVO); - - /** - * 基于指定的 SPU 编号数组,获得它们匹配的满减送活动 - * - * @param spuIds SPU 编号数组 - * @return 满减送活动列表 - */ - List getMatchRewardActivityList(Collection spuIds); - - /** - * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 - * - * @param spuIds spu 编号 - * @param status 状态 - * @param dateTime 当前日期时间 - * @return 满减送活动列表 - */ - List getRewardActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java deleted file mode 100755 index b7884c746..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java +++ /dev/null @@ -1,182 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.reward; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.reward.RewardActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.reward.RewardActivityMapper; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import cn.iocoder.yudao.module.promotion.util.PromotionUtils; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Arrays.asList; - -/** - * 满减送活动 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class RewardActivityServiceImpl implements RewardActivityService { - - @Resource - private RewardActivityMapper rewardActivityMapper; - - @Override - public Long createRewardActivity(RewardActivityCreateReqVO createReqVO) { - // 校验商品是否冲突 - validateRewardActivitySpuConflicts(null, createReqVO.getProductSpuIds()); - - // 插入 - RewardActivityDO rewardActivity = RewardActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getEndTime())); - rewardActivityMapper.insert(rewardActivity); - // 返回 - return rewardActivity.getId(); - } - - @Override - public void updateRewardActivity(RewardActivityUpdateReqVO updateReqVO) { - // 校验存在 - RewardActivityDO dbRewardActivity = validateRewardActivityExists(updateReqVO.getId()); - if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能修改噢 - throw exception(REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); - } - // 校验商品是否冲突 - validateRewardActivitySpuConflicts(updateReqVO.getId(), updateReqVO.getProductSpuIds()); - - // 更新 - RewardActivityDO updateObj = RewardActivityConvert.INSTANCE.convert(updateReqVO) - .setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getEndTime())); - rewardActivityMapper.updateById(updateObj); - } - - @Override - public void closeRewardActivity(Long id) { - // 校验存在 - RewardActivityDO dbRewardActivity = validateRewardActivityExists(id); - if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能关闭噢 - throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); - } - if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.END.getStatus())) { // 已关闭的活动,不能关闭噢 - throw exception(REWARD_ACTIVITY_CLOSE_FAIL_STATUS_END); - } - - // 更新 - RewardActivityDO updateObj = new RewardActivityDO().setId(id).setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); - rewardActivityMapper.updateById(updateObj); - } - - @Override - public void deleteRewardActivity(Long id) { - // 校验存在 - RewardActivityDO dbRewardActivity = validateRewardActivityExists(id); - if (!dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 未关闭的活动,不能删除噢 - throw exception(REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED); - } - - // 删除 - rewardActivityMapper.deleteById(id); - } - - private RewardActivityDO validateRewardActivityExists(Long id) { - RewardActivityDO activity = rewardActivityMapper.selectById(id); - if (activity == null) { - throw exception(REWARD_ACTIVITY_NOT_EXISTS); - } - return activity; - } - - // TODO @芋艿:逻辑有问题,需要优化;要分成全场、和指定来校验; - - /** - * 校验商品参加的活动是否冲突 - * - * @param id 活动编号 - * @param spuIds 商品 SPU 编号数组 - */ - private void validateRewardActivitySpuConflicts(Long id, Collection spuIds) { - if (CollUtil.isEmpty(spuIds)) { - return; - } - // 查询商品参加的活动 - List rewardActivityList = getRewardActivityListBySpuIds(spuIds, - asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus())); - if (id != null) { // 排除自己这个活动 - rewardActivityList.removeIf(activity -> id.equals(activity.getId())); - } - // 如果非空,则说明冲突 - if (CollUtil.isNotEmpty(rewardActivityList)) { - throw exception(REWARD_ACTIVITY_SPU_CONFLICTS); - } - } - - /** - * 获得商品参加的满减送活动的数组 - * - * @param spuIds 商品 SPU 编号数组 - * @param statuses 活动状态数组 - * @return 商品参加的满减送活动的数组 - */ - private List getRewardActivityListBySpuIds(Collection spuIds, - Collection statuses) { - List list = rewardActivityMapper.selectListByStatus(statuses); - return CollUtil.filter(list, activity -> CollUtil.containsAny(activity.getProductSpuIds(), spuIds)); - } - - @Override - public RewardActivityDO getRewardActivity(Long id) { - return rewardActivityMapper.selectById(id); - } - - @Override - public PageResult getRewardActivityPage(RewardActivityPageReqVO pageReqVO) { - return rewardActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getMatchRewardActivityList(Collection spuIds) { - // TODO 芋艿:待实现;先指定,然后再全局的; -// // 如果有全局活动,则直接选择它 -// List allActivities = rewardActivityMapper.selectListByProductScopeAndStatus( -// PromotionProductScopeEnum.ALL.getScope(), PromotionActivityStatusEnum.RUN.getStatus()); -// if (CollUtil.isNotEmpty(allActivities)) { -// return MapUtil.builder(allActivities.get(0), spuIds).build(); -// } -// -// // 查询某个活动参加的活动 -// List productActivityList = getRewardActivityListBySpuIds(spuIds, -// singleton(PromotionActivityStatusEnum.RUN.getStatus())); -// return convertMap(productActivityList, activity -> activity, -// rewardActivityDO -> intersectionDistinct(rewardActivityDO.getProductSpuIds(), spuIds)); // 求交集返回 - return null; - } - - @Override - public List getRewardActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime) { - // 1. 查询出指定 spuId 的 spu 参加的活动 - List rewardActivityList = rewardActivityMapper.selectListBySpuIdsAndStatus(spuIds, status); - if (CollUtil.isEmpty(rewardActivityList)) { - return Collections.emptyList(); - } - - // 2. 查询活动详情 - return rewardActivityMapper.selectListByIdsAndDateTimeLt(convertSet(rewardActivityList, RewardActivityDO::getId), dateTime); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java deleted file mode 100644 index 0ed6a4f5c..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityService.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -/** - * 秒杀活动 Service 接口 - * - * @author halfninety - */ -public interface SeckillActivityService { - - /** - * 创建秒杀活动 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSeckillActivity(@Valid SeckillActivityCreateReqVO createReqVO); - - /** - * 更新秒杀活动 - * - * @param updateReqVO 更新信息 - */ - void updateSeckillActivity(@Valid SeckillActivityUpdateReqVO updateReqVO); - - /** - * 更新秒杀库存(减少) - * - * @param id 活动编号 - * @param skuId sku 编号 - * @param count 数量(正数) - */ - void updateSeckillStockDecr(Long id, Long skuId, Integer count); - - /** - * 更新秒杀库存(增加) - * - * @param id 活动编号 - * @param skuId sku 编号 - * @param count 数量(正数) - */ - void updateSeckillStockIncr(Long id, Long skuId, Integer count); - - /** - * 关闭秒杀活动 - * - * @param id 编号 - */ - void closeSeckillActivity(Long id); - - /** - * 删除秒杀活动 - * - * @param id 编号 - */ - void deleteSeckillActivity(Long id); - - /** - * 获得秒杀活动 - * - * @param id 编号 - * @return 秒杀活动 - */ - SeckillActivityDO getSeckillActivity(Long id); - - /** - * 获得秒杀活动分页 - * - * @param pageReqVO 分页查询 - * @return 秒杀活动分页 - */ - PageResult getSeckillActivityPage(SeckillActivityPageReqVO pageReqVO); - - /** - * 通过活动编号获取活动商品 - * - * @param activityId 活动编号 - * @return 活动商品列表 - */ - List getSeckillProductListByActivityId(Long activityId); - - /** - * 通过活动编号获取活动商品 - * - * @param activityIds 活动编号 - * @return 活动商品列表 - */ - List getSeckillProductListByActivityId(Collection activityIds); - - /** - * 通过活动时段编号获取指定 status 的秒杀活动 - * - * @param configId 时段配置编号 - * @param status 状态 - * @return 秒杀活动列表 - */ - List getSeckillActivityListByConfigIdAndStatus(Long configId, Integer status); - - /** - * 通过活动时段获取秒杀活动 - * - * @param pageReqVO 请求 - * @return 秒杀活动列表 - */ - PageResult getSeckillActivityAppPageByConfigId(AppSeckillActivityPageReqVO pageReqVO); - - /** - * 校验是否参与秒杀商品 - * - * 如果校验失败,则抛出业务异常 - * - * @param activityId 活动编号 - * @param skuId SKU 编号 - * @param count 数量 - * @return 秒杀信息 - */ - SeckillValidateJoinRespDTO validateJoinSeckill(Long activityId, Long skuId, Integer count); - - /** - * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 - * - * @param spuIds spu 编号 - * @param status 状态 - * @param dateTime 日期时间 - * @return 秒杀活动列表 - */ - List getSeckillActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java deleted file mode 100644 index 8d2bc359b..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java +++ /dev/null @@ -1,339 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; -import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillProductDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillActivityMapper; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillProductMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.hutool.core.collection.CollUtil.isNotEmpty; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static java.util.Collections.singletonList; - -/** - * 秒杀活动 Service 实现类 - * - * @author halfninety - */ -@Service -@Validated -public class SeckillActivityServiceImpl implements SeckillActivityService { - - @Resource - private SeckillActivityMapper seckillActivityMapper; - @Resource - private SeckillProductMapper seckillProductMapper; - @Resource - private SeckillConfigService seckillConfigService; - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createSeckillActivity(SeckillActivityCreateReqVO createReqVO) { - // 1.1 校验商品秒杀时段是否冲突 - validateProductConflict(createReqVO.getConfigIds(), createReqVO.getSpuId(), null); - // 1.2 校验商品是否存在 - validateProductExists(createReqVO.getSpuId(), createReqVO.getProducts()); - - // 2.1 插入秒杀活动 - SeckillActivityDO activity = SeckillActivityConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.ENABLE.getStatus()) - .setStock(getSumValue(createReqVO.getProducts(), SeckillProductBaseVO::getStock, Integer::sum)); - activity.setTotalStock(activity.getStock()); - seckillActivityMapper.insert(activity); - // 2.2 插入商品 - List products = SeckillActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), activity); - seckillProductMapper.insertBatch(products); - return activity.getId(); - } - - /** - * 校验秒杀商品参与的活动是否存在冲突 - * - * 1. 校验秒杀时段是否存在 - * 2. 秒杀商品是否参加其它活动 - * - * @param configIds 秒杀时段数组 - * @param spuId 商品 SPU 编号 - * @param activityId 秒杀活动编号 - */ - private void validateProductConflict(List configIds, Long spuId, Long activityId) { - // 1. 校验秒杀时段是否存在 - seckillConfigService.validateSeckillConfigExists(configIds); - - // 2.1 查询所有开启的秒杀活动 - List activityList = seckillActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); - if (activityId != null) { // 排除自己 - activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId)); - } - // 2.2 过滤出所有 configIds 有交集的活动,判断是否存在重叠 - List conflictActivityList = filterList(activityList, s -> containsAny(s.getConfigIds(), configIds)); - if (isNotEmpty(conflictActivityList)) { - throw exception(SECKILL_ACTIVITY_SPU_CONFLICTS); - } - } - - /** - * 校验秒杀商品是否都存在 - * - * @param spuId 商品 SPU 编号 - * @param products 秒杀商品 - */ - private void validateProductExists(Long spuId, List products) { - // 1. 校验商品 spu 是否存在 - ProductSpuRespDTO spu = productSpuApi.getSpu(spuId).getCheckedData(); - if (spu == null) { - throw exception(SPU_NOT_EXISTS); - } - - // 2. 校验商品 sku 都存在 - List skus = productSkuApi.getSkuListBySpuId(singletonList(spuId)).getCheckedData(); - Map skuMap = convertMap(skus, ProductSkuRespDTO::getId); - products.forEach(product -> { - if (!skuMap.containsKey(product.getSkuId())) { - throw exception(SKU_NOT_EXISTS); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSeckillActivity(SeckillActivityUpdateReqVO updateReqVO) { - // 1.1 校验存在 - SeckillActivityDO activity = validateSeckillActivityExists(updateReqVO.getId()); - if (CommonStatusEnum.DISABLE.getStatus().equals(activity.getStatus())) { - throw exception(SECKILL_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); - } - // 1.2 校验商品是否冲突 - validateProductConflict(updateReqVO.getConfigIds(), updateReqVO.getSpuId(), updateReqVO.getId()); - // 1.3 校验商品是否存在 - validateProductExists(updateReqVO.getSpuId(), updateReqVO.getProducts()); - - // 2.1 更新活动 - SeckillActivityDO updateObj = SeckillActivityConvert.INSTANCE.convert(updateReqVO) - .setStock(getSumValue(updateReqVO.getProducts(), SeckillProductBaseVO::getStock, Integer::sum)); - if (updateObj.getStock() > activity.getTotalStock()) { // 如果更新的库存大于原来的库存,则更新总库存 - updateObj.setTotalStock(updateObj.getStock()); - } - seckillActivityMapper.updateById(updateObj); - // 2.2 更新商品 - updateSeckillProduct(updateObj, updateReqVO.getProducts()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSeckillStockDecr(Long id, Long skuId, Integer count) { - // 1.1 校验活动库存是否充足 - SeckillActivityDO seckillActivity = validateSeckillActivityExists(id); - if (count > seckillActivity.getTotalStock()) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - // 1.2 校验商品库存是否充足 - SeckillProductDO product = seckillProductMapper.selectByActivityIdAndSkuId(id, skuId); - if (product == null || count > product.getStock()) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - - // 2.1 更新活动商品库存 - int updateCount = seckillProductMapper.updateStockDecr(product.getId(), count); - if (updateCount == 0) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - - // 2.2 更新活动库存 - updateCount = seckillActivityMapper.updateStockDecr(seckillActivity.getId(), count); - if (updateCount == 0) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateSeckillStockIncr(Long id, Long skuId, Integer count) { - SeckillProductDO product = seckillProductMapper.selectByActivityIdAndSkuId(id, skuId); - // 更新活动商品库存 - seckillProductMapper.updateStockIncr(product.getId(), count); - // 更新活动库存 - seckillActivityMapper.updateStockIncr(id, count); - } - - /** - * 更新秒杀商品 - * - * @param activity 秒杀活动 - * @param products 该活动的最新商品配置 - */ - private void updateSeckillProduct(SeckillActivityDO activity, List products) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List newList = SeckillActivityConvert.INSTANCE.convertList(products, activity); - List oldList = seckillProductMapper.selectListByActivityId(activity.getId()); - List> diffList = diffList(oldList, newList, (oldVal, newVal) -> { - boolean same = ObjectUtil.equal(oldVal.getSkuId(), newVal.getSkuId()); - if (same) { - newVal.setId(oldVal.getId()); - } - return same; - }); - - // 第二步,批量添加、修改、删除 - if (isNotEmpty(diffList.get(0))) { - seckillProductMapper.insertBatch(diffList.get(0)); - } - if (isNotEmpty(diffList.get(1))) { - seckillProductMapper.updateBatch(diffList.get(1)); - } - if (isNotEmpty(diffList.get(2))) { - seckillProductMapper.deleteBatchIds(convertList(diffList.get(2), SeckillProductDO::getId)); - } - } - - @Override - public void closeSeckillActivity(Long id) { - // 校验存在 - SeckillActivityDO activity = validateSeckillActivityExists(id); - if (CommonStatusEnum.DISABLE.getStatus().equals(activity.getStatus())) { - throw exception(SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); - } - - // 更新 - SeckillActivityDO updateObj = new SeckillActivityDO().setId(id).setStatus(CommonStatusEnum.DISABLE.getStatus()); - seckillActivityMapper.updateById(updateObj); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteSeckillActivity(Long id) { - // 校验存在 - SeckillActivityDO seckillActivity = this.validateSeckillActivityExists(id); - if (CommonStatusEnum.ENABLE.getStatus().equals(seckillActivity.getStatus())) { - throw exception(SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END); - } - - // 删除活动 - seckillActivityMapper.deleteById(id); - // 删除活动商品 - List products = seckillProductMapper.selectListByActivityId(id); - seckillProductMapper.deleteBatchIds(convertSet(products, SeckillProductDO::getId)); - } - - private SeckillActivityDO validateSeckillActivityExists(Long id) { - SeckillActivityDO seckillActivity = seckillActivityMapper.selectById(id); - if (seckillActivity == null) { - throw exception(SECKILL_ACTIVITY_NOT_EXISTS); - } - return seckillActivity; - } - - @Override - public SeckillActivityDO getSeckillActivity(Long id) { - return seckillActivityMapper.selectById(id); - } - - @Override - public PageResult getSeckillActivityPage(SeckillActivityPageReqVO pageReqVO) { - return seckillActivityMapper.selectPage(pageReqVO); - } - - @Override - public List getSeckillProductListByActivityId(Long activityId) { - return seckillProductMapper.selectListByActivityId(activityId); - } - - @Override - public List getSeckillProductListByActivityId(Collection activityIds) { - return seckillProductMapper.selectListByActivityId(activityIds); - } - - @Override - public List getSeckillActivityListByConfigIdAndStatus(Long configId, Integer status) { - return filterList(seckillActivityMapper.selectList(SeckillActivityDO::getStatus, status), - item -> anyMatch(item.getConfigIds(), id -> ObjectUtil.equal(id, configId)) // 校验时段 - && isBetween(item.getStartTime(), item.getEndTime())); // 追加当前日期是否处在活动日期之间的校验条件 - } - - @Override - public PageResult getSeckillActivityAppPageByConfigId(AppSeckillActivityPageReqVO pageReqVO) { - return seckillActivityMapper.selectPage(pageReqVO, CommonStatusEnum.ENABLE.getStatus()); - } - - @Override - public SeckillValidateJoinRespDTO validateJoinSeckill(Long activityId, Long skuId, Integer count) { - // 1.1 校验秒杀活动是否存在 - SeckillActivityDO activity = validateSeckillActivityExists(activityId); - if (CommonStatusEnum.isDisable(activity.getStatus())) { - throw exception(SECKILL_JOIN_ACTIVITY_STATUS_CLOSED); - } - // 1.2 是否在活动时间范围内 - if (!LocalDateTimeUtils.isBetween(activity.getStartTime(), activity.getEndTime())) { - throw exception(SECKILL_JOIN_ACTIVITY_TIME_ERROR); - } - SeckillConfigDO config = seckillConfigService.getCurrentSeckillConfig(); - if (config == null || !CollectionUtil.contains(activity.getConfigIds(), config.getId())) { - throw exception(SECKILL_JOIN_ACTIVITY_TIME_ERROR); - } - // 1.3 超过单次购买限制 - if (count > activity.getSingleLimitCount()) { - throw exception(SECKILL_JOIN_ACTIVITY_SINGLE_LIMIT_COUNT_EXCEED); - } - - // 2.1 校验秒杀商品是否存在 - SeckillProductDO product = seckillProductMapper.selectByActivityIdAndSkuId(activityId, skuId); - if (product == null) { - throw exception(SECKILL_JOIN_ACTIVITY_PRODUCT_NOT_EXISTS); - } - // 2.2 校验库存是否充足 - if (count > product.getStock()) { - throw exception(SECKILL_ACTIVITY_UPDATE_STOCK_FAIL); - } - return SeckillActivityConvert.INSTANCE.convert02(activity, product); - } - - @Override - public List getSeckillActivityBySpuIdsAndStatusAndDateTimeLt(Collection spuIds, Integer status, LocalDateTime dateTime) { - // 1.查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号 - List> spuIdAndActivityIdMaps = seckillActivityMapper.selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(spuIds, status); - if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) { - return Collections.emptyList(); - } - // 2.查询活动详情 - return seckillActivityMapper.selectListByIdsAndDateTimeLt( - convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")), dateTime); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java deleted file mode 100644 index 13214e7f8..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigService.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 秒杀时段 Service 接口 - * - * @author halfninety - */ -public interface SeckillConfigService { - - /** - * 创建秒杀时段 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createSeckillConfig(@Valid SeckillConfigCreateReqVO createReqVO); - - /** - * 更新秒杀时段 - * - * @param updateReqVO 更新信息 - */ - void updateSeckillConfig(@Valid SeckillConfigUpdateReqVO updateReqVO); - - /** - * 删除秒杀时段 - * - * @param id 编号 - */ - void deleteSeckillConfig(Long id); - - /** - * 获得秒杀时段 - * - * @param id 编号 - * @return 秒杀时段 - */ - SeckillConfigDO getSeckillConfig(Long id); - - /** - * 获得所有秒杀时段列表 - * - * @return 所有秒杀时段列表 - */ - List getSeckillConfigList(); - - /** - * 校验秒杀时段是否存在 - * - * @param ids 秒杀时段 id 集合 - */ - void validateSeckillConfigExists(Collection ids); - - /** - * 获得秒杀时间段配置分页数据 - * - * @param pageVO 分页请求参数 - * @return 秒杀时段分页列表 - */ - PageResult getSeckillConfigPage(SeckillConfigPageReqVO pageVO); - - /** - * 获得所有正常状态的时段配置列表 - * - * @param status 状态 - * @return 秒杀时段列表 - */ - List getSeckillConfigListByStatus(Integer status); - - /** - * 更新秒杀时段配置状态 - * - * @param id id - * @param status 状态 - */ - void updateSeckillConfigStatus(Long id, Integer status); - - /** - * 获得当前的秒杀时段 - * - * 要求必须处于开启状态、且在当前时间段内 - * - * @return 时段 - */ - SeckillConfigDO getCurrentSeckillConfig(); - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java deleted file mode 100644 index c24493bd9..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillConfigServiceImpl.java +++ /dev/null @@ -1,160 +0,0 @@ -package cn.iocoder.yudao.module.promotion.service.seckill; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config.SeckillConfigUpdateReqVO; -import cn.iocoder.yudao.module.promotion.convert.seckill.seckillconfig.SeckillConfigConvert; -import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillConfigDO; -import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillconfig.SeckillConfigMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalTime; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; - -/** - * 秒杀时段 Service 实现类 - * - * @author halfninety - */ -@Service -@Validated -public class SeckillConfigServiceImpl implements SeckillConfigService { - - @Resource - private SeckillConfigMapper seckillConfigMapper; - - @Override - public Long createSeckillConfig(SeckillConfigCreateReqVO createReqVO) { - // 校验时间段是否冲突 - validateSeckillConfigConflict(createReqVO.getStartTime(), createReqVO.getEndTime(), null); - - // 插入 - SeckillConfigDO seckillConfig = SeckillConfigConvert.INSTANCE.convert(createReqVO); - seckillConfigMapper.insert(seckillConfig); - // 返回 - return seckillConfig.getId(); - } - - @Override - public void updateSeckillConfig(SeckillConfigUpdateReqVO updateReqVO) { - // 校验存在 - validateSeckillConfigExists(updateReqVO.getId()); - // 校验时间段是否冲突 - validateSeckillConfigConflict(updateReqVO.getStartTime(), updateReqVO.getEndTime(), updateReqVO.getId()); - - // 更新 - SeckillConfigDO updateObj = SeckillConfigConvert.INSTANCE.convert(updateReqVO); - seckillConfigMapper.updateById(updateObj); - } - - @Override - public void updateSeckillConfigStatus(Long id, Integer status) { - // 校验秒杀时段是否存在 - validateSeckillConfigExists(id); - - // 更新状态 - seckillConfigMapper.updateById(new SeckillConfigDO().setId(id).setStatus(status)); - } - - @Override - public SeckillConfigDO getCurrentSeckillConfig() { - List list = seckillConfigMapper.selectList(SeckillConfigDO::getStatus, CommonStatusEnum.ENABLE.getStatus()); - return findFirst(list, config -> isBetween(config.getStartTime(), config.getEndTime())); - } - - @Override - public void deleteSeckillConfig(Long id) { - // 校验存在 - validateSeckillConfigExists(id); - - // 删除 - seckillConfigMapper.deleteById(id); - } - - private void validateSeckillConfigExists(Long id) { - if (seckillConfigMapper.selectById(id) == null) { - throw exception(SECKILL_CONFIG_NOT_EXISTS); - } - } - - /** - * 校验时间是否存在冲突 - * - * @param startTimeStr 开始时间 - * @param endTimeStr 结束时间 - */ - private void validateSeckillConfigConflict(String startTimeStr, String endTimeStr, Long id) { - // 1. 查询出所有的时段配置 - LocalTime startTime = LocalTime.parse(startTimeStr); - LocalTime endTime = LocalTime.parse(endTimeStr); - List configs = seckillConfigMapper.selectList(); - // 更新时排除自己 - if (id != null) { - configs.removeIf(item -> ObjectUtil.equal(item.getId(), id)); - } - - // 2. 判断是否有重叠的时间 - boolean hasConflict = configs.stream().anyMatch(config -> LocalDateTimeUtils.isOverlap(startTime, endTime, - LocalTime.parse(config.getStartTime()), LocalTime.parse(config.getEndTime()))); - if (hasConflict) { - throw exception(SECKILL_CONFIG_TIME_CONFLICTS); - } - } - - - @Override - public SeckillConfigDO getSeckillConfig(Long id) { - return seckillConfigMapper.selectById(id); - } - - @Override - public List getSeckillConfigList() { - return seckillConfigMapper.selectList(); - } - - @Override - public void validateSeckillConfigExists(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return; - } - // 1. 如果有数量不匹配,说明有不存在的,则抛出 SECKILL_CONFIG_NOT_EXISTS 业务异常 - List configs = seckillConfigMapper.selectBatchIds(ids); - if (configs.size() != ids.size()) { - throw exception(SECKILL_CONFIG_NOT_EXISTS); - } - - // 2. 如果存在关闭,则抛出 SECKILL_CONFIG_DISABLE 业务异常 - configs.forEach(config -> { - if (ObjectUtil.equal(config.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { - throw exception(SECKILL_CONFIG_DISABLE); - } - }); - } - - @Override - public PageResult getSeckillConfigPage(SeckillConfigPageReqVO pageVO) { - return seckillConfigMapper.selectPage(pageVO); - } - - @Override - public List getSeckillConfigListByStatus(Integer status) { - List list = seckillConfigMapper.selectListByStatus(status); - list.sort(Comparator.comparing(SeckillConfigDO::getStartTime)); - return list; - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java deleted file mode 100644 index 2ad362fe2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/util/PromotionUtils.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.promotion.util; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; - -import java.time.LocalDateTime; - -/** - * 活动工具类 - * - * @author 芋道源码 - */ -public class PromotionUtils { - - /** - * 根据时间,计算活动状态 - * - * @param endTime 结束时间 - * @return 活动状态 - */ - public static Integer calculateActivityStatus(LocalDateTime endTime) { - return LocalDateTimeUtils.beforeNow(endTime) ? CommonStatusEnum.DISABLE.getStatus() : CommonStatusEnum.ENABLE.getStatus(); - } - -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-dev.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index b4696be2d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,103 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - # Spring Boot Admin Server 服务端的相关配置 - context-path: /admin # 配置 Spring - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - demo: true # 开启演示模式 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-local.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 09edef067..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,127 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.system.dal.mysql: debug - cn.iocoder.yudao.module.system.dal.mysql.sensitiveword.SensitiveWordMapper: INFO # 配置 SensitiveWordMapper 的日志级别为 info - cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - security: - mock-enable: true - xss: - enable: false - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application.yaml deleted file mode 100644 index b21ee163d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,109 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.promotion - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - captcha: - enable: true # 验证码的开关,默认为 true; - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - ignore-tables: - -debug: false diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 05266e5f4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: promotion-server - - profiles: - active: local - -server: - port: 48101 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/logback-spring.xml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/discount/DiscountProductMapper.xml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/discount/DiscountProductMapper.xml deleted file mode 100644 index 76af37db2..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/discount/DiscountProductMapper.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index c656a9fe4..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,47 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/logback.xml b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index 6a1a24252..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,12 +0,0 @@ -DELETE FROM "market_activity"; -DELETE FROM "promotion_coupon_template"; -DELETE FROM "promotion_coupon"; -DELETE FROM "promotion_reward_activity"; -DELETE FROM "promotion_discount_activity"; -DELETE FROM "promotion_discount_product"; -DELETE FROM "promotion_seckill_config"; -DELETE FROM "promotion_combination_activity"; -DELETE FROM "promotion_article_category"; -DELETE FROM "promotion_article"; -DELETE FROM "promotion_diy_template"; -DELETE FROM "promotion_diy_page"; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 00ac3f93d..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,256 +0,0 @@ -CREATE TABLE IF NOT EXISTS "market_activity" -( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "title" varchar(50) NOT NULL, - "activity_type" tinyint(4) NOT NULL, - "status" tinyint(4) NOT NULL, - "start_time" datetime NOT NULL, - "end_time" datetime NOT NULL, - "invalid_time" datetime, - "delete_time" datetime, - "time_limited_discount" varchar(2000), - "full_privilege" varchar(2000), - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint(20) NOT NULL, - PRIMARY KEY ("id") -) COMMENT '促销活动'; - -CREATE TABLE IF NOT EXISTS "promotion_coupon_template" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "status" int NOT NULL, - "total_count" int NOT NULL, - "take_limit_count" int NOT NULL, - "take_type" int NOT NULL, - "use_price" int NOT NULL, - "product_scope" int NOT NULL, - "product_spu_ids" varchar, - "validity_type" int NOT NULL, - "valid_start_time" datetime, - "valid_end_time" datetime, - "fixed_start_term" int, - "fixed_end_term" int, - "discount_type" int NOT NULL, - "discount_percent" int, - "discount_price" int, - "discount_limit_price" int, - "take_count" int NOT NULL DEFAULT 0, - "use_count" int NOT NULL DEFAULT 0, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '优惠劵模板'; - -CREATE TABLE IF NOT EXISTS "promotion_coupon" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "template_id" bigint NOT NULL, - "name" varchar NOT NULL, - "status" int NOT NULL, - "user_id" bigint NOT NULL, - "take_type" int NOT NULL, - "useprice" int NOT NULL, - "valid_start_time" datetime NOT NULL, - "valid_end_time" datetime NOT NULL, - "product_scope" int NOT NULL, - "product_spu_ids" varchar, - "discount_type" int NOT NULL, - "discount_percent" int, - "discount_price" int, - "discount_limit_price" int, - "use_order_id" bigint, - "use_time" datetime, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '优惠劵'; - -CREATE TABLE IF NOT EXISTS "promotion_reward_activity" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "status" int NOT NULL, - "start_time" datetime NOT NULL, - "end_time" datetime NOT NULL, - "remark" varchar, - "condition_type" int NOT NULL, - "product_scope" int NOT NULL, - "product_spu_ids" varchar, - "rules" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '满减送活动'; - -CREATE TABLE IF NOT EXISTS "promotion_discount_activity" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "status" int NOT NULL, - "start_time" datetime NOT NULL, - "end_time" datetime NOT NULL, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '限时折扣活动'; - -CREATE TABLE IF NOT EXISTS "promotion_seckill_activity" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "spu_id" bigint NOT NULL, - "name" varchar NOT NULL, - "status" int NOT NULL, - "remark" varchar, - "start_time" varchar NOT NULL, - "end_time" varchar NOT NULL, - "sort" int NOT NULL, - "config_ids" varchar NOT NULL, - "order_count" int NOT NULL, - "user_count" int NOT NULL, - "total_price" int NOT NULL, - "total_limit_count" int, - "single_limit_count" int, - "stock" int, - "total_stock" int, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '秒杀活动'; - -CREATE TABLE IF NOT EXISTS "promotion_seckill_config" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "start_time" varchar NOT NULL, - "end_time" varchar NOT NULL, - "pic_url" varchar NOT NULL, - "status" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '秒杀时段配置'; - -CREATE TABLE IF NOT EXISTS "promotion_combination_activity" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "spu_id" bigint, - "total_limit_count" int NOT NULL, - "single_limit_count" int NOT NULL, - "start_time" varchar NOT NULL, - "end_time" varchar NOT NULL, - "user_size" int NOT NULL, - "total_num" int NOT NULL, - "success_num" int NOT NULL, - "order_user_count" int NOT NULL, - "virtual_group" int NOT NULL, - "status" int NOT NULL, - "limit_duration" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '拼团活动'; - -CREATE TABLE IF NOT EXISTS "promotion_article_category" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "pic_url" varchar, - "status" int NOT NULL, - "sort" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '文章分类表'; - -CREATE TABLE IF NOT EXISTS "promotion_article" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "category_id" bigint NOT NULL, - "title" varchar NOT NULL, - "author" varchar, - "pic_url" varchar NOT NULL, - "introduction" varchar, - "browse_count" varchar, - "sort" int NOT NULL, - "status" int NOT NULL, - "spu_id" bigint NOT NULL, - "recommend_hot" bit NOT NULL, - "recommend_banner" bit NOT NULL, - "content" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '文章管理表'; - -CREATE TABLE IF NOT EXISTS "promotion_diy_template" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "used" bit NOT NULL, - "used_time" varchar, - "remark" varchar, - "preview_pic_urls" varchar, - "property" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL DEFAULT 0, - PRIMARY KEY ("id") -) COMMENT '装修模板'; -CREATE TABLE IF NOT EXISTS "promotion_diy_page" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "template_id" bigint NOT NULL, - "name" varchar NOT NULL, - "remark" varchar, - "preview_pic_urls" varchar, - "property" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL, - PRIMARY KEY ("id") -) COMMENT '装修页面'; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-api/pom.xml b/yudao-module-mall/yudao-module-statistics-api/pom.xml deleted file mode 100644 index 79e592c96..000000000 --- a/yudao-module-mall/yudao-module-statistics-api/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-statistics-api - jar - - ${project.artifactId} - - statistics 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - diff --git a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/api/package-info.java b/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/api/package-info.java deleted file mode 100644 index 2963c120a..000000000 --- a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位,无特殊含义 - */ -package cn.iocoder.yudao.module.statistics.api; diff --git a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java b/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java deleted file mode 100644 index 5f3c8fe22..000000000 --- a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.statistics.enums; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 时间范围类型的枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum TimeRangeTypeEnum implements IntArrayValuable { - - /** - * 天 - */ - DAY(1), - /** - * 周 - */ - WEEK(7), - /** - * 月 - */ - MONTH(30), - /** - * 年 - */ - YEAR(365), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TimeRangeTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/package-info.java b/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/package-info.java deleted file mode 100644 index f885ae076..000000000 --- a/yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位,无特殊含义 - */ -package cn.iocoder.yudao.module.statistics.enums; diff --git a/yudao-module-mall/yudao-module-statistics-biz/pom.xml b/yudao-module-mall/yudao-module-statistics-biz/pom.xml deleted file mode 100644 index 0e66532b9..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/pom.xml +++ /dev/null @@ -1,153 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-statistics-biz - jar - - ${project.artifactId} - - statistics 模块,主要实现统计相关功能 - 例如:统计商品、会员、交易等功能。 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-statistics-api - ${revision} - - - cn.iocoder.cloud - yudao-module-promotion-api - ${revision} - - - cn.iocoder.cloud - yudao-module-product-api - ${revision} - - - cn.iocoder.cloud - yudao-module-trade-api - ${revision} - - - cn.iocoder.cloud - yudao-module-member-api - ${revision} - - - cn.iocoder.cloud - yudao-module-pay-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-ip - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-web - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-job - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/StatisticsServerApplication.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/StatisticsServerApplication.java deleted file mode 100644 index 8811256d2..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/StatisticsServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.statistics; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class StatisticsServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(StatisticsServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/common/vo/DataComparisonRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/common/vo/DataComparisonRespVO.java deleted file mode 100644 index efd889a87..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/common/vo/DataComparisonRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.common.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - 数据对照 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DataComparisonRespVO { - - @Schema(description = "当前数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private T value; - - @Schema(description = "参照数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private T reference; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java deleted file mode 100644 index 9b0f7158b..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java +++ /dev/null @@ -1,114 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member; - -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.NumberUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; -import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert; -import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService; -import cn.iocoder.yudao.module.statistics.service.member.MemberStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 会员统计") -@RestController -@RequestMapping("/statistics/member") -@Validated -@Slf4j -public class MemberStatisticsController { - - @Resource - private MemberStatisticsService memberStatisticsService; - @Resource - private TradeOrderStatisticsService tradeOrderStatisticsService; - @Resource - private ApiAccessLogStatisticsService apiAccessLogStatisticsService; - - @GetMapping("/summary") - @Operation(summary = "获得会员统计(实时统计)") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult getMemberSummary() { - return success(memberStatisticsService.getMemberSummary()); - } - - @GetMapping("/analyse") - @Operation(summary = "获得会员分析数据") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult getMemberAnalyse(MemberAnalyseReqVO reqVO) { - // 1. 查询数据 - LocalDateTime beginTime = ArrayUtil.get(reqVO.getTimes(), 0); - LocalDateTime endTime = ArrayUtil.get(reqVO.getTimes(), 1); - // 1.1 查询分析对照数据 - DataComparisonRespVO comparisonData = memberStatisticsService.getMemberAnalyseComparisonData(beginTime, endTime); - // TODO @疯狂:这个可能有点特殊,要按照 create_time 来查询;不然它的漏斗就不统一;因为是访问数量 > 今日下单人 > 今日支付人;是一个统一的维度; - // 1.2 查询成交用户数量 - Integer payUserCount = tradeOrderStatisticsService.getPayUserCount(beginTime, endTime); - // 1.3 计算客单价 - int atv = 0; - if (payUserCount != null && payUserCount > 0) { - // TODO @疯狂:类似上面的 payUserCount - Integer payPrice = tradeOrderStatisticsService.getOrderPayPrice(beginTime, endTime); - atv = NumberUtil.div(payPrice, payUserCount).intValue(); - } - // 1.4 查询访客数量 - Integer visitUserCount = apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime); - // 1.5 下单用户数量 - Integer orderUserCount = tradeOrderStatisticsService.getOrderUserCount(beginTime, endTime); - - // 2. 拼接返回 - return success(MemberStatisticsConvert.INSTANCE.convert(visitUserCount, orderUserCount, payUserCount, atv, comparisonData)); - } - - @GetMapping("/area-statistics-list") - @Operation(summary = "按照省份,获得会员统计列表") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getMemberAreaStatisticsList() { - return success(memberStatisticsService.getMemberAreaStatisticsList()); - } - - @GetMapping("/sex-statistics-list") - @Operation(summary = "按照性别,获得会员统计列表") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getMemberSexStatisticsList() { - return success(memberStatisticsService.getMemberSexStatisticsList()); - } - - @GetMapping("/terminal-statistics-list") - @Operation(summary = "按照终端,获得会员统计列表") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getMemberTerminalStatisticsList() { - return success(memberStatisticsService.getMemberTerminalStatisticsList()); - } - - // TODO @疯狂:要注意 date 的排序; - @GetMapping("/user-count-comparison") - @Operation(summary = "获得用户数量对照") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getUserCountComparison() { - return success(memberStatisticsService.getUserCountComparison()); - } - - @GetMapping("/register-count-list") - @Operation(summary = "获得会员注册数量列表") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") - public CommonResult> getMemberRegisterCountList(MemberAnalyseReqVO reqVO) { - return success(memberStatisticsService.getMemberRegisterCountList( - ArrayUtil.get(reqVO.getTimes(), 0), ArrayUtil.get(reqVO.getTimes(), 1))); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseDataRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseDataRespVO.java deleted file mode 100644 index d2dd3e483..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseDataRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员分析数据 Response VO") -@Data -public class MemberAnalyseDataRespVO { - - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer registerUserCount; - - @Schema(description = "活跃用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer visitUserCount; - - @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") - private Integer rechargeUserCount; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseReqVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseReqVO.java deleted file mode 100644 index e0106b4e8..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseReqVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员分析 Request VO") -@Data -public class MemberAnalyseReqVO { - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "时间范围") - private LocalDateTime[] times; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseRespVO.java deleted file mode 100644 index e1c46547b..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员分析 Response VO") -@Data -public class MemberAnalyseRespVO { - - @Schema(description = "访客数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer visitUserCount; - - @Schema(description = "下单用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderUserCount; - - @Schema(description = "成交用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer payUserCount; - - @Schema(description = "客单价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer atv; - - @Schema(description = "对照数据", requiredMode = Schema.RequiredMode.REQUIRED) - private DataComparisonRespVO comparison; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java deleted file mode 100644 index 1024d04ef..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员地区统计 Response VO") -@Data -public class MemberAreaStatisticsRespVO { - - @Schema(description = "省份编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer areaId; - @Schema(description = "省份名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "浙江省") - private String areaName; - - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer userCount; - - @Schema(description = "下单的会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderCreateUserCount; - @Schema(description = "支付订单的会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") - private Integer orderPayUserCount; - - @Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622") - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java deleted file mode 100644 index ce81658cf..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员数量统计 Response VO") -@Data -public class MemberCountRespVO { - - @Schema(description = "用户访问量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer visitUserCount; - - @Schema(description = "注册用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer registerUserCount; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java deleted file mode 100644 index fb7fc2ac4..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDate; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -@Schema(description = "管理后台 - 会员注册数量 Response VO") -@Data -public class MemberRegisterCountRespVO { - - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY, timezone = TIME_ZONE_DEFAULT) - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private LocalDate date; - - @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java deleted file mode 100644 index eaf7ce5f5..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSexStatisticsRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员性别统计 Response VO") -@Data -public class MemberSexStatisticsRespVO { - - @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sex; - - // TODO @疯狂:要不还是其它字段,我们也补全,这样方便使用的用户,做定制化;就保持和 MemberAreaStatisticsRespVO 一致; - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer userCount; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java deleted file mode 100644 index 2a55e3897..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberSummaryRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员统计 Response VO") -@Data -public class MemberSummaryRespVO { - - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer userCount; - - @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") - private Integer rechargeUserCount; - - @Schema(description = "充值金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer rechargePrice; - - // TODO @疯狂:要不干脆这个字段改成:orderPayPrice?? - @Schema(description = "支出金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer expensePrice; // 只计算 mall 交易订单的支付金额,不考虑退款 - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java deleted file mode 100644 index 3ecf0f8fe..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberTerminalStatisticsRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员终端统计 Response VO") -@Data -public class MemberTerminalStatisticsRespVO { - - @Schema(description = "终端", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer terminal; - - // TODO @疯狂:要不 orderCreateUserCount 和 orderPayUserCount 貌似更统一一些; - @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer userCount; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java deleted file mode 100644 index 362ec7d57..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.pay; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO; -import cn.iocoder.yudao.module.statistics.convert.pay.PayStatisticsConvert; -import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 支付统计") -@RestController -@RequestMapping("/statistics/pay") -@Validated -@Slf4j -public class PayStatisticsController { - - @Resource - private PayWalletStatisticsService payWalletStatisticsService; - - @GetMapping("/summary") - @Operation(summary = "获取充值金额") - public CommonResult getWalletRechargePrice() { - Integer rechargePrice = payWalletStatisticsService.getRechargePriceSummary(); - return success(PayStatisticsConvert.INSTANCE.convert(rechargePrice)); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java deleted file mode 100644 index 01edc24cf..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.pay.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 支付统计 Response VO") -@Data -public class PaySummaryRespVO { - - @Schema(description = "充值金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer rechargePrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/ProductStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/ProductStatisticsController.java deleted file mode 100644 index b215d7067..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/ProductStatisticsController.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.product; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.SortablePageParam; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsReqVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.product.ProductStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.product.ProductStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 商品统计") -@RestController -@RequestMapping("/statistics/product") -@Validated -public class ProductStatisticsController { - - @Resource - private ProductStatisticsService productStatisticsService; - - @Resource - private ProductSpuApi productSpuApi; - - @GetMapping("/analyse") - @Operation(summary = "获得商品统计分析") - @PreAuthorize("@ss.hasPermission('statistics:product:query')") - public CommonResult> getProductStatisticsAnalyse(ProductStatisticsReqVO reqVO) { - return success(productStatisticsService.getProductStatisticsAnalyse(reqVO)); - } - - @GetMapping("/list") - @Operation(summary = "获得商品统计明细(日期维度)") - @PreAuthorize("@ss.hasPermission('statistics:product:query')") - public CommonResult> getProductStatisticsList(ProductStatisticsReqVO reqVO) { - List list = productStatisticsService.getProductStatisticsList(reqVO); - return success(BeanUtils.toBean(list, ProductStatisticsRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出获得商品统计明细 Excel(日期维度)") - @PreAuthorize("@ss.hasPermission('statistics:product:export')") - public void exportProductStatisticsExcel(ProductStatisticsReqVO reqVO, HttpServletResponse response) throws IOException { - List list = productStatisticsService.getProductStatisticsList(reqVO); - // 导出 Excel - List voList = BeanUtils.toBean(list, ProductStatisticsRespVO.class); - ExcelUtils.write(response, "商品状况.xls", "数据", ProductStatisticsRespVO.class, voList); - } - - @GetMapping("/rank-page") - @Operation(summary = "获得商品统计排行榜分页(商品维度)") - @PreAuthorize("@ss.hasPermission('statistics:product:query')") - public CommonResult> getProductStatisticsRankPage(@Valid ProductStatisticsReqVO reqVO, - @Valid SortablePageParam pageParam) { - PageResult pageResult = productStatisticsService.getProductStatisticsRankPage(reqVO, pageParam); - // 处理商品信息 - Set spuIds = convertSet(pageResult.getList(), ProductStatisticsDO::getSpuId); - Map spuMap = convertMap(productSpuApi.getSpuList(spuIds).getCheckedData(), ProductSpuRespDTO::getId); - return success(BeanUtils.toBean(pageResult, ProductStatisticsRespVO.class, - item -> Optional.ofNullable(spuMap.get(item.getSpuId())) - .ifPresent(spu -> item.setName(spu.getName()).setPicUrl(spu.getPicUrl())))); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/vo/ProductStatisticsReqVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/vo/ProductStatisticsReqVO.java deleted file mode 100644 index 02387c32f..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/vo/ProductStatisticsReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.product.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 商品统计分析 Request VO") -@Data -@ToString(callSuper = true) -@AllArgsConstructor -@NoArgsConstructor -public class ProductStatisticsReqVO { - - @Schema(description = "统计时间范围", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] times; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/vo/ProductStatisticsRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/vo/ProductStatisticsRespVO.java deleted file mode 100644 index 9d93142e3..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/vo/ProductStatisticsRespVO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.product.vo; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDate; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -@Schema(description = "管理后台 - 商品统计 Response VO") -@Data -@ExcelIgnoreUnannotated -public class ProductStatisticsRespVO { - - @Schema(description = "编号,主键自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "12393") - private Long id; - - @Schema(description = "统计日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-12-16") - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY) - @ExcelProperty("统计日期") - private LocalDate time; - - @Schema(description = "商品SPU编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15114") - @ExcelProperty("商品SPU编号") - private Long spuId; - - // region 商品信息 - - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "商品名称") - @ExcelProperty("商品名称") - private String name; - - @Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "15114") - @ExcelProperty("商品封面图") - private String picUrl; - - // endregion - - @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "17505") - @ExcelProperty("浏览量") - private Integer browseCount; - - @Schema(description = "访客量", requiredMode = Schema.RequiredMode.REQUIRED, example = "11814") - @ExcelProperty("访客量") - private Integer browseUserCount; - - @Schema(description = "收藏数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20950") - @ExcelProperty("收藏数量") - private Integer favoriteCount; - - @Schema(description = "加购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "28493") - @ExcelProperty("加购数量") - private Integer cartCount; - - @Schema(description = "下单件数", requiredMode = Schema.RequiredMode.REQUIRED, example = "18966") - @ExcelProperty("下单件数") - private Integer orderCount; - - @Schema(description = "支付件数", requiredMode = Schema.RequiredMode.REQUIRED, example = "15142") - @ExcelProperty("支付件数") - private Integer orderPayCount; - - @Schema(description = "支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "11595") - @ExcelProperty("支付金额,单位:分") - private Integer orderPayPrice; - - @Schema(description = "退款件数", requiredMode = Schema.RequiredMode.REQUIRED, example = "2591") - @ExcelProperty("退款件数") - private Integer afterSaleCount; - - @Schema(description = "退款金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "21709") - @ExcelProperty("退款金额,单位:分") - private Integer afterSaleRefundPrice; - - @Schema(description = "访客支付转化率(百分比)", requiredMode = Schema.RequiredMode.REQUIRED, example = "15") - private Integer browseConvertPercent; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java deleted file mode 100644 index 5aa88e51a..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java +++ /dev/null @@ -1,130 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; -import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.AfterSaleStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.BrokerageStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 交易统计") -@RestController -@RequestMapping("/statistics/trade") -@Validated -@Slf4j -public class TradeStatisticsController { - - @Resource - private TradeStatisticsService tradeStatisticsService; - @Resource - private TradeOrderStatisticsService tradeOrderStatisticsService; - @Resource - private AfterSaleStatisticsService afterSaleStatisticsService; - @Resource - private BrokerageStatisticsService brokerageStatisticsService; - - @GetMapping("/summary") - @Operation(summary = "获得交易统计") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult> getTradeSummaryComparison() { - // 1.1 昨天的数据 - TradeSummaryRespBO yesterdayData = tradeStatisticsService.getTradeSummaryByDays(-1); - // 1.2 前天的数据(用于对照昨天的数据) - TradeSummaryRespBO beforeYesterdayData = tradeStatisticsService.getTradeSummaryByDays(-2); - - // 2.1 本月数据 - TradeSummaryRespBO monthData = tradeStatisticsService.getTradeSummaryByMonths(0); - // 2.2 上月数据(用于对照本月的数据) - TradeSummaryRespBO lastMonthData = tradeStatisticsService.getTradeSummaryByMonths(-1); - // 拼接数据 - return success(TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData)); - } - - @GetMapping("/analyse") - @Operation(summary = "获得交易状况统计") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult> getTradeStatisticsAnalyse(TradeTrendReqVO reqVO) { - return success(tradeStatisticsService.getTradeStatisticsAnalyse(ArrayUtil.get(reqVO.getTimes(), 0), - ArrayUtil.get(reqVO.getTimes(), 1))); - } - - @GetMapping("/list") - @Operation(summary = "获得交易状况明细") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult> getTradeStatisticsList(TradeTrendReqVO reqVO) { - List list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), - ArrayUtil.get(reqVO.getTimes(), 1)); - return success(TradeStatisticsConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出获得交易状况明细 Excel") - @PreAuthorize("@ss.hasPermission('statistics:trade:export')") - public void exportTradeStatisticsExcel(TradeTrendReqVO reqVO, HttpServletResponse response) throws IOException { - List list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), - ArrayUtil.get(reqVO.getTimes(), 1)); - // 导出 Excel - List voList = TradeStatisticsConvert.INSTANCE.convertList(list); - List data = TradeStatisticsConvert.INSTANCE.convertList02(voList); - ExcelUtils.write(response, "交易状况.xls", "数据", TradeTrendSummaryExcelVO.class, data); - } - - @GetMapping("/order-count") - @Operation(summary = "获得交易订单数量") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult getOrderCount() { - // 订单统计 - Long undeliveredCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType( - TradeOrderStatusEnum.UNDELIVERED.getStatus(), DeliveryTypeEnum.EXPRESS.getType()); - // TODO @疯狂:订单支付后,如果是门店自提的,需要 update 成 DELIVERED;;目前还没搞~~突然反应过来 - Long pickUpCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType( - TradeOrderStatusEnum.DELIVERED.getStatus(), DeliveryTypeEnum.PICK_UP.getType()); - // 售后统计 - Long afterSaleApplyCount = afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY); - Long auditingWithdrawCount = brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING); - // 拼接返回 - return success(TradeStatisticsConvert.INSTANCE.convert(undeliveredCount, pickUpCount, afterSaleApplyCount, auditingWithdrawCount)); - } - - @GetMapping("/order-comparison") - @Operation(summary = "获得交易订单数量") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult> getOrderComparison() { - return success(tradeOrderStatisticsService.getOrderComparison()); - } - - @GetMapping("/order-count-trend") - @Operation(summary = "获得订单量趋势统计") - @PreAuthorize("@ss.hasPermission('statistics:trade:query')") - public CommonResult>> getOrderCountTrendComparison(@Valid TradeOrderTrendReqVO reqVO) { - // TODO @疯狂:要注意 date 的排序; - return success(tradeOrderStatisticsService.getOrderCountTrendComparison(reqVO)); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java deleted file mode 100644 index 1320a889e..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 交易订单数量 Response VO") -@Data -public class TradeOrderCountRespVO { - - @Schema(description = "待发货", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long undelivered; - - @Schema(description = "待核销", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long pickUp; - - @Schema(description = "退款中", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long afterSaleApply; - - @Schema(description = "提现待审核", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long auditingWithdraw; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java deleted file mode 100644 index 22d8f4a14..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 交易订单统计 Response VO") -@Data -public class TradeOrderSummaryRespVO { - - @Schema(description = "支付订单商品数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayCount; - - @Schema(description = "总支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java deleted file mode 100644 index 57f054629..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 交易订单量趋势统计 Request VO") -@Data -public class TradeOrderTrendReqVO { - - @Schema(description = "日期范围类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "日期范围类型不能为空") - @InEnum(value = TimeRangeTypeEnum.class, message = "日期范围类型,必须是 {value}") - private Integer type; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "起始时间") - private LocalDateTime beginTime; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "截止时间") - private LocalDateTime endTime; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java deleted file mode 100644 index d69c343cb..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 订单量趋势统计 Response VO") -@Data -public class TradeOrderTrendRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String date; - - @Schema(description = "订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayCount; - - @Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeSummaryRespVO.java deleted file mode 100644 index 5e0e7c62d..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeSummaryRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 交易统计 Response VO") -@Data -public class TradeSummaryRespVO { - - @Schema(description = "昨日订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer yesterdayOrderCount; - @Schema(description = "昨日支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer yesterdayPayPrice; - - @Schema(description = "本月订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer monthOrderCount; - @Schema(description = "本月支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer monthPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendReqVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendReqVO.java deleted file mode 100644 index 234b7a785..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 交易状况 Request VO") -@Data -public class TradeTrendReqVO { - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "时间范围") - private LocalDateTime[] times; -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java deleted file mode 100644 index 5b14fa1d4..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import cn.iocoder.yudao.framework.excel.core.convert.MoneyConvert; -import com.alibaba.excel.annotation.ExcelProperty; -import com.alibaba.excel.annotation.format.DateTimeFormat; -import lombok.Data; - -import java.time.LocalDate; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -/** - * 交易状况统计 Excel VO - * - * @author owen - */ -@Data -public class TradeTrendSummaryExcelVO { - - @ExcelProperty(value = "日期") - @DateTimeFormat(FORMAT_YEAR_MONTH_DAY) - private LocalDate date; - - @ExcelProperty(value = "营业额", converter = MoneyConvert.class) - private Integer turnoverPrice; - - @ExcelProperty(value = "商品支付金额", converter = MoneyConvert.class) - private Integer orderPayPrice; - - @ExcelProperty(value = "充值金额", converter = MoneyConvert.class) - private Integer rechargePrice; - - @ExcelProperty(value = "支出金额", converter = MoneyConvert.class) - private Integer expensePrice; - - @ExcelProperty(value = "余额支付金额", converter = MoneyConvert.class) - private Integer walletPayPrice; - - @ExcelProperty(value = "支付佣金金额", converter = MoneyConvert.class) - private Integer brokerageSettlementPrice; - - @ExcelProperty(value = "商品退款金额", converter = MoneyConvert.class) - private Integer afterSaleRefundPrice; -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java deleted file mode 100644 index be5a93a51..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; - -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDate; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -@Schema(description = "管理后台 - 交易状况统计 Response VO") -@Data -public class TradeTrendSummaryRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-12-16") - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY) - private LocalDate date; - - @Schema(description = "营业额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer turnoverPrice; // 营业额 = 商品支付金额 + 充值金额 - - @Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderPayPrice; - - @Schema(description = "余额支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer walletPayPrice; - - @Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer afterSaleRefundPrice; - - @Schema(description = "支付佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer brokerageSettlementPrice; - - @Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer rechargePrice; - - @Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer expensePrice; // 余额支付金额 + 支付佣金金额 + 商品退款金额 - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/app/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/app/package-info.java deleted file mode 100644 index 1384194b4..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/app/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占位 - */ -package cn.iocoder.yudao.module.statistics.controller.app; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java deleted file mode 100644 index 2d527b0a3..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.statistics.convert.member; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseDataRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * 会员统计 Convert - * - * @author owen - */ -@Mapper -public interface MemberStatisticsConvert { - - MemberStatisticsConvert INSTANCE = Mappers.getMapper(MemberStatisticsConvert.class); - - default List convertList(List areaList, - Map userCountMap, - Map orderMap) { - return CollectionUtils.convertList(areaList, area -> { - MemberAreaStatisticsRespBO orderVo = Optional.ofNullable(orderMap.get(area.getId())) - .orElseGet(MemberAreaStatisticsRespBO::new); - return new MemberAreaStatisticsRespVO() - .setAreaId(area.getId()).setAreaName(area.getName()) - .setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0)) - .setOrderCreateUserCount(ObjUtil.defaultIfNull(orderVo.getOrderCreateUserCount(), 0)) - .setOrderPayUserCount(ObjUtil.defaultIfNull(orderVo.getOrderPayUserCount(), 0)) - .setOrderPayPrice(ObjUtil.defaultIfNull(orderVo.getOrderPayPrice(), 0)); - }); - } - - MemberSummaryRespVO convert(RechargeSummaryRespBO rechargeSummary, Integer expensePrice, Integer userCount); - - MemberAnalyseRespVO convert(Integer visitUserCount, Integer orderUserCount, Integer payUserCount, int atv, - DataComparisonRespVO comparison); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java deleted file mode 100644 index 08f38005f..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.statistics.convert.pay; - -import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 支付统计 Convert - * - * @author owen - */ -@Mapper -public interface PayStatisticsConvert { - - PayStatisticsConvert INSTANCE = Mappers.getMapper(PayStatisticsConvert.class); - - PaySummaryRespVO convert(Integer rechargePrice); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java deleted file mode 100644 index 7c140628f..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.statistics.convert.trade; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderCountRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; -import org.mapstruct.IterableMapping; -import org.mapstruct.Mapper; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易统计 Convert - * - * @author owen - */ -@Mapper -public interface TradeStatisticsConvert { - - TradeStatisticsConvert INSTANCE = Mappers.getMapper(TradeStatisticsConvert.class); - - default DataComparisonRespVO convert(TradeSummaryRespBO yesterdayData, - TradeSummaryRespBO beforeYesterdayData, - TradeSummaryRespBO monthData, - TradeSummaryRespBO lastMonthData) { - return convert(convert(yesterdayData, monthData), convert(beforeYesterdayData, lastMonthData)); - } - - - default TradeSummaryRespVO convert(TradeSummaryRespBO yesterdayData, TradeSummaryRespBO monthData) { - return new TradeSummaryRespVO() - .setYesterdayOrderCount(yesterdayData.getCount()).setYesterdayPayPrice(yesterdayData.getSummary()) - .setMonthOrderCount(monthData.getCount()).setMonthPayPrice(monthData.getSummary()); - } - - DataComparisonRespVO convert(TradeSummaryRespVO value, TradeSummaryRespVO reference); - - DataComparisonRespVO convert(TradeTrendSummaryRespVO value, - TradeTrendSummaryRespVO reference); - - List convertList02(List list); - - TradeStatisticsDO convert(LocalDateTime time, TradeOrderSummaryRespBO orderSummary, - AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice, - WalletSummaryRespBO walletSummary); - - @IterableMapping(qualifiedByName = "convert") - List convertList(List list); - - TradeTrendSummaryRespVO convertA(TradeStatisticsDO tradeStatistics); - - @Named("convert") - default TradeTrendSummaryRespVO convert(TradeStatisticsDO tradeStatistics) { - TradeTrendSummaryRespVO vo = convertA(tradeStatistics); - return vo - .setDate(tradeStatistics.getTime().toLocalDate()) - // 营业额 = 商品支付金额 + 充值金额 - .setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice()) - // 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 - .setExpensePrice(tradeStatistics.getWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice()); - } - - TradeOrderCountRespVO convert(Long undelivered, Long pickUp, Long afterSaleApply, Long auditingWithdraw); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/package-info.java deleted file mode 100644 index 80eca3b41..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 todo - */ -package cn.iocoder.yudao.module.statistics.dal.dataobject; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/product/ProductStatisticsDO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/product/ProductStatisticsDO.java deleted file mode 100644 index 426906d47..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/product/ProductStatisticsDO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.dataobject.product; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDate; - -/** - * 商品统计 DO - * - * @author owen - */ -@TableName("product_statistics") -@KeySequence("product_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProductStatisticsDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - /** - * 统计日期 - */ - private LocalDate time; - /** - * 商品 SPU 编号 - */ - private Long spuId; - /** - * 浏览量 - */ - private Integer browseCount; - /** - * 访客量 - */ - private Integer browseUserCount; - /** - * 收藏数量 - */ - private Integer favoriteCount; - /** - * 加购数量 - */ - private Integer cartCount; - /** - * 下单件数 - */ - private Integer orderCount; - /** - * 支付件数 - */ - private Integer orderPayCount; - /** - * 支付金额,单位:分 - */ - private Integer orderPayPrice; - /** - * 退款件数 - */ - private Integer afterSaleCount; - /** - * 退款金额,单位:分 - */ - private Integer afterSaleRefundPrice; - /** - * 访客支付转化率(百分比) - */ - private Integer browseConvertPercent; - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java deleted file mode 100644 index 46e148aa4..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.dataobject.trade; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 交易统计 DO - *

- * 以天为维度,统计全部的数据 - * - * @author 芋道源码 - */ -@TableName("trade_statistics") -@KeySequence("trade_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeStatisticsDO extends BaseDO { - - /** - * 编号,主键自增 - */ - @TableId - private Long id; - - /** - * 统计日期 - */ - private LocalDateTime time; - - /** - * 创建订单数 - */ - private Integer orderCreateCount; - /** - * 支付订单商品数 - */ - private Integer orderPayCount; - /** - * 总支付金额,单位:分 - */ - private Integer orderPayPrice; - - /** - * 退款订单数 - */ - private Integer afterSaleCount; - /** - * 总退款金额,单位:分 - */ - private Integer afterSaleRefundPrice; - - /** - * 佣金金额(已结算),单位:分 - */ - private Integer brokerageSettlementPrice; - - /** - * 总支付金额(余额),单位:分 - */ - private Integer walletPayPrice; - /** - * 充值订单数 - *

- * 从 PayWalletRechargeDO 计算 - */ - private Integer rechargePayCount; - /** - * 充值金额,单位:分 - */ - private Integer rechargePayPrice; - /** - * 充值退款订单数 - */ - private Integer rechargeRefundCount; - /** - * 充值退款金额,单位:分 - */ - private Integer rechargeRefundPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java deleted file mode 100644 index 5f76b58fd..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.infra; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; - -// TODO @芋艿:api 访问日志,现在会清理,可能要单独有个偏业务的访问表; -/** - * API 访问日志的统计 Mapper - * - * @author owen - */ -@Mapper -@SuppressWarnings("rawtypes") -public interface ApiAccessLogStatisticsMapper extends BaseMapperX { - - Integer selectIpCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Integer selectUserCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java deleted file mode 100644 index 595e93d9e..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.member; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberRegisterCountRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 会员信息的统计 Mapper - * - * @author owen - */ -@Mapper -@SuppressWarnings("rawtypes") -public interface MemberStatisticsMapper extends BaseMapperX { - - List selectSummaryListByAreaId(); - - List selectSummaryListBySex(); - - List selectSummaryListByRegisterTerminal(); - - Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - /** - * 获得用户的每天注册数量列表 - * - * @param beginTime 开始时间 - * @param endTime 结束时间 - * @return 每天注册数量列表 - */ - List selectListByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java deleted file mode 100644 index b9b38fbbe..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.pay; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; - -/** - * 支付钱包的统计 Mapper - * - * @author owen - */ -@Mapper -@SuppressWarnings("rawtypes") -public interface PayWalletStatisticsMapper extends BaseMapperX { - - WalletSummaryRespBO selectRechargeSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime, - @Param("payStatus") Boolean payStatus); - - WalletSummaryRespBO selectRechargeSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime, - @Param("refundStatus") Integer refundStatus); - - Integer selectPriceSummaryByBizTypeAndCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime, - @Param("bizType") Integer bizType); - - RechargeSummaryRespBO selectRechargeSummaryGroupByWalletId(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime, - @Param("payStatus") Boolean payStatus); - - Integer selectRechargePriceSummary(@Param("payStatus") Integer payStatus); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductStatisticsMapper.java deleted file mode 100644 index 600296f66..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/product/ProductStatisticsMapper.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.SortablePageParam; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsReqVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.product.ProductStatisticsDO; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 商品统计 Mapper - * - * @author owen - */ -@Mapper -public interface ProductStatisticsMapper extends BaseMapperX { - - default PageResult selectPageGroupBySpuId(ProductStatisticsReqVO reqVO, SortablePageParam pageParam) { - return selectPage(pageParam, buildWrapper(reqVO) - .groupBy(ProductStatisticsDO::getSpuId) - .select(ProductStatisticsDO::getSpuId) - ); - } - - default List selectListByTimeBetween(ProductStatisticsReqVO reqVO) { - return selectList(buildWrapper(reqVO) - .groupBy(ProductStatisticsDO::getTime) - .select(ProductStatisticsDO::getTime)); - } - - default ProductStatisticsRespVO selectVoByTimeBetween(ProductStatisticsReqVO reqVO) { - return selectJoinOne(ProductStatisticsRespVO.class, buildWrapper(reqVO)); - } - - /** - * 构建 LambdaWrapper - * - * @param reqVO 查询参数 - * @return LambdaWrapper - */ - static MPJLambdaWrapperX buildWrapper(ProductStatisticsReqVO reqVO) { - return new MPJLambdaWrapperX() - .betweenIfPresent(ProductStatisticsDO::getTime, reqVO.getTimes()) - .selectSum(ProductStatisticsDO::getBrowseCount) - .selectSum(ProductStatisticsDO::getBrowseUserCount) - .selectSum(ProductStatisticsDO::getFavoriteCount) - .selectSum(ProductStatisticsDO::getCartCount) - .selectSum(ProductStatisticsDO::getOrderCount) - .selectSum(ProductStatisticsDO::getOrderPayCount) - .selectSum(ProductStatisticsDO::getOrderPayPrice) - .selectSum(ProductStatisticsDO::getAfterSaleCount) - .selectSum(ProductStatisticsDO::getAfterSaleRefundPrice) - .selectAvg(ProductStatisticsDO::getBrowseConvertPercent); - } - - /** - * 根据时间范围统计商品信息 - * - * @param page 分页参数 - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 统计 - */ - IPage selectStatisticsResultPageByTimeBetween(IPage page, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - default Long selectCountByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { - return selectCount(new LambdaQueryWrapperX().between(ProductStatisticsDO::getTime, beginTime, endTime)); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java deleted file mode 100644 index 7de0cb07b..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.trade; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; - -/** - * 售后订单的统计 Mapper - * - * @author owen - */ -@Mapper -public interface AfterSaleStatisticsMapper extends BaseMapperX { - - AfterSaleSummaryRespBO selectSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Long selectCountByStatus(@Param("status") Integer status); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java deleted file mode 100644 index 94ad06812..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.trade; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; - -/** - * 订单分销的统计 Mapper - * - * @author owen - */ -@Mapper -public interface BrokerageStatisticsMapper extends BaseMapperX { - - Integer selectSummaryPriceByStatusAndUnfreezeTimeBetween(@Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Long selectWithdrawCountByStatus(@Param("status") Integer status); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java deleted file mode 100644 index 86b32df2f..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.trade; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易订单的统计 Mapper - * - * @author owen - */ -@Mapper -public interface TradeOrderStatisticsMapper extends BaseMapperX { - - List selectSummaryListByAreaId(); - - Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Integer selectCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Integer selectSummaryPriceByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Integer selectUserCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Integer selectUserCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - /** - * 按照支付时间统计订单(按天分组) - * - * @param beginTime 支付起始时间 - * @param endTime 支付截止时间 - * @return 订单统计列表 - */ - List selectListByPayTimeBetweenAndGroupByDay(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - /** - * 按照支付时间统计订单(按月分组) - * - * @param beginTime 支付起始时间 - * @param endTime 支付截止时间 - * @return 订单统计列表 - */ - List selectListByPayTimeBetweenAndGroupByMonth(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - Long selectCountByStatusAndDeliveryType(@Param("status") Integer status, @Param("deliveryType") Integer deliveryType); - - TradeOrderSummaryRespVO selectPaySummaryByPayStatusAndPayTimeBetween(@Param("payStatus") Boolean payStatus, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsMapper.java deleted file mode 100644 index 67d2d5007..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsMapper.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.statistics.dal.mysql.trade; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易统计 Mapper - * - * @author owen - */ -@Mapper -public interface TradeStatisticsMapper extends BaseMapperX { - - TradeSummaryRespBO selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - TradeTrendSummaryRespVO selectVoByTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - default List selectListByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { - return selectList(new LambdaQueryWrapperX() - .between(TradeStatisticsDO::getTime, beginTime, endTime)); - } - - Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - default TradeStatisticsDO selectByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { - return selectOne(new LambdaQueryWrapperX() - .between(TradeStatisticsDO::getTime, beginTime, endTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/package-info.java deleted file mode 100644 index 032d7a91b..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 statistics 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.statistics.framework; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/rpc/config/RpcConfiguration.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index 6c613ecfe..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.statistics.framework.rpc.config; - -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {ProductSpuApi.class}) -public class RpcConfiguration { -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/rpc/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/rpc/package-info.java deleted file mode 100644 index ead659f46..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.statistics.framework.rpc; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/security/config/SecurityConfiguration.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 5fa5376b5..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.statistics.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Statistics 模块的 Security 配置 - */ -@Configuration("statisticsSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("statisticsAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - } - - }; - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/security/core/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/security/core/package-info.java deleted file mode 100644 index 01062c49e..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.statistics.framework.security.core; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/package-info.java deleted file mode 100644 index e8cf302e1..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿,占坑,无特殊含义 - */ -package cn.iocoder.yudao.module.statistics.job; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/product/ProductStatisticsJob.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/product/ProductStatisticsJob.java deleted file mode 100644 index 4d4182cec..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/product/ProductStatisticsJob.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.statistics.job.product; - -import cn.hutool.core.convert.Convert; -import cn.hutool.core.util.NumberUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.statistics.service.product.ProductStatisticsService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -// TODO 芋艿:缺个 Job 的配置;等和 Product 一起配置 - -/** - * 商品统计 Job - * - * @author owen - */ -@Component -public class ProductStatisticsJob { - - @Resource - private ProductStatisticsService productStatisticsService; - - /** - * 执行商品统计任务 - * - * @param param 要统计的天数,只能是正整数,1 代表昨日数据 - * @return 统计结果 - */ - @XxlJob("productStatisticsJob") - @TenantJob - public String execute(String param) { - // 默认昨日 - param = ObjUtil.defaultIfBlank(param, "1"); - // 校验参数的合理性 - if (!NumberUtil.isInteger(param)) { - throw new RuntimeException("商品统计任务的参数只能为是正整数"); - } - Integer days = Convert.toInt(param, 0); - if (days < 1) { - throw new RuntimeException("商品统计任务的参数只能为是正整数"); - } - String result = productStatisticsService.statisticsProduct(days); - return StrUtil.format("商品统计:\n{}", result); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java deleted file mode 100644 index 88e9f0c79..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.statistics.job.trade; - -import cn.hutool.core.convert.Convert; -import cn.hutool.core.util.NumberUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -// TODO 芋艿:缺个 Job 的配置;等和 Product 一起配置 -/** - * 交易统计 Job - * - * @author owen - */ -@Component -public class TradeStatisticsJob { - - @Resource - private TradeStatisticsService tradeStatisticsService; - - /** - * 执行交易统计任务 - * - * @param param 要统计的天数,只能是正整数,1 代表昨日数据 - * @return 统计结果 - */ - @XxlJob("tradeStatisticsJob") - @TenantJob - public String execute(String param) { - // 默认昨日 - param = ObjUtil.defaultIfBlank(param, "1"); - // 校验参数的合理性 - if (!NumberUtil.isInteger(param)) { - throw new RuntimeException("交易统计任务的参数只能为是正整数"); - } - Integer days = Convert.toInt(param, 0); - if (days < 1) { - throw new RuntimeException("交易统计任务的参数只能为是正整数"); - } - String result = tradeStatisticsService.statisticsTrade(days); - return StrUtil.format("交易统计:\n{}", result); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/package-info.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/package-info.java deleted file mode 100644 index 598e16c02..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * statistics 模块,主要实现统计相关功能。 - * 例如:统计商品、会员、交易等功能。 - * - * 1. Controller URL:以 /statistics/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 statistics_ 为后缀,方便在数据库中区分【特殊】 - */ -package cn.iocoder.yudao.module.statistics; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java deleted file mode 100644 index 6c200fdef..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.infra; - -import java.time.LocalDateTime; - -/** - * API 访问日志的统计 Service 接口 - * - * @author owen - */ -public interface ApiAccessLogStatisticsService { - - /** - * 获取活跃用户数量 - * - * @param userType 用户类型 - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 活跃用户数量 - */ - Integer getUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取访问用户数量 - * - * @param userType 用户类型 - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 访问用户数量 - */ - Integer getIpCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java deleted file mode 100644 index 7ad62d00a..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.infra; - -import cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -/** - * API 访问日志的统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class ApiAccessLogStatisticsServiceImpl implements ApiAccessLogStatisticsService { - - @Resource - private ApiAccessLogStatisticsMapper apiAccessLogStatisticsMapper; - - @Override - public Integer getUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) { - return apiAccessLogStatisticsMapper.selectUserCountByUserTypeAndCreateTimeBetween(userType, beginTime, endTime); - } - - @Override - public Integer getIpCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) { - return apiAccessLogStatisticsMapper.selectIpCountByUserTypeAndCreateTimeBetween(userType, beginTime, endTime); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java deleted file mode 100644 index 253cba68a..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.member; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 会员信息的统计 Service 接口 - * - * @author owen - */ -public interface MemberStatisticsService { - - /** - * 获取会员统计(实时统计) - * - * @return 会员统计 - */ - MemberSummaryRespVO getMemberSummary(); - - /** - * 获取会员分析对照数据 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 会员分析对照数据 - */ - DataComparisonRespVO getMemberAnalyseComparisonData(LocalDateTime beginTime, - LocalDateTime endTime); - - /** - * 按照省份,获得会员统计列表 - * - * @return 会员统计列表 - */ - List getMemberAreaStatisticsList(); - - /** - * 按照性别,获得会员统计列表 - * - * @return 会员统计列表 - */ - List getMemberSexStatisticsList(); - - /** - * 按照终端,获得会员统计列表 - * - * @return 会员统计列表 - */ - List getMemberTerminalStatisticsList(); - - /** - * 获取用户注册数量列表 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 注册数量列表 - */ - List getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获得用户数量量统计对照 - * - * @return 用户数量量统计对照 - */ - DataComparisonRespVO getUserCountComparison(); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java deleted file mode 100644 index 7b159059f..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.member; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.ip.core.Area; -import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; -import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert; -import cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper; -import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 会员信息的统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class MemberStatisticsServiceImpl implements MemberStatisticsService { - - @Resource - private MemberStatisticsMapper memberStatisticsMapper; - - @Resource - private PayWalletStatisticsService payWalletStatisticsService; - @Resource - private TradeStatisticsService tradeStatisticsService; - @Resource - private TradeOrderStatisticsService tradeOrderStatisticsService; - @Resource - private ApiAccessLogStatisticsService apiAccessLogStatisticsService; - - @Override - public MemberSummaryRespVO getMemberSummary() { - RechargeSummaryRespBO rechargeSummary = payWalletStatisticsService.getUserRechargeSummary(null, null); - // TODO @疯狂:1)这里是实时统计,不好走走 TradeStatistics 表;2)因为这个放在商城下,所以只考虑订单数据,即按照 trade_order 的 pay_price 并且已支付来计算; - Integer expensePrice = tradeStatisticsService.getExpensePrice(null, null); - Integer userCount = memberStatisticsMapper.selectUserCount(null, null); - return MemberStatisticsConvert.INSTANCE.convert(rechargeSummary, expensePrice, userCount); - } - - @Override - public List getMemberAreaStatisticsList() { - // 统计用户 - // TODO @疯狂:可能得把每个省的用户,都查询出来,然后去 order 那边 in;因为要按照这些人为基础来计算;;用户规模量大可能不太好,但是暂时就先这样搞吧 = = - Map userCountMap = convertMap(memberStatisticsMapper.selectSummaryListByAreaId(), - vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), - MemberAreaStatisticsRespBO::getUserCount, Integer::sum); - // 统计订单 - Map orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(), - bo -> AreaUtils.getParentIdByType(bo.getAreaId(), AreaTypeEnum.PROVINCE), - bo -> bo, - (a, b) -> new MemberAreaStatisticsRespBO() - .setOrderCreateUserCount(a.getOrderCreateUserCount() + b.getOrderCreateUserCount()) - .setOrderPayUserCount(a.getOrderPayUserCount() + b.getOrderPayUserCount()) - .setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice())); - // 拼接数据 - List areaList = AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area); - areaList.add(new Area().setId(null).setName("未知")); - return MemberStatisticsConvert.INSTANCE.convertList(areaList, userCountMap, orderMap); - } - - @Override - public DataComparisonRespVO getMemberAnalyseComparisonData(LocalDateTime beginTime, LocalDateTime endTime) { - // 当前数据 - MemberAnalyseDataRespVO vo = getMemberAnalyseData(beginTime, endTime); - // 对照数据 - LocalDateTime referenceEndDate = beginTime.minusDays(1); // 减少1天,防止出现时间重叠 - LocalDateTime referenceBeginDate = referenceEndDate.minus(Duration.between(beginTime, endTime)); - MemberAnalyseDataRespVO reference = getMemberAnalyseData( - LocalDateTimeUtil.beginOfDay(referenceBeginDate), LocalDateTimeUtil.endOfDay(referenceEndDate)); - return new DataComparisonRespVO<>(vo, reference); - } - - private MemberAnalyseDataRespVO getMemberAnalyseData(LocalDateTime beginTime, LocalDateTime endTime) { - Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime)) - .map(RechargeSummaryRespBO::getRechargeUserCount).orElse(0); - return new MemberAnalyseDataRespVO() - .setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) - .setVisitUserCount(apiAccessLogStatisticsService.getUserCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime)) - .setRechargeUserCount(rechargeUserCount); - } - - @Override - public List getMemberSexStatisticsList() { - return memberStatisticsMapper.selectSummaryListBySex(); - } - - @Override - public List getMemberTerminalStatisticsList() { - return memberStatisticsMapper.selectSummaryListByRegisterTerminal(); - } - - @Override - public List getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime) { - return memberStatisticsMapper.selectListByCreateTimeBetween(beginTime, endTime); - } - - @Override - public DataComparisonRespVO getUserCountComparison() { - // 今日时间范围 - LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); - LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(beginOfToday); - // 昨日时间范围 - LocalDateTime beginOfYesterday = LocalDateTimeUtil.beginOfDay(beginOfToday.minusDays(1)); - LocalDateTime endOfYesterday = LocalDateTimeUtil.endOfDay(beginOfYesterday); - return new DataComparisonRespVO() - .setValue(getUserCount(beginOfToday, endOfToday)) - .setReference(getUserCount(beginOfYesterday, endOfYesterday)); - } - - private MemberCountRespVO getUserCount(LocalDateTime beginTime, LocalDateTime endTime) { - return new MemberCountRespVO() - .setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) - .setVisitUserCount(apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime)); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/bo/MemberAreaStatisticsRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/bo/MemberAreaStatisticsRespBO.java deleted file mode 100644 index 6b2d9ceab..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/bo/MemberAreaStatisticsRespBO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.member.bo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员地区统计 Response BO") -@Data -public class MemberAreaStatisticsRespBO { - - /** - * 省份编号 - */ - private Integer areaId; - /** - * 省份名称 - */ - private String areaName; - - /** - * 会员数量 - */ - private Integer userCount; - - /** - * 下单的会员数量 - */ - private Integer orderCreateUserCount; - /** - * 支付订单的会员数量 - */ - private Integer orderPayUserCount; - - /** - * 订单支付金额,单位:分 - */ - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java deleted file mode 100644 index d43a57682..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.pay; - -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; - -import java.time.LocalDateTime; - -/** - * 钱包的统计 Service 接口 - * - * @author owen - */ -public interface PayWalletStatisticsService { - - /** - * 获取钱包统计 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 钱包统计 - */ - WalletSummaryRespBO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取钱包充值统计 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 钱包充值统计 - */ - RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取充值金额合计 - * - * @return 充值金额合计 - */ - Integer getRechargePriceSummary(); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java deleted file mode 100644 index 45532477e..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.pay; - -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import cn.iocoder.yudao.module.statistics.dal.mysql.pay.PayWalletStatisticsMapper; -import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -/** - * 钱包的统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsService { - - @Resource - private PayWalletStatisticsMapper payWalletStatisticsMapper; - - @Override - public WalletSummaryRespBO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) { - WalletSummaryRespBO paySummary = payWalletStatisticsMapper.selectRechargeSummaryByPayTimeBetween( - beginTime, endTime, true); - WalletSummaryRespBO refundSummary = payWalletStatisticsMapper.selectRechargeSummaryByRefundTimeBetween( - beginTime, endTime, PayRefundStatusEnum.SUCCESS.getStatus()); - Integer walletPayPrice = payWalletStatisticsMapper.selectPriceSummaryByBizTypeAndCreateTimeBetween( - beginTime, endTime, PayWalletBizTypeEnum.PAYMENT.getType()); - // 拼接 - paySummary.setWalletPayPrice(walletPayPrice) - .setRechargeRefundCount(refundSummary.getRechargeRefundCount()) - .setRechargeRefundPrice(refundSummary.getRechargeRefundPrice()); - return paySummary; - } - - @Override - public RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime) { - return payWalletStatisticsMapper.selectRechargeSummaryGroupByWalletId(beginTime, endTime, true); - } - - @Override - public Integer getRechargePriceSummary() { - return payWalletStatisticsMapper.selectRechargePriceSummary(PayOrderStatusEnum.SUCCESS.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/bo/RechargeSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/bo/RechargeSummaryRespBO.java deleted file mode 100644 index 05cfa1155..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/bo/RechargeSummaryRespBO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.pay.bo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 充值统计 Response BO - */ -@Data -public class RechargeSummaryRespBO { - - /** - * 充值会员数量 - */ - private Integer rechargeUserCount; - - /** - * 充值金额 - */ - private Integer rechargePrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/product/ProductStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/product/ProductStatisticsService.java deleted file mode 100644 index 09d84bdea..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/product/ProductStatisticsService.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.product; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.SortablePageParam; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsReqVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.product.ProductStatisticsDO; - -import java.util.List; - -/** - * 商品统计 Service 接口 - * - * @author owen - */ -public interface ProductStatisticsService { - - /** - * 获得商品统计排行榜分页 - * - * @param reqVO 查询条件 - * @param pageParam 分页排序查询 - * @return 商品统计分页 - */ - PageResult getProductStatisticsRankPage(ProductStatisticsReqVO reqVO, SortablePageParam pageParam); - - /** - * 获得商品状况统计分析 - * - * @param reqVO 查询条件 - * @return 统计数据对照 - */ - DataComparisonRespVO getProductStatisticsAnalyse(ProductStatisticsReqVO reqVO); - - /** - * 获得商品状况明细 - * - * @param reqVO 查询条件 - * @return 统计数据对照 - */ - List getProductStatisticsList(ProductStatisticsReqVO reqVO); - - /** - * 统计指定天数的商品数据 - * - * @return 统计结果 - */ - String statisticsProduct(Integer days); - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/product/ProductStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/product/ProductStatisticsServiceImpl.java deleted file mode 100644 index f56fc47a9..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/product/ProductStatisticsServiceImpl.java +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.product; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.SortablePageParam; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsReqVO; -import cn.iocoder.yudao.module.statistics.controller.admin.product.vo.ProductStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.product.ProductStatisticsDO; -import cn.iocoder.yudao.module.statistics.dal.mysql.product.ProductStatisticsMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Service; -import org.springframework.util.StopWatch; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - - -/** - * 商品统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class ProductStatisticsServiceImpl implements ProductStatisticsService { - - @Resource - private ProductStatisticsMapper productStatisticsMapper; - - - @Override - public PageResult getProductStatisticsRankPage(ProductStatisticsReqVO reqVO, SortablePageParam pageParam) { - PageUtils.buildDefaultSortingField(pageParam, ProductStatisticsDO::getBrowseCount); // 默认浏览量倒序 - return productStatisticsMapper.selectPageGroupBySpuId(reqVO, pageParam); - } - - @Override - public DataComparisonRespVO getProductStatisticsAnalyse(ProductStatisticsReqVO reqVO) { - LocalDateTime beginTime = ArrayUtil.get(reqVO.getTimes(), 0); - LocalDateTime endTime = ArrayUtil.get(reqVO.getTimes(), 1); - - // 统计数据 - ProductStatisticsRespVO value = productStatisticsMapper.selectVoByTimeBetween(reqVO); - // 对照数据 - LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime)); - ProductStatisticsReqVO referenceReqVO = new ProductStatisticsReqVO(new LocalDateTime[]{referenceBeginTime, beginTime}); - ProductStatisticsRespVO reference = productStatisticsMapper.selectVoByTimeBetween(referenceReqVO); - return new DataComparisonRespVO<>(value, reference); - } - - @Override - public List getProductStatisticsList(ProductStatisticsReqVO reqVO) { - return productStatisticsMapper.selectListByTimeBetween(reqVO); - } - - @Override - public String statisticsProduct(Integer days) { - LocalDateTime today = LocalDateTime.now(); - return IntStream.rangeClosed(1, days) - .mapToObj(day -> statisticsProduct(today.minusDays(day))) - .sorted() - .collect(Collectors.joining("\n")); - } - - /** - * 统计商品数据 - * - * @param date 需要统计的日期 - * @return 统计结果 - */ - private String statisticsProduct(LocalDateTime date) { - // 1. 处理统计时间范围 - LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date); - LocalDateTime endTime = LocalDateTimeUtil.endOfDay(date); - String dateStr = DatePattern.NORM_DATE_FORMATTER.format(date); - // 2. 检查该日是否已经统计过 - Long count = productStatisticsMapper.selectCountByTimeBetween(beginTime, endTime); - if (count != null && count > 0) { - return dateStr + " 数据已存在,如果需要重新统计,请先删除对应的数据"; - } - - StopWatch stopWatch = new StopWatch(dateStr); - stopWatch.start(); - // 4. 分页统计,避免商品表数据较多时,出现超时问题 - final int pageSize = 100; - for (int pageNo = 1; ; pageNo++) { - IPage page = productStatisticsMapper.selectStatisticsResultPageByTimeBetween( - Page.of(pageNo, pageSize, false), beginTime, endTime); - if (CollUtil.isEmpty(page.getRecords())) { - break; - } - // 4.1 计算访客支付转化率(百分比) - for (ProductStatisticsDO record : page.getRecords()) { - record.setTime(date.toLocalDate()); - if (record.getBrowseUserCount() != null && ObjUtil.notEqual(record.getBrowseUserCount(), 0)) { - record.setBrowseConvertPercent(100 * record.getOrderPayCount() / record.getBrowseUserCount()); - } - } - // 4.2 插入数据 - productStatisticsMapper.insertBatch(page.getRecords()); - } - return stopWatch.prettyPrint(); - } - -} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java deleted file mode 100644 index f584c3dc7..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; - -import java.time.LocalDateTime; - -/** - * 售后统计 Service 接口 - * - * @author owen - */ -public interface AfterSaleStatisticsService { - - /** - * 获取售后单统计 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 售后统计结果 - */ - AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取指定状态的售后订单数量 - * - * @param status 售后状态 - * @return 售后订单数量 - */ - Long getCountByStatus(AfterSaleStatusEnum status); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java deleted file mode 100644 index 46ab5f3ad..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.dal.mysql.trade.AfterSaleStatisticsMapper; -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -/** - * 售后统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class AfterSaleStatisticsServiceImpl implements AfterSaleStatisticsService { - - @Resource - private AfterSaleStatisticsMapper afterSaleStatisticsMapper; - - @Override - public AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime) { - return afterSaleStatisticsMapper.selectSummaryByRefundTimeBetween(beginTime, endTime); - } - - @Override - public Long getCountByStatus(AfterSaleStatusEnum status) { - return afterSaleStatisticsMapper.selectCountByStatus(status.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java deleted file mode 100644 index 6845b608a..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; - -import java.time.LocalDateTime; - -/** - * 分销统计 Service 接口 - * - * @author owen - */ -public interface BrokerageStatisticsService { - - /** - * 获取已结算的佣金金额 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 已结算的佣金金额 - */ - Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取指定状态的提现记录数量 - * - * @param status 提现记录状态 - * @return 提现记录数量 - */ - Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java deleted file mode 100644 index d7af3d523..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.dal.mysql.trade.BrokerageStatisticsMapper; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -/** - * 分销统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class BrokerageStatisticsServiceImpl implements BrokerageStatisticsService { - - @Resource - private BrokerageStatisticsMapper brokerageStatisticsMapper; - - @Override - public Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime) { - return brokerageStatisticsMapper.selectSummaryPriceByStatusAndUnfreezeTimeBetween( - BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), - beginTime, endTime); - } - - @Override - public Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status) { - return brokerageStatisticsMapper.selectWithdrawCountByStatus(status.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java deleted file mode 100644 index 2197515c4..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易订单的统计 Service 接口 - * - * @author owen - */ -public interface TradeOrderStatisticsService { - - /** - * 获取订单统计 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 订单统计结果 - */ - TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取地区订单统计 - * - * @return 订单统计结果 - */ - List getSummaryListByAreaId(); - - /** - * 获取下单用户数量 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 下单用户数量 - */ - Integer getOrderUserCount(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取支付用户数量 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 支付用户数量 - */ - Integer getPayUserCount(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获取支付金额 - * - * @param beginTime 起始时间 - * @param endTime 截止时间 - * @return 支付用户金额 - */ - Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 根据订单状态、物流类型,获得交易订单数量 - * - * @return 订单数量 - */ - Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType); - - /** - * 交易订单销售额对照 - * - * @return 销售额对照 - */ - DataComparisonRespVO getOrderComparison(); - - /** - * 获得订单量趋势统计 - * - * @param reqVO 统计参数 - * @return 订单量趋势统计 - */ - List> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java deleted file mode 100644 index 8ad81fb46..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendReqVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO; -import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper; -import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum; -import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -/** - * 交易订单统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsService { - - @Resource - private TradeOrderStatisticsMapper tradeOrderStatisticsMapper; - - @Override - public TradeOrderSummaryRespBO getOrderSummary(LocalDateTime beginTime, LocalDateTime endTime) { - return new TradeOrderSummaryRespBO() - .setOrderCreateCount(tradeOrderStatisticsMapper.selectCountByCreateTimeBetween(beginTime, endTime)) - .setOrderPayCount(tradeOrderStatisticsMapper.selectCountByPayTimeBetween(beginTime, endTime)) - .setOrderPayPrice(tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime)); - } - - @Override - public List getSummaryListByAreaId() { - return tradeOrderStatisticsMapper.selectSummaryListByAreaId(); - } - - @Override - public Integer getOrderUserCount(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeOrderStatisticsMapper.selectUserCountByCreateTimeBetween(beginTime, endTime); - } - - @Override - public Integer getPayUserCount(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeOrderStatisticsMapper.selectUserCountByPayTimeBetween(beginTime, endTime); - } - - @Override - public Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime); - } - - @Override - public Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType) { - return tradeOrderStatisticsMapper.selectCountByStatusAndDeliveryType(status, deliveryType); - } - - @Override - public DataComparisonRespVO getOrderComparison() { - return new DataComparisonRespVO() - .setValue(getPayPriceSummary(LocalDateTime.now())) - .setReference(getPayPriceSummary(LocalDateTime.now().minusDays(1))); - } - - private TradeOrderSummaryRespVO getPayPriceSummary(LocalDateTime date) { - LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date); - LocalDateTime endTime = LocalDateTimeUtil.endOfDay(date); - return tradeOrderStatisticsMapper.selectPaySummaryByPayStatusAndPayTimeBetween( - Boolean.TRUE, beginTime, endTime); - } - - @Override - public List> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO) { - // 查询当前数据 - List value = getOrderCountTrend(reqVO.getType(), reqVO.getBeginTime(), reqVO.getEndTime()); - // 查询对照数据 - LocalDateTime referenceEndTime = reqVO.getBeginTime().minusDays(1); - LocalDateTime referenceBeginTime = referenceEndTime.minus(Duration.between(reqVO.getBeginTime(), reqVO.getEndTime())); - List reference = getOrderCountTrend(reqVO.getType(), referenceBeginTime, referenceEndTime); - // 顺序对比返回 - return IntStream.range(0, value.size()) - .mapToObj(index -> new DataComparisonRespVO() - .setValue(CollUtil.get(value, index)) - .setReference(CollUtil.get(reference, index))) - .collect(Collectors.toList()); - } - - private List getOrderCountTrend(Integer timeRangeType, LocalDateTime beginTime, LocalDateTime endTime) { - // 情况一:按年统计时,以月份分组 - if (TimeRangeTypeEnum.YEAR.getType().equals(timeRangeType)) { - return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByMonth(beginTime, endTime); - } - // 情况二:其它以天分组(天、周、月) - return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByDay(beginTime, endTime); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java deleted file mode 100644 index e175985fb..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 交易统计 Service 接口 - * - * @author owen - */ -public interface TradeStatisticsService { - - /** - * 获得交易状况统计对照 - * - * @return 统计数据对照 - */ - DataComparisonRespVO getTradeStatisticsAnalyse( - LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获得交易状况统计 - * - * @param beginTime 开始时间 - * @param endTime 结束时间 - * @return 统计数据对照 - */ - Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获得交易状况明细 - * - * @param beginTime 开始时间 - * @param endTime 结束时间 - * @return 统计数据列表 - */ - List getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 统计指定天数的交易数据 - * - * @return 统计结果 - */ - String statisticsTrade(Integer days); - - /** - * 统计指定日期的交易数据 - * - * @param days 增加的天数 - * @return 交易数据 - */ - TradeSummaryRespBO getTradeSummaryByDays(int days); - - /** - * 统计指定月份的交易数据 - * - * @param months 增加的月数 - * @return 交易数据 - */ - TradeSummaryRespBO getTradeSummaryByMonths(int months); - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java deleted file mode 100644 index 5c608bda9..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; -import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; -import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper; -import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; -import org.springframework.stereotype.Service; -import org.springframework.util.StopWatch; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -/** - * 交易统计 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class TradeStatisticsServiceImpl implements TradeStatisticsService { - - @Resource - private TradeStatisticsMapper tradeStatisticsMapper; - - @Resource - private TradeOrderStatisticsService tradeOrderStatisticsService; - @Resource - private AfterSaleStatisticsService afterSaleStatisticsService; - @Resource - private BrokerageStatisticsService brokerageStatisticsService; - @Resource - private PayWalletStatisticsService payWalletStatisticsService; - - @Override - public TradeSummaryRespBO getTradeSummaryByDays(int days) { - LocalDateTime date = LocalDateTime.now().plusDays(days); - return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween( - LocalDateTimeUtil.beginOfDay(date), LocalDateTimeUtil.endOfDay(date)); - } - - @Override - public TradeSummaryRespBO getTradeSummaryByMonths(int months) { - LocalDateTime monthDate = LocalDateTime.now().plusMonths(months); - return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween( - LocalDateTimeUtils.beginOfMonth(monthDate), LocalDateTimeUtils.endOfMonth(monthDate)); - } - - @Override - public DataComparisonRespVO getTradeStatisticsAnalyse(LocalDateTime beginTime, - LocalDateTime endTime) { - // 统计数据 - TradeTrendSummaryRespVO value = tradeStatisticsMapper.selectVoByTimeBetween(beginTime, endTime); - // 对照数据 - LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime)); - TradeTrendSummaryRespVO reference = tradeStatisticsMapper.selectVoByTimeBetween(referenceBeginTime, beginTime); - return TradeStatisticsConvert.INSTANCE.convert(value, reference); - } - - @Override - public Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeStatisticsMapper.selectExpensePriceByTimeBetween(beginTime, endTime); - } - - @Override - public List getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) { - return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime); - } - - @Override - public String statisticsTrade(Integer days) { - LocalDateTime today = LocalDateTime.now(); - return IntStream.rangeClosed(1, days) - .mapToObj(day -> statisticsTrade(today.minusDays(day))) - .sorted() - .collect(Collectors.joining("\n")); - } - - /** - * 统计交易数据 - * - * @param date 需要统计的日期 - * @return 统计结果 - */ - private String statisticsTrade(LocalDateTime date) { - // 1. 处理统计时间范围 - LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date); - LocalDateTime endTime = LocalDateTimeUtil.endOfDay(date); - String dateStr = DatePattern.NORM_DATE_FORMATTER.format(date); - // 2. 检查该日是否已经统计过 - TradeStatisticsDO entity = tradeStatisticsMapper.selectByTimeBetween(beginTime, endTime); - if (entity != null) { - return dateStr + " 数据已存在,如果需要重新统计,请先删除对应的数据"; - } - - // 3. 从各个数据表,统计对应数据 - StopWatch stopWatch = new StopWatch(dateStr); - // 3.1 统计订单 - stopWatch.start("统计订单"); - TradeOrderSummaryRespBO orderSummary = tradeOrderStatisticsService.getOrderSummary(beginTime, endTime); - stopWatch.stop(); - // 3.2 统计售后 - stopWatch.start("统计售后"); - AfterSaleSummaryRespBO afterSaleSummary = afterSaleStatisticsService.getAfterSaleSummary(beginTime, endTime); - stopWatch.stop(); - // 3.3 统计佣金 - stopWatch.start("统计佣金"); - Integer brokerageSettlementPrice = brokerageStatisticsService.getBrokerageSettlementPriceSummary(beginTime, endTime); - stopWatch.stop(); - // 3.4 统计充值 - stopWatch.start("统计充值"); - WalletSummaryRespBO walletSummary = payWalletStatisticsService.getWalletSummary(beginTime, endTime); - stopWatch.stop(); - - // 4. 插入数据 - entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice, - walletSummary); - tradeStatisticsMapper.insert(entity); - return stopWatch.prettyPrint(); - } - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/AfterSaleSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/AfterSaleSummaryRespBO.java deleted file mode 100644 index 985643636..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/AfterSaleSummaryRespBO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 售后统计 Response DTO - * - * @author owen - */ -@Data -public class AfterSaleSummaryRespBO { - - /** - * 退款订单数 - */ - private Integer afterSaleCount; - /** - * 总退款金额,单位:分 - */ - private Integer afterSaleRefundPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java deleted file mode 100644 index 3d3572f90..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 会员地区统计 Response BO - * - * @author owen - */ -@Data -public class MemberAreaStatisticsRespBO { - - /** - * 省份编号 - */ - private Integer areaId; - /** - * 省份名称 - */ - private String areaName; - - /** - * 会员数量 - */ - private Integer userCount; - - /** - * 下单的会员数量 - */ - private Integer orderCreateUserCount; - /** - * 支付订单的会员数量 - */ - private Integer orderPayUserCount; - - /** - * 订单支付金额,单位:分 - */ - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeOrderSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeOrderSummaryRespBO.java deleted file mode 100644 index bc4f3903b..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeOrderSummaryRespBO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 订单统计 Response BO - * - * @author owen - */ -@Data -public class TradeOrderSummaryRespBO { - - /** - * 创建订单数 - */ - private Integer orderCreateCount; - /** - * 支付订单商品数 - */ - private Integer orderPayCount; - /** - * 总支付金额,单位:分 - */ - private Integer orderPayPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeSummaryRespBO.java deleted file mode 100644 index 8937c809c..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeSummaryRespBO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 交易统计 Resp BO - * - * @author owen - */ -@Data -public class TradeSummaryRespBO { - - /** - * 数量 - */ - private Integer count; - - /** - * 合计 - */ - private Integer summary; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java deleted file mode 100644 index 89371f6c1..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.statistics.service.trade.bo; - -import lombok.Data; - -/** - * 钱包统计 Response DTO - * - * @author owen - */ -@Data -public class WalletSummaryRespBO { - - /** - * 总支付金额(余额),单位:分 - */ - private Integer walletPayPrice; - - /** - * 充值订单数 - */ - private Integer rechargePayCount; - /** - * 充值金额,单位:分 - */ - private Integer rechargePayPrice; - /** - * 充值退款订单数 - */ - private Integer rechargeRefundCount; - /** - * 充值退款金额,单位:分 - */ - private Integer rechargeRefundPrice; - -} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-dev.yaml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index b4696be2d..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,103 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - # Spring Boot Admin Server 服务端的相关配置 - context-path: /admin # 配置 Spring - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - demo: true # 开启演示模式 diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-local.yaml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 09edef067..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,127 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.system.dal.mysql: debug - cn.iocoder.yudao.module.system.dal.mysql.sensitiveword.SensitiveWordMapper: INFO # 配置 SensitiveWordMapper 的日志级别为 info - cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - security: - mock-enable: true - xss: - enable: false - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application.yaml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application.yaml deleted file mode 100644 index 5c8477d46..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,109 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.statistics - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - captcha: - enable: true # 验证码的开关,默认为 true; - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - ignore-tables: - -debug: false diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/bootstrap.yaml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 4808939ca..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: statistics-server - - profiles: - active: local - -server: - port: 48103 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/logback-spring.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml deleted file mode 100644 index e64161597..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml deleted file mode 100644 index 33500fb43..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml deleted file mode 100644 index 097780841..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/product/ProductStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/product/ProductStatisticsMapper.xml deleted file mode 100644 index e640d1d83..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/product/ProductStatisticsMapper.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml deleted file mode 100644 index 933c45610..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml deleted file mode 100644 index dff7e444f..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml deleted file mode 100644 index 07d2f0d58..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml deleted file mode 100644 index 2415f6d55..000000000 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-trade-api/pom.xml b/yudao-module-mall/yudao-module-trade-api/pom.xml deleted file mode 100644 index 84c99130d..000000000 --- a/yudao-module-mall/yudao-module-trade-api/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-trade-api - jar - - ${project.artifactId} - - trade 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java deleted file mode 100644 index b422cee2a..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.trade.api.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import cn.iocoder.yudao.module.trade.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.Collection; -import java.util.List; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 订单") -public interface TradeOrderApi { - - String PREFIX = ApiConstants.PREFIX + "/order"; - - @GetMapping(PREFIX + "/list") - @Operation(summary = "获得订单列表") - @Parameter(name = "ids", description = "订单编号数组", required = true) - CommonResult> getOrderList(@RequestParam("ids") Collection ids); - - @GetMapping(PREFIX + "/get") - @Operation(summary = "获得订单") - @Parameter(name = "id", description = "订单编号", required = true) - CommonResult getOrder(@RequestParam("id") Long id); - - // TODO 芋艿:需要优化下; - @PutMapping(PREFIX + "/cancel-paid") - @Parameters({ - @Parameter(name = "userId", description = "用户编号", required = true, example = "1024"), - @Parameter(name = "orderId", description = "订单编号", required = true, example = "2048"), - }) - CommonResult cancelPaidOrder(@RequestParam("userId") Long userId, - @RequestParam("orderId") Long orderId); - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java deleted file mode 100644 index 24ec028ed..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.trade.api.order.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 订单信息 Response DTO - * - * @author HUIHUI - */ -@Schema(description = "RPC 服务 - 订单信息 Response DTO") -@Data -public class TradeOrderRespDTO { - - // ========== 订单基本信息 ========== - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "订单类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; // 参见 TradeOrderTypeEnum 枚举 - - @Schema(description = "订单来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer terminal; // 参见 TerminalEnum 枚举 - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long userId; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - private String userIp; - - @Schema(description = "用户备注", example = "这个商品不错哦") - private String userRemark; - - @Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; // 参见 TradeOrderStatusEnum 枚举 - - @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer productCount; - - @Schema(description = "订单完成时间") - private LocalDateTime finishTime; - - @Schema(description = "订单取消时间") - private LocalDateTime cancelTime; - - @Schema(description = "取消类型", example = "1") - private Integer cancelType; // 参见 TradeOrderCancelTypeEnum 枚举 - - @Schema(description = "商家备注", example = "这个用户很喜欢退货") - private String remark; - - @Schema(description = "是否评价", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean commentStatus; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - - @Schema(description = "是否已支付", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean payStatus; - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java deleted file mode 100644 index 5b0e37dcc..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.trade.api; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ApiConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ApiConstants.java deleted file mode 100644 index 9f557fd4b..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "trade-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/trade"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java deleted file mode 100644 index ff09e59d8..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums; - -/** - * Trade 字典类型的枚举类 - * - * @author owen - */ -public interface DictTypeConstants { - - String BROKERAGE_WITHDRAW_STATUS = "brokerage_withdraw_status"; // 佣金提现状态 - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java deleted file mode 100644 index 33081d461..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Trade 错误码枚举类 - * trade 系统,使用 1-011-000-000 段 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -public interface ErrorCodeConstants { - - // ========== Order 模块 1-011-000-000 ========== - ErrorCode ORDER_ITEM_NOT_FOUND = new ErrorCode(1_011_000_010, "交易订单项不存在"); - ErrorCode ORDER_NOT_FOUND = new ErrorCode(1_011_000_011, "交易订单不存在"); - ErrorCode ORDER_ITEM_UPDATE_AFTER_SALE_STATUS_FAIL = new ErrorCode(1_011_000_012, "交易订单项更新售后状态失败,请重试"); - ErrorCode ORDER_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_011_000_013, "交易订单更新支付状态失败,订单不是【未支付】状态"); - ErrorCode ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR = new ErrorCode(1_011_000_014, "交易订单更新支付状态失败,支付单编号不匹配"); - ErrorCode ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1_011_000_015, "交易订单更新支付状态失败,支付单状态不是【支付成功】状态"); - ErrorCode ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH = new ErrorCode(1_011_000_016, "交易订单更新支付状态失败,支付单金额不匹配"); - ErrorCode ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED = new ErrorCode(1_011_000_017, "交易订单发货失败,订单不是【待发货】状态"); - ErrorCode ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1_011_000_018, "交易订单收货失败,订单不是【待收货】状态"); - ErrorCode ORDER_COMMENT_FAIL_STATUS_NOT_COMPLETED = new ErrorCode(1_011_000_019, "创建交易订单项的评价失败,订单不是【已完成】状态"); - ErrorCode ORDER_COMMENT_STATUS_NOT_FALSE = new ErrorCode(1_011_000_020, "创建交易订单项的评价失败,订单已评价"); - ErrorCode ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE = new ErrorCode(1_011_000_021, "交易订单发货失败,订单已退款或部分退款"); - ErrorCode ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1_011_000_022, "交易订单发货失败,拼团未成功"); - ErrorCode ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1_011_000_023, "交易订单发货失败,砍价未成功"); - ErrorCode ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS = new ErrorCode(1_011_000_024, "交易订单发货失败,发货类型不是快递"); - ErrorCode ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID = new ErrorCode(1_011_000_025, "交易订单取消失败,订单不是【待支付】状态"); - ErrorCode ORDER_UPDATE_PRICE_FAIL_PAID = new ErrorCode(1_011_000_026, "支付订单调价失败,原因:支付订单已付款,不能调价"); - ErrorCode ORDER_UPDATE_PRICE_FAIL_ALREADY = new ErrorCode(1_011_000_027, "支付订单调价失败,原因:已经修改过价格"); - ErrorCode ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR = new ErrorCode(1_011_000_028, "支付订单调价失败,原因:调整后支付价格不能小于 0.01 元"); - ErrorCode ORDER_DELETE_FAIL_STATUS_NOT_CANCEL = new ErrorCode(1_011_000_029, "交易订单删除失败,订单不是【已取消】状态"); - ErrorCode ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP = new ErrorCode(1_011_000_030, "交易订单自提失败,收货方式不是【用户自提】"); - ErrorCode ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED = new ErrorCode(1_011_000_031, "交易订单修改收货地址失败,原因:订单不是【待发货】状态"); - ErrorCode ORDER_CREATE_FAIL_EXIST_UNPAID = new ErrorCode(1_011_000_032, "交易订单创建失败,原因:存在未付款订单"); - - // ========== After Sale 模块 1-011-000-100 ========== - ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在"); - ErrorCode AFTER_SALE_CREATE_FAIL_REFUND_PRICE_ERROR = new ErrorCode(1_011_000_101, "申请退款金额错误"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_CANCELED = new ErrorCode(1_011_000_102, "订单已关闭,无法申请售后"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_PAID = new ErrorCode(1_011_000_103, "订单未支付,无法申请售后"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_DELIVERED = new ErrorCode(1_011_000_104, "订单未发货,无法申请【退货退款】售后"); - ErrorCode AFTER_SALE_CREATE_FAIL_ORDER_ITEM_APPLIED = new ErrorCode(1_011_000_105, "订单项已申请售后,无法重复申请"); - ErrorCode AFTER_SALE_AUDIT_FAIL_STATUS_NOT_APPLY = new ErrorCode(1_011_000_106, "审批失败,售后状态不处于审批中"); - ErrorCode AFTER_SALE_UPDATE_STATUS_FAIL = new ErrorCode(1_011_000_107, "操作售后单失败,请刷新后重试"); - ErrorCode AFTER_SALE_DELIVERY_FAIL_STATUS_NOT_SELLER_AGREE = new ErrorCode(1_011_000_108, "退货失败,售后单状态不处于【待买家退货】"); - ErrorCode AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_DELIVERY = new ErrorCode(1_011_000_109, "确认收货失败,售后单状态不处于【待确认收货】"); - ErrorCode AFTER_SALE_REFUND_FAIL_STATUS_NOT_WAIT_REFUND = new ErrorCode(1_011_000_110, "退款失败,售后单状态不是【待退款】"); - ErrorCode AFTER_SALE_CANCEL_FAIL_STATUS_NOT_APPLY_OR_AGREE_OR_BUYER_DELIVERY = - new ErrorCode(1_011_000_111, "取消售后单失败,售后单状态不是【待审核】或【卖家同意】或【商家待收货】"); - - // ========== Cart 模块 1-011-002-000 ========== - ErrorCode CARD_ITEM_NOT_FOUND = new ErrorCode(1_011_002_000, "购物车项不存在"); - - // ========== Price 相关 1-011-003-000 ============ - ErrorCode PRICE_CALCULATE_PAY_PRICE_ILLEGAL = new ErrorCode(1_011_003_000, "支付价格计算异常,原因:价格小于等于 0"); - ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_TEMPLATE_NOT_FOUND = new ErrorCode(1_011_003_002, "计算快递运费异常,找不到对应的运费模板"); - ErrorCode PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER = new ErrorCode(1_011_003_004, "参与秒杀、拼团、砍价的营销商品,无法使用优惠劵"); - ErrorCode PRICE_CALCULATE_SECKILL_TOTAL_LIMIT_COUNT = new ErrorCode(1_011_003_005, "参与秒杀的商品,超过了秒杀总限购数量"); - - // ========== 物流 Express 模块 1-011-004-000 ========== - ErrorCode EXPRESS_NOT_EXISTS = new ErrorCode(1_011_004_000, "快递公司不存在"); - ErrorCode EXPRESS_CODE_DUPLICATE = new ErrorCode(1_011_004_001, "已经存在该编码的快递公司"); - ErrorCode EXPRESS_CLIENT_NOT_PROVIDE = new ErrorCode(1_011_004_002, "需要接入快递服务商,比如【快递100】"); - ErrorCode EXPRESS_STATUS_NOT_ENABLE = new ErrorCode(1_011_004_003, "快递公司未启用"); - - ErrorCode EXPRESS_API_QUERY_ERROR = new ErrorCode(1_011_004_101, "快递查询接口异常"); - ErrorCode EXPRESS_API_QUERY_FAILED = new ErrorCode(1_011_004_102, "快递查询返回失败,原因:{}"); - - // ========== 物流 Template 模块 1-011-005-000 ========== - ErrorCode EXPRESS_TEMPLATE_NAME_DUPLICATE = new ErrorCode(1_011_005_000, "已经存在该运费模板名"); - ErrorCode EXPRESS_TEMPLATE_NOT_EXISTS = new ErrorCode(1_011_005_001, "运费模板不存在"); - - // ========== 物流 PICK_UP 模块 1-011-006-000 ========== - ErrorCode PICK_UP_STORE_NOT_EXISTS = new ErrorCode(1_011_006_000, "自提门店不存在"); - - // ========== 分销用户 模块 1-011-007-000 ========== - ErrorCode BROKERAGE_USER_NOT_EXISTS = new ErrorCode(1_011_007_000, "分销用户不存在"); - ErrorCode BROKERAGE_USER_FROZEN_PRICE_NOT_ENOUGH = new ErrorCode(1_011_007_001, "用户冻结佣金({})数量不足"); - ErrorCode BROKERAGE_BIND_SELF = new ErrorCode(1_011_007_002, "不能绑定自己"); - ErrorCode BROKERAGE_BIND_USER_NOT_ENABLED = new ErrorCode(1_011_007_003, "绑定用户没有推广资格"); - ErrorCode BROKERAGE_BIND_CONDITION_ADMIN = new ErrorCode(1_011_007_004, "仅可在后台绑定推广员"); - ErrorCode BROKERAGE_BIND_MODE_REGISTER = new ErrorCode(1_011_007_005, "只有在注册时可以绑定"); - ErrorCode BROKERAGE_BIND_OVERRIDE = new ErrorCode(1_011_007_006, "已绑定了推广人"); - ErrorCode BROKERAGE_BIND_LOOP = new ErrorCode(1_011_007_007, "下级不能绑定自己的上级"); - ErrorCode BROKERAGE_USER_LEVEL_NOT_SUPPORT = new ErrorCode(1_011_007_008, "目前只支持 level 小于等于 2"); - - // ========== 分销提现 模块 1-011-008-000 ========== - ErrorCode BROKERAGE_WITHDRAW_NOT_EXISTS = new ErrorCode(1_011_008_000, "佣金提现记录不存在"); - ErrorCode BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING = new ErrorCode(1_011_008_001, "佣金提现记录状态不是审核中"); - ErrorCode BROKERAGE_WITHDRAW_MIN_PRICE = new ErrorCode(1_011_008_002, "提现金额不能低于 {} 元"); - ErrorCode BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH = new ErrorCode(1_011_008_003, "您当前最多可提现 {} 元"); - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java deleted file mode 100644 index 5041139b4..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums; - -// TODO @芋艿:枚举 -/** - * 通知模板枚举类 - * - * @author HUIHUI - */ -public interface MessageTemplateConstants { - - String ORDER_DELIVERY = "order_delivery"; // 短信模版编号 - - String BROKERAGE_WITHDRAW_AUDIT_APPROVE = "brokerage_withdraw_audit_approve"; // 佣金提现(审核通过) - String BROKERAGE_WITHDRAW_AUDIT_REJECT = "brokerage_withdraw_audit_reject"; // 佣金提现(审核不通过) - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java deleted file mode 100644 index db870c637..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -/** - * 售后操作类型的枚举 - * - * @author 陈賝 - * @since 2023/6/13 13:53 - */ -@RequiredArgsConstructor -@Getter -public enum AfterSaleOperateTypeEnum { - - MEMBER_CREATE(10, "会员申请退款"), - ADMIN_AGREE_APPLY(11, "商家同意退款"), - ADMIN_DISAGREE_APPLY(12, "商家拒绝退款"), - MEMBER_DELIVERY(20, "会员填写退货物流信息,快递公司:{deliveryName},快递单号:{logisticsNo}"), - ADMIN_AGREE_RECEIVE(21, "商家收货"), - ADMIN_DISAGREE_RECEIVE(22, "商家拒绝收货,原因:{reason}"), - ADMIN_REFUND(30, "商家退款"), - MEMBER_CANCEL(40, "会员取消退款"), - ; - - /** - * 操作类型 - */ - private final Integer type; - /** - * 操作描述 - */ - private final String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleStatusEnum.java deleted file mode 100644 index 23c1b2efe..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleStatusEnum.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; -import java.util.Collection; - -import static cn.hutool.core.util.ArrayUtil.firstMatch; - -/** - * 售后状态的枚举 - * - * 状态流转 - * - * @author 芋道源码 - */ -@AllArgsConstructor -@Getter -public enum AfterSaleStatusEnum implements IntArrayValuable { - - /** - * 【申请售后】 - */ - APPLY(10,"申请中", "会员申请退款"), // 有赞的状态提示:退款申请待商家处理 - /** - * 卖家通过售后;【商品待退货】 - */ - SELLER_AGREE(20, "卖家通过", "商家同意退款"), // 有赞的状态提示:请退货并填写物流信息 - /** - * 买家已退货,等待卖家收货;【商家待收货】 - */ - BUYER_DELIVERY(30,"待卖家收货", "会员填写退货物流信息"), // 有赞的状态提示:退货退款申请待商家处理 - /** - * 卖家已收货,等待平台退款;等待退款【等待退款】 - */ - WAIT_REFUND(40, "等待平台退款", "商家收货"), // 有赞的状态提示:无(有赞无该状态) - /** - * 完成退款【退款成功】 - */ - COMPLETE(50, "完成", "商家确认退款"), // 有赞的状态提示:退款成功 - /** - * 【买家取消】 - */ - BUYER_CANCEL(61, "买家取消售后", "会员取消退款"), // 有赞的状态提示:退款关闭 - /** - * 卖家拒绝售后;商家拒绝【商家拒绝】 - */ - SELLER_DISAGREE(62,"卖家拒绝", "商家拒绝退款"), // 有赞的状态提示:商家不同意退款申请 - /** - * 卖家拒绝收货,终止售后;【商家拒收货】 - */ - SELLER_REFUSE(63,"卖家拒绝收货", "商家拒绝收货"), // 有赞的状态提示:商家拒绝收货,不同意退款 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AfterSaleStatusEnum::getStatus).toArray(); - - /** - * 进行中的售后状态 - * - * 不包括已经结束的状态 - */ - public static final Collection APPLYING_STATUSES = Arrays.asList( - APPLY.getStatus(), - SELLER_AGREE.getStatus(), - BUYER_DELIVERY.getStatus(), - WAIT_REFUND.getStatus() - ); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - /** - * 操作内容 - * - * 目的:记录售后日志的内容 - */ - private final String content; - - @Override - public int[] array() { - return ARRAYS; - } - - public static AfterSaleStatusEnum valueOf(Integer status) { - return firstMatch(value -> value.getStatus().equals(status), values()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleTypeEnum.java deleted file mode 100644 index dfb32f7be..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易售后 - 类型 - * - * @author 芋道源码 - */ -@RequiredArgsConstructor -@Getter -public enum AfterSaleTypeEnum implements IntArrayValuable { - - IN_SALE(10, "售中退款"), // 交易完成前买家申请退款 - AFTER_SALE(20, "售后退款"); // 交易完成后买家申请退款 - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AfterSaleTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleWayEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleWayEnum.java deleted file mode 100644 index 1d608a102..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleWayEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.aftersale; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易售后 - 方式 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum AfterSaleWayEnum implements IntArrayValuable { - - REFUND(10, "仅退款"), - RETURN_AND_REFUND(20, "退货退款"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AfterSaleWayEnum::getWay).toArray(); - - /** - * 方式 - */ - private final Integer way; - /** - * 方式名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageBindModeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageBindModeEnum.java deleted file mode 100644 index 72ce10032..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageBindModeEnum.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 分销关系绑定模式枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageBindModeEnum implements IntArrayValuable { - - /** - * 只要用户没有推广人,随时都可以绑定分销关系 - */ - ANYTIME(1, "首次绑定"), - /** - * 仅新用户注册时才能绑定推广关系 - */ - REGISTER(2, "注册绑定"), - /** - * 每次扫码都覆盖 - */ - OVERRIDE(3, "覆盖绑定"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageBindModeEnum::getMode).toArray(); - - /** - * 模式 - */ - private final Integer mode; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageEnabledConditionEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageEnabledConditionEnum.java deleted file mode 100644 index 990d10e16..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageEnabledConditionEnum.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 分佣模式枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageEnabledConditionEnum implements IntArrayValuable { - - /** - * 所有用户都可以分销 - */ - ALL(1, "人人分销"), - /** - * 仅可后台手动设置推广员 - */ - ADMIN(2, "指定分销"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageEnabledConditionEnum::getCondition).toArray(); - - /** - * 模式 - */ - private final Integer condition; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java deleted file mode 100644 index 546069465..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 佣金记录业务类型枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageRecordBizTypeEnum implements IntArrayValuable { - - ORDER(1, "获得推广佣金", "获得推广佣金 {}", true), - WITHDRAW(2, "提现申请", "提现申请扣除佣金 {}", false), - WITHDRAW_REJECT(3, "提现申请驳回", "提现申请驳回,返还佣金 {}", true), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageRecordBizTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 标题 - */ - private final String title; - /** - * 描述 - */ - private final String description; - /** - * 是否为增加佣金 - */ - private final boolean add; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordStatusEnum.java deleted file mode 100644 index 827390998..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordStatusEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 佣金记录状态枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageRecordStatusEnum implements IntArrayValuable { - - WAIT_SETTLEMENT(0, "待结算"), - SETTLEMENT(1, "已结算"), - CANCEL(2, "已取消"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageRecordStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java deleted file mode 100644 index b68db4a71..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -// TODO 芋艿:提现的打通,在纠结下; -/** - * 佣金提现状态枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageWithdrawStatusEnum implements IntArrayValuable { - - AUDITING(0, "审核中"), - AUDIT_SUCCESS(10, "审核通过"), - WITHDRAW_SUCCESS(11, "提现成功"), - AUDIT_FAIL(20, "审核不通过"), - WITHDRAW_FAIL(21, "提现失败"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawStatusEnum::getStatus).toArray(); - - /** - * 状态 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java deleted file mode 100644 index 46edf010e..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawTypeEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.brokerage; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 佣金提现类型枚举 - * - * @author owen - */ -@AllArgsConstructor -@Getter -public enum BrokerageWithdrawTypeEnum implements IntArrayValuable { - - WALLET(1, "钱包"), - BANK(2, "银行卡"), - WECHAT(3, "微信"), - ALIPAY(4, "支付宝"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryExpressChargeModeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryExpressChargeModeEnum.java deleted file mode 100644 index 7503dd322..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryExpressChargeModeEnum.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.delivery; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 快递配送计费方式枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum DeliveryExpressChargeModeEnum implements IntArrayValuable { - - COUNT(1, "按件"), - WEIGHT(2,"按重量"), - VOLUME(3, "按体积"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryExpressChargeModeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 描述 - */ - private final String desc; - - @Override - public int[] array() { - return ARRAYS; - } - - public static DeliveryExpressChargeModeEnum valueOf(Integer value) { - return ArrayUtil.firstMatch(chargeMode -> chargeMode.getType().equals(value), DeliveryExpressChargeModeEnum.values()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryTypeEnum.java deleted file mode 100644 index 27e11370c..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/delivery/DeliveryTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.delivery; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 配送方式枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum DeliveryTypeEnum implements IntArrayValuable { - - EXPRESS(1, "快递发货"), - PICK_UP(2, "用户自提"),; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryTypeEnum::getType).toArray(); - - /** - * 配送方式 - */ - private final Integer type; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java deleted file mode 100644 index 74c6b23fe..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/notify/TradeNotifyEnums.java +++ /dev/null @@ -1,5 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.notify; - -// TODO @芋艿:这个枚举的作用? -public interface TradeNotifyEnums { -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderCancelTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderCancelTypeEnum.java deleted file mode 100644 index 8ec1e9b16..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderCancelTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 关闭类型 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderCancelTypeEnum implements IntArrayValuable { - - PAY_TIMEOUT(10, "超时未支付"), - AFTER_SALE_CLOSE(20, "退款关闭"), - MEMBER_CANCEL(30, "买家取消"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderCancelTypeEnum::getType).toArray(); - - /** - * 关闭类型 - */ - private final Integer type; - /** - * 关闭类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderItemAfterSaleStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderItemAfterSaleStatusEnum.java deleted file mode 100644 index 50640717e..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderItemAfterSaleStatusEnum.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单项 - 售后状态 - * - * @author 芋道源码 - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderItemAfterSaleStatusEnum implements IntArrayValuable { - - NONE(0, "未售后"), - APPLY(10, "售后中"), - SUCCESS(20, "售后成功"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderItemAfterSaleStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - /** - * 判断指定状态,是否正处于【未申请】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isNone(Integer status) { - return ObjectUtil.equals(status, NONE.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java deleted file mode 100644 index 695cb41ce..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -/** - * 订单操作类型的枚举 - * - * @author 陈賝 - * @since 2023/7/6 15:31 - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderOperateTypeEnum { - - MEMBER_CREATE(1, "用户下单"), - ADMIN_UPDATE_PRICE(2, "订单价格 {oldPayPrice} 修改,调整价格 {adjustPrice},实际支付金额为 {newPayPrice} 元"), - MEMBER_PAY(10, "用户付款成功"), - ADMIN_UPDATE_ADDRESS(11, "收货地址修改"), - ADMIN_DELIVERY(20, "已发货,快递公司:{deliveryName},快递单号:{logisticsNo}"), - MEMBER_RECEIVE(30, "用户已收货"), - SYSTEM_RECEIVE(31, "到期未收货,系统自动确认收货"), - ADMIN_PICK_UP_RECEIVE(32, "管理员自提收货"), - MEMBER_COMMENT(33, "用户评价"), - SYSTEM_COMMENT(34, "到期未评价,系统自动评价"), - MEMBER_CANCEL(40, "取消订单"), - SYSTEM_CANCEL(41, "到期未支付,系统自动取消订单"), - // 42 预留:管理员取消订单 - ADMIN_CANCEL_AFTER_SALE(43, "订单全部售后,管理员自动取消订单"), - MEMBER_DELETE(49, "删除订单"), - ; - - /** - * 操作类型 - */ - private final Integer type; - /** - * 操作描述 - */ - private final String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderRefundStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderRefundStatusEnum.java deleted file mode 100644 index d0e4190bb..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderRefundStatusEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 退款状态 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderRefundStatusEnum implements IntArrayValuable { - - NONE(0, "未退款"), - PART(10, "部分退款"), - ALL(20, "全部退款"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderRefundStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderStatusEnum.java deleted file mode 100644 index 86d3d996f..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderStatusEnum.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 状态 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderStatusEnum implements IntArrayValuable { - - UNPAID(0, "待支付"), - UNDELIVERED(10, "待发货"), - DELIVERED(20, "已发货"), - COMPLETED(30, "已完成"), - CANCELED(40, "已取消"); - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderStatusEnum::getStatus).toArray(); - - /** - * 状态值 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - // ========== 问:为什么写了很多 isXXX 和 haveXXX 的判断逻辑呢? ========== - // ========== 答:方便找到某一类判断,哪些业务正在使用 ========== - - /** - * 判断指定状态,是否正处于【未付款】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isUnpaid(Integer status) { - return ObjectUtil.equal(UNPAID.getStatus(), status); - } - - /** - * 判断指定状态,是否正处于【待发货】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isUndelivered(Integer status) { - return ObjectUtil.equal(UNDELIVERED.getStatus(), status); - } - - /** - * 判断指定状态,是否正处于【已发货】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isDelivered(Integer status) { - return ObjectUtil.equals(status, DELIVERED.getStatus()); - } - - /** - * 判断指定状态,是否正处于【已取消】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isCanceled(Integer status) { - return ObjectUtil.equals(status, CANCELED.getStatus()); - } - - /** - * 判断指定状态,是否正处于【已完成】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean isCompleted(Integer status) { - return ObjectUtil.equals(status, COMPLETED.getStatus()); - } - - /** - * 判断指定状态,是否有过【已付款】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean havePaid(Integer status) { - return ObjectUtils.equalsAny(status, UNDELIVERED.getStatus(), - DELIVERED.getStatus(), COMPLETED.getStatus()); - } - - /** - * 判断指定状态,是否有过【已发货】状态 - * - * @param status 指定状态 - * @return 是否 - */ - public static boolean haveDelivered(Integer status) { - return ObjectUtils.equalsAny(status, DELIVERED.getStatus(), COMPLETED.getStatus()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderTypeEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderTypeEnum.java deleted file mode 100644 index f82071206..000000000 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderTypeEnum.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.trade.enums.order; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -/** - * 交易订单 - 类型 - * - * @author Sin - */ -@RequiredArgsConstructor -@Getter -public enum TradeOrderTypeEnum implements IntArrayValuable { - - NORMAL(0, "普通订单"), - SECKILL(1, "秒杀订单"), - BARGAIN(2, "砍价订单"), - COMBINATION(3, "拼团订单"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderTypeEnum::getType).toArray(); - - /** - * 类型 - */ - private final Integer type; - /** - * 类型名 - */ - private final String name; - - @Override - public int[] array() { - return ARRAYS; - } - - public static boolean isNormal(Integer type) { - return ObjectUtil.equal(type, NORMAL.getType()); - } - - public static boolean isSeckill(Integer type) { - return ObjectUtil.equal(type, SECKILL.getType()); - } - - public static boolean isBargain(Integer type) { - return ObjectUtil.equal(type, BARGAIN.getType()); - } - - public static boolean isCombination(Integer type) { - return ObjectUtil.equal(type, COMBINATION.getType()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/Dockerfile b/yudao-module-mall/yudao-module-trade-biz/Dockerfile deleted file mode 100644 index 872f55c16..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-trade-biz -WORKDIR /yudao-module-trade-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-trade-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48102 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-mall/yudao-module-trade-biz/pom.xml b/yudao-module-mall/yudao-module-trade-biz/pom.xml deleted file mode 100644 index f00538d8b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/pom.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-mall - ${revision} - - 4.0.0 - yudao-module-trade-biz - jar - - ${project.artifactId} - - trade 模块,主要实现交易相关功能 - 例如:订单、退款、购物车等功能。 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-trade-api - ${revision} - - - cn.iocoder.cloud - yudao-module-product-api - ${revision} - - - cn.iocoder.cloud - yudao-module-pay-api - ${revision} - - - cn.iocoder.cloud - yudao-module-promotion-api - ${revision} - - - cn.iocoder.cloud - yudao-module-member-api - ${revision} - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-ip - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-web - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-job - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/TradeServerApplication.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/TradeServerApplication.java deleted file mode 100644 index be59b7804..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/TradeServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class TradeServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(TradeServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java deleted file mode 100644 index a342c6baf..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.trade.api.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 订单 API 接口实现类 - * - * @author HUIHUI - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class TradeOrderApiImpl implements TradeOrderApi { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - - @Override - public CommonResult> getOrderList(Collection ids) { - return success(TradeOrderConvert.INSTANCE.convertList04(tradeOrderQueryService.getOrderList(ids))); - } - - @Override - public CommonResult getOrder(Long id) { - return success(TradeOrderConvert.INSTANCE.convert(tradeOrderQueryService.getOrder(id))); - } - - @Override - public CommonResult cancelPaidOrder(Long userId, Long orderId) { - tradeOrderUpdateService.cancelPaidOrder(userId, orderId); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java deleted file mode 100644 index 5b0e37dcc..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.trade.api; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/AfterSaleController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/AfterSaleController.java deleted file mode 100644 index a15637428..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/AfterSaleController.java +++ /dev/null @@ -1,144 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.*; -import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleLogService; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.annotation.security.PermitAll; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 售后订单") -@RestController -@RequestMapping("/trade/after-sale") -@Validated -@Slf4j -public class AfterSaleController { - - @Resource - private AfterSaleService afterSaleService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - @Resource - private AfterSaleLogService afterSaleLogService; - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/page") - @Operation(summary = "获得售后订单分页") - @PreAuthorize("@ss.hasPermission('trade:after-sale:query')") - public CommonResult> getAfterSalePage(@Valid AfterSalePageReqVO pageVO) { - // 查询售后 - PageResult pageResult = afterSaleService.getAfterSalePage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 查询会员 - Map memberUsers = memberUserApi.getUserMap( - convertSet(pageResult.getList(), AfterSaleDO::getUserId)); - return success(AfterSaleConvert.INSTANCE.convertPage(pageResult, memberUsers)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得售后订单详情") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:query')") - public CommonResult getOrderDetail(@RequestParam("id") Long id) { - // 查询订单 - AfterSaleDO afterSale = afterSaleService.getAfterSale(id); - if (afterSale == null) { - return success(null); - } - - // 查询订单 - TradeOrderDO order = tradeOrderQueryService.getOrder(afterSale.getOrderId()); - // 查询订单项 - TradeOrderItemDO orderItem = tradeOrderQueryService.getOrderItem(afterSale.getOrderItemId()); - // 拼接数据 - MemberUserRespDTO user = memberUserApi.getUser(afterSale.getUserId()).getCheckedData(); - List logs = afterSaleLogService.getAfterSaleLogList(afterSale.getId()); - return success(AfterSaleConvert.INSTANCE.convert(afterSale, order, orderItem, user, logs)); - } - - @PutMapping("/agree") - @Operation(summary = "同意售后") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:agree')") - public CommonResult agreeAfterSale(@RequestParam("id") Long id) { - afterSaleService.agreeAfterSale(getLoginUserId(), id); - return success(true); - } - - @PutMapping("/disagree") - @Operation(summary = "拒绝售后") - @PreAuthorize("@ss.hasPermission('trade:after-sale:disagree')") - public CommonResult disagreeAfterSale(@RequestBody AfterSaleDisagreeReqVO confirmReqVO) { - afterSaleService.disagreeAfterSale(getLoginUserId(), confirmReqVO); - return success(true); - } - - @PutMapping("/receive") - @Operation(summary = "确认收货") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:receive')") - public CommonResult receiveAfterSale(@RequestParam("id") Long id) { - afterSaleService.receiveAfterSale(getLoginUserId(), id); - return success(true); - } - - @PutMapping("/refuse") - @Operation(summary = "拒绝收货") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:receive')") - public CommonResult refuseAfterSale(AfterSaleRefuseReqVO refuseReqVO) { - afterSaleService.refuseAfterSale(getLoginUserId(), refuseReqVO); - return success(true); - } - - @PutMapping("/refund") - @Operation(summary = "确认退款") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:after-sale:refund')") - public CommonResult refundAfterSale(@RequestParam("id") Long id) { - afterSaleService.refundAfterSale(getLoginUserId(), getClientIP(), id); - return success(true); - } - - @PostMapping("/update-refunded") - @Operation(summary = "更新售后订单为已退款") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录,安全由 PayDemoOrderService 内部校验实现 - public CommonResult updateAfterRefund(@RequestBody PayRefundNotifyReqDTO notifyReqDTO) { - // 目前业务逻辑,不需要做任何事情 - // 当然,退款会有小概率会失败的情况,可以监控失败状态,进行告警 - log.info("[updateAfterRefund][notifyReqDTO({})]", notifyReqDTO); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.http deleted file mode 100644 index 81cb35cbf..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.http +++ /dev/null @@ -1,33 +0,0 @@ -### 获得交易售后分页 => 成功 -GET {{baseUrl}}/trade/after-sale/page?pageNo=1&pageSize=10 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 同意售后 => 成功 -PUT {{baseUrl}}/trade/after-sale/agree?id=7 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} -Content-Type: application/json - -### 拒绝售后 => 成功 -PUT {{baseUrl}}/trade/after-sale/disagree -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} -Content-Type: application/json - -{ - "id": 6, - "auditReason": "阿巴巴" -} - -### 确认退款 => 成功 -PUT {{baseUrl}}/trade/after-sale/refund?id=6 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} -Content-Type: application/json - -### 确认收货 => 成功 -PUT {{baseUrl}}/trade/after-sale/receive?id=7 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} -Content-Type: application/json diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleBaseVO.java deleted file mode 100644 index ae7bd395c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleBaseVO.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** -* 交易售后 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class AfterSaleBaseVO { - - @Schema(description = "售后流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "202211190847450020500077") - @NotNull(message = "售后流水号不能为空") - private String no; - - @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "售后状态不能为空") - private Integer status; - - @Schema(description = "售后类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - @NotNull(message = "售后类型不能为空") - private Integer type; - - @Schema(description = "售后方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "售后方式不能为空") - private Integer way; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30337") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "申请原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "不喜欢") - @NotNull(message = "申请原因不能为空") - private String applyReason; - - @Schema(description = "补充描述", example = "你说的对") - private String applyDescription; - - @Schema(description = "补充凭证图片", example = "https://www.iocoder.cn/1.png") - private List applyPicUrls; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18078") - @NotNull(message = "订单编号不能为空") - private Long orderId; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022111917190001") - @NotNull(message = "订单流水号不能为空") - private String orderNo; - - @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "572") - @NotNull(message = "订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2888") - @NotNull(message = "商品 SPU 编号不能为空") - private Long spuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "商品 SPU 名称不能为空") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15657") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品图片", example = "https://www.iocoder.cn/2.png") - private String picUrl; - - @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20012") - @NotNull(message = "购买数量不能为空") - private Integer count; - - @Schema(description = "审批时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime auditTime; - - @Schema(description = "审批人", example = "30835") - private Long auditUserId; - - @Schema(description = "审批备注", example = "不香") - private String auditReason; - - @Schema(description = "退款金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "18077") - @NotNull(message = "退款金额,单位:分不能为空") - private Integer refundPrice; - - @Schema(description = "支付退款编号", example = "10271") - private Long payRefundId; - - @Schema(description = "退款时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime refundTime; - - @Schema(description = "退货物流公司编号", example = "10") - private Long logisticsId; - - @Schema(description = "退货物流单号", example = "610003952009") - private String logisticsNo; - - @Schema(description = "退货时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime deliveryTime; - - @Schema(description = "收货时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime receiveTime; - - @Schema(description = "收货备注", example = "不喜欢") - private String receiveReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDetailRespVO.java deleted file mode 100644 index 3f220770b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDetailRespVO.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log.AfterSaleLogRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderBaseVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderItemBaseVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - 售后订单的详情 Response VO") -@Data -public class AfterSaleDetailRespVO extends AfterSaleBaseVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - - - /** - * 订单基本信息 - */ - private TradeOrderBaseVO order; - /** - * 订单项列表 - */ - private OrderItem orderItem; - - /** - * 用户信息 - */ - private MemberUserRespVO user; - - /** - * 售后日志 - */ - private List logs; - - @Schema(description = "管理后台 - 交易订单的详情的订单项目") - @Data - public static class OrderItem extends TradeOrderItemBaseVO { - - /** - * 属性数组 - */ - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDisagreeReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDisagreeReqVO.java deleted file mode 100644 index 6fa511acd..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleDisagreeReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 交易售后拒绝 Request VO") -@Data -public class AfterSaleDisagreeReqVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "售后编号不能为空") - private Long id; - - @Schema(description = "审批备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - @NotEmpty(message = "审批备注不能为空") - private String auditReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSalePageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSalePageReqVO.java deleted file mode 100644 index f74c84b8f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSalePageReqVO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleWayEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 交易售后分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AfterSalePageReqVO extends PageParam { - - @Schema(description = "售后流水号", example = "202211190847450020500077") - private String no; - - @Schema(description = "售后状态", example = "10") - @InEnum(value = AfterSaleStatusEnum.class, message = "售后状态必须是 {value}") - private Integer status; - - @Schema(description = "售后类型", example = "20") - @InEnum(value = AfterSaleTypeEnum.class, message = "售后类型必须是 {value}") - private Integer type; - - @Schema(description = "售后方式", example = "10") - @InEnum(value = AfterSaleWayEnum.class, message = "售后方式必须是 {value}") - private Integer way; - - @Schema(description = "订单编号", example = "18078") - private String orderNo; - - @Schema(description = "商品 SPU 名称", example = "李四") - private String spuName; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRefuseReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRefuseReqVO.java deleted file mode 100644 index 6dfced4d8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRefuseReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 交易售后拒绝收货 Request VO") -@Data -public class AfterSaleRefuseReqVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "售后编号不能为空") - private Long id; - - @Schema(description = "收货备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - @NotNull(message = "收货备注不能为空") - private String refuseMemo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRespPageItemVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRespPageItemVO.java deleted file mode 100644 index 3e76405e9..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/AfterSaleRespPageItemVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 交易售后分页的每一条记录 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class AfterSaleRespPageItemVO extends AfterSaleBaseVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27630") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - /** - * 商品属性数组 - */ - private List properties; - - /** - * 用户信息 - */ - private MemberUserRespVO user; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/log/AfterSaleLogRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/log/AfterSaleLogRespVO.java deleted file mode 100644 index 0a5e019a0..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/log/AfterSaleLogRespVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 交易售后日志 Response VO") -@Data -public class AfterSaleLogRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20669") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22634") - private Long userId; - - @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer userType; - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3023") - private Long afterSaleId; - - @Schema(description = "售后状态(之前)", example = "2") - private Integer beforeStatus; - - @Schema(description = "售后状态(之后)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer afterStatus; - - @Schema(description = "操作明细", requiredMode = Schema.RequiredMode.REQUIRED, example = "维权完成,退款金额:¥37776.00") - private String content; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/package-info.java deleted file mode 100644 index f874e482d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,可忽略 - */ -package cn.iocoder.yudao.module.trade.controller.admin.base.member; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/user/MemberUserRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/user/MemberUserRespVO.java deleted file mode 100644 index 2d7c3512d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/member/user/MemberUserRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.base.member.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 会员用户 Response VO") -@Data -public class MemberUserRespVO { - - @Schema(description = "用户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String nickname; - - @Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png") - private String avatar; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/package-info.java deleted file mode 100644 index 0baa83e49..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 放置该模块通用的 VO 类 - */ -package cn.iocoder.yudao.module.trade.controller.admin.base; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/product/property/ProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/product/property/ProductPropertyValueDetailRespVO.java deleted file mode 100644 index 3d6d3b061..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/base/product/property/ProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.base.product.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 商品属性值的明细 Response VO") -@Data -public class ProductPropertyValueDetailRespVO { - - @Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long propertyId; - - @Schema(description = "属性的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String propertyName; - - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long valueId; - - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java deleted file mode 100644 index ff9bd5285..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageRecordController.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 佣金记录") -@RestController -@RequestMapping("/trade/brokerage-record") -@Validated -public class BrokerageRecordController { - - @Resource - private BrokerageRecordService brokerageRecordService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/get") - @Operation(summary = "获得佣金记录") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:brokerage-record:query')") - public CommonResult getBrokerageRecord(@RequestParam("id") Integer id) { - BrokerageRecordDO brokerageRecord = brokerageRecordService.getBrokerageRecord(id); - return success(BrokerageRecordConvert.INSTANCE.convert(brokerageRecord)); - } - - @GetMapping("/page") - @Operation(summary = "获得佣金记录分页") - @PreAuthorize("@ss.hasPermission('trade:brokerage-record:query')") - public CommonResult> getBrokerageRecordPage(@Valid BrokerageRecordPageReqVO pageVO) { - PageResult pageResult = brokerageRecordService.getBrokerageRecordPage(pageVO); - - // 查询用户信息 - Set userIds = convertSet(pageResult.getList(), BrokerageRecordDO::getUserId); - userIds.addAll(convertList(pageResult.getList(), BrokerageRecordDO::getSourceUserId)); - Map userMap = memberUserApi.getUserMap(userIds); - // 拼接数据 - return success(BrokerageRecordConvert.INSTANCE.convertPage(pageResult, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java deleted file mode 100644 index 7844b93e5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.*; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageUserConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 分销用户") -@RestController -@RequestMapping("/trade/brokerage-user") -@Validated -public class BrokerageUserController { - - @Resource - private BrokerageUserService brokerageUserService; - @Resource - private BrokerageRecordService brokerageRecordService; - @Resource - private BrokerageWithdrawService brokerageWithdrawService; - - @Resource - private MemberUserApi memberUserApi; - - @PutMapping("/update-bind-user") - @Operation(summary = "修改推广员") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:update-bind-user')") - public CommonResult updateBindUser(@Valid @RequestBody BrokerageUserUpdateBrokerageUserReqVO updateReqVO) { - brokerageUserService.updateBrokerageUserId(updateReqVO.getId(), updateReqVO.getBindUserId()); - return success(true); - } - - @PutMapping("/clear-bind-user") - @Operation(summary = "清除推广员") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:clear-bind-user')") - public CommonResult clearBindUser(@Valid @RequestBody BrokerageUserClearBrokerageUserReqVO updateReqVO) { - brokerageUserService.updateBrokerageUserId(updateReqVO.getId(), null); - return success(true); - } - - @PutMapping("/update-brokerage-enable") - @Operation(summary = "修改推广资格") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:update-brokerage-enable')") - public CommonResult updateBrokerageEnabled(@Valid @RequestBody BrokerageUserUpdateBrokerageEnabledReqVO updateReqVO) { - brokerageUserService.updateBrokerageUserEnabled(updateReqVO.getId(), updateReqVO.getEnabled()); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得分销用户") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:query')") - public CommonResult getBrokerageUser(@RequestParam("id") Long id) { - BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(id); - // TODO @疯狂:是不是搞成一个统一的 convert? - BrokerageUserRespVO respVO = BrokerageUserConvert.INSTANCE.convert(brokerageUser); - return success(BrokerageUserConvert.INSTANCE.copyTo(memberUserApi.getUser(id).getCheckedData(), respVO)); - } - - @GetMapping("/page") - @Operation(summary = "获得分销用户分页") - @PreAuthorize("@ss.hasPermission('trade:brokerage-user:query')") - public CommonResult> getBrokerageUserPage(@Valid BrokerageUserPageReqVO pageVO) { - // 分页查询 - PageResult pageResult = brokerageUserService.getBrokerageUserPage(pageVO); - - // 查询用户信息 - Set userIds = convertSet(pageResult.getList(), BrokerageUserDO::getId); - Map userMap = memberUserApi.getUserMap(userIds); - // 合计分佣的推广订单 - Map brokerageOrderSummaryMap = brokerageRecordService.getUserBrokerageSummaryMapByUserId( - userIds, BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus()); - // 合计分佣的推广用户 - // TODO @疯狂:转成 map 批量读取 - Map brokerageUserCountMap = convertMap(userIds, - userId -> userId, - userId -> brokerageUserService.getBrokerageUserCountByBindUserId(userId, null)); - // 合计分佣的提现 - // TODO @疯狂:如果未来支持了打款这个动作,可能 status 会不对; - Map withdrawMap = brokerageWithdrawService.getWithdrawSummaryMapByUserId( - userIds, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS); - // 拼接返回 - return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap, - brokerageOrderSummaryMap, withdrawMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java deleted file mode 100644 index 609cfa433..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageWithdrawController.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRejectReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 佣金提现") -@RestController -@RequestMapping("/trade/brokerage-withdraw") -@Validated -public class BrokerageWithdrawController { - - @Resource - private BrokerageWithdrawService brokerageWithdrawService; - - @Resource - private MemberUserApi memberUserApi; - - @PutMapping("/approve") - @Operation(summary = "通过申请") - @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:audit')") - public CommonResult approveBrokerageWithdraw(@RequestParam("id") Integer id) { - brokerageWithdrawService.auditBrokerageWithdraw(id, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS, ""); - return success(true); - } - - @PutMapping("/reject") - @Operation(summary = "驳回申请") - @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:audit')") - public CommonResult rejectBrokerageWithdraw(@Valid @RequestBody BrokerageWithdrawRejectReqVO reqVO) { - brokerageWithdrawService.auditBrokerageWithdraw(reqVO.getId(), BrokerageWithdrawStatusEnum.AUDIT_FAIL, reqVO.getAuditReason()); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得佣金提现") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:query')") - public CommonResult getBrokerageWithdraw(@RequestParam("id") Integer id) { - BrokerageWithdrawDO brokerageWithdraw = brokerageWithdrawService.getBrokerageWithdraw(id); - return success(BrokerageWithdrawConvert.INSTANCE.convert(brokerageWithdraw)); - } - - @GetMapping("/page") - @Operation(summary = "获得佣金提现分页") - @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:query')") - public CommonResult> getBrokerageWithdrawPage(@Valid BrokerageWithdrawPageReqVO pageVO) { - // 分页查询 - PageResult pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(pageVO); - - // 拼接信息 - Map userMap = memberUserApi.getUserMap( - convertSet(pageResult.getList(), BrokerageWithdrawDO::getUserId)); - return success(BrokerageWithdrawConvert.INSTANCE.convertPage(pageResult, userMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java deleted file mode 100644 index 0c53f99fb..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordBaseVO.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 佣金记录 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BrokerageRecordBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25973") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23353") - @NotEmpty(message = "业务编号不能为空") - private String bizId; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "业务类型不能为空") - private Integer bizType; - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "标题不能为空") - private String title; - - @Schema(description = "金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "28731") - @NotNull(message = "金额不能为空") - private Integer price; - - @Schema(description = "当前总佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "13226") - @NotNull(message = "当前总佣金不能为空") - private Integer totalPrice; - - @Schema(description = "说明", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对") - @NotNull(message = "说明不能为空") - private String description; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "冻结时间(天)", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "冻结时间(天)不能为空") - private Integer frozenDays; - - @Schema(description = "解冻时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime unfreezeTime; - - @Schema(description = "来源用户等级") - private Integer sourceUserLevel; - - @Schema(description = "来源用户编号") - private Long sourceUserId; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordPageReqVO.java deleted file mode 100644 index 36c4744e8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordPageReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 佣金记录分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageRecordPageReqVO extends PageParam { - - @Schema(description = "用户编号", example = "25973") - private Long userId; - - @Schema(description = "业务类型", example = "1") - private Integer bizType; - - @Schema(description = "状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "用户类型", example = "1") - private Integer sourceUserLevel; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java deleted file mode 100644 index 224ecf1e5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/record/BrokerageRecordRespVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 佣金记录 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageRecordRespVO extends BrokerageRecordBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28896") - private Integer id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - - // ========== 用户信息 ========== - - @Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png") - private String userAvatar; - @Schema(description = "用户昵称", example = "李四") - private String userNickname; - - - // ========== 来源用户信息 ========== - - @Schema(description = "来源用户头像", example = "https://www.iocoder.cn/xxx.png") - private String sourceUserAvatar; - @Schema(description = "来源用户昵称", example = "李四") - private String sourceUserNickname; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java deleted file mode 100644 index 05e5935b0..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserBaseVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 分销用户 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BrokerageUserBaseVO { - - @Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4587") - @NotNull(message = "推广员编号不能为空") - private Long bindUserId; - - @Schema(description = "推广员绑定时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime bindUserTime; - - @Schema(description = "推广资格", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "推广资格不能为空") - private Boolean brokerageEnabled; - - @Schema(description = "成为分销员时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime brokerageTime; - - @Schema(description = "可用佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "11089") - @NotNull(message = "可用佣金不能为空") - private Integer price; - - @Schema(description = "冻结佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "30916") - @NotNull(message = "冻结佣金不能为空") - private Integer frozenPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java deleted file mode 100644 index 5a05c56ce..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserClearBrokerageUserReqVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 分销用户 - 清除推广员 Request VO") -@Data -@ToString(callSuper = true) -public class BrokerageUserClearBrokerageUserReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - @NotNull(message = "用户编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserPageReqVO.java deleted file mode 100644 index cb0ce8954..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserPageReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 分销用户分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageUserPageReqVO extends PageParam { - - @Schema(description = "推广员编号", example = "4587") - private Long bindUserId; - - @Schema(description = "推广资格", example = "true") - private Boolean brokerageEnabled; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "用户等级", example = "1") // 注意,这了不是用户的会员等级,而是过滤推广的层级 - private Integer level; - - @Schema(description = "绑定时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] bindUserTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserRespVO.java deleted file mode 100644 index 3f5fe258f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserRespVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 分销用户 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageUserRespVO extends BrokerageUserBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 用户信息 ========== - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.png") - private String avatar; - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String nickname; - - // ========== 推广信息 ========== 注意:是包括 1 + 2 级的数据 - - @Schema(description = "推广用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer brokerageUserCount; - @Schema(description = "推广订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer brokerageOrderCount; - @Schema(description = "推广订单金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer brokerageOrderPrice; - - // ========== 提现信息 ========== - - @Schema(description = "已提现金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer withdrawPrice; - @Schema(description = "已提现次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - private Integer withdrawCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java deleted file mode 100644 index d097855a2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageEnabledReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 分销用户 - 修改推广员 Request VO") -@Data -@ToString(callSuper = true) -public class BrokerageUserUpdateBrokerageEnabledReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - @NotNull(message = "用户编号不能为空") - private Long id; - - @Schema(description = "推广资格", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "推广资格不能为空") - private Boolean enabled; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java deleted file mode 100644 index 56391c4d5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/user/BrokerageUserUpdateBrokerageUserReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 分销用户 - 修改推广员 Request VO") -@Data -@ToString(callSuper = true) -public class BrokerageUserUpdateBrokerageUserReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20019") - @NotNull(message = "用户编号不能为空") - private Long id; - - @Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4587") - @NotNull(message = "推广员编号不能为空") - private Long bindUserId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java deleted file mode 100644 index 8aca8a2bb..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawBaseVO.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 佣金提现 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class BrokerageWithdrawBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11436") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "提现金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "18781") - @NotNull(message = "提现金额不能为空") - private Integer price; - - @Schema(description = "提现手续费", requiredMode = Schema.RequiredMode.REQUIRED, example = "11417") - @NotNull(message = "提现手续费不能为空") - private Integer feePrice; - - @Schema(description = "当前总佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "18576") - @NotNull(message = "当前总佣金不能为空") - private Integer totalPrice; - - @Schema(description = "提现类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "提现类型不能为空") - private Integer type; - - @Schema(description = "真实姓名", example = "赵六") - private String name; - - @Schema(description = "账号", example = "88677912132") - private String accountNo; - - @Schema(description = "银行名称", example = "1") - private String bankName; - - @Schema(description = "开户地址", example = "海淀支行") - private String bankAddress; - - @Schema(description = "收款码", example = "https://www.iocoder.cn") - private String accountQrCodeUrl; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "审核驳回原因", example = "不对") - private String auditReason; - - @Schema(description = "审核时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime auditTime; - - @Schema(description = "备注", example = "随便") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawPageReqVO.java deleted file mode 100644 index b18ff74af..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawPageReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 佣金提现分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageWithdrawPageReqVO extends PageParam { - - @Schema(description = "用户编号", example = "11436") - private Long userId; - - @Schema(description = "提现类型", example = "1") - @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现类型必须是 {value}") - private Integer type; - - @Schema(description = "真实姓名", example = "赵六") - private String name; - - @Schema(description = "账号", example = "886779132") - private String accountNo; - - @Schema(description = "银行名称", example = "1") - private String bankName; - - @Schema(description = "状态", example = "1") - @InEnum(value = BrokerageWithdrawStatusEnum.class, message = "状态必须是 {value}") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java deleted file mode 100644 index 23e6c28e5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRejectReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.ToString; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 驳回申请 Request VO") -@Data -@ToString(callSuper = true) -public class BrokerageWithdrawRejectReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") - @NotNull(message = "编号不能为空") - private Integer id; - - @Schema(description = "审核驳回原因", example = "不对") - @NotEmpty(message = "审核驳回原因不能为空") - private String auditReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java deleted file mode 100644 index de74bb4f6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/vo/withdraw/BrokerageWithdrawRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 佣金提现 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BrokerageWithdrawRespVO extends BrokerageWithdrawBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") - private Integer id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") - private String userNickname; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/TradeConfigController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/TradeConfigController.java deleted file mode 100644 index 5e0558fbf..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/TradeConfigController.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.config; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; -import cn.iocoder.yudao.module.trade.convert.config.TradeConfigConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 交易中心配置") -@RestController -@RequestMapping("/trade/config") -@Validated -public class TradeConfigController { - - @Resource - private TradeConfigService tradeConfigService; - - @Value("${yudao.tencent-lbs-key}") - private String tencentLbsKey; - - @PutMapping("/save") - @Operation(summary = "更新交易中心配置") - @PreAuthorize("@ss.hasPermission('trade:config:save')") - public CommonResult updateConfig(@Valid @RequestBody TradeConfigSaveReqVO updateReqVO) { - tradeConfigService.saveTradeConfig(updateReqVO); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得交易中心配置") - @PreAuthorize("@ss.hasPermission('trade:config:query')") - public CommonResult getConfig() { - TradeConfigDO config = tradeConfigService.getTradeConfig(); - TradeConfigRespVO configVO = TradeConfigConvert.INSTANCE.convert(config); - if (configVO != null) { - configVO.setTencentLbsKey(tencentLbsKey); - } - return success(configVO); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java deleted file mode 100644 index 3c58275fa..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigBaseVO.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.config.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.Range; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.PositiveOrZero; -import java.util.List; - -/** - * 交易中心配置 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class TradeConfigBaseVO { - - // ========== 售后相关 ========== - - @Schema(description = "售后的退款理由", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "售后的退款理由不能为空") - private List afterSaleRefundReasons; - - @Schema(description = "售后的退货理由", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "售后的退货理由不能为空") - private List afterSaleReturnReasons; - - // ========== 配送相关 ========== - - /** - * 是否启用全场包邮 - */ - @Schema(description = "是否启用全场包邮", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否启用全场包邮不能为空") - private Boolean deliveryExpressFreeEnabled; - - @Schema(description = "全场包邮的最小金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @NotNull(message = "全场包邮的最小金额不能为空") - @PositiveOrZero(message = "全场包邮的最小金额不能是负数") - private Integer deliveryExpressFreePrice; - - @Schema(description = "是否开启自提", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否开启自提不能为空") - private Boolean deliveryPickUpEnabled; - - // ========== 分销相关 ========== - - @Schema(description = "是否启用分佣", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否启用分佣不能为空") - private Boolean brokerageEnabled; - - @Schema(description = "分佣模式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "分佣模式不能为空") - @InEnum(value = BrokerageEnabledConditionEnum.class, message = "分佣模式必须是 {value}") - private Integer brokerageEnabledCondition; - - @Schema(description = "分销关系绑定模式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "分销关系绑定模式不能为空") - @InEnum(value = BrokerageBindModeEnum.class, message = "分销关系绑定模式必须是 {value}") - private Integer brokerageBindMode; - - @Schema(description = "分销海报图地址数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/yudao.jpg]") - private List brokeragePosterUrls; - - @Schema(description = "一级返佣比例", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "一级返佣比例不能为空") - @Range(min = 0, max = 100, message = "一级返佣比例必须在 0 - 100 之间") - private Integer brokerageFirstPercent; - - @Schema(description = "二级返佣比例", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "二级返佣比例不能为空") - @Range(min = 0, max = 100, message = "二级返佣比例必须在 0 - 100 之间") - private Integer brokerageSecondPercent; - - @Schema(description = "用户提现最低金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @NotNull(message = "用户提现最低金额不能为空") - @PositiveOrZero(message = "用户提现最低金额不能是负数") - private Integer brokerageWithdrawMinPrice; - - @Schema(description = "用户提现手续费百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @NotNull(message = "用户提现手续费百分比不能为空") - @PositiveOrZero(message = "用户提现手续费百分比不能是负数") - private Integer brokerageWithdrawFeePercent; - - @Schema(description = "佣金冻结时间(天)", requiredMode = Schema.RequiredMode.REQUIRED, example = "7") - @NotNull(message = "佣金冻结时间(天)不能为空") - @PositiveOrZero(message = "佣金冻结时间不能是负数") - private Integer brokerageFrozenDays; - - @Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[0, 1]") - @NotEmpty(message = "提现方式不能为空") - @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现方式必须是 {value}") - private List brokerageWithdrawTypes; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigRespVO.java deleted file mode 100644 index 5ded00ace..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 交易中心配置 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class TradeConfigRespVO extends TradeConfigBaseVO { - - @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "腾讯地图 KEY", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - private String tencentLbsKey; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java deleted file mode 100644 index 03a0c41df..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 交易中心配置更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class TradeConfigSaveReqVO extends TradeConfigBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java deleted file mode 100644 index 63f77c1d8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressController.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery; - -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.*; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 快递公司") -@RestController -@RequestMapping("/trade/delivery/express") -@Validated -public class DeliveryExpressController { - - @Resource - private DeliveryExpressService deliveryExpressService; - - @PostMapping("/create") - @Operation(summary = "创建快递公司") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:create')") - public CommonResult createDeliveryExpress(@Valid @RequestBody DeliveryExpressCreateReqVO createReqVO) { - return success(deliveryExpressService.createDeliveryExpress(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新快递公司") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:update')") - public CommonResult updateDeliveryExpress(@Valid @RequestBody DeliveryExpressUpdateReqVO updateReqVO) { - deliveryExpressService.updateDeliveryExpress(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除快递公司") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('trade:delivery:express:delete')") - public CommonResult deleteDeliveryExpress(@RequestParam("id") Long id) { - deliveryExpressService.deleteDeliveryExpress(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得快递公司") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:query')") - public CommonResult getDeliveryExpress(@RequestParam("id") Long id) { - DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(id); - return success(DeliveryExpressConvert.INSTANCE.convert(deliveryExpress)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取快递公司精简信息列表", description = "主要用于前端的下拉选项") - public CommonResult> getSimpleDeliveryExpressList() { - List list = deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus()); - return success(DeliveryExpressConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得快递公司分页") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:query')") - public CommonResult> getDeliveryExpressPage(@Valid DeliveryExpressPageReqVO pageVO) { - PageResult pageResult = deliveryExpressService.getDeliveryExpressPage(pageVO); - return success(DeliveryExpressConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出快递公司 Excel") - @PreAuthorize("@ss.hasPermission('trade:delivery:express:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportDeliveryExpressExcel(@Valid DeliveryExpressExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = deliveryExpressService.getDeliveryExpressList(exportReqVO); - // 导出 Excel - List dataList = DeliveryExpressConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "快递公司.xls", "数据", DeliveryExpressExcelVO.class, dataList); - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java deleted file mode 100644 index 5dc83682a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.*; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressTemplateConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressTemplateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 快递运费模板") -@RestController -@RequestMapping("/trade/delivery/express-template") -@Validated -public class DeliveryExpressTemplateController { - - @Resource - private DeliveryExpressTemplateService deliveryExpressTemplateService; - - @PostMapping("/create") - @Operation(summary = "创建快递运费模板") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:create')") - public CommonResult createDeliveryExpressTemplate(@Valid @RequestBody DeliveryExpressTemplateCreateReqVO createReqVO) { - return success(deliveryExpressTemplateService.createDeliveryExpressTemplate(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新快递运费模板") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:update')") - public CommonResult updateDeliveryExpressTemplate(@Valid @RequestBody DeliveryExpressTemplateUpdateReqVO updateReqVO) { - deliveryExpressTemplateService.updateDeliveryExpressTemplate(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除快递运费模板") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:delete')") - public CommonResult deleteDeliveryExpressTemplate(@RequestParam("id") Long id) { - deliveryExpressTemplateService.deleteDeliveryExpressTemplate(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得快递运费模板") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:query')") - public CommonResult getDeliveryExpressTemplate(@RequestParam("id") Long id) { - return success(deliveryExpressTemplateService.getDeliveryExpressTemplate(id)); - } - - @GetMapping("/list") - @Operation(summary = "获得快递运费模板列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:query')") - public CommonResult> getDeliveryExpressTemplateList(@RequestParam("ids") Collection ids) { - List list = deliveryExpressTemplateService.getDeliveryExpressTemplateList(ids); - return success(DeliveryExpressTemplateConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取快递模版精简信息列表", description = "主要用于前端的下拉选项") - public CommonResult> getSimpleTemplateList() { - // 获取运费模版列表,只要开启状态的 - List list = deliveryExpressTemplateService.getDeliveryExpressTemplateList(); - // 排序后,返回给前端 - return success(DeliveryExpressTemplateConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得快递运费模板分页") - @PreAuthorize("@ss.hasPermission('trade:delivery:express-template:query')") - public CommonResult> getDeliveryExpressTemplatePage(@Valid DeliveryExpressTemplatePageReqVO pageVO) { - PageResult pageResult = deliveryExpressTemplateService.getDeliveryExpressTemplatePage(pageVO); - return success(DeliveryExpressTemplateConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java deleted file mode 100644 index 4235d6ef5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java +++ /dev/null @@ -1,91 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.*; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 自提门店") -@RestController -@RequestMapping("/trade/delivery/pick-up-store") -@Validated -public class DeliveryPickUpStoreController { - - @Resource - private DeliveryPickUpStoreService deliveryPickUpStoreService; - - @PostMapping("/create") - @Operation(summary = "创建自提门店") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:create')") - public CommonResult createDeliveryPickUpStore(@Valid @RequestBody DeliveryPickUpStoreCreateReqVO createReqVO) { - return success(deliveryPickUpStoreService.createDeliveryPickUpStore(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新自提门店") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:update')") - public CommonResult updateDeliveryPickUpStore(@Valid @RequestBody DeliveryPickUpStoreUpdateReqVO updateReqVO) { - deliveryPickUpStoreService.updateDeliveryPickUpStore(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除自提门店") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:delete')") - public CommonResult deleteDeliveryPickUpStore(@RequestParam("id") Long id) { - deliveryPickUpStoreService.deleteDeliveryPickUpStore(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得自提门店") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") - public CommonResult getDeliveryPickUpStore(@RequestParam("id") Long id) { - DeliveryPickUpStoreDO deliveryPickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(id); - return success(DeliveryPickUpStoreConvert.INSTANCE.convert(deliveryPickUpStore)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获得自提门店精简信息列表") - public CommonResult> getSimpleDeliveryPickUpStoreList() { - List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList1(list)); - } - - @GetMapping("/list") - @Operation(summary = "获得自提门店列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") - public CommonResult> getDeliveryPickUpStoreList(@RequestParam("ids") Collection ids) { - List list = deliveryPickUpStoreService.getDeliveryPickUpStoreList(ids); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得自提门店分页") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") - public CommonResult> getDeliveryPickUpStorePage(@Valid DeliveryPickUpStorePageReqVO pageVO) { - PageResult pageResult = deliveryPickUpStoreService.getDeliveryPickUpStorePage(pageVO); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressBaseVO.java deleted file mode 100644 index cc7b8bedd..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressBaseVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** -* 快递公司 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class DeliveryExpressBaseVO { - - @Schema(description = "快递公司编码", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "快递公司编码不能为空") - private String code; - - @Schema(description = "快递公司名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "快递公司名称不能为空") - private String name; - - @Schema(description = "快递公司logo") - private String logo; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "排序不能为空") - private Integer sort; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressCreateReqVO.java deleted file mode 100644 index a9ba8a7cb..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "管理后台 - 快递公司创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressCreateReqVO extends DeliveryExpressBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExcelVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExcelVO.java deleted file mode 100644 index c84a3a189..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExcelVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 快递公司 Excel VO - */ -@Data -public class DeliveryExpressExcelVO { - - @ExcelProperty("编号") - private Long id; - - @ExcelProperty("快递公司编码") - private String code; - - @ExcelProperty("快递公司名称") - private String name; - - @ExcelProperty("快递公司 logo") - private String logo; - - @ExcelProperty("排序") - private Integer sort; - - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExportReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExportReqVO.java deleted file mode 100644 index c601721e8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressExportReqVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 快递公司 Excel 导出 Request VO") -@Data -public class DeliveryExpressExportReqVO { - - @Schema(description = "快递公司编码") - private String code; - - @Schema(description = "快递公司名称", example = "李四") - private String name; - - @Schema(description = "状态(0正常 1停用)", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressPageReqVO.java deleted file mode 100644 index 4a000f319..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressPageReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 快递公司分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressPageReqVO extends PageParam { - - @Schema(description = "快递公司编码") - private String code; - - @Schema(description = "快递公司名称", example = "李四") - private String name; - - @Schema(description = "状态(0正常 1停用)", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressRespVO.java deleted file mode 100644 index cc314d105..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 快递公司 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressRespVO extends DeliveryExpressBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6592") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java deleted file mode 100644 index b97cc2317..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressSimpleRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 快递公司精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DeliveryExpressSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6592") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "快递公司名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "顺丰速运") - @NotNull(message = "快递公司名称不能为空") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressUpdateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressUpdateReqVO.java deleted file mode 100644 index e51366ded..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/express/DeliveryExpressUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 快递公司更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressUpdateReqVO extends DeliveryExpressBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6592") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateBaseVO.java deleted file mode 100644 index 3be8ffc3b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateBaseVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** -* 快递运费模板 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class DeliveryExpressTemplateBaseVO { - - @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotNull(message = "模板名称不能为空") - private String name; - - @Schema(description = "配送计费方式 1:按件 2:按重量 3:按体积", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "配送计费方式 1:按件 2:按重量 3:按体积不能为空") - private Integer chargeMode; - - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "排序不能为空") - private Integer sort; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateChargeBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateChargeBaseVO.java deleted file mode 100644 index efb15c894..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateChargeBaseVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 快递运费模板运费设置 Base VO,提供给添加运费模板使用 - */ -@Data -public class DeliveryExpressTemplateChargeBaseVO { - - @Schema(description = "编号", example = "6592", hidden = true) // 由于想简单一点,复用这个 VO 在更新操作,所以 hidden 为 false - private Long id; - - @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]") - @NotEmpty(message = "区域编号列表不能为空") - private List areaIds; - - @Schema(description = "首件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "首件数量不能为空") - private Double startCount; - - @Schema(description = "起步价", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @NotNull(message = "起步价不能为空") - private Integer startPrice; - - @Schema(description = "续件数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "续件数量不能为空") - private Double extraCount; - - @Schema(description = "额外价", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - @NotNull(message = "额外价不能为空") - private Integer extraPrice; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java deleted file mode 100644 index c5eeaebc9..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import java.util.List; - -@Schema(description = "管理后台 - 快递运费模板创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplateCreateReqVO extends DeliveryExpressTemplateBaseVO { - - @Schema(description = "区域运费列表") - @Valid - private List charges; - - @Schema(description = "包邮区域列表") - @Valid - private List frees; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateDetailRespVO.java deleted file mode 100644 index 272ab59a0..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateDetailRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.List; - -@Schema(description = "管理后台 - 快递运费模板的详细 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplateDetailRespVO extends DeliveryExpressTemplateBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "371") - private Long id; - - @Schema(description = "运费模板运费设置", requiredMode = Schema.RequiredMode.REQUIRED) - private List charges; - - @Schema(description = "运费模板包邮区域", requiredMode = Schema.RequiredMode.REQUIRED) - private List frees; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateFreeBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateFreeBaseVO.java deleted file mode 100644 index b3e0f12b5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateFreeBaseVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 快递运费模板包邮 Base VO,提供给添加运费模板使用 - */ -@Data -public class DeliveryExpressTemplateFreeBaseVO { - - @Schema(description = "区域编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1,120000]") - @NotEmpty(message = "区域编号列表不能为空") - private List areaIds; - - @Schema(description = "包邮金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "5000") - @NotNull(message = "包邮金额不能为空") - private Integer freePrice; - - @Schema(description = "包邮件数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "包邮件数不能为空") - private Integer freeCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplatePageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplatePageReqVO.java deleted file mode 100644 index ea1e4ab3e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplatePageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 快递运费模板分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplatePageReqVO extends PageParam { - - @Schema(description = "模板名称", example = "王五") - private String name; - - @Schema(description = "配送计费方式 1:按件 2:按重量 3:按体积") - private Integer chargeMode; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateRespVO.java deleted file mode 100644 index 19a8c1621..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 快递运费模板 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplateRespVO extends DeliveryExpressTemplateBaseVO { - - @Schema(description = "编号,自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "371") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateSimpleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateSimpleRespVO.java deleted file mode 100644 index 074cc5337..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateSimpleRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - - -@Schema(description = "管理后台 - 模版精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DeliveryExpressTemplateSimpleRespVO { - - @Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试模版") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java deleted file mode 100644 index 4c1774524..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/expresstemplate/DeliveryExpressTemplateUpdateReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 快递运费模板更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryExpressTemplateUpdateReqVO extends DeliveryExpressTemplateBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "371") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "区域运费列表") - @Valid - private List charges; - - @Schema(description = "包邮区域列表") - @Valid - private List frees; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreBaseVO.java deleted file mode 100644 index 6a4ab1141..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreBaseVO.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import java.time.LocalTime; - -/** -* 自提门店 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class DeliveryPickUpStoreBaseVO { - - @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotBlank(message = "门店名称不能为空") - private String name; - - @Schema(description = "门店简介", example = "我是门店简介") - private String introduction; - - @Schema(description = "门店手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601892312") - @NotBlank(message = "门店手机不能为空") - @Mobile - private String phone; - - @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733") - @NotNull(message = "区域编号不能为空") - private Integer areaId; - - @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") - @NotBlank(message = "门店详细地址不能为空") - private String detailAddress; - - @Schema(description = "门店 logo", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - @NotBlank(message = "门店 logo 不能为空") - private String logo; - - @Schema(description = "营业开始时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "营业开始时间不能为空") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") - private LocalTime openingTime; - - @Schema(description = "营业结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "营业结束时间不能为空") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm") - private LocalTime closingTime; - - @Schema(description = "纬度", requiredMode = Schema.RequiredMode.REQUIRED, example = "5.88") - @NotNull(message = "纬度不能为空") - private Double latitude; - - @Schema(description = "经度", requiredMode = Schema.RequiredMode.REQUIRED, example = "6.99") - @NotNull(message = "经度不能为空") - private Double longitude; - - @Schema(description = "门店状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "门店状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreCreateReqVO.java deleted file mode 100644 index d3d23f977..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "管理后台 - 自提门店创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryPickUpStoreCreateReqVO extends DeliveryPickUpStoreBaseVO { - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStorePageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStorePageReqVO.java deleted file mode 100644 index ee3ce2e49..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStorePageReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import lombok.*; - -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 自提门店分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryPickUpStorePageReqVO extends PageParam { - - @Schema(description = "门店名称", example = "李四") - private String name; - - @Schema(description = "门店手机") - private String phone; - - @Schema(description = "区域编号", example = "18733") - private Integer areaId; - - @Schema(description = "门店状态", example = "1") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java deleted file mode 100644 index 5b5bd0d0c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 自提门店 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryPickUpStoreRespVO extends DeliveryPickUpStoreBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java deleted file mode 100644 index c12fc9fc3..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreSimpleRespVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - 自提门店精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DeliveryPickUpStoreSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") - private Long id; - - @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String name; - - @Schema(description = "门店手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601892312") - private String phone; - - @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733") - private Integer areaId; - - @Schema(description = "区域名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "xx市") - private String areaName; - - @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") - private String detailAddress; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreUpdateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreUpdateReqVO.java deleted file mode 100644 index 2b0548d9d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/vo/pickup/DeliveryPickUpStoreUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 自提门店更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class DeliveryPickUpStoreUpdateReqVO extends DeliveryPickUpStoreBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.http deleted file mode 100644 index 0bf8812b2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.http +++ /dev/null @@ -1,9 +0,0 @@ -### 获得交易订单分页 => 成功 -GET {{baseUrl}}/trade/order/page?pageNo=1&pageSize=10 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 获得交易订单分页 => 成功 -GET {{baseUrl}}/trade/order/get-detail?id=21 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java deleted file mode 100644 index 3109ff35c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java +++ /dev/null @@ -1,169 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderLogService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 交易订单") -@RestController -@RequestMapping("/trade/order") -@Validated -@Slf4j -public class TradeOrderController { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - @Resource - private TradeOrderLogService tradeOrderLogService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/page") - @Operation(summary = "获得交易订单分页") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult> getOrderPage(TradeOrderPageReqVO reqVO) { - // 查询订单 - PageResult pageResult = tradeOrderQueryService.getOrderPage(reqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 查询用户信息 - Set userIds = CollUtil.unionDistinct(convertList(pageResult.getList(), TradeOrderDO::getUserId), - convertList(pageResult.getList(), TradeOrderDO::getBrokerageUserId, Objects::nonNull)); - Map userMap = memberUserApi.getUserMap(userIds); - // 查询订单项 - List orderItems = tradeOrderQueryService.getOrderItemListByOrderId( - convertSet(pageResult.getList(), TradeOrderDO::getId)); - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convertPage(pageResult, orderItems, userMap)); - } - - @GetMapping("/summary") - @Operation(summary = "获得交易订单统计") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult getOrderSummary(TradeOrderPageReqVO reqVO) { - return success(tradeOrderQueryService.getOrderSummary(reqVO)); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得交易订单详情") - @Parameter(name = "id", description = "订单编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult getOrderDetail(@RequestParam("id") Long id) { - // 查询订单 - TradeOrderDO order = tradeOrderQueryService.getOrder(id); - if (order == null) { - return success(null); - } - // 查询订单项 - List orderItems = tradeOrderQueryService.getOrderItemListByOrderId(id); - - // 拼接数据 - MemberUserRespDTO user = memberUserApi.getUser(order.getUserId()).getCheckedData(); - MemberUserRespDTO brokerageUser = order.getBrokerageUserId() != null ? - memberUserApi.getUser(order.getBrokerageUserId()).getCheckedData() : null; - List orderLogs = tradeOrderLogService.getOrderLogListByOrderId(id); - return success(TradeOrderConvert.INSTANCE.convert(order, orderItems, orderLogs, user, brokerageUser)); - } - - @GetMapping("/get-express-track-list") - @Operation(summary = "获得交易订单的物流轨迹") - @Parameter(name = "id", description = "交易订单编号") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult> getOrderExpressTrackList(@RequestParam("id") Long id) { - return success(TradeOrderConvert.INSTANCE.convertList02( - tradeOrderQueryService.getExpressTrackList(id))); - } - - @PutMapping("/delivery") - @Operation(summary = "订单发货") - @PreAuthorize("@ss.hasPermission('trade:order:update')") - public CommonResult deliveryOrder(@RequestBody TradeOrderDeliveryReqVO deliveryReqVO) { - tradeOrderUpdateService.deliveryOrder(deliveryReqVO); - return success(true); - } - - @PutMapping("/update-remark") - @Operation(summary = "订单备注") - @PreAuthorize("@ss.hasPermission('trade:order:update')") - public CommonResult updateOrderRemark(@RequestBody TradeOrderRemarkReqVO reqVO) { - tradeOrderUpdateService.updateOrderRemark(reqVO); - return success(true); - } - - @PutMapping("/update-price") - @Operation(summary = "订单调价") - @PreAuthorize("@ss.hasPermission('trade:order:update')") - public CommonResult updateOrderPrice(@RequestBody TradeOrderUpdatePriceReqVO reqVO) { - tradeOrderUpdateService.updateOrderPrice(reqVO); - return success(true); - } - - @PutMapping("/update-address") - @Operation(summary = "修改订单收货地址") - @PreAuthorize("@ss.hasPermission('trade:order:update')") - public CommonResult updateOrderAddress(@RequestBody TradeOrderUpdateAddressReqVO reqVO) { - tradeOrderUpdateService.updateOrderAddress(reqVO); - return success(true); - } - - @PutMapping("/pick-up-by-id") - @Operation(summary = "订单核销") - @Parameter(name = "id", description = "交易订单编号") - @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") - public CommonResult pickUpOrderById(@RequestParam("id") Long id) { - tradeOrderUpdateService.pickUpOrderByAdmin(id); - return success(true); - } - - @PutMapping("/pick-up-by-verify-code") - @Operation(summary = "订单核销") - @Parameter(name = "pickUpVerifyCode", description = "自提核销码") - @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") - public CommonResult pickUpOrderByVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) { - tradeOrderUpdateService.pickUpOrderByAdmin(pickUpVerifyCode); - return success(true); - } - - @GetMapping("/get-by-pick-up-verify-code") - @Operation(summary = "查询核销码对应的订单") - @Parameter(name = "pickUpVerifyCode", description = "自提核销码") - @PreAuthorize("@ss.hasPermission('trade:order:query')") - public CommonResult getByPickUpVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) { - TradeOrderDO tradeOrder = tradeOrderUpdateService.getByPickUpVerifyCode(pickUpVerifyCode); - return success(TradeOrderConvert.INSTANCE.convert2(tradeOrder, null)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java deleted file mode 100755 index 88f5b0cd4..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderBaseVO.java +++ /dev/null @@ -1,151 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 交易订单 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class TradeOrderBaseVO { - - // ========== 订单基本信息 ========== - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "订单类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - @Schema(description = "订单来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer terminal; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long userId; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - private String userIp; - - @Schema(description = "用户备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String userRemark; - - @Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer productCount; - - @Schema(description = "订单完成时间") - private LocalDateTime finishTime; - - @Schema(description = "订单取消时间") - private LocalDateTime cancelTime; - - @Schema(description = "取消类型", example = "10") - private Integer cancelType; - - @Schema(description = "商家备注", example = "你猜一下") - private String remark; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - - @Schema(description = "是否已支付", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean payStatus; - - @Schema(description = "付款时间") - private LocalDateTime payTime; - - @Schema(description = "支付渠道", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx_lite") - private String payChannelCode; - - @Schema(description = "商品原价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer totalPrice; - - @Schema(description = "订单优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer discountPrice; - - @Schema(description = "运费金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer deliveryPrice; - - @Schema(description = "订单调价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer adjustPrice; - - @Schema(description = "应付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - - @Schema(description = "配送方式", example = "10") - private Integer deliveryType; - - @Schema(description = "自提门店", example = "10") - private Long pickUpStoreId; - - @Schema(description = "自提核销码", example = "10") - private Long pickUpVerifyCode; - - @Schema(description = "配送模板编号", example = "1024") - private Long deliveryTemplateId; - - @Schema(description = "发货物流公司编号", example = "1024") - private Long logisticsId; - - @Schema(description = "发货物流单号", example = "1024") - private String logisticsNo; - - @Schema(description = "发货时间") - private LocalDateTime deliveryTime; - - @Schema(description = "收货时间") - private LocalDateTime receiveTime; - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String receiverName; - - @Schema(description = "收件人手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "13800138000") - private String receiverMobile; - - @Schema(description = "收件人地区编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "110000") - private Integer receiverAreaId; - - @Schema(description = "收件人详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "中关村大街 1 号") - private String receiverDetailAddress; - - // ========== 售后基本信息 ========== - - @Schema(description = "售后状态", example = "1") - private Integer afterSaleStatus; - - @Schema(description = "退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer refundPrice; - - // ========== 营销基本信息 ========== - - @Schema(description = "优惠劵编号", example = "1024") - private Long couponId; - - @Schema(description = "优惠劵减免金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer couponPrice; - - @Schema(description = "积分抵扣的金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer pointPrice; - - @Schema(description = "VIP 减免金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Integer vipPrice; - - @Schema(description = "推广人编号", example = "1") - private Long brokerageUserId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java deleted file mode 100644 index 791c4088e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDeliveryReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 订单发货 Request VO") -@Data -public class TradeOrderDeliveryReqVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "订单编号不能为空") - private Long id; - - @Schema(description = "发货物流公司编号", example = "1") - @NotNull(message = "发货物流公司不能为空") - private Long logisticsId; - - @Schema(description = "发货物流单号", example = "SF123456789") - private String logisticsNo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java deleted file mode 100644 index 055639e47..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderDetailRespVO.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 交易订单的详情 Response VO") -@Data -public class TradeOrderDetailRespVO extends TradeOrderBaseVO { - - /** - * 订单项列表 - */ - private List items; - - /** - * 下单用户信息 - */ - private MemberUserRespVO user; - /** - * 推广用户信息 - */ - private MemberUserRespVO brokerageUser; - - /** - * 操作日志列表 - */ - private List logs; - - @Schema(description = "收件人地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海 上海市 普陀区") - private String receiverAreaName; - - @Schema(description = "管理后台 - 交易订单的操作日志") - @Data - public static class OrderLog { - - @Schema(description = "操作详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "订单发货") - private String content; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-06-01 10:50:20") - private LocalDateTime createTime; - - @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer userType; - - } - - @Schema(description = "管理后台 - 交易订单的详情的订单项目") - @Data - public static class Item extends TradeOrderItemBaseVO { - - /** - * 属性数组 - */ - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderItemBaseVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderItemBaseVO.java deleted file mode 100644 index ded1fe7a1..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderItemBaseVO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 交易订单项 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class TradeOrderItemBaseVO { - - // ========== 订单项基本信息 ========== - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long userId; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long orderId; - - // ========== 商品基本信息 ========== - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long spuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long skuId; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "商品原价(单)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - - @Schema(description = "商品优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer discountPrice; - - @Schema(description = "商品实付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer payPrice; - - @Schema(description = "子订单分摊金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer orderPartPrice; - - @Schema(description = "分摊后子订单实付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer orderDividePrice; - - // ========== 营销基本信息 ========== - - // TODO 芋艿:在捉摸一下 - - // ========== 售后基本信息 ========== - - @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer afterSaleStatus; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageItemRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageItemRespVO.java deleted file mode 100644 index 704067ed0..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageItemRespVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "管理后台 - 交易订单的分页项 Response VO") -@Data -public class TradeOrderPageItemRespVO extends TradeOrderBaseVO { - - @Schema(description = "收件人地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海 上海市 普陀区") - private String receiverAreaName; - - @Schema(description = "订单项列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "用户信息", requiredMode = Schema.RequiredMode.REQUIRED) - private MemberUserRespVO user; - - @Schema(description = "推广人信息") - private MemberUserRespVO brokerageUser; - - @Schema(description = "管理后台 - 交易订单的分页项的订单项目") - @Data - public static class Item extends TradeOrderItemBaseVO { - - @Schema(description = "属性列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List properties; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java deleted file mode 100644 index 074a1e544..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageReqVO.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 交易订单的分页 Request VO") -@Data -public class TradeOrderPageReqVO extends PageParam { - - @Schema(description = "订单号", example = "88888888") - private String no; - - @Schema(description = "用户编号", example = "1024") - private Long userId; - - @Schema(description = "用户昵称", example = "小王") - private String userNickname; - - @Schema(description = "用户手机号", example = "小王") - @Mobile - private String userMobile; - - @Schema(description = "配送方式", example = "1") - private Integer deliveryType; - - @Schema(description = "发货物流公司编号", example = "1") - private Long logisticsId; - - @Schema(description = "自提门店编号", example = "[1,2]") - private List pickUpStoreIds; - - @Schema(description = "自提核销码", example = "12345678") - private String pickUpVerifyCode; - - @Schema(description = "订单类型", example = "1") - private Integer type; - - @Schema(description = "订单状态", example = "1") - @InEnum(value = TradeOrderStatusEnum.class, message = "订单状态必须是 {value}") - private Integer status; - - @Schema(description = "支付渠道", example = "wx_lite") - private String payChannelCode; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "订单来源", example = "10") - @InEnum(value = TerminalEnum.class, message = "订单来源 {value}") - private Integer terminal; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java deleted file mode 100644 index 4ef8da40e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderRemarkReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 订单备注 Request VO") -@Data -public class TradeOrderRemarkReqVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "订单编号不能为空") - private Long id; - - @Schema(description = "商家备注", example = "你猜一下") - @NotEmpty(message = "订单备注不能为空") - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderSummaryRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderSummaryRespVO.java deleted file mode 100644 index 184c8db83..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderSummaryRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 交易订单统计 Response VO") -@Data -public class TradeOrderSummaryRespVO { - - @Schema(description = "订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderCount; - - @Schema(description = "订单金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderPayPrice; - - @Schema(description = "退款单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long afterSaleCount; - - @Schema(description = "退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long afterSalePrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdateAddressReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdateAddressReqVO.java deleted file mode 100644 index b66216b46..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdateAddressReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 订单修改地址 Request VO") -@Data -public class TradeOrderUpdateAddressReqVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "订单编号不能为空") - private Long id; - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "z张三") - @NotEmpty(message = "收件人名称不能为空") - private String receiverName; - - @Schema(description = "收件人手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "19988188888") - @NotEmpty(message = "收件人手机不能为空") - private String receiverMobile; - - @Schema(description = "收件人地区编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7310") - @NotNull(message = "收件人地区编号不能为空") - private Integer receiverAreaId; - - @Schema(description = "收件人详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "昆明市五华区xxx小区xxx") - @NotEmpty(message = "收件人详细地址不能为空") - private String receiverDetailAddress; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdatePriceReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdatePriceReqVO.java deleted file mode 100644 index d3e0afb7c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderUpdatePriceReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 订单改价 Request VO") -@Data -public class TradeOrderUpdatePriceReqVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "订单编号不能为空") - private Long id; - - @Schema(description = "订单调价,单位:分。正数,加价;负数,减价", requiredMode = Schema.RequiredMode.REQUIRED, example = "-100") - @NotNull(message = "订单调价价格不能为空") - private Integer adjustPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleController.java deleted file mode 100644 index 4874610aa..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleController.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log.AfterSaleLogRespVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleRespVO; -import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleConvert; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; - -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 交易售后") -@RestController -@RequestMapping("/trade/after-sale") -@Validated -@Slf4j -public class AppAfterSaleController { - - @Resource - private AfterSaleService afterSaleService; - - @GetMapping(value = "/page") - @Operation(summary = "获得售后分页") - public CommonResult> getAfterSalePage(PageParam pageParam) { - return success(AfterSaleConvert.INSTANCE.convertPage02( - afterSaleService.getAfterSalePage(getLoginUserId(), pageParam))); - } - - @GetMapping(value = "/get") - @Operation(summary = "获得售后订单") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - public CommonResult getAfterSale(@RequestParam("id") Long id) { - return success(AfterSaleConvert.INSTANCE.convert(afterSaleService.getAfterSale(getLoginUserId(), id))); - } - - @PostMapping(value = "/create") - @Operation(summary = "申请售后") - public CommonResult createAfterSale(@RequestBody AppAfterSaleCreateReqVO createReqVO) { - return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO)); - } - - @PutMapping(value = "/delivery") - @Operation(summary = "退回货物") - public CommonResult deliveryAfterSale(@RequestBody AppAfterSaleDeliveryReqVO deliveryReqVO) { - afterSaleService.deliveryAfterSale(getLoginUserId(), deliveryReqVO); - return success(true); - } - - @DeleteMapping(value = "/cancel") - @Operation(summary = "取消售后") - @Parameter(name = "id", description = "售后编号", required = true, example = "1") - public CommonResult cancelAfterSale(@RequestParam("id") Long id) { - afterSaleService.cancelAfterSale(getLoginUserId(), id); - return success(true); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleLogController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleLogController.java deleted file mode 100644 index c54ed0c4e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppAfterSaleLogController.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.log.AppAfterSaleLogRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleLogService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 售后日志") -@RestController -@RequestMapping("/trade/after-sale-log") -@Validated -@Slf4j -public class AppAfterSaleLogController { - - @Resource - private AfterSaleLogService afterSaleLogService; - - @GetMapping("/list") - @Operation(summary = "获得售后日志列表") - @Parameter(name = "afterSaleId", description = "售后编号", required = true, example = "1") - public CommonResult> getAfterSaleLogList( - @RequestParam("afterSaleId") Long afterSaleId) { - List logs = afterSaleLogService.getAfterSaleLogList(afterSaleId); - return success(BeanUtils.toBean(logs, AppAfterSaleLogRespVO.class)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleCreateReqVO.java deleted file mode 100644 index 253db62a2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleCreateReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleWayEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 交易售后创建 Request VO") -@Data -public class AppAfterSaleCreateReqVO { - - @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "售后方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "售后方式不能为空") - @InEnum(value = AfterSaleWayEnum.class, message = "售后方式必须是 {value}") - private Integer way; - - @Schema(description = "退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "退款金额不能为空") - @Min(value = 1, message = "退款金额必须大于 0") - private Integer refundPrice; - - @Schema(description = "申请原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "申请原因不能为空") - private String applyReason; - - @Schema(description = "补充描述", example = "商品质量不好") - private String applyDescription; - - @Schema(description = "补充凭证图片", example = "https://www.iocoder.cn/1.png, https://www.iocoder.cn/2.png") - private List applyPicUrls; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleDeliveryReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleDeliveryReqVO.java deleted file mode 100644 index 83b88d133..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleDeliveryReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 交易售后退回货物 Request VO") -@Data -public class AppAfterSaleDeliveryReqVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "售后编号不能为空") - private Long id; - - @Schema(description = "退货物流公司编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "退货物流公司编号不能为空") - private Long logisticsId; - - @Schema(description = "退货物流单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "SF123456789") - @NotNull(message = "退货物流单号不能为空") - private String logisticsNo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleRespVO.java deleted file mode 100644 index 1da0595c7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppAfterSaleRespVO.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 交易售后 Response VO") -@Data -public class AppAfterSaleRespVO { - - @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "售后流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "售后方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer way; - - @Schema(description = "售后类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - @Schema(description = "申请原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String applyReason; - - @Schema(description = "补充描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String applyDescription; - - @Schema(description = "补充凭证图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private List applyPicUrls; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime updateTime; - - // ========== 交易订单相关 ========== - - @Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long orderId; - - @Schema(description = "交易订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String orderNo; - - @Schema(description = "交易订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long orderItemId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long spuId; - - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long skuId; - - /** - * 属性数组 - */ - private List properties; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/01.jpg") - private String picUrl; - - @Schema(description = "退货商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - // ========== 审批相关 ========== - - /** - * 审批备注 - * - * 注意,只有审批不通过才会填写 - */ - private String auditReason; - - // ========== 退款相关 ========== - - @Schema(description = "退款金额,单位:分", example = "100") - private Integer refundPrice; - - @Schema(description = "退款时间") - private LocalDateTime refundTime; - - // ========== 退货相关 ========== - - @Schema(description = "退货物流公司编号", example = "1") - private Long logisticsId; - - @Schema(description = "退货物流单号", example = "SF123456789") - private String logisticsNo; - - @Schema(description = "退货时间") - private LocalDateTime deliveryTime; - - @Schema(description = "收货时间") - private LocalDateTime receiveTime; - - @Schema(description = "收货备注") - private String receiveReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/log/AppAfterSaleLogRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/log/AppAfterSaleLogRespVO.java deleted file mode 100644 index 4d7fb66a4..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/log/AppAfterSaleLogRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.log; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - App 交易售后日志 Response VO") -@Data -public class AppAfterSaleLogRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20669") - private Long id; - - @Schema(description = "操作明细", requiredMode = Schema.RequiredMode.REQUIRED, example = "维权完成,退款金额:¥37776.00") - private String content; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/package-info.java deleted file mode 100644 index 08acfdbca..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 基础包,放一些通用的 VO 类 - */ -package cn.iocoder.yudao.module.trade.controller.app.base; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/property/AppProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/property/AppProductPropertyValueDetailRespVO.java deleted file mode 100644 index 750f16bf3..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/property/AppProductPropertyValueDetailRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.base.property; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 商品属性值的明细 Response VO") -@Data -public class AppProductPropertyValueDetailRespVO { - - @Schema(description = "属性的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long propertyId; - - @Schema(description = "属性的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "颜色") - private String propertyName; - - @Schema(description = "属性值的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long valueId; - - @Schema(description = "属性值的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "红色") - private String valueName; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/sku/AppProductSkuBaseRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/sku/AppProductSkuBaseRespVO.java deleted file mode 100644 index ac0c0ee6b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/sku/AppProductSkuBaseRespVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.base.sku; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -/** - * 商品 SKU 基础 Response VO - * - * @author 芋道源码 - */ -@Data -public class AppProductSkuBaseRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "图片地址", example = "https://www.iocoder.cn/xx.png") - private String picUrl; - - @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer stock; - - /** - * 属性数组 - */ - private List properties; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/spu/AppProductSpuBaseRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/spu/AppProductSpuBaseRespVO.java deleted file mode 100644 index a0e1bc670..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/base/spu/AppProductSpuBaseRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.base.spu; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -/** - * 商品 SPU 基础 Response VO - * - * @author 芋道源码 - */ -@Data -public class AppProductSpuBaseRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "商品 SPU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - - @Schema(description = "商品主图地址", example = "https://www.iocoder.cn/xx.png") - private String picUrl; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java deleted file mode 100644 index 212db07bb..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageRecordController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 分销用户") -@RestController -@RequestMapping("/trade/brokerage-record") -@Validated -@Slf4j -public class AppBrokerageRecordController { - @Resource - private BrokerageRecordService brokerageRecordService; - - @GetMapping("/page") - @Operation(summary = "获得分销记录分页") - @PreAuthenticated - public CommonResult> getBrokerageRecordPage(@Valid AppBrokerageRecordPageReqVO pageReqVO) { - PageResult pageResult = brokerageRecordService.getBrokerageRecordPage( - BrokerageRecordConvert.INSTANCE.convert(pageReqVO, getLoginUserId())); - return success(BeanUtils.toBean(pageResult, AppBrokerageRecordRespVO.class)); - } - - @GetMapping("/get-product-brokerage-price") - @Operation(summary = "获得商品的分销金额") - public CommonResult getProductBrokeragePrice(@RequestParam("spuId") Long spuId) { - return success(brokerageRecordService.calculateProductBrokeragePrice(getLoginUserId(), spuId)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java deleted file mode 100644 index 141ee68dd..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java +++ /dev/null @@ -1,141 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.*; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageUserConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.Map; -import java.util.Optional; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 分销用户") -@RestController -@RequestMapping("/trade/brokerage-user") -@Validated -@Slf4j -public class AppBrokerageUserController { - - @Resource - private BrokerageUserService brokerageUserService; - @Resource - private BrokerageRecordService brokerageRecordService; - @Resource - private BrokerageWithdrawService brokerageWithdrawService; - - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/get") - @Operation(summary = "获得个人分销信息") - @PreAuthenticated - public CommonResult getBrokerageUser() { - Optional user = Optional.ofNullable(brokerageUserService.getBrokerageUser(getLoginUserId())); - // 返回数据 - AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO() - .setBrokerageEnabled(user.map(BrokerageUserDO::getBrokerageEnabled).orElse(false)) - .setBrokeragePrice(user.map(BrokerageUserDO::getBrokeragePrice).orElse(0)) - .setFrozenPrice(user.map(BrokerageUserDO::getFrozenPrice).orElse(0)); - return success(respVO); - } - - @PutMapping("/bind") - @Operation(summary = "绑定推广员") - @PreAuthenticated - public CommonResult bindBrokerageUser(@Valid @RequestBody AppBrokerageUserBindReqVO reqVO) { - return success(brokerageUserService.bindBrokerageUser(getLoginUserId(), reqVO.getBindUserId())); - } - - @GetMapping("/get-summary") - @Operation(summary = "获得个人分销统计") - @PreAuthenticated - public CommonResult getBrokerageUserSummary() { - // 查询当前登录用户信息 - BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(getLoginUserId()); - // 统计用户昨日的佣金 - LocalDateTime yesterday = LocalDateTime.now().minusDays(1); - LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday); - LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday); - Integer yesterdayPrice = brokerageRecordService.getSummaryPriceByUserId(brokerageUser.getId(), - BrokerageRecordBizTypeEnum.ORDER, BrokerageRecordStatusEnum.SETTLEMENT, beginTime, endTime); - // 统计用户提现的佣金 - Integer withdrawPrice = brokerageWithdrawService.getWithdrawSummaryListByUserId(Collections.singleton(brokerageUser.getId()), - BrokerageWithdrawStatusEnum.AUDIT_SUCCESS).stream() - .findFirst().map(BrokerageWithdrawSummaryRespBO::getPrice).orElse(0); - // 统计分销用户数量(一级) - Long firstBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 1); - // 统计分销用户数量(二级) - Long secondBrokerageUserCount = brokerageUserService.getBrokerageUserCountByBindUserId(brokerageUser.getId(), 2); - - // 拼接返回 - return success(BrokerageUserConvert.INSTANCE.convert(yesterdayPrice, withdrawPrice, firstBrokerageUserCount, secondBrokerageUserCount, brokerageUser)); - } - - @GetMapping("/rank-page-by-user-count") - @Operation(summary = "获得分销用户排行分页(基于用户量)") - @PreAuthenticated - public CommonResult> getBrokerageUserRankPageByUserCount(AppBrokerageUserRankPageReqVO pageReqVO) { - // 分页查询 - PageResult pageResult = brokerageUserService.getBrokerageUserRankPageByUserCount(pageReqVO); - // 拼接数据 - Map userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), AppBrokerageUserRankByUserCountRespVO::getId)); - return success(BrokerageUserConvert.INSTANCE.convertPage03(pageResult, userMap)); - } - - @GetMapping("/rank-page-by-price") - @Operation(summary = "获得分销用户排行分页(基于佣金)") - @PreAuthenticated - public CommonResult> getBrokerageUserChildSummaryPageByPrice(AppBrokerageUserRankPageReqVO pageReqVO) { - // 分页查询 - PageResult pageResult = brokerageRecordService.getBrokerageUserChildSummaryPageByPrice(pageReqVO); - // 拼接数据 - Map userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), AppBrokerageUserRankByPriceRespVO::getId)); - return success(BrokerageRecordConvert.INSTANCE.convertPage03(pageResult, userMap)); - } - - @GetMapping("/child-summary-page") - @Operation(summary = "获得下级分销统计分页") - @PreAuthenticated - public CommonResult> getBrokerageUserChildSummaryPage( - AppBrokerageUserChildSummaryPageReqVO pageReqVO) { - PageResult pageResult = brokerageUserService.getBrokerageUserChildSummaryPage(pageReqVO, getLoginUserId()); - return success(pageResult); - } - - @GetMapping("/get-rank-by-price") - @Operation(summary = "获得分销用户排行(基于佣金)") - @Parameter(name = "times", description = "时间段", required = true) - public CommonResult getRankByPrice( - @RequestParam("times") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) LocalDateTime[] times) { - return success(brokerageRecordService.getUserRankByPrice(getLoginUserId(), times)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java deleted file mode 100644 index b1ef5f890..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 分销提现") -@RestController -@RequestMapping("/trade/brokerage-withdraw") -@Validated -@Slf4j -public class AppBrokerageWithdrawController { - - @Resource - private BrokerageWithdrawService brokerageWithdrawService; - - @GetMapping("/page") - @Operation(summary = "获得分销提现分页") - @PreAuthenticated - public CommonResult> getBrokerageWithdrawPage(AppBrokerageWithdrawPageReqVO pageReqVO) { - PageResult pageResult = brokerageWithdrawService.getBrokerageWithdrawPage( - BrokerageWithdrawConvert.INSTANCE.convert(pageReqVO, getLoginUserId())); - return success(BrokerageWithdrawConvert.INSTANCE.convertPage03(pageResult)); - } - - @PostMapping("/create") - @Operation(summary = "创建分销提现") - @PreAuthenticated - public CommonResult createBrokerageWithdraw(@RequestBody @Valid AppBrokerageWithdrawCreateReqVO createReqVO) { - return success(brokerageWithdrawService.createBrokerageWithdraw(getLoginUserId(), createReqVO)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageProductPriceRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageProductPriceRespVO.java deleted file mode 100644 index 6b2191d5f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageProductPriceRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 商品的分销金额 Response VO") -@Data -public class AppBrokerageProductPriceRespVO { - - @Schema(description = "是否开启", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Boolean enabled; - - @Schema(description = "分销最小金额,单位:分", example = "100") - private Integer brokerageMinPrice; - - @Schema(description = "分销最大金额,单位:分", example = "100") - private Integer brokerageMaxPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordPageReqVO.java deleted file mode 100644 index 2100c2324..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordPageReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "应用 App - 分销记录分页 Request VO") -@Data -public class AppBrokerageRecordPageReqVO extends PageParam { - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageRecordBizTypeEnum.class, message = "业务类型必须是 {value}") - private Integer bizType; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageRecordStatusEnum.class, message = "状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordRespVO.java deleted file mode 100644 index 993006e34..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/record/AppBrokerageRecordRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 分销记录 Response VO") -@Data -public class AppBrokerageRecordRespVO { - - @Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "业务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private String bizId; - - @Schema(description = "分销标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "用户下单") - private String title; - - @Schema(description = "分销金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer price; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "完成时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime finishTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserBindReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserBindReqVO.java deleted file mode 100644 index f2a14996a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserBindReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "应用 App - 绑定推广员 Request VO") -@Data -public class AppBrokerageUserBindReqVO extends PageParam { - - @Schema(description = "推广员编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "推广员编号不能为空") - private Long bindUserId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryPageReqVO.java deleted file mode 100644 index 890500c62..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.SortingField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.Range; - -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 下级分销统计分页 Request VO") -@Data -public class AppBrokerageUserChildSummaryPageReqVO extends PageParam { - - public static final String SORT_FIELD_USER_COUNT = "userCount"; - public static final String SORT_FIELD_ORDER_COUNT = "orderCount"; - public static final String SORT_FIELD_PRICE = "price"; - - @Schema(description = "用户昵称", example = "李") // 模糊匹配 - private String nickname; - - @Schema(description = "排序字段", example = "userCount") - private SortingField sortingField; - - @Schema(description = "下级的级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 1 - 直接下级;2 - 间接下级 - @NotNull(message = "下级的级别不能为空") - @Range(min = 1, max = 2, message = "下级的级别只能是 {min} 或者 {max}") - private Integer level; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java deleted file mode 100644 index 6bc4184e8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 下级分销统计 Response VO") -@Data -public class AppBrokerageUserChildSummaryRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小王") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - @Schema(description = "佣金金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer brokeragePrice; - - @Schema(description = "分销订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer brokerageOrderCount; - - @Schema(description = "分销用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") - private Integer brokerageUserCount; - - @Schema(description = "绑定推广员的时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime brokerageTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserMySummaryRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserMySummaryRespVO.java deleted file mode 100644 index 8a0c387c6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserMySummaryRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 个人分销统计 Response VO") -@Data -public class AppBrokerageUserMySummaryRespVO { - - @Schema(description = "昨天的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer yesterdayPrice; - - @Schema(description = "提现的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer withdrawPrice; - - @Schema(description = "可用的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2408") - private Integer brokeragePrice; - - @Schema(description = "冻结的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "234") - private Integer frozenPrice; - - @Schema(description = "分销用户数量(一级)", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long firstBrokerageUserCount; - - @Schema(description = "分销用户数量(二级)", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long secondBrokerageUserCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByPriceRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByPriceRespVO.java deleted file mode 100644 index 91345ea78..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByPriceRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 分销排行用户(基于用户量) Response VO") -@Data -public class AppBrokerageUserRankByPriceRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小王") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - @Schema(description = "佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer brokeragePrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByUserCountRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByUserCountRespVO.java deleted file mode 100644 index 1a6de8138..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankByUserCountRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 分销排行用户(基于用户量) Response VO") -@Data -public class AppBrokerageUserRankByUserCountRespVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小王") - private String nickname; - - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - - @Schema(description = "邀请用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer brokerageUserCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankPageReqVO.java deleted file mode 100644 index de1d61a7b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRankPageReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotEmpty; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "应用 App - 分销用户排行 Request VO") -@Data -public class AppBrokerageUserRankPageReqVO extends PageParam { - - @Schema(description = "开始 + 结束时间", requiredMode = Schema.RequiredMode.REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @NotEmpty(message = "时间不能为空") - private LocalDateTime[] times; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRespVO.java deleted file mode 100644 index f98da7eb6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 分销用户信息 Response VO") -@Data -public class AppBrokerageUserRespVO { - - @Schema(description = "是否有分销资格", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean brokerageEnabled; - - @Schema(description = "可用的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2408") - private Integer brokeragePrice; - - @Schema(description = "冻结的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "234") - private Integer frozenPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java deleted file mode 100644 index d49957d25..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw; - -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.URL; - -import javax.validation.Validator; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.PositiveOrZero; - -@Schema(description = "用户 App - 分销提现创建 Request VO") -@Data -public class AppBrokerageWithdrawCreateReqVO { - - @Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现方式必须是 {value}") - private Integer type; - - @Schema(description = "提现金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - @PositiveOrZero(message = "提现金额不能小于 0") - @NotNull(message = "提现金额不能为空") - private Integer price; - - // ========== 银行卡、微信、支付宝 提现相关字段 ========== - - @Schema(description = "提现账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456789") - @NotBlank(message = "提现账号不能为空", groups = {Bank.class, Wechat.class, Alipay.class}) - private String accountNo; - - // ========== 微信、支付宝 提现相关字段 ========== - - @Schema(description = "收款码的图片", example = "https://www.iocoder.cn/1.png") - @URL(message = "收款码的图片,必须是一个 URL") - private String accountQrCodeUrl; - - // ========== 银行卡 提现相关字段 ========== - - @Schema(description = "持卡人姓名", example = "张三") - @NotBlank(message = "持卡人姓名不能为空", groups = {Bank.class}) - private String name; - @Schema(description = "提现银行", example = "1") - @NotNull(message = "提现银行不能为空", groups = {Bank.class}) - private Integer bankName; - @Schema(description = "开户地址", example = "海淀支行") - private String bankAddress; - - public interface Wallet { - } - - public interface Bank { - } - - public interface Wechat { - } - - public interface Alipay { - } - - public void validate(Validator validator) { - if (BrokerageWithdrawTypeEnum.WALLET.getType().equals(type)) { - ValidationUtils.validate(validator, this, Wallet.class); - } else if (BrokerageWithdrawTypeEnum.BANK.getType().equals(type)) { - ValidationUtils.validate(validator, this, Bank.class); - } else if (BrokerageWithdrawTypeEnum.WECHAT.getType().equals(type)) { - ValidationUtils.validate(validator, this, Wechat.class); - } else if (BrokerageWithdrawTypeEnum.ALIPAY.getType().equals(type)) { - ValidationUtils.validate(validator, this, Alipay.class); - } - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawPageReqVO.java deleted file mode 100644 index b1757d43e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawPageReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "应用 App - 分销提现分页 Request VO") -@Data -public class AppBrokerageWithdrawPageReqVO extends PageParam { - - @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "类型必须是 {value}") - private Integer type; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = BrokerageWithdrawStatusEnum.class, message = "状态必须是 {value}") - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawRespVO.java deleted file mode 100644 index 4cfe930c8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 App - 分销提现 Response VO") -@Data -public class AppBrokerageWithdrawRespVO { - - @Schema(description = "提现编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Long id; - - @Schema(description = "提现状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer status; - - @Schema(description = "提现状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "审核中") - private String statusName; - - @Schema(description = "提现金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer price; - - @Schema(description = "提现时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.http deleted file mode 100644 index b341a4886..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.http +++ /dev/null @@ -1,42 +0,0 @@ -### 请求 /trade/cart/add 接口 => 成功 -POST {{appApi}}/trade/cart/add -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} -Content-Type: application/json - -{ - "skuId": 1, - "count": 10, - "addStatus": true -} - -### 请求 /trade/cart/update 接口 => 成功 -PUT {{appApi}}/trade/cart/update -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} -Content-Type: application/json - -{ - "id": 35, - "count": 5 -} - -### 请求 /trade/cart/delete 接口 => 成功 -DELETE {{appApi}}/trade/cart/delete?ids=1 -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /trade/cart/get-count 接口 => 成功 -GET {{appApi}}/trade/cart/get-count -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /trade/cart/get-count-map 接口 => 成功 -GET {{appApi}}/trade/cart/get-count-map -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} - -### 请求 /trade/cart/list 接口 => 成功 -GET {{appApi}}/trade/cart/list -tenant-id: {{appTenentId}} -Authorization: Bearer {{appToken}} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.java deleted file mode 100644 index 2c9d77b52..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/AppCartController.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.*; -import cn.iocoder.yudao.module.trade.service.cart.CartService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 购物车") -@RestController -@RequestMapping("/trade/cart") -@RequiredArgsConstructor -@Validated -@Slf4j -public class AppCartController { - - @Resource - private CartService cartService; - - @PostMapping("/add") - @Operation(summary = "添加购物车商品") - @PreAuthenticated - public CommonResult addCart(@Valid @RequestBody AppCartAddReqVO addCountReqVO) { - return success(cartService.addCart(getLoginUserId(), addCountReqVO)); - } - - @PutMapping("/update-count") - @Operation(summary = "更新购物车商品数量") - @PreAuthenticated - public CommonResult updateCartCount(@Valid @RequestBody AppCartUpdateCountReqVO updateReqVO) { - cartService.updateCartCount(getLoginUserId(), updateReqVO); - return success(true); - } - - @PutMapping("/update-selected") - @Operation(summary = "更新购物车商品选中") - @PreAuthenticated - public CommonResult updateCartSelected(@Valid @RequestBody AppCartUpdateSelectedReqVO updateReqVO) { - cartService.updateCartSelected(getLoginUserId(), updateReqVO); - return success(true); - } - - @PutMapping("/reset") - @Operation(summary = "重置购物车商品") - @PreAuthenticated - public CommonResult resetCart(@Valid @RequestBody AppCartResetReqVO updateReqVO) { - cartService.resetCart(getLoginUserId(), updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除购物车商品") - @Parameter(name = "ids", description = "购物车商品编号", required = true, example = "1024,2048") - @PreAuthenticated - public CommonResult deleteCart(@RequestParam("ids") List ids) { - cartService.deleteCart(getLoginUserId(), ids); - return success(true); - } - - @GetMapping("get-count") - @Operation(summary = "查询用户在购物车中的商品数量") - @PreAuthenticated - public CommonResult getCartCount() { - return success(cartService.getCartCount(getLoginUserId())); - } - - @GetMapping("/list") - @Operation(summary = "查询用户的购物车列表") - @PreAuthenticated - public CommonResult getCartList() { - return success(cartService.getCartList(getLoginUserId())); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartAddReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartAddReqVO.java deleted file mode 100644 index 57eb0582e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartAddReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 购物车添加购物项 Request VO") -@Data -public class AppCartAddReqVO { - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED,example = "1024") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "新增商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "数量不能为空") - @Min(value = 1, message = "商品数量必须大于等于 1") - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartDetailRespVO.java deleted file mode 100644 index 1a28d96a6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartDetailRespVO.java +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.sku.AppProductSkuBaseRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 用户的购物车明细 Response VO") -@Data -public class AppCartDetailRespVO { - - /** - * 商品分组数组 - */ - private List itemGroups; - - /** - * 费用 - */ - private Order order; - - @Schema(description = "商品分组") // 多个商品,参加同一个活动,从而形成分组 - @Data - public static class ItemGroup { - - /** - * 商品数组 - */ - private List items; - /** - * 营销活动,订单级别 - */ - private Promotion promotion; - - } - - @Schema(description = "商品 SKU") - @Data - public static class Sku extends AppProductSkuBaseRespVO { - - /** - * SPU 信息 - */ - private AppProductSkuBaseRespVO spu; - - // ========== 购物车相关的字段 ========== - - @Schema(description = "商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - @Schema(description = "是否选中", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean selected; - - // ========== 价格相关的字段,对应 PriceCalculateRespDTO.OrderItem 的属性 ========== - - // TODO 芋艿:后续可以去除一些无用的字段 - - @Schema(description = "商品原价(单)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer originalPrice; - @Schema(description = "商品原价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer totalOriginalPrice; - @Schema(description = "商品级优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "300") - private Integer totalPromotionPrice; - @Schema(description = "最终购买金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "400") - private Integer totalPresentPrice; - @Schema(description = "最终购买金额(单)", requiredMode = Schema.RequiredMode.REQUIRED, example = "500") - private Integer presentPrice; - @Schema(description = "应付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "600") - private Integer totalPayPrice; - - // ========== 营销相关的字段 ========== - /** - * 营销活动,商品级别 - */ - private Promotion promotion; - - } - - @Schema(description = "订单") // 对应 PriceCalculateRespDTO.Order 类,用于费用(合计) - @Data - public static class Order { - - // TODO 芋艿:后续可以去除一些无用的字段 - - @Schema(description = "商品原价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer skuOriginalPrice; - @Schema(description = "商品优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Integer skuPromotionPrice; - @Schema(description = "订单优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "300") - private Integer orderPromotionPrice; - @Schema(description = "运费金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "400") - private Integer deliveryPrice; - @Schema(description = "应付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "500") - private Integer payPrice; - - } - - @Schema(description = "营销活动") // 对应 PriceCalculateRespDTO.Promotion 类的属性 - @Data - public static class Promotion { - - @Schema(description = "营销编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") // 营销活动的编号、优惠劵的编号 - private Long id; - @Schema(description = "营销名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "xx 活动") - private String name; - @Schema(description = "营销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer type; - - // ========== 匹配情况 ========== - @Schema(description = "是否满足优惠条件", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean meet; - @Schema(description = "满足条件的提示", requiredMode = Schema.RequiredMode.REQUIRED, example = "圣诞价:省 150.00 元") - private String meetTip; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartListRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartListRespVO.java deleted file mode 100644 index cef09f78f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartListRespVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.sku.AppProductSkuBaseRespVO; -import cn.iocoder.yudao.module.trade.controller.app.base.spu.AppProductSpuBaseRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 用户的购物列表 Response VO") -@Data -public class AppCartListRespVO { - - /** - * 有效的购物项数组 - */ - private List validList; - - /** - * 无效的购物项数组 - */ - private List invalidList; - - @Schema(description = "购物项") - @Data - public static class Cart { - - @Schema(description = "购物项的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - @Schema(description = "是否选中", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean selected; - - /** - * 商品 SPU - */ - private AppProductSpuBaseRespVO spu; - /** - * 商品 SKU - */ - private AppProductSkuBaseRespVO sku; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartResetReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartResetReqVO.java deleted file mode 100644 index 1ef82c69b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartResetReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 购物车重置 Request VO") -@Data -public class AppCartResetReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED,example = "1024") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "数量不能为空") - @Min(message = "数量必须大于 0", value = 1L) - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateCountReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateCountReqVO.java deleted file mode 100644 index 4341d501d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateCountReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; - -@Schema(description = "用户 App - 购物车更新数量 Request VO") -@Data -public class AppCartUpdateCountReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "数量不能为空") - @Min(message = "数量必须大于 0", value = 1L) - private Integer count; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateSelectedReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateSelectedReqVO.java deleted file mode 100644 index 3348d2d19..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/cart/vo/AppCartUpdateSelectedReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.cart.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.Collection; - -@Schema(description = "用户 App - 购物车更新是否选中 Request VO") -@Data -public class AppCartUpdateSelectedReqVO { - - @Schema(description = "编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024,2048") - @NotNull(message = "编号列表不能为空") - private Collection ids; - - @Schema(description = "是否选中", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否选中不能为空") - private Boolean selected; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java deleted file mode 100644 index 5046c6512..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.config; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO; -import cn.iocoder.yudao.module.trade.convert.config.TradeConfigConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 交易配置") -@RestController -@RequestMapping("/trade/config") -@RequiredArgsConstructor -@Validated -@Slf4j -public class AppTradeConfigController { - - @Resource - private TradeConfigService tradeConfigService; - - @Value("${yudao.tencent-lbs-key}") - private String tencentLbsKey; - - @GetMapping("/get") - @Operation(summary = "获得交易配置") - public CommonResult getTradeConfig() { - TradeConfigDO config = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO()); - return success(TradeConfigConvert.INSTANCE.convert02(config).setTencentLbsKey(tencentLbsKey)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java deleted file mode 100644 index c80472c8b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.config.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 交易配置 Response VO") -@Data -public class AppTradeConfigRespVO { - - @Schema(description = "腾讯地图 KEY", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - private String tencentLbsKey; - - // ========== 配送相关 ========== - - @Schema(description = "是否开启自提", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否开启自提不能为空") - private Boolean deliveryPickUpEnabled; - - // ========== 售后相关 ========== - - @Schema(description = "售后的退款理由", requiredMode = Schema.RequiredMode.REQUIRED) - private List afterSaleRefundReasons; - - @Schema(description = "售后的退货理由", requiredMode = Schema.RequiredMode.REQUIRED) - private List afterSaleReturnReasons; - - // ========== 分销相关 ========== - - @Schema(description = "分销海报地址数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List brokeragePosterUrls; - - @Schema(description = "佣金冻结时间(天)", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer brokerageFrozenDays; - - @Schema(description = "佣金提现最小金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer brokerageWithdrawMinPrice; - - @Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]") - private List brokerageWithdrawTypes; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverConfigController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverConfigController.java deleted file mode 100644 index 1d4e36f90..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverConfigController.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.config.AppDeliveryConfigRespVO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 配送配置") -@RestController -@RequestMapping("/trade/delivery/config") -@Validated -public class AppDeliverConfigController { - - // TODO @芋艿:这里后面干掉,合并到 AppTradeConfigController 中 - @GetMapping("/get") - @Operation(summary = "获得配送配置") - public CommonResult getDeliveryConfig() { - return success(new AppDeliveryConfigRespVO().setPickUpEnable(true).setTencentLbsKey("123456")); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java deleted file mode 100644 index 20cdef588..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverExpressController.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.express.AppDeliveryExpressRespVO; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.Comparator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 快递公司") -@RestController -@RequestMapping("/trade/delivery/express") -@Validated -public class AppDeliverExpressController { - - @Resource - private DeliveryExpressService deliveryExpressService; - - @GetMapping("/list") - @Operation(summary = "获得快递公司列表") - public CommonResult> getDeliveryExpressList() { - List list = deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus()); - list.sort(Comparator.comparing(DeliveryExpressDO::getSort)); - return success(DeliveryExpressConvert.INSTANCE.convertList03(list)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java deleted file mode 100644 index fcc4993f1..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/AppDeliverPickUpStoreController.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup.AppDeliveryPickUpStoreRespVO; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 App - 自提门店") -@RestController -@RequestMapping("/trade/delivery/pick-up-store") -@Validated -public class AppDeliverPickUpStoreController { - - @Resource - private DeliveryPickUpStoreService deliveryPickUpStoreService; - - @GetMapping("/list") - @Operation(summary = "获得自提门店列表") - @Parameters({ - @Parameter(name = "latitude", description = "精度", example = "110"), - @Parameter(name = "longitude", description = "纬度", example = "120") - }) - public CommonResult> getDeliveryPickUpStoreList( - @RequestParam(value = "latitude", required = false) Double latitude, - @RequestParam(value = "longitude", required = false) Double longitude) { - List list = deliveryPickUpStoreService.getDeliveryPickUpStoreListByStatus( - CommonStatusEnum.ENABLE.getStatus()); - return success(DeliveryPickUpStoreConvert.INSTANCE.convertList(list, latitude, longitude)); - } - - @GetMapping("/get") - @Operation(summary = "获得自提门店") - @Parameter(name = "id", description = "门店编号") - public CommonResult getOrder(@RequestParam("id") Long id) { - DeliveryPickUpStoreDO store = deliveryPickUpStoreService.getDeliveryPickUpStore(id); - return success(DeliveryPickUpStoreConvert.INSTANCE.convert03(store)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/config/AppDeliveryConfigRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/config/AppDeliveryConfigRespVO.java deleted file mode 100644 index f3b50bf84..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/config/AppDeliveryConfigRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery.vo.config; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -// TODO 芋艿:后续要实现下,配送配置;后续融合到 AppTradeConfigRespVO 中 -@Schema(description = "用户 App - 配送配置 Response VO") -@Data -public class AppDeliveryConfigRespVO { - - @Schema(description = "腾讯地图 KEY", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") - private String tencentLbsKey; - - @Schema(description = "是否开启自提", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean pickUpEnable; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/express/AppDeliveryExpressRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/express/AppDeliveryExpressRespVO.java deleted file mode 100644 index d01d90502..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/express/AppDeliveryExpressRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery.vo.express; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 快递公司 Response VO") -@Data -public class AppDeliveryExpressRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "顺丰") - private String name; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/pickup/AppDeliveryPickUpStoreRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/pickup/AppDeliveryPickUpStoreRespVO.java deleted file mode 100644 index 1ca25ade5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/delivery/vo/pickup/AppDeliveryPickUpStoreRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 自提门店 Response VO") -@Data -public class AppDeliveryPickUpStoreRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23128") - private Long id; - - @Schema(description = "门店名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - private String name; - - @Schema(description = "门店 logo", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String logo; - - @Schema(description = "门店手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601892312") - private String phone; - - @Schema(description = "区域编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18733") - private Integer areaId; - - @Schema(description = "地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海上海市普陀区") - private String areaName; - - @Schema(description = "门店详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "复旦大学路 188 号") - private String detailAddress; - - @Schema(description = "纬度", requiredMode = Schema.RequiredMode.REQUIRED, example = "5.88") - private Double latitude; - - @Schema(description = "经度", requiredMode = Schema.RequiredMode.REQUIRED, example = "6.99") - private Double longitude; - - @Schema(description = "距离,单位:千米", example = "100") // 只有在用户传递了经纬度时,才进行计算 - private Double distance; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.http b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.http deleted file mode 100644 index 4a9441694..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.http +++ /dev/null @@ -1,64 +0,0 @@ -### /trade-order/settlement 获得订单结算信息(基于商品) -GET {{appApi}}/trade/order/settlement?type=0&items[0].skuId=1&items[0].count=2&items[1].skuId=2&items[1].count=3&couponId=1 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### /trade-order/settlement 获得订单结算信息(基于购物车) -GET {{appApi}}/trade/order/settlement?type=0&items[0].cartId=50&couponId=1 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### /trade-order/create 创建订单(基于商品)【快递】 -POST {{appApi}}/trade/order/create -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "pointStatus": true, - "deliveryType": 1, - "addressId": 21, - "items": [ - { - "skuId": 1, - "count": 2 - } - ], - "remark": "我是备注" -} - -### /trade-order/create 创建订单(基于商品)【自提】 -POST {{appApi}}/trade/order/create -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "pointStatus": true, - "deliveryType": 2, - "pickUpStoreId": 1, - "items": [ - { - "skuId": 1, - "count": 2 - } - ], - "remark": "我是备注", - "receiverName": "土豆", - "receiverMobile": "15601691300" -} - -### 获得订单交易的分页 -GET {{appApi}}/trade/order/page?pageNo=1&pageSize=10 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得订单交易的详细 -GET {{appApi}}/trade/order/get-detail?id=21 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -### 获得交易订单的物流轨迹 -GET {{appApi}}/trade/order/get-express-track-list?id=70 -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java deleted file mode 100644 index 762b238c7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java +++ /dev/null @@ -1,182 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.*; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import com.google.common.collect.Maps; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 App - 交易订单") -@RestController -@RequestMapping("/trade/order") -@Validated -@Slf4j -public class AppTradeOrderController { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - @Resource - private DeliveryExpressService deliveryExpressService; - - @Resource - private AfterSaleService afterSaleService; - - @Resource - private TradeOrderProperties tradeOrderProperties; - - @GetMapping("/settlement") - @Operation(summary = "获得订单结算信息") - @PreAuthenticated - public CommonResult settlementOrder(@Valid AppTradeOrderSettlementReqVO settlementReqVO) { - return success(tradeOrderUpdateService.settlementOrder(getLoginUserId(), settlementReqVO)); - } - - @PostMapping("/create") - @Operation(summary = "创建订单") - @PreAuthenticated - public CommonResult createOrder(@Valid @RequestBody AppTradeOrderCreateReqVO createReqVO) { - TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), createReqVO); - return success(new AppTradeOrderCreateRespVO().setId(order.getId()).setPayOrderId(order.getPayOrderId())); - } - - @PostMapping("/update-paid") - @Operation(summary = "更新订单为已支付") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - public CommonResult updateOrderPaid(@RequestBody PayOrderNotifyReqDTO notifyReqDTO) { - tradeOrderUpdateService.updateOrderPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), - notifyReqDTO.getPayOrderId()); - return success(true); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得交易订单") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult getOrder(@RequestParam("id") Long id) { - // 查询订单 - TradeOrderDO order = tradeOrderQueryService.getOrder(getLoginUserId(), id); - if (order == null) { - return success(null); - } - - // 查询订单项 - List orderItems = tradeOrderQueryService.getOrderItemListByOrderId(order.getId()); - // 查询物流公司 - DeliveryExpressDO express = order.getLogisticsId() != null && order.getLogisticsId() > 0 ? - deliveryExpressService.getDeliveryExpress(order.getLogisticsId()) : null; - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convert02(order, orderItems, tradeOrderProperties, express)); - } - - @GetMapping("/get-express-track-list") - @Operation(summary = "获得交易订单的物流轨迹") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult> getOrderExpressTrackList(@RequestParam("id") Long id) { - return success(TradeOrderConvert.INSTANCE.convertList02( - tradeOrderQueryService.getExpressTrackList(id, getLoginUserId()))); - } - - @GetMapping("/page") - @Operation(summary = "获得交易订单分页") - public CommonResult> getOrderPage(AppTradeOrderPageReqVO reqVO) { - // 查询订单 - PageResult pageResult = tradeOrderQueryService.getOrderPage(getLoginUserId(), reqVO); - // 查询订单项 - List orderItems = tradeOrderQueryService.getOrderItemListByOrderId( - convertSet(pageResult.getList(), TradeOrderDO::getId)); - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems)); - } - - @GetMapping("/get-count") - @Operation(summary = "获得交易订单数量") - public CommonResult> getOrderCount() { - Map orderCount = Maps.newLinkedHashMapWithExpectedSize(5); - // 全部 - orderCount.put("allCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), null, null)); - // 待付款(未支付) - orderCount.put("unpaidCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), - TradeOrderStatusEnum.UNPAID.getStatus(), null)); - // 待发货 - orderCount.put("undeliveredCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), - TradeOrderStatusEnum.UNDELIVERED.getStatus(), null)); - // 待收货 - orderCount.put("deliveredCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), - TradeOrderStatusEnum.DELIVERED.getStatus(), null)); - // 待评价 - orderCount.put("uncommentedCount", tradeOrderQueryService.getOrderCount(getLoginUserId(), - TradeOrderStatusEnum.COMPLETED.getStatus(), false)); - // 售后数量 - orderCount.put("afterSaleCount", afterSaleService.getApplyingAfterSaleCount(getLoginUserId())); - return success(orderCount); - } - - @PutMapping("/receive") - @Operation(summary = "确认交易订单收货") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult receiveOrder(@RequestParam("id") Long id) { - tradeOrderUpdateService.receiveOrderByMember(getLoginUserId(), id); - return success(true); - } - - @DeleteMapping("/cancel") - @Operation(summary = "取消交易订单") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult cancelOrder(@RequestParam("id") Long id) { - tradeOrderUpdateService.cancelOrderByMember(getLoginUserId(), id); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除交易订单") - @Parameter(name = "id", description = "交易订单编号") - public CommonResult deleteOrder(@RequestParam("id") Long id) { - tradeOrderUpdateService.deleteOrder(getLoginUserId(), id); - return success(true); - } - - // ========== 订单项 ========== - - @GetMapping("/item/get") - @Operation(summary = "获得交易订单项") - @Parameter(name = "id", description = "交易订单项编号") - public CommonResult getOrderItem(@RequestParam("id") Long id) { - TradeOrderItemDO item = tradeOrderQueryService.getOrderItem(getLoginUserId(), id); - return success(TradeOrderConvert.INSTANCE.convert03(item)); - } - - @PostMapping("/item/create-comment") - @Operation(summary = "创建交易订单项的评价") - public CommonResult createOrderItemComment(@RequestBody AppTradeOrderItemCommentCreateReqVO createReqVO) { - return success(tradeOrderUpdateService.createOrderItemCommentByMember(getLoginUserId(), createReqVO)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppOrderExpressTrackRespDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppOrderExpressTrackRespDTO.java deleted file mode 100644 index 2324c40bb..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppOrderExpressTrackRespDTO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 快递查询的轨迹 Resp DTO - * - * @author jason - */ -@Schema(description = "用户 App - 快递查询的轨迹 Response VO") -@Data -public class AppOrderExpressTrackRespDTO { - - @Schema(description = "发生时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime time; - - @Schema(description = "快递状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "已签收") - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateReqVO.java deleted file mode 100644 index 2f4503d02..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.AssertTrue; - -@Schema(description = "用户 App - 交易订单创建 Request VO") -@Data -public class AppTradeOrderCreateReqVO extends AppTradeOrderSettlementReqVO { - - @Schema(description = "备注", example = "这个是我的订单哟") - private String remark; - - @AssertTrue(message = "配送方式不能为空") - @JsonIgnore - public boolean isDeliveryTypeNotNull() { - return getDeliveryType() != null; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateRespVO.java deleted file mode 100644 index ae3f83194..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderCreateRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 App - 交易订单创建 Response VO") -@Data -public class AppTradeOrderCreateRespVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java deleted file mode 100644 index b91bbf1a6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderDetailRespVO.java +++ /dev/null @@ -1,151 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 订单交易的明细 Response VO") -@Data -public class AppTradeOrderDetailRespVO { - - // ========== 订单基本信息 ========== - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "订单类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer type; - - @Schema(description = "下单时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "用户备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - private String userRemark; - - @Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer productCount; - - @Schema(description = "订单完成时间") - private LocalDateTime finishTime; - - @Schema(description = "订单取消时间") - private LocalDateTime cancelTime; - - @Schema(description = "是否评价", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean commentStatus; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "是否已支付", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean payStatus; - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - - @Schema(description = "付款时间") - private LocalDateTime payTime; - - @Schema(description = "付款超时时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime payExpireTime; - - @Schema(description = "支付渠道", example = "wx_lite_pay") - private String payChannelCode; - @Schema(description = "支付渠道名", example = "微信小程序支付") - private String payChannelName; - - @Schema(description = "商品原价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer totalPrice; - - @Schema(description = "订单优惠(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer discountPrice; - - @Schema(description = "运费金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer deliveryPrice; - - @Schema(description = "订单调价(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer adjustPrice; - - @Schema(description = "应付金额(总)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - - @Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer deliveryType; - - @Schema(description = "发货物流公司编号", example = "10") - private Long logisticsId; - - @Schema(description = "发货物流名称", example = "顺丰快递") - private String logisticsName; - - @Schema(description = "发货物流单号", example = "1024") - private String logisticsNo; - - @Schema(description = "发货时间") - private LocalDateTime deliveryTime; - - @Schema(description = "收货时间") - private LocalDateTime receiveTime; - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - private String receiverName; - - @Schema(description = "收件人手机", requiredMode = Schema.RequiredMode.REQUIRED, example = "13800138000") - private String receiverMobile; - - @Schema(description = "收件人地区编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "110000") - private Integer receiverAreaId; - - @Schema(description = "收件人地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海 上海市 普陀区") - private String receiverAreaName; - - @Schema(description = "收件人详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "中关村大街 1 号") - private String receiverDetailAddress; - - @Schema(description = "自提门店编号", example = "1088") - private Long pickUpStoreId; - - @Schema(description = "自提核销码", example = "40964096") - private String pickUpVerifyCode; - - // ========== 售后基本信息 ========== - - @Schema(description = "售后状态", example = "0") - private Integer refundStatus; - - @Schema(description = "退款金额,单位:分", example = "100") - private Integer refundPrice; - - // ========== 营销基本信息 ========== - - @Schema(description = "优惠劵编号", example = "1024") - private Long couponId; - - @Schema(description = "优惠劵减免金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer couponPrice; - - @Schema(description = "积分抵扣的金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer pointPrice; - - @Schema(description = "VIP 减免金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - private Integer vipPrice; - - @Schema(description = "拼团记录编号", example = "100") - private Long combinationRecordId; - - /** - * 订单项数组 - */ - private List items; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java deleted file mode 100644 index ba7b8138c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageItemRespVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "用户 App - 订单交易的分页项 Response VO") -@Data -public class AppTradeOrderPageItemRespVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1146347329394184195") - private String no; - - @Schema(description = "订单类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer type; - - @Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer productCount; - - @Schema(description = "是否评价", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean commentStatus; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long payOrderId; - - @Schema(description = "应付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - - @Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer deliveryType; - - /** - * 订单项数组 - */ - private List items; - - // ========== 营销基本信息 ========== - - @Schema(description = "拼团记录编号", example = "100") - private Long combinationRecordId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageReqVO.java deleted file mode 100644 index c1e07c176..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderPageReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "交易订单分页 Request VO") -@Data -public class AppTradeOrderPageReqVO extends PageParam { - - @Schema(description = "订单状态", example = "1") - @InEnum(value = TradeOrderStatusEnum.class, message = "订单状态必须是 {value}") - private Integer status; - - @Schema(description = "是否评价", example = "true") - private Boolean commentStatus; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java deleted file mode 100644 index e8ed038ff..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementReqVO.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.common.validation.Mobile; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 交易订单结算 Request VO") -@Data -@Valid -public class AppTradeOrderSettlementReqVO { - - @Schema(description = "商品项数组", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "商品不能为空") - private List items; - - @Schema(description = "优惠劵编号", example = "1024") - private Long couponId; - - @Schema(description = "是否使用积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否使用积分不能为空") - private Boolean pointStatus; - - // ========== 配送相关相关字段 ========== - @Schema(description = "配送方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = DeliveryTypeEnum.class, message = "配送方式不正确") - private Integer deliveryType; - - @Schema(description = "收件地址编号", example = "1") - private Long addressId; - - @Schema(description = "自提门店编号", example = "1088") - private Long pickUpStoreId; - @Schema(description = "收件人名称", example = "芋艿") // 选择门店自提时,该字段为联系人名 - private String receiverName; - @Schema(description = "收件人手机", example = "15601691300") // 选择门店自提时,该字段为联系人手机 - @Mobile(message = "收件人手机格式不正确") - private String receiverMobile; - - // ========== 秒杀活动相关字段 ========== - @Schema(description = "秒杀活动编号", example = "1024") - private Long seckillActivityId; - - // ========== 拼团活动相关字段 ========== - @Schema(description = "拼团活动编号", example = "1024") - private Long combinationActivityId; - - @Schema(description = "拼团团长编号", example = "2048") - private Long combinationHeadId; - - // ========== 砍价活动相关字段 ========== - @Schema(description = "砍价记录编号", example = "123") - private Long bargainRecordId; - - @AssertTrue(message = "活动商品每次只能购买一种规格") - @JsonIgnore - public boolean isValidActivityItems() { - // 校验是否是活动订单 - if (ObjUtil.isAllEmpty(seckillActivityId, combinationActivityId, combinationHeadId, bargainRecordId)) { - return true; - } - // 校验订单项是否超出 - return items.size() == 1; - } - - @Data - @Schema(description = "用户 App - 商品项") - @Valid - public static class Item { - - @Schema(description = "商品 SKU 编号", example = "2048") - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - @Schema(description = "购买数量", example = "1") - @Min(value = 1, message = "购买数量最小值为 {value}") - private Integer count; - - @Schema(description = "购物车项的编号", example = "1024") - private Long cartId; - - @AssertTrue(message = "商品不正确") - @JsonIgnore - public boolean isValid() { - // 组合一:skuId + count 使用商品 SKU - if (skuId != null && count != null) { - return true; - } - // 组合二:cartId 使用购物车项 - return cartId != null; - } - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java deleted file mode 100644 index 0c851bf34..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderSettlementRespVO.java +++ /dev/null @@ -1,125 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "用户 App - 交易订单结算信息 Response VO") -@Data -public class AppTradeOrderSettlementRespVO { - - @Schema(description = "交易类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 对应 TradeOrderTypeEnum 枚举 - private Integer type; - - @Schema(description = "购物项数组", requiredMode = Schema.RequiredMode.REQUIRED) - private List items; - - @Schema(description = "费用", requiredMode = Schema.RequiredMode.REQUIRED) - private Price price; - - @Schema(description = "收件地址", requiredMode = Schema.RequiredMode.REQUIRED) - private Address address; - - @Schema(description = "已使用的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer usedPoint; - - @Schema(description = "总积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer totalPoint; - - @Schema(description = "购物项") - @Data - public static class Item { - - // ========== SPU 信息 ========== - - @Schema(description = "品类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long categoryId; - @Schema(description = "SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long spuId; - @Schema(description = "SPU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "Apple iPhone 12") - private String spuName; - - // ========== SKU 信息 ========== - - @Schema(description = "SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer skuId; - @Schema(description = "价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - @Schema(description = "图片地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "属性数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private List properties; - - // ========== 购物车信息 ========== - - @Schema(description = "购物车编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long cartId; - - @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - } - - @Schema(description = "费用(合计)") - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class Price { - - @Schema(description = "商品原价(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "500") - private Integer totalPrice; - - @Schema(description = "订单优惠(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") - private Integer discountPrice; - - @Schema(description = "运费金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer deliveryPrice; - - @Schema(description = "优惠劵减免金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer couponPrice; - - @Schema(description = "积分抵扣的金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer pointPrice; - - @Schema(description = "VIP 减免金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") - private Integer vipPrice; - - @Schema(description = "实际支付金额(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "450") - private Integer payPrice; - - } - - @Schema(description = "地址信息") - @Data - public static class Address { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小王") - private String name; - - @Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300") - private String mobile; - - @Schema(description = "地区编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "地区编号不能为空") - private Long areaId; - @Schema(description = "地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海上海市普陀区") - private String areaName; - - @Schema(description = "详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "望京悠乐汇 A 座") - private String detailAddress; - - @Schema(description = "是否默认收件地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean defaultStatus; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemCommentCreateReqVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemCommentCreateReqVO.java deleted file mode 100644 index a6a8b9582..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemCommentCreateReqVO.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo.item; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.List; - -@Schema(description = "用户 App - 商品评价创建 Request VO") -@Data -public class AppTradeOrderItemCommentCreateReqVO { - - @Schema(description = "是否匿名", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "是否匿名不能为空") - private Boolean anonymous; - - @Schema(description = "交易订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2312312") - @NotNull(message = "交易订单项编号不能为空") - private Long orderItemId; - - @Schema(description = "描述星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "描述星级 1-5 分不能为空") - private Integer descriptionScores; - - @Schema(description = "服务星级 1-5 分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - @NotNull(message = "服务星级 1-5 分不能为空") - private Integer benefitScores; - - @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "穿身上很漂亮诶(*^▽^*)") - @NotNull(message = "评论内容不能为空") - private String content; - - @Schema(description = "评论图片地址数组,以逗号分隔最多上传 9 张", requiredMode = Schema.RequiredMode.REQUIRED, example = "[https://www.iocoder.cn/xx.png]") - @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张") - private List picUrls; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemRespVO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemRespVO.java deleted file mode 100644 index 98d1820bc..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/item/AppTradeOrderItemRespVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.trade.controller.app.order.vo.item; - -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; - -@Schema(description = "用户 App - 订单交易项 Response VO") -@Data -public class AppTradeOrderItemRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderId; - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long spuId; - @Schema(description = "商品 SPU 名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String spuName; - - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long skuId; - - /** - * 属性数组 - */ - private List properties; - - @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String picUrl; - - @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer count; - - @Schema(description = "是否评价", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean commentStatus; - - // ========== 价格 + 支付基本信息 ========== - - @Schema(description = "商品原价(单)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer price; - - @Schema(description = "应付金额(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") - private Integer payPrice; - - // ========== 营销基本信息 ========== - - // TODO 芋艿:在捉摸一下 - - // ========== 售后基本信息 ========== - - @Schema(description = "售后编号", example = "1024") - private Long afterSaleId; - - @Schema(description = "售后状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer afterSaleStatus; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/package-info.java deleted file mode 100644 index aa2f99f35..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.trade.controller; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleConvert.java deleted file mode 100644 index fd759c625..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleConvert.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRespPageItemVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.log.AfterSaleLogRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderBaseVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -@Mapper -public interface AfterSaleConvert { - - AfterSaleConvert INSTANCE = Mappers.getMapper(AfterSaleConvert.class); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(target = "createTime", ignore = true), - @Mapping(target = "updateTime", ignore = true), - @Mapping(target = "creator", ignore = true), - @Mapping(target = "updater", ignore = true), - }) - AfterSaleDO convert(AppAfterSaleCreateReqVO createReqVO, TradeOrderItemDO tradeOrderItem); - - @Mappings({ - @Mapping(source = "afterSale.orderId", target = "merchantOrderId"), - @Mapping(source = "afterSale.id", target = "merchantRefundId"), - @Mapping(source = "afterSale.applyReason", target = "reason"), - @Mapping(source = "afterSale.refundPrice", target = "price") - }) - PayRefundCreateReqDTO convert(String userIp, AfterSaleDO afterSale, - TradeOrderProperties orderProperties); - - MemberUserRespVO convert(MemberUserRespDTO bean); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult pageResult, - Map memberUsers) { - PageResult voPageResult = convertPage(pageResult); - // 处理会员 - voPageResult.getList().forEach(afterSale -> afterSale.setUser( - convert(memberUsers.get(afterSale.getUserId())))); - return voPageResult; - } - - ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean); - - AppAfterSaleRespVO convert(AfterSaleDO bean); - - PageResult convertPage02(PageResult page); - - default AfterSaleDetailRespVO convert(AfterSaleDO afterSale, TradeOrderDO order, TradeOrderItemDO orderItem, - MemberUserRespDTO user, List logs) { - AfterSaleDetailRespVO respVO = convert02(afterSale); - // 处理用户信息 - respVO.setUser(convert(user)); - // 处理订单信息 - respVO.setOrder(convert(order)); - respVO.setOrderItem(convert02(orderItem)); - // 处理售后日志 - respVO.setLogs(convertList1(logs)); - return respVO; - } - - List convertList1(List list); - AfterSaleDetailRespVO convert02(AfterSaleDO bean); - AfterSaleDetailRespVO.OrderItem convert02(TradeOrderItemDO bean); - TradeOrderBaseVO convert(TradeOrderDO bean); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleLogConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleLogConvert.java deleted file mode 100644 index e8960c4ac..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/AfterSaleLogConvert.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.aftersale; - -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.service.aftersale.bo.AfterSaleLogCreateReqBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface AfterSaleLogConvert { - - AfterSaleLogConvert INSTANCE = Mappers.getMapper(AfterSaleLogConvert.class); - - AfterSaleLogDO convert(AfterSaleLogCreateReqBO bean); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java deleted file mode 100644 index 0f1fe6178..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.brokerage; - -import cn.hutool.core.math.Money; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import org.mapstruct.Mapper; -import org.mapstruct.MappingTarget; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * 佣金记录 Convert - * - * @author owen - */ -@Mapper -public interface BrokerageRecordConvert { - - BrokerageRecordConvert INSTANCE = Mappers.getMapper(BrokerageRecordConvert.class); - - BrokerageRecordRespVO convert(BrokerageRecordDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default BrokerageRecordDO convert(BrokerageUserDO user, BrokerageRecordBizTypeEnum bizType, String bizId, - Integer brokerageFrozenDays, int brokeragePrice, LocalDateTime unfreezeTime, - String title, Long sourceUserId, Integer sourceUserLevel) { - brokerageFrozenDays = ObjectUtil.defaultIfNull(brokerageFrozenDays, 0); - // 不冻结时,佣金直接就是结算状态 - Integer status = brokerageFrozenDays > 0 - ? BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus() - : BrokerageRecordStatusEnum.SETTLEMENT.getStatus(); - return new BrokerageRecordDO().setUserId(user.getId()) - .setBizType(bizType.getType()).setBizId(bizId) - .setPrice(brokeragePrice).setTotalPrice(user.getBrokeragePrice()) - .setTitle(title) - .setDescription(StrUtil.format(bizType.getDescription(), MoneyUtils.fenToYuanStr(Math.abs(brokeragePrice)))) - .setStatus(status).setFrozenDays(brokerageFrozenDays).setUnfreezeTime(unfreezeTime) - .setSourceUserLevel(sourceUserLevel).setSourceUserId(sourceUserId); - } - - default PageResult convertPage(PageResult pageResult, Map userMap) { - PageResult result = convertPage(pageResult); - for (BrokerageRecordRespVO respVO : result.getList()) { - Optional.ofNullable(userMap.get(respVO.getUserId())).ifPresent(user -> - respVO.setUserNickname(user.getNickname()).setUserAvatar(user.getAvatar())); - Optional.ofNullable(userMap.get(respVO.getSourceUserId())).ifPresent(user -> - respVO.setSourceUserNickname(user.getNickname()).setSourceUserAvatar(user.getAvatar())); - } - return result; - } - - BrokerageRecordPageReqVO convert(AppBrokerageRecordPageReqVO pageReqVO, Long userId); - - default PageResult convertPage03(PageResult pageResult, Map userMap) { - for (AppBrokerageUserRankByPriceRespVO vo : pageResult.getList()) { - copyTo(userMap.get(vo.getId()), vo); - } - return pageResult; - } - - void copyTo(MemberUserRespDTO from, @MappingTarget AppBrokerageUserRankByPriceRespVO to); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageUserConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageUserConvert.java deleted file mode 100644 index aa4ba348d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageUserConvert.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.brokerage; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserMySummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; -import org.mapstruct.Mapper; -import org.mapstruct.MappingTarget; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * 分销用户 Convert - * - * @author owen - */ -@Mapper -public interface BrokerageUserConvert { - - BrokerageUserConvert INSTANCE = Mappers.getMapper(BrokerageUserConvert.class); - - BrokerageUserRespVO convert(BrokerageUserDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page, Map userMap, Map brokerageUserCountMap, Map userOrderSummaryMap); - - default PageResult convertPage(PageResult pageResult, - Map userMap, - Map brokerageUserCountMap, - Map userOrderSummaryMap, - Map withdrawMap) { - PageResult result = convertPage(pageResult, userMap, brokerageUserCountMap, userOrderSummaryMap); - for (BrokerageUserRespVO userVO : result.getList()) { - // 用户信息 - copyTo(userMap.get(userVO.getId()), userVO); - // 推广用户数量 - userVO.setBrokerageUserCount(MapUtil.getInt(brokerageUserCountMap, userVO.getId(), 0)); - // 推广订单数量、推广订单金额 - Optional orderSummaryOptional = Optional.ofNullable(userOrderSummaryMap.get(userVO.getId())); - userVO.setBrokerageOrderCount(orderSummaryOptional.map(UserBrokerageSummaryRespBO::getCount).orElse(0)) - .setBrokerageOrderPrice(orderSummaryOptional.map(UserBrokerageSummaryRespBO::getPrice).orElse(0)); - // 已提现次数、已提现金额 - Optional withdrawSummaryOptional = Optional.ofNullable(withdrawMap.get(userVO.getId())); - userVO.setWithdrawCount(withdrawSummaryOptional.map(BrokerageWithdrawSummaryRespBO::getCount).orElse(0)) - .setWithdrawPrice(withdrawSummaryOptional.map(BrokerageWithdrawSummaryRespBO::getPrice).orElse(0)); - } - return result; - } - - default BrokerageUserRespVO copyTo(MemberUserRespDTO source, BrokerageUserRespVO target) { - Optional.ofNullable(source).ifPresent( - user -> target.setNickname(user.getNickname()).setAvatar(user.getAvatar())); - return target; - } - - default PageResult convertPage03(PageResult pageResult, - Map userMap) { - pageResult.getList().forEach(vo -> copyTo(userMap.get(vo.getId()), vo)); - return pageResult; - } - - void copyTo(MemberUserRespDTO from, @MappingTarget AppBrokerageUserRankByUserCountRespVO to); - - default AppBrokerageUserMySummaryRespVO convert(Integer yesterdayPrice, Integer withdrawPrice, - Long firstBrokerageUserCount, Long secondBrokerageUserCount, - BrokerageUserDO brokerageUser) { - AppBrokerageUserMySummaryRespVO respVO = new AppBrokerageUserMySummaryRespVO() - .setYesterdayPrice(ObjUtil.defaultIfNull(yesterdayPrice, 0)) - .setWithdrawPrice(ObjUtil.defaultIfNull(withdrawPrice, 0)) - .setBrokeragePrice(0).setFrozenPrice(0) - .setFirstBrokerageUserCount(ObjUtil.defaultIfNull(firstBrokerageUserCount, 0L)) - .setSecondBrokerageUserCount(ObjUtil.defaultIfNull(secondBrokerageUserCount, 0L)); - // 设置 brokeragePrice、frozenPrice 字段 - Optional.ofNullable(brokerageUser) - .ifPresent(user -> respVO.setBrokeragePrice(user.getBrokeragePrice()).setFrozenPrice(user.getFrozenPrice())); - return respVO; - } - - default void copyTo(List list, Map userMap) { - for (AppBrokerageUserChildSummaryRespVO vo : list) { - Optional.ofNullable(userMap.get(vo.getId())).ifPresent(user -> - vo.setNickname(user.getNickname()).setAvatar(user.getAvatar())); - } - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java deleted file mode 100644 index 4b818af25..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.enums.DictTypeConstants; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * 佣金提现 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BrokerageWithdrawConvert { - - BrokerageWithdrawConvert INSTANCE = Mappers.getMapper(BrokerageWithdrawConvert.class); - - BrokerageWithdrawDO convert(AppBrokerageWithdrawCreateReqVO createReqVO, Long userId, Integer feePrice); - - BrokerageWithdrawRespVO convert(BrokerageWithdrawDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult pageResult, Map userMap) { - PageResult result = convertPage(pageResult); - for (BrokerageWithdrawRespVO vo : result.getList()) { - vo.setUserNickname(Optional.ofNullable(userMap.get(vo.getUserId())).map(MemberUserRespDTO::getNickname).orElse(null)); - } - return result; - } - - PageResult convertPage02(PageResult pageResult); - - default PageResult convertPage03(PageResult pageResult) { - PageResult result = convertPage02(pageResult); - for (AppBrokerageWithdrawRespVO vo : result.getList()) { - vo.setStatusName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_WITHDRAW_STATUS, vo.getStatus())); - } - return result; - } - - BrokerageWithdrawPageReqVO convert(AppBrokerageWithdrawPageReqVO pageReqVO, Long userId); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/cart/TradeCartConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/cart/TradeCartConvert.java deleted file mode 100644 index 83cd45954..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/cart/TradeCartConvert.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.cart; - -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; -import cn.iocoder.yudao.module.trade.controller.app.base.sku.AppProductSkuBaseRespVO; -import cn.iocoder.yudao.module.trade.controller.app.base.spu.AppProductSpuBaseRespVO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.AppCartListRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -@Mapper -public interface TradeCartConvert { - - TradeCartConvert INSTANCE = Mappers.getMapper(TradeCartConvert.class); - - default AppCartListRespVO convertList(List carts, - List spus, List skus) { - Map spuMap = convertMap(spus, ProductSpuRespDTO::getId); - Map skuMap = convertMap(skus, ProductSkuRespDTO::getId); - // 遍历,开始转换 - List validList = new ArrayList<>(carts.size()); - List invalidList = new ArrayList<>(); - carts.forEach(cart -> { - AppCartListRespVO.Cart cartVO = new AppCartListRespVO.Cart(); - cartVO.setId(cart.getId()).setCount(cart.getCount()).setSelected(cart.getSelected()); - ProductSpuRespDTO spu = spuMap.get(cart.getSpuId()); - ProductSkuRespDTO sku = skuMap.get(cart.getSkuId()); - cartVO.setSpu(convert(spu)).setSku(convert(sku)); - // 如果 SPU 不存在,或者下架,或者库存不足,说明是无效的 - if (spu == null - || !ProductSpuStatusEnum.isEnable(spu.getStatus()) - || spu.getStock() <= 0) { - cartVO.setSelected(false); // 强制设置成不可选中 - invalidList.add(cartVO); - } else { - // 虽然 SKU 可能也会不存在,但是可以通过购物车重新选择 - validList.add(cartVO); - } - }); - return new AppCartListRespVO().setValidList(validList).setInvalidList(invalidList); - } - AppProductSpuBaseRespVO convert(ProductSpuRespDTO spu); - AppProductSkuBaseRespVO convert(ProductSkuRespDTO sku); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java deleted file mode 100644 index 57da020c2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.config; - -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; -import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 交易中心配置 Convert - * - * @author owen - */ -@Mapper -public interface TradeConfigConvert { - - TradeConfigConvert INSTANCE = Mappers.getMapper(TradeConfigConvert.class); - - TradeConfigDO convert(TradeConfigSaveReqVO bean); - - TradeConfigRespVO convert(TradeConfigDO bean); - - AppTradeConfigRespVO convert02(TradeConfigDO tradeConfig); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java deleted file mode 100644 index 3910dcaa3..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.*; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExcelVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.express.AppDeliveryExpressRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface DeliveryExpressConvert { - - DeliveryExpressConvert INSTANCE = Mappers.getMapper(DeliveryExpressConvert.class); - - DeliveryExpressDO convert(DeliveryExpressCreateReqVO bean); - - DeliveryExpressDO convert(DeliveryExpressUpdateReqVO bean); - - DeliveryExpressRespVO convert(DeliveryExpressDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - - List convertList1(List list); - - List convertList03(List list); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressTemplateConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressTemplateConvert.java deleted file mode 100644 index b917d874b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryExpressTemplateConvert.java +++ /dev/null @@ -1,93 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.*; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateFreeDO; -import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplateRespBO; -import com.google.common.collect.Maps; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; - -@Mapper -public interface DeliveryExpressTemplateConvert { - - DeliveryExpressTemplateConvert INSTANCE = Mappers.getMapper(DeliveryExpressTemplateConvert.class); - - // ========== Template ========== - - DeliveryExpressTemplateDO convert(DeliveryExpressTemplateCreateReqVO bean); - - DeliveryExpressTemplateDO convert(DeliveryExpressTemplateUpdateReqVO bean); - - DeliveryExpressTemplateRespVO convert(DeliveryExpressTemplateDO bean); - - DeliveryExpressTemplateDetailRespVO convert2(DeliveryExpressTemplateDO bean); - - List convertList(List list); - - List convertList1(List list); - - PageResult convertPage(PageResult page); - - default DeliveryExpressTemplateDetailRespVO convert(DeliveryExpressTemplateDO bean, - List chargeList, - List freeList) { - DeliveryExpressTemplateDetailRespVO respVO = convert2(bean); - respVO.setCharges(convertTemplateChargeList(chargeList)); - respVO.setFrees(convertTemplateFreeList(freeList)); - return respVO; - } - - // ========== Template Charge ========== - - DeliveryExpressTemplateChargeDO convertTemplateCharge(Long templateId, Integer chargeMode, DeliveryExpressTemplateChargeBaseVO vo); - - DeliveryExpressTemplateRespBO.Charge convertTemplateCharge(DeliveryExpressTemplateChargeDO bean); - - default List convertTemplateChargeList(Long templateId, Integer chargeMode, List list) { - return CollectionUtils.convertList(list, vo -> convertTemplateCharge(templateId, chargeMode, vo)); - } - - // ========== Template Free ========== - - DeliveryExpressTemplateFreeDO convertTemplateFree(Long templateId, DeliveryExpressTemplateFreeBaseVO vo); - - DeliveryExpressTemplateRespBO.Free convertTemplateFree(DeliveryExpressTemplateFreeDO bean); - - List convertTemplateChargeList(List list); - - List convertTemplateFreeList(List list); - - default List convertTemplateFreeList(Long templateId, List list) { - return CollectionUtils.convertList(list, vo -> convertTemplateFree(templateId, vo)); - } - - default Map convertMap(Integer areaId, List templateList, - List chargeList, - List freeList) { - Map> templateIdChargeMap = convertMultiMap(chargeList, - DeliveryExpressTemplateChargeDO::getTemplateId); - Map> templateIdFreeMap = convertMultiMap(freeList, - DeliveryExpressTemplateFreeDO::getTemplateId); - // 组合运费模板配置 RespBO - Map result = Maps.newHashMapWithExpectedSize(templateList.size()); - templateList.forEach(template -> { - DeliveryExpressTemplateRespBO bo = new DeliveryExpressTemplateRespBO() - .setChargeMode(template.getChargeMode()) - .setCharge(convertTemplateCharge(findFirst(templateIdChargeMap.get(template.getId()), charge -> charge.getAreaIds().contains(areaId)))) - .setFree(convertTemplateFree(findFirst(templateIdFreeMap.get(template.getId()), free -> free.getAreaIds().contains(areaId)))); - result.put(template.getId(), bo); - }); - return result; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java deleted file mode 100644 index 1d5b360a5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/delivery/DeliveryPickUpStoreConvert.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreSimpleRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.delivery.vo.pickup.AppDeliveryPickUpStoreRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface DeliveryPickUpStoreConvert { - - DeliveryPickUpStoreConvert INSTANCE = Mappers.getMapper(DeliveryPickUpStoreConvert.class); - - DeliveryPickUpStoreDO convert(DeliveryPickUpStoreCreateReqVO bean); - - DeliveryPickUpStoreDO convert(DeliveryPickUpStoreUpdateReqVO bean); - - DeliveryPickUpStoreRespVO convert(DeliveryPickUpStoreDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList1(List list); - @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") - DeliveryPickUpStoreSimpleRespVO convert02(DeliveryPickUpStoreDO bean); - - @Named("convertAreaIdToAreaName") - default String convertAreaIdToAreaName(Integer areaId) { - return AreaUtils.format(areaId); - } - - default List convertList(List list, - Double latitude, Double longitude) { - List voList = CollectionUtils.convertList(list, store -> { - AppDeliveryPickUpStoreRespVO storeVO = convert03(store); - if (latitude != null && longitude != null) { - storeVO.setDistance(NumberUtils.getDistance(latitude, longitude, storeVO.getLatitude(), storeVO.getLongitude())); - } - return storeVO; - }); - return voList; - } - @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName") - AppDeliveryPickUpStoreRespVO convert03(DeliveryPickUpStoreDO bean); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java deleted file mode 100644 index 64f74c99f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java +++ /dev/null @@ -1,288 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.order; - -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.enums.DictTypeConstants; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*; -import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.*; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageAddReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; - -@Mapper -public interface TradeOrderConvert { - - TradeOrderConvert INSTANCE = Mappers.getMapper(TradeOrderConvert.class); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "userId", target = "userId"), - @Mapping(source = "createReqVO.couponId", target = "couponId"), - @Mapping(target = "remark", ignore = true), - @Mapping(source = "createReqVO.remark", target = "userRemark"), - @Mapping(source = "calculateRespBO.price.totalPrice", target = "totalPrice"), - @Mapping(source = "calculateRespBO.price.discountPrice", target = "discountPrice"), - @Mapping(source = "calculateRespBO.price.deliveryPrice", target = "deliveryPrice"), - @Mapping(source = "calculateRespBO.price.couponPrice", target = "couponPrice"), - @Mapping(source = "calculateRespBO.price.pointPrice", target = "pointPrice"), - @Mapping(source = "calculateRespBO.price.vipPrice", target = "vipPrice"), - @Mapping(source = "calculateRespBO.price.payPrice", target = "payPrice") - }) - TradeOrderDO convert(Long userId, AppTradeOrderCreateReqVO createReqVO, TradePriceCalculateRespBO calculateRespBO); - - TradeOrderRespDTO convert(TradeOrderDO orderDO); - - default List convertList(TradeOrderDO tradeOrderDO, TradePriceCalculateRespBO calculateRespBO) { - return CollectionUtils.convertList(calculateRespBO.getItems(), item -> { - TradeOrderItemDO orderItem = convert(item); - orderItem.setOrderId(tradeOrderDO.getId()); - orderItem.setUserId(tradeOrderDO.getUserId()); - orderItem.setAfterSaleStatus(TradeOrderItemAfterSaleStatusEnum.NONE.getStatus()); - orderItem.setCommentStatus(false); - return orderItem; - }); - } - - TradeOrderItemDO convert(TradePriceCalculateRespBO.OrderItem item); - - default ProductSkuUpdateStockReqDTO convert(List list) { - List items = CollectionUtils.convertList(list, item -> - new ProductSkuUpdateStockReqDTO.Item().setId(item.getSkuId()).setIncrCount(item.getCount())); - return new ProductSkuUpdateStockReqDTO(items); - } - - default ProductSkuUpdateStockReqDTO convertNegative(List list) { - List items = CollectionUtils.convertList(list, item -> - new ProductSkuUpdateStockReqDTO.Item().setId(item.getSkuId()).setIncrCount(-item.getCount())); - return new ProductSkuUpdateStockReqDTO(items); - } - - default PayOrderCreateReqDTO convert(TradeOrderDO order, List orderItems, - TradeOrderProperties orderProperties) { - PayOrderCreateReqDTO createReqDTO = new PayOrderCreateReqDTO() - .setAppId(orderProperties.getAppId()).setUserIp(order.getUserIp()); - // 商户相关字段 - createReqDTO.setMerchantOrderId(String.valueOf(order.getId())); - String subject = orderItems.get(0).getSpuName(); - subject = StrUtils.maxLength(subject, PayOrderCreateReqDTO.SUBJECT_MAX_LENGTH); // 避免超过 32 位 - createReqDTO.setSubject(subject); - createReqDTO.setBody(subject); // TODO 芋艿:临时写死 - // 订单相关字段 - createReqDTO.setPrice(order.getPayPrice()).setExpireTime(addTime(orderProperties.getPayExpireTime())); - return createReqDTO; - } - - default PageResult convertPage(PageResult pageResult, - List orderItems, - Map memberUserMap) { - Map> orderItemMap = convertMultiMap(orderItems, TradeOrderItemDO::getOrderId); - // 转化 List - List orderVOs = CollectionUtils.convertList(pageResult.getList(), order -> { - List xOrderItems = orderItemMap.get(order.getId()); - TradeOrderPageItemRespVO orderVO = convert(order, xOrderItems); - // 处理收货地址 - orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); - // 增加用户信息 - orderVO.setUser(convertUser(memberUserMap.get(orderVO.getUserId()))); - // 增加推广人信息 - orderVO.setBrokerageUser(convertUser(memberUserMap.get(orderVO.getBrokerageUserId()))); - return orderVO; - }); - return new PageResult<>(orderVOs, pageResult.getTotal()); - } - - MemberUserRespVO convertUser(MemberUserRespDTO memberUserRespDTO); - - TradeOrderPageItemRespVO convert(TradeOrderDO order, List items); - - ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean); - - default TradeOrderDetailRespVO convert(TradeOrderDO order, List orderItems, - List orderLogs, - MemberUserRespDTO user, MemberUserRespDTO brokerageUser) { - TradeOrderDetailRespVO orderVO = convert2(order, orderItems); - // 处理收货地址 - orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); - // 处理用户信息 - orderVO.setUser(convert(user)); - orderVO.setBrokerageUser(convert(brokerageUser)); - // 处理日志 - orderVO.setLogs(convertList03(orderLogs)); - return orderVO; - } - List convertList03(List orderLogs); - - TradeOrderDetailRespVO convert2(TradeOrderDO order, List items); - - MemberUserRespVO convert(MemberUserRespDTO bean); - - default PageResult convertPage02(PageResult pageResult, - List orderItems) { - Map> orderItemMap = convertMultiMap(orderItems, TradeOrderItemDO::getOrderId); - // 转化 List - List orderVOs = CollectionUtils.convertList(pageResult.getList(), order -> { - List xOrderItems = orderItemMap.get(order.getId()); - return convert02(order, xOrderItems); - }); - return new PageResult<>(orderVOs, pageResult.getTotal()); - } - - AppTradeOrderPageItemRespVO convert02(TradeOrderDO order, List items); - - AppProductPropertyValueDetailRespVO convert02(ProductPropertyValueDetailRespDTO bean); - - default AppTradeOrderDetailRespVO convert02(TradeOrderDO order, List orderItems, - TradeOrderProperties tradeOrderProperties, - DeliveryExpressDO express) { - AppTradeOrderDetailRespVO orderVO = convert3(order, orderItems); - orderVO.setPayExpireTime(addTime(tradeOrderProperties.getPayExpireTime())); - if (StrUtil.isNotEmpty(order.getPayChannelCode())) { - orderVO.setPayChannelName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.CHANNEL_CODE, order.getPayChannelCode())); - } - // 处理收货地址 - orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); - if (express != null) { - orderVO.setLogisticsId(express.getId()).setLogisticsName(express.getName()); - } - return orderVO; - } - - AppTradeOrderDetailRespVO convert3(TradeOrderDO order, List items); - - AppTradeOrderItemRespVO convert03(TradeOrderItemDO bean); - - @Mappings({ - @Mapping(target = "skuId", source = "tradeOrderItemDO.skuId"), - @Mapping(target = "orderId", source = "tradeOrderItemDO.orderId"), - @Mapping(target = "orderItemId", source = "tradeOrderItemDO.id"), - @Mapping(target = "descriptionScores", source = "createReqVO.descriptionScores"), - @Mapping(target = "benefitScores", source = "createReqVO.benefitScores"), - @Mapping(target = "content", source = "createReqVO.content"), - @Mapping(target = "picUrls", source = "createReqVO.picUrls"), - @Mapping(target = "anonymous", source = "createReqVO.anonymous"), - @Mapping(target = "userId", source = "tradeOrderItemDO.userId") - }) - ProductCommentCreateReqDTO convert04(AppTradeOrderItemCommentCreateReqVO createReqVO, TradeOrderItemDO tradeOrderItemDO); - - TradePriceCalculateReqBO convert(AppTradeOrderSettlementReqVO settlementReqVO); - - default TradePriceCalculateReqBO convert(Long userId, AppTradeOrderSettlementReqVO settlementReqVO, - List cartList) { - TradePriceCalculateReqBO reqBO = new TradePriceCalculateReqBO().setUserId(userId) - .setItems(new ArrayList<>(settlementReqVO.getItems().size())) - .setCouponId(settlementReqVO.getCouponId()).setPointStatus(settlementReqVO.getPointStatus()) - // 物流信息 - .setDeliveryType(settlementReqVO.getDeliveryType()).setAddressId(settlementReqVO.getAddressId()) - .setPickUpStoreId(settlementReqVO.getPickUpStoreId()) - // 各种活动 - .setSeckillActivityId(settlementReqVO.getSeckillActivityId()) - .setBargainRecordId(settlementReqVO.getBargainRecordId()) - .setCombinationActivityId(settlementReqVO.getCombinationActivityId()) - .setCombinationHeadId(settlementReqVO.getCombinationHeadId()); - // 商品项的构建 - Map cartMap = convertMap(cartList, CartDO::getId); - for (AppTradeOrderSettlementReqVO.Item item : settlementReqVO.getItems()) { - // 情况一:skuId + count - if (item.getSkuId() != null) { - reqBO.getItems().add(new TradePriceCalculateReqBO.Item().setSkuId(item.getSkuId()).setCount(item.getCount()) - .setSelected(true)); // true 的原因,下单一定选中 - continue; - } - // 情况二:cartId - CartDO cart = cartMap.get(item.getCartId()); - if (cart == null) { - continue; - } - reqBO.getItems().add(new TradePriceCalculateReqBO.Item().setSkuId(cart.getSkuId()).setCount(cart.getCount()) - .setCartId(item.getCartId()).setSelected(true)); // true 的原因,下单一定选中 - } - return reqBO; - } - - default AppTradeOrderSettlementRespVO convert(TradePriceCalculateRespBO calculate, MemberAddressRespDTO address) { - AppTradeOrderSettlementRespVO respVO = convert0(calculate, address); - if (address != null) { - respVO.getAddress().setAreaName(AreaUtils.format(address.getAreaId())); - } - return respVO; - } - - AppTradeOrderSettlementRespVO convert0(TradePriceCalculateRespBO calculate, MemberAddressRespDTO address); - - List convertList02(List list); - - TradeOrderDO convert(TradeOrderUpdateAddressReqVO reqVO); - - TradeOrderDO convert(TradeOrderUpdatePriceReqVO reqVO); - - TradeOrderDO convert(TradeOrderRemarkReqVO reqVO); - - default BrokerageAddReqBO convert(MemberUserRespDTO user, TradeOrderItemDO item, - ProductSpuRespDTO spu, ProductSkuRespDTO sku) { - BrokerageAddReqBO bo = new BrokerageAddReqBO().setBizId(String.valueOf(item.getId())).setSourceUserId(item.getUserId()) - .setBasePrice(item.getPayPrice() * item.getCount()) - .setTitle(StrUtil.format("{}成功购买{}", user.getNickname(), item.getSpuName())) - .setFirstFixedPrice(0).setSecondFixedPrice(0); - if (BooleanUtil.isTrue(spu.getSubCommissionType())) { - bo.setFirstFixedPrice(sku.getFirstBrokeragePrice()).setSecondFixedPrice(sku.getSecondBrokeragePrice()); - } - return bo; - } - - @Named("convertList04") - List convertList04(List list); - - @Mappings({ - @Mapping(target = "activityId", source = "order.combinationActivityId"), - @Mapping(target = "spuId", source = "item.spuId"), - @Mapping(target = "skuId", source = "item.skuId"), - @Mapping(target = "count", source = "item.count"), - @Mapping(target = "orderId", source = "order.id"), - @Mapping(target = "userId", source = "order.userId"), - @Mapping(target = "headId", source = "order.combinationHeadId"), - @Mapping(target = "combinationPrice", source = "item.payPrice"), - }) - CombinationRecordCreateReqDTO convert(TradeOrderDO order, TradeOrderItemDO item); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderLogConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderLogConvert.java deleted file mode 100644 index 763f05822..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderLogConvert.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.trade.convert.order; - -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeOrderLogCreateReqBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface TradeOrderLogConvert { - - TradeOrderLogConvert INSTANCE = Mappers.getMapper(TradeOrderLogConvert.class); - - TradeOrderLogDO convert(TradeOrderLogCreateReqBO bean); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleDO.java deleted file mode 100644 index 214592b62..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleDO.java +++ /dev/null @@ -1,201 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.aftersale; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleWayEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 售后订单,用于处理 {@link TradeOrderDO} 交易订单的退款退货流程 - * - * @author 芋道源码 - */ -@TableName(value = "trade_after_sale", autoResultMap = true) -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class AfterSaleDO extends BaseDO { - - /** - * 售后编号,主键自增 - */ - private Long id; - /** - * 售后单号 - * - * 例如说,1146347329394184195 - */ - private String no; - /** - * 退款状态 - * - * 枚举 {@link AfterSaleStatusEnum} - */ - private Integer status; - /** - * 售后方式 - * - * 枚举 {@link AfterSaleWayEnum} - */ - private Integer way; - /** - * 售后类型 - * - * 枚举 {@link AfterSaleTypeEnum} - */ - private Integer type; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 申请原因 - * - * type = 退款,对应 trade_after_sale_refund_reason 类型 - * type = 退货退款,对应 trade_after_sale_refund_and_return_reason 类型 - */ - private String applyReason; - /** - * 补充描述 - */ - private String applyDescription; - /** - * 补充凭证图片 - * - * 数组,以逗号分隔 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List applyPicUrls; - - // ========== 交易订单相关 ========== - /** - * 交易订单编号 - * - * 关联 {@link TradeOrderDO#getId()} - */ - private Long orderId; - /** - * 订单流水号 - * - * 冗余 {@link TradeOrderDO#getNo()} - */ - private String orderNo; - /** - * 交易订单项编号 - * - * 关联 {@link TradeOrderItemDO#getId()} - */ - private Long orderItemId; - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id 字段 - * 冗余 {@link TradeOrderItemDO#getSpuId()} - */ - private Long spuId; - /** - * 商品 SPU 名称 - * - * 关联 ProductSkuDO 的 name 字段 - * 冗余 {@link TradeOrderItemDO#getSpuName()} - */ - private String spuName; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的编号 - */ - private Long skuId; - /** - * 属性数组,JSON 格式 - * - * 冗余 {@link TradeOrderItemDO#getProperties()} - */ - @TableField(typeHandler = TradeOrderItemDO.PropertyTypeHandler.class) - private List properties; - /** - * 商品图片 - * - * 冗余 {@link TradeOrderItemDO#getPicUrl()} - */ - private String picUrl; - /** - * 退货商品数量 - */ - private Integer count; - - // ========== 审批相关 ========== - - /** - * 审批时间 - */ - private LocalDateTime auditTime; - /** - * 审批人 - * - * 关联 AdminUserDO 的 id 编号 - */ - private Long auditUserId; - /** - * 审批备注 - * - * 注意,只有审批不通过才会填写 - */ - private String auditReason; - - // ========== 退款相关 ========== - /** - * 退款金额,单位:分。 - */ - private Integer refundPrice; - /** - * 支付退款编号 - * - * 对接 pay-module-biz 支付服务的退款订单编号,即 PayRefundDO 的 id 编号 - */ - private Long payRefundId; - /** - * 退款时间 - */ - private LocalDateTime refundTime; - - // ========== 退货相关 ========== - /** - * 退货物流公司编号 - * - * 关联 LogisticsDO 的 id 编号 - */ - private Long logisticsId; - /** - * 退货物流单号 - */ - private String logisticsNo; - /** - * 退货时间 - */ - private LocalDateTime deliveryTime; - /** - * 收货时间 - */ - private LocalDateTime receiveTime; - /** - * 收货备注 - * - * 注意,只有拒绝收货才会填写 - */ - private String receiveReason; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleLogDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleLogDO.java deleted file mode 100644 index 2820f23e1..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleLogDO.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.aftersale; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 交易售后日志 DO - * - * @author 芋道源码 - */ -@TableName("trade_after_sale_log") -@KeySequence("trade_after_sale_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class AfterSaleLogDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 1:AdminUserDO 的 id 字段 - * 关联 2:MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 用户类型 - * - * 枚举 {@link UserTypeEnum} - */ - private Integer userType; - - /** - * 售后编号 - * - * 关联 {@link AfterSaleDO#getId()} - */ - private Long afterSaleId; - /** - * 操作前状态 - */ - private Integer beforeStatus; - /** - * 操作后状态 - */ - private Integer afterStatus; - - /** - * 操作类型 - * - * 枚举 {@link AfterSaleOperateTypeEnum} - */ - private Integer operateType; - /** - * 操作明细 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageRecordDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageRecordDO.java deleted file mode 100644 index c819d723b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageRecordDO.java +++ /dev/null @@ -1,97 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 佣金记录 DO - * - * @author owen - */ -@TableName("trade_brokerage_record") -@KeySequence("trade_brokerage_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageRecordDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Integer id; - /** - * 用户编号 - *

- * 关联 MemberUserDO.id - */ - private Long userId; - /** - * 业务编号 - */ - private String bizId; - /** - * 业务类型 - *

- * 枚举 {@link BrokerageRecordBizTypeEnum} - */ - private Integer bizType; - - /** - * 标题 - */ - private String title; - /** - * 说明 - */ - private String description; - - /** - * 金额 - */ - private Integer price; - /** - * 当前总佣金 - */ - private Integer totalPrice; - - /** - * 状态 - *

- * 枚举 {@link BrokerageRecordStatusEnum} - */ - private Integer status; - - /** - * 冻结时间(天) - */ - private Integer frozenDays; - /** - * 解冻时间 - */ - private LocalDateTime unfreezeTime; - - /** - * 来源用户等级 - *

- * 被推广用户和 {@link #userId} 的推广层级关系 - */ - private Integer sourceUserLevel; - /** - * 来源用户编号 - *

- * 关联 MemberUserDO.id 字段,被推广用户的编号 - */ - private Long sourceUserId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java deleted file mode 100644 index 8d73858ec..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 分销用户 DO - * - * @author owen - */ -@TableName("trade_brokerage_user") -@KeySequence("trade_brokerage_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageUserDO extends BaseDO { - - /** - * 用户编号 - *

- * 对应 MemberUserDO 的 id 字段 - */ - @TableId - private Long id; - - /** - * 推广员编号 - *

- * 关联 MemberUserDO 的 id 字段 - */ - private Long bindUserId; - /** - * 推广员绑定时间 - */ - private LocalDateTime bindUserTime; - - /** - * 是否有分销资格 - */ - private Boolean brokerageEnabled; - /** - * 成为分销员时间 - */ - private LocalDateTime brokerageTime; - - /** - * 可用佣金 - */ - private Integer brokeragePrice; - /** - * 冻结佣金 - */ - private Integer frozenPrice; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java deleted file mode 100644 index f31c23800..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageWithdrawDO.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 佣金提现 DO - * - * @author 芋道源码 - */ -@TableName("trade_brokerage_withdraw") -@KeySequence("trade_brokerage_withdraw_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageWithdrawDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 字段 - */ - private Long userId; - - /** - * 提现金额,单位:分 - */ - private Integer price; - /** - * 提现手续费,单位:分 - */ - private Integer feePrice; - /** - * 当前总佣金,单位:分 - */ - private Integer totalPrice; - /** - * 提现类型 - *

- * 枚举 {@link BrokerageWithdrawTypeEnum} - */ - private Integer type; - - /** - * 真实姓名 - */ - private String name; - /** - * 账号 - */ - private String accountNo; - /** - * 银行名称 - */ - private String bankName; - /** - * 开户地址 - */ - private String bankAddress; - /** - * 收款码 - */ - private String accountQrCodeUrl; - /** - * 状态 - *

- * 枚举 {@link BrokerageWithdrawStatusEnum} - */ - private Integer status; - /** - * 审核驳回原因 - */ - private String auditReason; - /** - * 审核时间 - */ - private LocalDateTime auditTime; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/cart/CartDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/cart/CartDO.java deleted file mode 100644 index d8bf14088..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/cart/CartDO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.cart; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -/** - * 购物车的商品信息 DO - * - * 每个商品,对应一条记录,通过 {@link #spuId} 和 {@link #skuId} 关联 - * - * @author 芋道源码 - */ -@TableName("trade_cart") -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class CartDO extends BaseDO { - - // ========= 基础字段 BEGIN ========= - - /** - * 编号,唯一自增 - */ - private Long id; - - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - - // ========= 商品信息 ========= - - /** - * 商品 SPU 编号 - * - * 关联 ProductSpuDO 的 id 编号 - */ - private Long spuId; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的 id 编号 - */ - private Long skuId; - /** - * 商品购买数量 - */ - private Integer count; - /** - * 是否选中 - */ - private Boolean selected; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java deleted file mode 100644 index 5d7116b9d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/config/TradeConfigDO.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.config; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.List; - -/** - * 交易中心配置 DO - * - * @author owen - */ -@TableName(value = "trade_config", autoResultMap = true) -@KeySequence("trade_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeConfigDO extends BaseDO { - - /** - * 自增主键 - */ - @TableId - private Long id; - - // ========== 售后相关 ========== - - /** - * 售后的退款理由 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List afterSaleRefundReasons; - /** - * 售后的退货理由 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List afterSaleReturnReasons; - - // ========== 配送相关 ========== - - /** - * 是否启用全场包邮 - */ - private Boolean deliveryExpressFreeEnabled; - /** - * 全场包邮的最小金额,单位:分 - */ - private Integer deliveryExpressFreePrice; - - /** - * 是否开启自提 - */ - private Boolean deliveryPickUpEnabled; - - // ========== 分销相关 ========== - - /** - * 是否启用分佣 - */ - private Boolean brokerageEnabled; - /** - * 分佣模式 - *

- * 枚举 {@link BrokerageEnabledConditionEnum 对应的类} - */ - private Integer brokerageEnabledCondition; - /** - * 分销关系绑定模式 - *

- * 枚举 {@link BrokerageBindModeEnum 对应的类} - */ - private Integer brokerageBindMode; - /** - * 分销海报图地址数组 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private List brokeragePosterUrls; - /** - * 一级返佣比例 - */ - private Integer brokerageFirstPercent; - /** - * 二级返佣比例 - */ - private Integer brokerageSecondPercent; - /** - * 用户提现最低金额 - */ - private Integer brokerageWithdrawMinPrice; - /** - * 用户提现手续费百分比 - */ - private Integer brokerageWithdrawFeePercent; - /** - * 佣金冻结时间(天) - */ - private Integer brokerageFrozenDays; - /** - * 提现方式 - *

- * 枚举 {@link BrokerageWithdrawTypeEnum 对应的类} - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List brokerageWithdrawTypes; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressDO.java deleted file mode 100644 index 265066d83..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressDO.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -/** - * 快递公司 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_express") -@KeySequence("trade_delivery_express_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryExpressDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 快递公司 code - */ - private String code; - - /** - * 快递公司名称 - */ - private String name; - - /** - * 快递公司 logo - */ - private String logo; - - /** - * 排序 - */ - private Integer sort; - - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - - // TODO 芋艿:c 和结算相关的字段,后续在看 - // partnerId 是否需要月结账号 - // partnerKey 是否需要月结密码 - // net 是否需要取件网店 - // account 账号 - // password 网点名称 - // isShow 是否显示 -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java deleted file mode 100644 index c3bb30e9a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateChargeDO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.util.List; - -/** - * 快递运费模板计费配置 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_express_template_charge", autoResultMap = true) -@KeySequence("trade_delivery_express_template_charge_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryExpressTemplateChargeDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 配送模板编号 - * - * 关联 {@link DeliveryExpressTemplateDO#getId()} - */ - private Long templateId; - - /** - * 配送区域编号列表 - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List areaIds; - - /** - * 配送计费方式 - * - * 冗余 {@link DeliveryExpressTemplateDO#getChargeMode()} - */ - private Integer chargeMode; - - /** - * 首件数量(件数,重量,或体积) - */ - private Double startCount; - /** - * 起步价,单位:分 - */ - private Integer startPrice; - - /** - * 续件数量(件, 重量,或体积) - */ - private Double extraCount; - /** - * 额外价,单位:分 - */ - private Integer extraPrice; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateDO.java deleted file mode 100644 index b6d6db3b7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateDO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryExpressChargeModeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 快递运费模板 DO - * - * @author jason - */ -@TableName("trade_delivery_express_template") -@KeySequence("trade_delivery_express_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryExpressTemplateDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 模板名称 - */ - private String name; - - /** - * 配送计费方式 - * - * 枚举 {@link DeliveryExpressChargeModeEnum} - */ - private Integer chargeMode; - - /** - * 排序 - */ - private Integer sort; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java deleted file mode 100644 index 07eef1be2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryExpressTemplateFreeDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.IntegerListTypeHandler; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.util.List; - -/** - * 快递运费模板包邮配置 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_express_template_free", autoResultMap = true) -@KeySequence("trade_delivery_express_template_free_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryExpressTemplateFreeDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 配送模板编号 - * - * 关联 {@link DeliveryExpressTemplateDO#getId()} - */ - private Long templateId; - - - /** - * 配送区域编号列表 - */ - @TableField(typeHandler = IntegerListTypeHandler.class) - private List areaIds; - - /** - * 包邮金额,单位:分 - * - * 订单总金额 > 包邮金额时,才免运费 - */ - private Integer freePrice; - - /** - * 包邮件数 - * - * 订单总件数 > 包邮件数时,才免运费 - */ - private Integer freeCount; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java deleted file mode 100644 index 21ff99374..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreDO.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.time.LocalTime; - -/** - * 自提门店 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_pick_up_store") -@KeySequence("trade_delivery_pick_up_store_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryPickUpStoreDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 门店名称 - */ - private String name; - - /** - * 门店简介 - */ - private String introduction; - - /** - * 门店手机 - */ - private String phone; - - /** - * 区域编号 - */ - private Integer areaId; - - /** - * 门店详细地址 - */ - private String detailAddress; - - /** - * 门店 logo - */ - private String logo; - - /** - * 营业开始时间 - */ - private LocalTime openingTime; - - /** - * 营业结束时间 - */ - private LocalTime closingTime; - - /** - * 纬度 - */ - private Double latitude; - /** - * 经度 - */ - private Double longitude; - - /** - * 门店状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java deleted file mode 100644 index 4c03a8e5d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/delivery/DeliveryPickUpStoreStaffDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -// TODO @芋艿:后续再详细 review 一轮 -// TODO @芋艿:可能改成 DeliveryPickUpStoreUserDO -/** - * 自提门店店员 DO - * - * @author jason - */ -@TableName(value ="trade_delivery_pick_up_store_staff") -@KeySequence("trade_delivery_pick_up_store_staff_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class DeliveryPickUpStoreStaffDO extends BaseDO { - - /** - * 编号,自增 - */ - @TableId - private Long id; - - /** - * 自提门店编号 - * - * 关联 {@link DeliveryPickUpStoreDO#getId()} - */ - private Long storeId; - - /** - * 管理员用户id - * - * 关联 {AdminUserDO#getId()} - */ - private Long adminUserId; - - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java deleted file mode 100644 index b127004aa..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderDO.java +++ /dev/null @@ -1,333 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.order; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderCancelTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderRefundStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 交易订单 DO - * - * @author 芋道源码 - */ -@TableName("trade_order") -@KeySequence("trade_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeOrderDO extends BaseDO { - - /** - * 发货物流公司编号 - 空(无需发货) - */ - public static final Long LOGISTICS_ID_NULL = 0L; - - // ========== 订单基本信息 ========== - /** - * 订单编号,主键自增 - */ - private Long id; - /** - * 订单流水号 - * - * 例如说,1146347329394184195 - */ - private String no; - /** - * 订单类型 - * - * 枚举 {@link TradeOrderTypeEnum} - */ - private Integer type; - /** - * 订单来源 - * - * 枚举 {@link TerminalEnum} - */ - private Integer terminal; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 用户 IP - */ - private String userIp; - /** - * 用户备注 - */ - private String userRemark; - /** - * 订单状态 - * - * 枚举 {@link TradeOrderStatusEnum} - */ - private Integer status; - /** - * 购买的商品数量 - */ - private Integer productCount; - /** - * 订单完成时间 - */ - private LocalDateTime finishTime; - /** - * 订单取消时间 - */ - private LocalDateTime cancelTime; - /** - * 取消类型 - * - * 枚举 {@link TradeOrderCancelTypeEnum} - */ - private Integer cancelType; - /** - * 商家备注 - */ - private String remark; - /** - * 是否评价 - * - * true - 已评价 - * false - 未评价 - */ - private Boolean commentStatus; - - /** - * 推广人编号 - * - * 关联 {@link BrokerageUserDO#getId()} 字段,即 {@link MemberUserRespDTO#getId()} 字段 - */ - private Long brokerageUserId; - - // ========== 价格 + 支付基本信息 ========== - - // 价格文档 - 淘宝:https://open.taobao.com/docV3.htm?docId=108471&docType=1 - // 价格文档 - 京东到家:https://openo2o.jddj.com/api/getApiDetail/182/4d1494c5e7ac4679bfdaaed950c5bc7f.htm - // 价格文档 - 有赞:https://doc.youzanyun.com/detail/API/0/906 - - /** - * 支付订单编号 - * - * 对接 pay-module-biz 支付服务的支付订单编号,即 PayOrderDO 的 id 编号 - */ - private Long payOrderId; - /** - * 是否已支付 - * - * true - 已经支付过 - * false - 没有支付过 - */ - private Boolean payStatus; - /** - * 付款时间 - */ - private LocalDateTime payTime; - /** - * 支付渠道 - * - * 对应 PayChannelEnum 枚举 - */ - private String payChannelCode; - - /** - * 商品原价,单位:分 - * - * totalPrice = {@link TradeOrderItemDO#getPrice()} * {@link TradeOrderItemDO#getCount()} 求和 - * - * 对应 taobao 的 trade.total_fee 字段 - */ - private Integer totalPrice; - /** - * 优惠金额,单位:分 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 运费金额,单位:分 - */ - private Integer deliveryPrice; - /** - * 订单调价,单位:分 - * - * 正数,加价;负数,减价 - */ - private Integer adjustPrice; - /** - * 应付金额(总),单位:分 - * - * = {@link #totalPrice} - * - {@link #couponPrice} - * - {@link #pointPrice} - * - {@link #discountPrice} - * + {@link #deliveryPrice} - * + {@link #adjustPrice} - * - {@link #vipPrice} - */ - private Integer payPrice; - - // ========== 收件 + 物流基本信息 ========== - /** - * 配送方式 - * - * 枚举 {@link DeliveryTypeEnum} - */ - private Integer deliveryType; - /** - * 发货物流公司编号 - * - * 如果无需发货,则 logisticsId 设置为 0。原因是,不想再添加额外字段 - * - * 关联 {@link DeliveryExpressDO#getId()} - */ - private Long logisticsId; - /** - * 发货物流单号 - * - * 如果无需发货,则 logisticsNo 设置 ""。原因是,不想再添加额外字段 - */ - private String logisticsNo; - /** - * 发货时间 - */ - private LocalDateTime deliveryTime; - - /** - * 收货时间 - */ - private LocalDateTime receiveTime; - /** - * 收件人名称 - */ - private String receiverName; - /** - * 收件人手机 - */ - private String receiverMobile; - /** - * 收件人地区编号 - */ - private Integer receiverAreaId; - /** - * 收件人详细地址 - */ - private String receiverDetailAddress; - - /** - * 自提门店编号 - * - * 关联 {@link DeliveryPickUpStoreDO#getId()} - */ - private Long pickUpStoreId; - /** - * 自提核销码 - */ - private String pickUpVerifyCode; - - // ========== 售后基本信息 ========== - /** - * 售后状态 - * - * 枚举 {@link TradeOrderRefundStatusEnum} - */ - private Integer refundStatus; - /** - * 退款金额,单位:分 - * - * 注意,退款并不会影响 {@link #payPrice} 实际支付金额 - * 也就说,一个订单最终产生多少金额的收入 = payPrice - refundPrice - */ - private Integer refundPrice; - - // ========== 营销基本信息 ========== - /** - * 优惠劵编号 - */ - private Long couponId; - /** - * 优惠劵减免金额,单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 使用的积分 - */ - private Integer usePoint; - /** - * 积分抵扣的金额,单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - /** - * 赠送的积分 - */ - private Integer givePoint; - /** - * 退还的使用的积分 - */ - private Integer refundPoint; - /** - * VIP 减免金额,单位:分 - */ - private Integer vipPrice; - - /** - * 秒杀活动编号 - * - * 关联 SeckillActivityDO 的 id 字段 - */ - private Long seckillActivityId; - - /** - * 砍价活动编号 - * - * 关联 BargainActivityDO 的 id 字段 - */ - private Long bargainActivityId; - /** - * 砍价记录编号 - * - * 关联 BargainRecordDO 的 id 字段 - */ - private Long bargainRecordId; - - /** - * 拼团活动编号 - * - * 关联 CombinationActivityDO 的 id 字段 - */ - private Long combinationActivityId; - /** - * 拼团团长编号 - * - * 关联 CombinationRecordDO 的 headId 字段 - */ - private Long combinationHeadId; - /** - * 拼团记录编号 - * - * 关联 CombinationRecordDO 的 id 字段 - */ - private Long combinationRecordId; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java deleted file mode 100644 index 675067713..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java +++ /dev/null @@ -1,229 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.order; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.List; - -/** - * 交易订单项 DO - * - * @author 芋道源码 - */ -@TableName(value = "trade_order_item", autoResultMap = true) -@Data -@Accessors(chain = true) -@EqualsAndHashCode(callSuper = true) -public class TradeOrderItemDO extends BaseDO { - - // ========== 订单项基本信息 ========== - /** - * 编号 - */ - private Long id; - /** - * 用户编号 - * - * 关联 MemberUserDO 的 id 编号 - */ - private Long userId; - /** - * 订单编号 - * - * 关联 {@link TradeOrderDO#getId()} - */ - private Long orderId; - /** - * 购物车项编号 - * - * 关联 {@link CartDO#getId()} - */ - private Long cartId; - - // ========== 商品基本信息; 冗余较多字段,减少关联查询 ========== - /** - * 商品 SPU 编号 - * - * 关联 ProductSkuDO 的 spuId 编号 - */ - private Long spuId; - /** - * 商品 SPU 名称 - * - * 冗余 ProductSkuDO 的 spuName 名称 - */ - private String spuName; - /** - * 商品 SKU 编号 - * - * 关联 ProductSkuDO 的 id 编号 - */ - private Long skuId; - /** - * 属性数组,JSON 格式 - * - * 冗余 ProductSkuDO 的 properties 字段 - */ - @TableField(typeHandler = PropertyTypeHandler.class) - private List properties; - /** - * 商品图片 - */ - private String picUrl; - /** - * 购买数量 - */ - private Integer count; - /** - * 是否评价 - * - * true - 已评价 - * false - 未评价 - */ - private Boolean commentStatus; - - // ========== 价格 + 支付基本信息 ========== - - /** - * 商品原价(单),单位:分 - * - * 对应 ProductSkuDO 的 price 字段 - * 对应 taobao 的 order.price 字段 - */ - private Integer price; - /** - * 优惠金额(总),单位:分 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 运费金额(总),单位:分 - */ - private Integer deliveryPrice; - /** - * 订单调价(总),单位:分 - * - * 正数,加价;负数,减价 - */ - private Integer adjustPrice; - /** - * 应付金额(总),单位:分 - * - * = {@link #price} * {@link #count} - * - {@link #couponPrice} - * - {@link #pointPrice} - * - {@link #discountPrice} - * + {@link #deliveryPrice} - * + {@link #adjustPrice} - * - {@link #vipPrice} - */ - private Integer payPrice; - - // ========== 营销基本信息 ========== - - /** - * 优惠劵减免金额,单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 积分抵扣的金额,单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - /** - * 使用的积分 - * - * 目的:用于后续取消或者售后订单时,需要归还赠送 - */ - private Integer usePoint; - /** - * 赠送的积分 - * - * 目的:用于后续取消或者售后订单时,需要扣减赠送 - */ - private Integer givePoint; - /** - * VIP 减免金额,单位:分 - */ - private Integer vipPrice; - - // ========== 售后基本信息 ========== - - /** - * 售后单编号 - * - * 关联 {@link AfterSaleDO#getId()} 字段 - */ - private Long afterSaleId; - /** - * 售后状态 - * - * 枚举 {@link TradeOrderItemAfterSaleStatusEnum} - */ - private Integer afterSaleStatus; - - /** - * 商品属性 - */ - @Data - public static class Property implements Serializable { - - /** - * 属性编号 - * - * 关联 ProductPropertyDO 的 id 编号 - */ - private Long propertyId; - /** - * 属性名字 - * - * 关联 ProductPropertyDO 的 name 字段 - */ - private String propertyName; - - /** - * 属性值编号 - * - * 关联 ProductPropertyValueDO 的 id 编号 - */ - private Long valueId; - /** - * 属性值名字 - * - * 关联 ProductPropertyValueDO 的 name 字段 - */ - private String valueName; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class PropertyTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List parse(String json) { - return JsonUtils.parseArray(json, Property.class); - } - - @Override - protected String toJson(List obj) { - return JsonUtils.toJsonString(obj); - } - - } - -} - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderLogDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderLogDO.java deleted file mode 100644 index 36022c16e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderLogDO.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.dataobject.order; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderOperateTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 订单日志 DO - * - * @author 陈賝 - */ -@TableName("trade_order_log") -@KeySequence("trade_order_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TradeOrderLogDO extends BaseDO { - - /** - * 用户类型 - 系统 - * - * 例如说:Job 自动过期订单时,通过系统自动操作 - */ - public static final Integer USER_TYPE_SYSTEM = 0; - /** - * 用户编号 - 系统 - */ - public static final Long USER_ID_SYSTEM = 0L; - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 用户编号 - * - * 关联 AdminUserDO 的 id 字段、或者 MemberUserDO 的 id 字段 - */ - private Long userId; - /** - * 用户类型 - * - * 枚举 {@link UserTypeEnum} - */ - private Integer userType; - - /** - * 订单号 - * - * 关联 {@link TradeOrderDO#getId()} - */ - private Long orderId; - /** - * 操作前状态 - */ - private Integer beforeStatus; - /** - * 操作后状态 - */ - private Integer afterStatus; - - /** - * 操作类型 - * - * {@link TradeOrderOperateTypeEnum} - */ - private Integer operateType; - /** - * 订单日志信息 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleLogMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleLogMapper.java deleted file mode 100644 index c0ec91c6d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleLogMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.aftersale; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface AfterSaleLogMapper extends BaseMapperX { - - default List selectListByAfterSaleId(Long afterSaleId) { - return selectList(AfterSaleLogDO::getAfterSaleId, afterSaleId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java deleted file mode 100644 index 68a09a82a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/aftersale/AfterSaleMapper.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; - -@Mapper -public interface AfterSaleMapper extends BaseMapperX { - - default PageResult selectPage(AfterSalePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(AfterSaleDO::getNo, reqVO.getNo()) - .eqIfPresent(AfterSaleDO::getStatus, reqVO.getStatus()) - .eqIfPresent(AfterSaleDO::getType, reqVO.getType()) - .eqIfPresent(AfterSaleDO::getWay, reqVO.getWay()) - .likeIfPresent(AfterSaleDO::getOrderNo, reqVO.getOrderNo()) - .likeIfPresent(AfterSaleDO::getSpuName, reqVO.getSpuName()) - .betweenIfPresent(AfterSaleDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(AfterSaleDO::getId)); - } - - default PageResult selectPage(Long userId, PageParam pageParam) { - return selectPage(pageParam, new LambdaQueryWrapperX() - .eqIfPresent(AfterSaleDO::getUserId, userId) - .orderByDesc(AfterSaleDO::getId)); - } - - default int updateByIdAndStatus(Long id, Integer status, AfterSaleDO update) { - return update(update, new LambdaUpdateWrapper() - .eq(AfterSaleDO::getId, id).eq(AfterSaleDO::getStatus, status)); - } - - default AfterSaleDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(AfterSaleDO::getId, id, - AfterSaleDO::getUserId, userId); - } - - default Long selectCountByUserIdAndStatus(Long userId, Collection statuses) { - return selectCount(new LambdaQueryWrapperX() - .eq(AfterSaleDO::getUserId, userId) - .in(AfterSaleDO::getStatus, statuses)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java deleted file mode 100644 index 388f927ad..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageRecordMapper.java +++ /dev/null @@ -1,113 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.brokerage; - -import cn.hutool.core.bean.BeanUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.yulichang.toolkit.MPJWrappers; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 佣金记录 Mapper - * - * @author owen - */ -@Mapper -public interface BrokerageRecordMapper extends BaseMapperX { - - default PageResult selectPage(BrokerageRecordPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BrokerageRecordDO::getUserId, reqVO.getUserId()) - .eqIfPresent(BrokerageRecordDO::getBizType, reqVO.getBizType()) - .eqIfPresent(BrokerageRecordDO::getStatus, reqVO.getStatus()) - .eqIfPresent(BrokerageRecordDO::getSourceUserLevel, reqVO.getSourceUserLevel()) - .betweenIfPresent(BrokerageRecordDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(BrokerageRecordDO::getId)); - } - - default List selectListByStatusAndUnfreezeTimeLt(Integer status, LocalDateTime unfreezeTime) { - return selectList(new LambdaQueryWrapper() - .eq(BrokerageRecordDO::getStatus, status) - .lt(BrokerageRecordDO::getUnfreezeTime, unfreezeTime)); - } - - default int updateByIdAndStatus(Integer id, Integer status, BrokerageRecordDO updateObj) { - return update(updateObj, new LambdaQueryWrapper() - .eq(BrokerageRecordDO::getId, id) - .eq(BrokerageRecordDO::getStatus, status)); - } - - default BrokerageRecordDO selectByBizTypeAndBizIdAndUserId(Integer bizType, String bizId, Long userId) { - return selectOne(BrokerageRecordDO::getBizType, bizType, - BrokerageRecordDO::getBizId, bizId, - BrokerageRecordDO::getUserId, userId); - } - - default List selectCountAndSumPriceByUserIdInAndBizTypeAndStatus(Collection userIds, - Integer bizType, - Integer status) { - List> list = selectMaps(MPJWrappers.lambdaJoin(BrokerageRecordDO.class) - .select(BrokerageRecordDO::getUserId) - .selectCount(BrokerageRecordDO::getId, UserBrokerageSummaryRespBO::getCount) - .selectSum(BrokerageRecordDO::getPrice) - .in(BrokerageRecordDO::getUserId, userIds) - .eq(BrokerageRecordDO::getBizId, bizType) - .eq(BrokerageRecordDO::getStatus, status) - .groupBy(BrokerageRecordDO::getUserId)); // 按照 userId 聚合 - return BeanUtil.copyToList(list, UserBrokerageSummaryRespBO.class); - // selectJoinList有BUG,会与租户插件冲突:解析SQL时,发生异常 https://gitee.com/best_handsome/mybatis-plus-join/issues/I84GYW -// return selectJoinList(UserBrokerageSummaryBO.class, MPJWrappers.lambdaJoin(BrokerageRecordDO.class) -// .select(BrokerageRecordDO::getUserId) -// .selectCount(BrokerageRecordDO::getId, UserBrokerageSummaryBO::getCount) -// .selectSum(BrokerageRecordDO::getPrice) -// .in(BrokerageRecordDO::getUserId, userIds) -// .eq(BrokerageRecordDO::getBizId, bizType) -// .eq(BrokerageRecordDO::getStatus, status) -// .groupBy(BrokerageRecordDO::getUserId)); - } - - @Select("SELECT SUM(price) FROM trade_brokerage_record " + - "WHERE user_id = #{userId} AND biz_type = #{bizType} AND status = #{status} " + - "AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE") - Integer selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(@Param("userId") Long userId, - @Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - // TODO @芋艿:收敛掉 @Select 注解操作,统一成 MyBatis-Plus 的方式,或者 xml - @Select("SELECT user_id AS id, SUM(price) AS brokeragePrice FROM trade_brokerage_record " + - "WHERE biz_type = #{bizType} AND status = #{status} AND deleted = FALSE " + - "AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} " + - "GROUP BY user_id " + - "ORDER BY brokeragePrice DESC") - IPage selectSummaryPricePageGroupByUserId(IPage page, - @Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - @Select("SELECT COUNT(1) FROM trade_brokerage_record " + - "WHERE biz_type = #{bizType} AND status = #{status} AND deleted = FALSE " + - "AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} " + - "GROUP BY user_id HAVING SUM(price) > #{brokeragePrice}") - Integer selectCountByPriceGt(@Param("brokeragePrice") Integer brokeragePrice, - @Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java deleted file mode 100644 index 6c24cac90..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java +++ /dev/null @@ -1,167 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.brokerage; - -import cn.hutool.core.convert.Convert; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.SortingField; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * 分销用户 Mapper - * - * @author owen - */ -@Mapper -public interface BrokerageUserMapper extends BaseMapperX { - - default PageResult selectPage(BrokerageUserPageReqVO reqVO, List ids) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .inIfPresent(BrokerageUserDO::getId, ids) - .eqIfPresent(BrokerageUserDO::getBrokerageEnabled, reqVO.getBrokerageEnabled()) - .betweenIfPresent(BrokerageUserDO::getCreateTime, reqVO.getCreateTime()) - .betweenIfPresent(BrokerageUserDO::getBindUserTime, reqVO.getBindUserTime()) - .orderByDesc(BrokerageUserDO::getId)); - } - - /** - * 更新用户可用佣金(增加) - * - * @param id 用户编号 - * @param incrCount 增加佣金(正数) - */ - default void updatePriceIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount > 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" brokerage_price = brokerage_price + " + incrCount) - .eq(BrokerageUserDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户可用佣金(减少) - * 注意:理论上佣金可能已经提现,这时会扣出负数,确保平台不会造成损失 - * - * @param id 用户编号 - * @param incrCount 增加佣金(负数) - * @return 更新行数 - */ - default int updatePriceDecr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" brokerage_price = brokerage_price + " + incrCount) // 负数,所以使用 + 号 - .eq(BrokerageUserDO::getId, id); - return update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户冻结佣金(增加) - * - * @param id 用户编号 - * @param incrCount 增加冻结佣金(正数) - */ - default void updateFrozenPriceIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount > 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" frozen_price = frozen_price + " + incrCount) - .eq(BrokerageUserDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户冻结佣金(减少) - * 注意:理论上冻结佣金可能已经解冻,这时会扣出负数,确保平台不会造成损失 - * - * @param id 用户编号 - * @param incrCount 减少冻结佣金(负数) - */ - default void updateFrozenPriceDecr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" frozen_price = frozen_price + " + incrCount) // 负数,所以使用 + 号 - .eq(BrokerageUserDO::getId, id); - update(null, lambdaUpdateWrapper); - } - - /** - * 更新用户冻结佣金(减少), 更新用户佣金(增加) - * - * @param id 用户编号 - * @param incrCount 减少冻结佣金(负数) - * @return 更新条数 - */ - default int updateFrozenPriceDecrAndPriceIncr(Long id, Integer incrCount) { - Assert.isTrue(incrCount < 0); - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" frozen_price = frozen_price + " + incrCount + // 负数,所以使用 + 号 - ", brokerage_price = brokerage_price + " + -incrCount) // 负数,所以使用 - 号 - .eq(BrokerageUserDO::getId, id) - .ge(BrokerageUserDO::getFrozenPrice, -incrCount); // cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - default void updateBindUserIdAndBindUserTimeToNull(Long id) { - update(null, new LambdaUpdateWrapper() - .eq(BrokerageUserDO::getId, id) - .set(BrokerageUserDO::getBindUserId, null).set(BrokerageUserDO::getBindUserTime, null)); - } - - default void updateEnabledFalseAndBrokerageTimeToNull(Long id) { - update(null, new LambdaUpdateWrapper() - .eq(BrokerageUserDO::getId, id) - .set(BrokerageUserDO::getBrokerageEnabled, false).set(BrokerageUserDO::getBrokerageTime, null)); - } - - @Select("SELECT bind_user_id AS id, COUNT(1) AS brokerageUserCount FROM trade_brokerage_user " + - "WHERE bind_user_id IS NOT NULL AND deleted = FALSE " + - "AND bind_user_time BETWEEN #{beginTime} AND #{endTime} " + - "GROUP BY bind_user_id " + - "ORDER BY brokerageUserCount DESC") - IPage selectCountPageGroupByBindUserId(Page page, - @Param("beginTime") LocalDateTime beginTime, - @Param("endTime") LocalDateTime endTime); - - /** - * 下级分销统计(分页) - * - * @param bizType 业务类型 - * @param status 状态 - * @param ids 用户编号列表 - * @param sortingField 排序字段 - * @return 下级分销统计分页列表 - */ - IPage selectSummaryPageByUserId(Page page, - @Param("bizType") Integer bizType, - @Param("status") Integer status, - @Param("ids") Collection ids, - @Param("sortingField") SortingField sortingField); - - /** - * 获得被 bindUserIds 推广的用户编号数组 - * - * @param bindUserIds 推广员编号数组 - * @return 用户编号数组 - */ - default List selectIdListByBindUserIdIn(Collection bindUserIds) { - return Convert.toList(Long.class, - selectObjs(new LambdaQueryWrapperX() - .select(Collections.singletonList(BrokerageUserDO::getId)) // 只查询 id 字段,加速返回速度 - .in(BrokerageUserDO::getBindUserId, bindUserIds))); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java deleted file mode 100644 index 9e2cf68ad..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.brokerage; - -import cn.hutool.core.bean.BeanUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.github.yulichang.wrapper.MPJLambdaWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 佣金提现 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface BrokerageWithdrawMapper extends BaseMapperX { - - default PageResult selectPage(BrokerageWithdrawPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(BrokerageWithdrawDO::getUserId, reqVO.getUserId()) - .eqIfPresent(BrokerageWithdrawDO::getType, reqVO.getType()) - .likeIfPresent(BrokerageWithdrawDO::getName, reqVO.getName()) - .eqIfPresent(BrokerageWithdrawDO::getAccountNo, reqVO.getAccountNo()) - .likeIfPresent(BrokerageWithdrawDO::getBankName, reqVO.getBankName()) - .eqIfPresent(BrokerageWithdrawDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(BrokerageWithdrawDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(BrokerageWithdrawDO::getStatus).orderByDesc(BrokerageWithdrawDO::getId)); - } - - default int updateByIdAndStatus(Integer id, Integer status, BrokerageWithdrawDO updateObj) { - return update(updateObj, new LambdaUpdateWrapper() - .eq(BrokerageWithdrawDO::getId, id) - .eq(BrokerageWithdrawDO::getStatus, status)); - } - - default List selectCountAndSumPriceByUserIdAndStatus(Collection userIds, Integer status) { - List> list = selectMaps(new MPJLambdaWrapper() - .select(BrokerageWithdrawDO::getUserId) - .selectCount(BrokerageWithdrawDO::getId, BrokerageWithdrawSummaryRespBO::getCount) - .selectSum(BrokerageWithdrawDO::getPrice) - .in(BrokerageWithdrawDO::getUserId, userIds) - .eq(BrokerageWithdrawDO::getStatus, status) - .groupBy(BrokerageWithdrawDO::getUserId)); - return BeanUtil.copyToList(list, BrokerageWithdrawSummaryRespBO.class); - // selectJoinList有BUG,会与租户插件冲突:解析SQL时,发生异常 https://gitee.com/best_handsome/mybatis-plus-join/issues/I84GYW -// return selectJoinList(UserWithdrawSummaryBO.class, new MPJLambdaWrapper() -// .select(BrokerageWithdrawDO::getUserId) -// .selectCount(BrokerageWithdrawDO::getId, UserWithdrawSummaryBO::getCount) -// .selectSum(BrokerageWithdrawDO::getPrice) -// .in(BrokerageWithdrawDO::getUserId, userIds) -// .eq(BrokerageWithdrawDO::getStatus, status) -// .groupBy(BrokerageWithdrawDO::getUserId)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/cart/CartMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/cart/CartMapper.java deleted file mode 100644 index b67265156..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/cart/CartMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.cart; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -@Mapper -public interface CartMapper extends BaseMapperX { - - default CartDO selectByUserIdAndSkuId(Long userId, Long skuId) { - return selectOne(CartDO::getUserId, userId, - CartDO::getSkuId, skuId); - } - - default Integer selectSumByUserId(Long userId) { - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("SUM(count) AS sumCount") - .eq("user_id", userId) - .eq("selected", true)); // 只计算选中的 - // 获得数量 - return CollUtil.getFirst(result) != null ? MapUtil.getInt(result.get(0), "sumCount") : 0; - } - - default CartDO selectById(Long id, Long userId) { - return selectOne(CartDO::getId, id, - CartDO::getUserId, userId); - } - - default List selectListByIds(Collection ids, Long userId) { - return selectList(new LambdaQueryWrapper() - .in(CartDO::getId, ids) - .eq(CartDO::getUserId, userId)); - } - - default List selectListByUserId(Long userId) { - return selectList(new LambdaQueryWrapper() - .eq(CartDO::getUserId, userId)); - } - - default List selectListByUserId(Long userId, Set ids) { - return selectList(new LambdaQueryWrapper() - .eq(CartDO::getUserId, userId) - .in(CartDO::getId, ids)); - } - - default void updateByIds(Collection ids, Long userId, CartDO updateObj) { - update(updateObj, new LambdaQueryWrapper() - .in(CartDO::getId, ids) - .eq(CartDO::getUserId, userId)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/config/TradeConfigMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/config/TradeConfigMapper.java deleted file mode 100644 index 18a3f4df7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/config/TradeConfigMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.config; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 交易中心配置 Mapper - * - * @author owen - */ -@Mapper -public interface TradeConfigMapper extends BaseMapperX { - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressMapper.java deleted file mode 100644 index 59e7cf02e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressMapper.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface DeliveryExpressMapper extends BaseMapperX { - - default PageResult selectPage(DeliveryExpressPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DeliveryExpressDO::getCode, reqVO.getCode()) - .likeIfPresent(DeliveryExpressDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryExpressDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DeliveryExpressDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(DeliveryExpressDO::getSort)); - } - - default List selectList(DeliveryExpressExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(DeliveryExpressDO::getCode, reqVO.getCode()) - .likeIfPresent(DeliveryExpressDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryExpressDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DeliveryExpressDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(DeliveryExpressDO::getSort)); - } - - default DeliveryExpressDO selectByCode(String code) { - return selectOne(new LambdaQueryWrapper() - .eq(DeliveryExpressDO::getCode, code)); - } - - default List selectListByStatus(Integer status) { - return selectList(DeliveryExpressDO::getStatus, status); - } - -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateChargeMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateChargeMapper.java deleted file mode 100644 index a2403f019..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateChargeMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface DeliveryExpressTemplateChargeMapper extends BaseMapperX { - - default List selectListByTemplateId(Long templateId){ - return selectList(new LambdaQueryWrapper() - .eq(DeliveryExpressTemplateChargeDO::getTemplateId, templateId)); - } - - default int deleteByTemplateId(Long templateId){ - return delete(new LambdaQueryWrapper() - .eq(DeliveryExpressTemplateChargeDO::getTemplateId, templateId)); - } - - default List selectByTemplateIds(Collection templateIds) { - return selectList(DeliveryExpressTemplateChargeDO::getTemplateId, templateIds); - } - -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateFreeMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateFreeMapper.java deleted file mode 100644 index b64a3c979..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateFreeMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateFreeDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface DeliveryExpressTemplateFreeMapper extends BaseMapperX { - - default List selectListByTemplateId(Long templateId) { - return selectList(new LambdaQueryWrapper() - .eq(DeliveryExpressTemplateFreeDO::getTemplateId, templateId)); - } - - default int deleteByTemplateId(Long templateId) { - return delete(new LambdaQueryWrapper() - .eq(DeliveryExpressTemplateFreeDO::getTemplateId, templateId)); - } - - default List selectListByTemplateIds(Collection templateIds) { - return selectList(DeliveryExpressTemplateFreeDO::getTemplateId, templateIds); - } -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateMapper.java deleted file mode 100644 index c93346894..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryExpressTemplateMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplatePageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface DeliveryExpressTemplateMapper extends BaseMapperX { - - default PageResult selectPage(DeliveryExpressTemplatePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DeliveryExpressTemplateDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryExpressTemplateDO::getChargeMode, reqVO.getChargeMode()) - .betweenIfPresent(DeliveryExpressTemplateDO::getCreateTime, reqVO.getCreateTime()) - .orderByAsc(DeliveryExpressTemplateDO::getSort)); - } - - default DeliveryExpressTemplateDO selectByName(String name) { - return selectOne(DeliveryExpressTemplateDO::getName,name); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java deleted file mode 100644 index b26b1c015..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface DeliveryPickUpStoreMapper extends BaseMapperX { - - default PageResult selectPage(DeliveryPickUpStorePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(DeliveryPickUpStoreDO::getName, reqVO.getName()) - .eqIfPresent(DeliveryPickUpStoreDO::getPhone, reqVO.getPhone()) - .eqIfPresent(DeliveryPickUpStoreDO::getAreaId, reqVO.getAreaId()) - .eqIfPresent(DeliveryPickUpStoreDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(DeliveryPickUpStoreDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(DeliveryPickUpStoreDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(DeliveryPickUpStoreDO::getStatus, status); - } - -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java deleted file mode 100644 index 06cc14e26..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/delivery/DeliveryPickUpStoreStaffMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.delivery; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreStaffDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface DeliveryPickUpStoreStaffMapper extends BaseMapperX { - -} - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java deleted file mode 100644 index b701b7f87..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.order; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -@Mapper -public interface TradeOrderItemMapper extends BaseMapperX { - - default int updateAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus, - Long afterSaleId) { - return update(new TradeOrderItemDO().setAfterSaleStatus(newAfterSaleStatus).setAfterSaleId(afterSaleId), - new LambdaUpdateWrapper<>(new TradeOrderItemDO().setId(id).setAfterSaleStatus(oldAfterSaleStatus))); - } - - default List selectListByOrderId(Long orderId) { - return selectList(TradeOrderItemDO::getOrderId, orderId); - } - - default List selectListByOrderId(Collection orderIds) { - return selectList(TradeOrderItemDO::getOrderId, orderIds); - } - - default TradeOrderItemDO selectByIdAndUserId(Long orderItemId, Long loginUserId) { - return selectOne(new LambdaQueryWrapperX() - .eq(TradeOrderItemDO::getId, orderItemId) - .eq(TradeOrderItemDO::getUserId, loginUserId)); - } - - default List selectListByOrderIdAndCommentStatus(Long orderId, Boolean commentStatus) { - return selectList(new LambdaQueryWrapperX() - .eq(TradeOrderItemDO::getOrderId, orderId) - .eq(TradeOrderItemDO::getCommentStatus, commentStatus)); - } - - default int selectProductSumByOrderId(@Param("orderIds") Set orderIds) { - // SQL sum 查询 - List> result = selectMaps(new QueryWrapper() - .select("SUM(count) AS sumCount") - .in("order_id", orderIds)); // 只计算选中的 - // 获得数量 - return CollUtil.getFirst(result) != null ? MapUtil.getInt(result.get(0), "sumCount") : 0; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderLogMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderLogMapper.java deleted file mode 100644 index 7788030ff..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderLogMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.order; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface TradeOrderLogMapper extends BaseMapperX { - - default List selectListByOrderId(Long orderId) { - return selectList(TradeOrderLogDO::getOrderId, orderId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java deleted file mode 100644 index 21fc038ba..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.mysql.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.Set; - -@Mapper -public interface TradeOrderMapper extends BaseMapperX { - - default int updateByIdAndStatus(Long id, Integer status, TradeOrderDO update) { - return update(update, new LambdaUpdateWrapper() - .eq(TradeOrderDO::getId, id).eq(TradeOrderDO::getStatus, status)); - } - - default TradeOrderDO selectByIdAndUserId(Long id, Long userId) { - return selectOne(TradeOrderDO::getId, id, TradeOrderDO::getUserId, userId); - } - - default PageResult selectPage(TradeOrderPageReqVO reqVO, Set userIds) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(TradeOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(TradeOrderDO::getUserId, reqVO.getUserId()) - .eqIfPresent(TradeOrderDO::getDeliveryType, reqVO.getDeliveryType()) - .inIfPresent(TradeOrderDO::getUserId, userIds) - .eqIfPresent(TradeOrderDO::getType, reqVO.getType()) - .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) - .eqIfPresent(TradeOrderDO::getPayChannelCode, reqVO.getPayChannelCode()) - .eqIfPresent(TradeOrderDO::getTerminal, reqVO.getTerminal()) - .eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId()) - .inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds()) - .likeIfPresent(TradeOrderDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode()) - .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(TradeOrderDO::getId)); - } - - // TODO @疯狂:如果用 map 返回,要不这里直接用 TradeOrderSummaryRespVO 返回?也算合理,就当 sql 查询出这么个玩意~~ - default List> selectOrderSummaryGroupByRefundStatus(TradeOrderPageReqVO reqVO, Set userIds) { - return selectMaps(new MPJLambdaWrapperX() - .selectAs(TradeOrderDO::getRefundStatus, TradeOrderDO::getRefundStatus) // 售后状态 - .selectCount(TradeOrderDO::getId, "count") // 售后状态对应的数量 - .selectSum(TradeOrderDO::getPayPrice, "price") // 售后状态对应的支付金额 - .likeIfPresent(TradeOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(TradeOrderDO::getUserId, reqVO.getUserId()) - .eqIfPresent(TradeOrderDO::getDeliveryType, reqVO.getDeliveryType()) - .inIfPresent(TradeOrderDO::getUserId, userIds) - .eqIfPresent(TradeOrderDO::getType, reqVO.getType()) - .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) - .eqIfPresent(TradeOrderDO::getPayChannelCode, reqVO.getPayChannelCode()) - .eqIfPresent(TradeOrderDO::getTerminal, reqVO.getTerminal()) - .eqIfPresent(TradeOrderDO::getLogisticsId, reqVO.getLogisticsId()) - .inIfPresent(TradeOrderDO::getPickUpStoreId, reqVO.getPickUpStoreIds()) - .likeIfPresent(TradeOrderDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode()) - .betweenIfPresent(TradeOrderDO::getCreateTime, reqVO.getCreateTime()) - .groupBy(TradeOrderDO::getRefundStatus)); // 按售后状态分组 - } - - default PageResult selectPage(AppTradeOrderPageReqVO reqVO, Long userId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(TradeOrderDO::getUserId, userId) - .eqIfPresent(TradeOrderDO::getStatus, reqVO.getStatus()) - .eqIfPresent(TradeOrderDO::getCommentStatus, reqVO.getCommentStatus()) - .orderByDesc(TradeOrderDO::getId)); // TODO 芋艿:未来不同的 status,不同的排序 - } - - default Long selectCountByUserIdAndStatus(Long userId, Integer status, Boolean commentStatus) { - return selectCount(new LambdaQueryWrapperX() - .eq(TradeOrderDO::getUserId, userId) - .eqIfPresent(TradeOrderDO::getStatus, status) - .eqIfPresent(TradeOrderDO::getCommentStatus, commentStatus)); - } - - default TradeOrderDO selectOrderByIdAndUserId(Long orderId, Long loginUserId) { - return selectOne(new LambdaQueryWrapperX() - .eq(TradeOrderDO::getId, orderId) - .eq(TradeOrderDO::getUserId, loginUserId)); - } - - default List selectListByStatusAndCreateTimeLt(Integer status, LocalDateTime createTime) { - return selectList(new LambdaUpdateWrapper() - .eq(TradeOrderDO::getStatus, status) - .lt(TradeOrderDO::getCreateTime, createTime)); - } - - default List selectListByStatusAndDeliveryTimeLt(Integer status, LocalDateTime deliveryTime) { - return selectList(new LambdaUpdateWrapper() - .eq(TradeOrderDO::getStatus, status) - .lt(TradeOrderDO::getDeliveryTime, deliveryTime)); - } - - default List selectListByStatusAndReceiveTimeLt(Integer status, LocalDateTime receive, - Boolean commentStatus) { - return selectList(new LambdaUpdateWrapper() - .eq(TradeOrderDO::getStatus, status) - .lt(TradeOrderDO::getReceiveTime, receive) - .eq(TradeOrderDO::getCommentStatus, commentStatus)); - } - - default List selectListByUserIdAndSeckillActivityId(Long userId, Long seckillActivityId) { - return selectList(new LambdaUpdateWrapper<>(TradeOrderDO.class) - .eq(TradeOrderDO::getUserId, userId) - .eq(TradeOrderDO::getSeckillActivityId, seckillActivityId)); - } - - default TradeOrderDO selectOneByPickUpVerifyCode(String pickUpVerifyCode) { - return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); - } - - default TradeOrderDO selectByUserIdAndCombinationActivityIdAndStatus(Long userId, Long combinationActivityId, Integer status) { - return selectOne(new LambdaQueryWrapperX() - .eq(TradeOrderDO::getUserId, userId) - .eq(TradeOrderDO::getStatus, status) - .eq(TradeOrderDO::getCombinationActivityId, combinationActivityId) - ); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/package-info.java deleted file mode 100644 index 37e0ba7d6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位 - */ -package cn.iocoder.yudao.module.trade.dal.mysql; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/RedisKeyConstants.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/RedisKeyConstants.java deleted file mode 100644 index eff48e51c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/RedisKeyConstants.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.redis; - -/** - * 交易 Redis Key 枚举类 - * - * @author 芋道源码 - */ -public interface RedisKeyConstants { - - /** - * 交易序号的缓存 - * - * KEY 格式:trade_no:{prefix} - * VALUE 数据格式:编号自增 - */ - String TRADE_NO = "trade_no:"; - - /** - * 交易序号的缓存 - * - * KEY 格式:express_track:{code-logisticsNo-receiverMobile} - * VALUE 数据格式 String, 物流信息集合 - */ - String EXPRESS_TRACK = "express_track"; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/no/TradeNoRedisDAO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/no/TradeNoRedisDAO.java deleted file mode 100644 index 8b76f195e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/redis/no/TradeNoRedisDAO.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.dal.redis.no; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.module.trade.dal.redis.RedisKeyConstants; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Repository; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; - -/** - * 订单序号的 Redis DAO - * - * @author HUIHUI - */ -@Repository -public class TradeNoRedisDAO { - - public static final String TRADE_ORDER_NO_PREFIX = "o"; - - public static final String AFTER_SALE_NO_PREFIX = "r"; - - @Resource - private StringRedisTemplate stringRedisTemplate; - - /** - * 生成序号 - * - * @param prefix 前缀 - * @return 序号 - */ - public String generate(String prefix) { - // 递增序号 - String noPrefix = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN); - String key = RedisKeyConstants.TRADE_NO + noPrefix; - Long no = stringRedisTemplate.opsForValue().increment(key); - // 设置过期时间 - stringRedisTemplate.expire(key, Duration.ofMinutes(1L)); - return noPrefix + no; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/config/AfterSaleLogConfiguration.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/config/AfterSaleLogConfiguration.java deleted file mode 100644 index 1c2613789..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/config/AfterSaleLogConfiguration.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.aftersale.config; - -import cn.iocoder.yudao.module.trade.framework.aftersale.core.aop.AfterSaleLogAspect; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -// TODO @chenchen:改成 aftersale 好点哈; -/** - * trade 模块的 afterSaleLog 组件的 Configuration - * - * @author 陈賝 - * @since 2023/6/18 11:09 - */ -@Configuration(proxyBeanMethods = false) -public class AfterSaleLogConfiguration { - - @Bean - public AfterSaleLogAspect afterSaleLogAspect() { - return new AfterSaleLogAspect(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/annotations/AfterSaleLog.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/annotations/AfterSaleLog.java deleted file mode 100644 index bc41bf986..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/annotations/AfterSaleLog.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.aftersale.core.annotations; - -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; -import cn.iocoder.yudao.module.trade.framework.aftersale.core.aop.AfterSaleLogAspect; - -import java.lang.annotation.*; - -/** - * 售后日志的注解 - * - * 写在方法上时,会自动记录售后日志 - * - * @author 陈賝 - * @since 2023/6/8 17:04 - * @see AfterSaleLogAspect - */ -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface AfterSaleLog { - - /** - * 操作类型 - */ - AfterSaleOperateTypeEnum operateType(); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/aop/AfterSaleLogAspect.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/aop/AfterSaleLogAspect.java deleted file mode 100644 index f7b3f7e90..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/aop/AfterSaleLogAspect.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.aftersale.core.aop; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.framework.aftersale.core.annotations.AfterSaleLog; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleLogService; -import cn.iocoder.yudao.module.trade.service.aftersale.bo.AfterSaleLogCreateReqBO; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.AfterReturning; -import org.aspectj.lang.annotation.Aspect; - -import javax.annotation.Resource; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static java.util.Collections.emptyMap; - -/** - * 售后订单的操作记录的 AOP 切面 - * - * @author 陈賝 - * @since 2023/6/13 13:54 - */ -@Slf4j -@Aspect -public class AfterSaleLogAspect { - - /** - * 用户编号 - * - * 目前的使用场景:支付回调时,需要强制设置下用户编号 - */ - private static final ThreadLocal USER_ID = new ThreadLocal<>(); - /** - * 用户类型 - */ - private static final ThreadLocal USER_TYPE = new ThreadLocal<>(); - /** - * 订单编号 - */ - private static final ThreadLocal AFTER_SALE_ID = new ThreadLocal<>(); - /** - * 操作前的状态 - */ - private static final ThreadLocal BEFORE_STATUS = new ThreadLocal<>(); - /** - * 操作后的状态 - */ - private static final ThreadLocal AFTER_STATUS = new ThreadLocal<>(); - /** - * 拓展参数 Map,用于格式化操作内容 - */ - private static final ThreadLocal> EXTS = new ThreadLocal<>(); - - @Resource - private AfterSaleLogService afterSaleLogService; - - @AfterReturning(pointcut = "@annotation(afterSaleLog)") - public void doAfterReturning(JoinPoint joinPoint, AfterSaleLog afterSaleLog) { - try { - // 1.1 操作用户 - Integer userType = getUserType(); - Long userId = getUserId(); - // 1.2 售后信息 - Long afterSaleId = AFTER_SALE_ID.get(); - if (afterSaleId == null) { // 如果未设置,只有注解,说明不需要记录日志 - return; - } - Integer beforeStatus = BEFORE_STATUS.get(); - Integer afterStatus = AFTER_STATUS.get(); - Map exts = ObjectUtil.defaultIfNull(EXTS.get(), emptyMap()); - String content = StrUtil.format(afterSaleLog.operateType().getContent(), exts); - - // 2. 记录日志 - AfterSaleLogCreateReqBO createBO = new AfterSaleLogCreateReqBO() - .setUserId(userId).setUserType(userType) - .setAfterSaleId(afterSaleId).setBeforeStatus(beforeStatus).setAfterStatus(afterStatus) - .setOperateType(afterSaleLog.operateType().getType()).setContent(content); - afterSaleLogService.createAfterSaleLog(createBO); - } catch (Exception exception) { - log.error("[doAfterReturning][afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception); - } finally { - clear(); - } - } - - /** - * 获得用户类型 - * - * 如果没有,则约定为 {@link TradeOrderLogDO#getUserType()} 系统 - * - * @return 用户类型 - */ - private static Integer getUserType() { - return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserType(), TradeOrderLogDO.USER_TYPE_SYSTEM); - } - - /** - * 获得用户编号 - * - * 如果没有,则约定为 {@link TradeOrderLogDO#getUserId()} 系统 - * - * @return 用户类型 - */ - private static Long getUserId() { - return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserId(), TradeOrderLogDO.USER_ID_SYSTEM); - } - - public static void setAfterSale(Long id, Integer beforeStatus, Integer afterStatus, Map exts) { - AFTER_SALE_ID.set(id); - BEFORE_STATUS.set(beforeStatus); - AFTER_STATUS.set(afterStatus); - EXTS.set(exts); - } - - public static void setUserInfo(Long userId, Integer userType) { - USER_ID.set(userId); - USER_TYPE.set(userType); - } - - private static void clear() { - USER_ID.remove(); - USER_TYPE.remove(); - AFTER_SALE_ID.remove(); - BEFORE_STATUS.remove(); - AFTER_STATUS.remove(); - EXTS.remove(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/utils/AfterSaleLogUtils.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/utils/AfterSaleLogUtils.java deleted file mode 100644 index 3f9fc5d74..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersale/core/utils/AfterSaleLogUtils.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.aftersale.core.utils; - - -import cn.iocoder.yudao.module.trade.framework.aftersale.core.aop.AfterSaleLogAspect; - -import java.util.Map; - -/** - * 操作日志工具类 - * 目前主要的作用,是提供给业务代码,记录操作明细和拓展字段 - * - * @author 芋道源码 - */ -public class AfterSaleLogUtils { - - public static void setAfterSaleInfo(Long id, Integer beforeStatus, Integer afterStatus) { - setAfterSaleInfo(id, beforeStatus, afterStatus, null); - } - - public static void setAfterSaleInfo(Long id, Integer beforeStatus, Integer afterStatus, - Map exts) { - AfterSaleLogAspect.setAfterSale(id, beforeStatus, afterStatus, exts); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/ExpressClientConfig.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/ExpressClientConfig.java deleted file mode 100644 index 2799c3f1c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/ExpressClientConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.config; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClientFactory; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.ExpressClientFactoryImpl; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.client.RestTemplate; - -/** - * 快递客户端端配置类: - * - * 1. 快递客户端工厂 {@link ExpressClientFactory} - * 2. 默认的快递客户端实现 {@link ExpressClient} - * - * @author jason - */ -@Configuration(proxyBeanMethods = false) -public class ExpressClientConfig { - - @Bean - public ExpressClientFactory expressClientFactory(TradeExpressProperties tradeExpressProperties, - RestTemplate restTemplate) { - return new ExpressClientFactoryImpl(tradeExpressProperties, restTemplate); - } - - @Bean - public ExpressClient defaultExpressClient(ExpressClientFactory expressClientFactory) { - return expressClientFactory.getDefaultExpressClient(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/TradeExpressProperties.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/TradeExpressProperties.java deleted file mode 100644 index 73efef90a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/config/TradeExpressProperties.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.config; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.enums.ExpressClientEnum; -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; - -// TODO @芋艿:未来要不要放数据库中?考虑 saas 多租户时,不同租户使用不同的配置? -/** - * 交易运费快递的配置项 - * - * @author jason - */ -@Component -@ConfigurationProperties(prefix = "yudao.trade.express") -@Data -@Validated -public class TradeExpressProperties { - - /** - * 快递客户端 - * - * 默认不提供,需要提醒用户配置一个快递服务商。 - */ - private ExpressClientEnum client = ExpressClientEnum.NOT_PROVIDE; - - /** - * 快递鸟配置 - */ - @Valid - private KdNiaoConfig kdNiao; - /** - * 快递 100 配置 - */ - @Valid - private Kd100Config kd100; - - /** - * 快递鸟配置项目 - */ - @Data - public static class KdNiaoConfig { - - /** - * 快递鸟用户 ID - */ - @NotEmpty(message = "快递鸟用户 ID 配置项不能为空") - private String businessId; - /** - * 快递鸟 API Key - */ - @NotEmpty(message = "快递鸟 Api Key 配置项不能为空") - private String apiKey; - - } - - /** - * 快递 100 配置项 - */ - @Data - public static class Kd100Config { - - /** - * 快递 100 授权码 - */ - @NotEmpty(message = "快递 100 授权码配置项不能为空") - private String customer; - /** - * 快递 100 授权 key - */ - @NotEmpty(message = "快递 100 授权 Key 配置项不能为空") - private String key; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClient.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClient.java deleted file mode 100644 index 76b361c3f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClient.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; - -import java.util.List; - -/** - * 快递客户端接口 - * - * @author jason - */ -public interface ExpressClient { - - /** - * 快递实时查询 - * - * @param reqDTO 查询请求参数 - */ - // TODO @jason:返回字段可以参考 https://doc.youzanyun.com/detail/API/0/5 响应的 data - List getExpressTrackList(ExpressTrackQueryReqDTO reqDTO); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClientFactory.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClientFactory.java deleted file mode 100644 index 5e457092f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/ExpressClientFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.enums.ExpressClientEnum; - -/** - * 快递客户端工厂接口:用于创建和缓存快递客户端 - * - * @author jason - */ -public interface ExpressClientFactory { - - /** - * 获取默认的快递客户端 - */ - ExpressClient getDefaultExpressClient(); - - /** - * 通过枚举获取快递客户端,如果不存在,就创建一个对应快递客户端 - * - * @param clientEnum 快递客户端枚举 - */ - ExpressClient getOrCreateExpressClient(ExpressClientEnum clientEnum); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/convert/ExpressQueryConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/convert/ExpressQueryConvert.java deleted file mode 100644 index b68e119c5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/convert/ExpressQueryConvert.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.convert; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao.KdNiaoExpressQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao.KdNiaoExpressQueryRespDTO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface ExpressQueryConvert { - - ExpressQueryConvert INSTANCE = Mappers.getMapper(ExpressQueryConvert.class); - - List convertList(List list); - @Mapping(source = "acceptTime", target = "time") - @Mapping(source = "acceptStation", target = "content") - ExpressTrackRespDTO convert(KdNiaoExpressQueryRespDTO.ExpressTrack track); - - List convertList2(List list); - @Mapping(source = "context", target = "content") - ExpressTrackRespDTO convert(Kd100ExpressQueryRespDTO.ExpressTrack track); - - KdNiaoExpressQueryReqDTO convert(ExpressTrackQueryReqDTO dto); - - Kd100ExpressQueryReqDTO convert2(ExpressTrackQueryReqDTO dto); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackQueryReqDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackQueryReqDTO.java deleted file mode 100644 index 34ad0128d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackQueryReqDTO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto; - -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import lombok.Data; - -/** - * 快递轨迹的查询 Req DTO - * - * @author jason - */ -@Data -public class ExpressTrackQueryReqDTO { - - /** - * 快递公司编码 - * - * 对应 {@link DeliveryExpressDO#getCode()} - */ - private String expressCode; - - /** - * 发货快递单号 - */ - private String logisticsNo; - - /** - * 收、寄件人的电话号码 - */ - private String phone; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackRespDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackRespDTO.java deleted file mode 100644 index bc99e1cba..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/ExpressTrackRespDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto; - -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 快递查询的轨迹 Resp DTO - * - * @author jason - */ -@Data -public class ExpressTrackRespDTO { - - /** - * 发生时间 - */ - private LocalDateTime time; - - /** - * 快递状态 - */ - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryReqDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryReqDTO.java deleted file mode 100644 index 7befc84f7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryReqDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -/** - * 快递 100 快递查询 Req DTO - * - * @author jason - */ -@Data -@JsonInclude(JsonInclude.Include.NON_NULL) -public class Kd100ExpressQueryReqDTO { - - /** - * 快递公司编码 - */ - @JsonProperty("com") - private String expressCode; - - /** - * 快递单号 - */ - @JsonProperty("num") - private String logisticsNo; - - /** - * 收、寄件人的电话号码 - */ - private String phone; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryRespDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryRespDTO.java deleted file mode 100644 index 9d33cac21..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kd100/Kd100ExpressQueryRespDTO.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** - * 快递 100 实时快递查询 Resp DTO - * - * 参见 快递 100 文档 - * - * @author jason - */ -@Data -public class Kd100ExpressQueryRespDTO { - - /** - * 快递公司编码 - */ - @JsonProperty("com") - private String expressCompanyCode; - /** - * 快递单号 - */ - @JsonProperty("nu") - private String logisticsNo; - /** - * 快递单当前状态 - */ - private String state; - - /** - * 查询结果 - * - * 失败返回 "false" - */ - private String result; - /** - * 查询结果失败时的错误信息 - */ - private String message; - - /** - * 轨迹数组 - */ - @JsonProperty("data") - private List tracks; - - @Data - public static class ExpressTrack { - - /** - * 轨迹发生时间 - */ - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - private LocalDateTime time; - - /** - * 轨迹描述 - */ - private String context; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryReqDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryReqDTO.java deleted file mode 100644 index bcb6e3353..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryReqDTO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -/** - * 快递鸟快递查询 Req DTO - * - * @author jason - */ -@Data -@JsonInclude(JsonInclude.Include.NON_NULL) -public class KdNiaoExpressQueryReqDTO { - - /** - * 快递公司编码 - */ - @JsonProperty("ShipperCode") - private String expressCode; - /** - * 快递单号 - */ - @JsonProperty("LogisticCode") - private String logisticsNo; - /** - * 订单编号 - */ - @JsonProperty("OrderCode") - private String orderNo; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryRespDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryRespDTO.java deleted file mode 100644 index 04a7c1431..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/dto/kdniao/KdNiaoExpressQueryRespDTO.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; - -/** - * 快递鸟快递查询 Resp DTO - * - * 参见 快递鸟接口文档 - * - * @author jason - */ -@Data -public class KdNiaoExpressQueryRespDTO { - - /** - * 快递公司编码 - */ - @JsonProperty("ShipperCode") - private String shipperCode; - - /** - * 快递单号 - */ - @JsonProperty("LogisticCode") - private String logisticsNo; - - /** - * 订单编号 - */ - @JsonProperty("OrderCode") - private String orderNo; - - /** - * 用户 ID - */ - @JsonProperty("EBusinessID") - private String businessId; - - /** - * 普通物流状态 - * - * 0 - 暂无轨迹信息 - * 1 - 已揽收 - * 2 - 在途中 - * 3 - 签收 - * 4 - 问题件 - * 5 - 转寄 - * 6 - 清关 - */ - @JsonProperty("State") - private String state; - - /** - * 成功与否 - */ - @JsonProperty("Success") - private Boolean success; - /** - * 失败原因 - */ - @JsonProperty("Reason") - private String reason; - - /** - * 轨迹数组 - */ - @JsonProperty("Traces") - private List tracks; - - @Data - public static class ExpressTrack { - - /** - * 发生时间 - */ - @JsonProperty("AcceptTime") - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) - @JsonDeserialize(using = LocalDateTimeDeserializer.class) - private LocalDateTime acceptTime; - - /** - * 轨迹描述 - */ - @JsonProperty("AcceptStation") - private String acceptStation; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/ExpressClientFactoryImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/ExpressClientFactoryImpl.java deleted file mode 100644 index d4432b264..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/ExpressClientFactoryImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kd100.Kd100ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kdniao.KdNiaoExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.enums.ExpressClientEnum; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClientFactory; -import lombok.AllArgsConstructor; -import org.springframework.web.client.RestTemplate; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * 快递客户端工厂实现类 - * - * @author jason - */ -@AllArgsConstructor -public class ExpressClientFactoryImpl implements ExpressClientFactory { - - private final Map clientMap = new ConcurrentHashMap<>(8); - - private final TradeExpressProperties tradeExpressProperties; - private final RestTemplate restTemplate; - - @Override - public ExpressClient getDefaultExpressClient() { - ExpressClient defaultClient = getOrCreateExpressClient(tradeExpressProperties.getClient()); - Assert.notNull("默认的快递客户端不能为空"); - return defaultClient; - } - - @Override - public ExpressClient getOrCreateExpressClient(ExpressClientEnum clientEnum) { - return clientMap.computeIfAbsent(clientEnum, - client -> createExpressClient(client, tradeExpressProperties)); - } - - private ExpressClient createExpressClient(ExpressClientEnum queryProviderEnum, - TradeExpressProperties tradeExpressProperties) { - switch (queryProviderEnum) { - case NOT_PROVIDE: - return new NoProvideExpressClient(); - case KD_NIAO: - return new KdNiaoExpressClient(restTemplate, tradeExpressProperties.getKdNiao()); - case KD_100: - return new Kd100ExpressClient(restTemplate, tradeExpressProperties.getKd100()); - } - return null; - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/NoProvideExpressClient.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/NoProvideExpressClient.java deleted file mode 100644 index 7289710f6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/NoProvideExpressClient.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl; - -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; - -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_CLIENT_NOT_PROVIDE; - -/** - * 未实现的快递客户端,用来提醒用户需要接入快递服务商, - * - * @author jason - */ -public class NoProvideExpressClient implements ExpressClient { - - @Override - public List getExpressTrackList(ExpressTrackQueryReqDTO reqDTO) { - throw exception(EXPRESS_CLIENT_NOT_PROVIDE); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kd100/Kd100ExpressClient.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kd100/Kd100ExpressClient.java deleted file mode 100644 index f04abde70..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kd100/Kd100ExpressClient.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kd100; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.HexUtil; -import cn.hutool.crypto.digest.DigestUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kd100.Kd100ExpressQueryRespDTO; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.*; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_API_QUERY_ERROR; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_API_QUERY_FAILED; -import static cn.iocoder.yudao.module.trade.framework.delivery.core.client.convert.ExpressQueryConvert.INSTANCE; - -/** - * 快递 100 客户端 - * - * @author jason - */ -@Slf4j -@AllArgsConstructor -public class Kd100ExpressClient implements ExpressClient { - - private static final String REAL_TIME_QUERY_URL = "https://poll.kuaidi100.com/poll/query.do"; - - private final RestTemplate restTemplate; - private final TradeExpressProperties.Kd100Config config; - - /** - * 查询快递轨迹 - * - * @see 接口文档 - * - * @param reqDTO 查询请求参数 - * @return 快递轨迹 - */ - @Override - public List getExpressTrackList(ExpressTrackQueryReqDTO reqDTO) { - // 发起请求 - Kd100ExpressQueryReqDTO requestDTO = INSTANCE.convert2(reqDTO) - .setExpressCode(reqDTO.getExpressCode().toLowerCase()); - Kd100ExpressQueryRespDTO respDTO = httpRequest(REAL_TIME_QUERY_URL, requestDTO, - Kd100ExpressQueryRespDTO.class); - - // 处理结果 - if (Objects.equals("false", respDTO.getResult())) { - throw exception(EXPRESS_API_QUERY_FAILED, respDTO.getMessage()); - } - if (CollUtil.isEmpty(respDTO.getTracks())) { - return Collections.emptyList(); - } - return INSTANCE.convertList2(respDTO.getTracks()); - } - - /** - * 快递 100 API 请求 - * - * @param url 请求 url - * @param req 对应请求的请求参数 - * @param respClass 对应请求的响应 class - * @param 每个请求的请求结构 Req DTO - * @param 每个请求的响应结构 Resp DTO - */ - private Resp httpRequest(String url, Req req, Class respClass) { - // 请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - // 请求体 - String param = JsonUtils.toJsonString(req); - String sign = generateReqSign(param, config.getKey(), config.getCustomer()); // 签名 - MultiValueMap requestBody = new LinkedMultiValueMap<>(); - requestBody.add("customer", config.getCustomer()); - requestBody.add("sign", sign); - requestBody.add("param", param); - log.debug("[httpRequest][请求参数({})]", requestBody); - - // 发送请求 - HttpEntity> requestEntity = new HttpEntity<>(requestBody, headers); - ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class); - log.debug("[httpRequest][的响应结果({})]", responseEntity); - // 处理响应 - if (!responseEntity.getStatusCode().is2xxSuccessful()) { - throw exception(EXPRESS_API_QUERY_ERROR); - } - return JsonUtils.parseObject(responseEntity.getBody(), respClass); - } - - private String generateReqSign(String param, String key, String customer) { - String plainText = String.format("%s%s%s", param, key, customer); - return HexUtil.encodeHexStr(DigestUtil.md5(plainText), false); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kdniao/KdNiaoExpressClient.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kdniao/KdNiaoExpressClient.java deleted file mode 100644 index 1f1116882..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/client/impl/kdniao/KdNiaoExpressClient.java +++ /dev/null @@ -1,125 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kdniao; - -import cn.hutool.core.codec.Base64; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.net.URLEncodeUtil; -import cn.hutool.crypto.digest.DigestUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClient; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao.KdNiaoExpressQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.kdniao.KdNiaoExpressQueryRespDTO; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.*; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_API_QUERY_FAILED; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_API_QUERY_ERROR; -import static cn.iocoder.yudao.module.trade.framework.delivery.core.client.convert.ExpressQueryConvert.INSTANCE; - -/** - * 快递鸟客户端 - * - * @author jason - */ -@Slf4j -@AllArgsConstructor -public class KdNiaoExpressClient implements ExpressClient { - - private static final String REAL_TIME_QUERY_URL = "https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx"; - - /** - * 快递鸟即时查询免费版 RequestType - */ - private static final String REAL_TIME_FREE_REQ_TYPE = "1002"; - - private final RestTemplate restTemplate; - private final TradeExpressProperties.KdNiaoConfig config; - - /** - * 查询快递轨迹【免费版】 - * - * 仅支持 3 家:申通快递、圆通速递、百世快递 - * - * @see 接口文档 - * - * @param reqDTO 查询请求参数 - * @return 快递轨迹 - */ - @Override - public List getExpressTrackList(ExpressTrackQueryReqDTO reqDTO) { - // 发起请求 - KdNiaoExpressQueryReqDTO requestDTO = INSTANCE.convert(reqDTO) - .setExpressCode(reqDTO.getExpressCode().toUpperCase()); - KdNiaoExpressQueryRespDTO respDTO = httpRequest(REAL_TIME_QUERY_URL, REAL_TIME_FREE_REQ_TYPE, - requestDTO, KdNiaoExpressQueryRespDTO.class); - - // 处理结果 - if (respDTO == null || !respDTO.getSuccess()) { - throw exception(EXPRESS_API_QUERY_FAILED, respDTO == null ? "" : respDTO.getReason()); - } - if (CollUtil.isEmpty(respDTO.getTracks())) { - return Collections.emptyList(); - } - return INSTANCE.convertList(respDTO.getTracks()); - } - - /** - * 快递鸟 API 请求 - * - * @param url 请求 url - * @param requestType 对应的请求指令 (快递鸟的 RequestType) - * @param req 对应请求的请求参数 - * @param respClass 对应请求的响应 class - * @param 每个请求的请求结构 Req DTO - * @param 每个请求的响应结构 Resp DTO - */ - private Resp httpRequest(String url, String requestType, Req req, Class respClass) { - // 请求头 - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - // 请求体 - String reqData = JsonUtils.toJsonString(req); - String dataSign = generateDataSign(reqData, config.getApiKey()); - MultiValueMap requestBody = new LinkedMultiValueMap<>(); - requestBody.add("RequestData", reqData); - requestBody.add("DataType", "2"); - requestBody.add("EBusinessID", config.getBusinessId()); - requestBody.add("DataSign", dataSign); - requestBody.add("RequestType", requestType); - log.debug("[httpRequest][RequestType({}) 的请求参数({})]", requestType, requestBody); - - // 发送请求 - HttpEntity> requestEntity = new HttpEntity<>(requestBody, headers); - ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class); - log.debug("[httpRequest][RequestType({}) 的响应结果({})", requestType, responseEntity); - // 处理响应 - if (!responseEntity.getStatusCode().is2xxSuccessful()) { - throw exception(EXPRESS_API_QUERY_ERROR); - } - return JsonUtils.parseObject(responseEntity.getBody(), respClass); - } - - /** - * 快递鸟生成请求签名 - * - * 参见 签名说明 - * - * @param reqData 请求实体 - * @param apiKey api Key - */ - private String generateDataSign(String reqData, String apiKey) { - String plainText = String.format("%s%s", reqData, apiKey); - return URLEncodeUtil.encode(Base64.encode(DigestUtil.md5Hex(plainText))); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/enums/ExpressClientEnum.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/enums/ExpressClientEnum.java deleted file mode 100644 index 81b96184c..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/delivery/core/enums/ExpressClientEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.delivery.core.enums; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 快递客户端枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -public enum ExpressClientEnum { - - NOT_PROVIDE("not-provide","未提供"), - KD_NIAO("kd-niao", "快递鸟"), - KD_100("kd-100", "快递100"); - - /** - * 快递服务商唯一编码 - */ - private final String code; - /** - * 快递服务商名称 - */ - private final String name; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java deleted file mode 100644 index 715169275..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderConfig.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.config; - -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -// TODO @LeeYan9: 可以直接给 TradeOrderProperties 一个 @Component生效哈 -/** - * @author LeeYan9 - * @since 2022-09-15 - */ -@Configuration -@EnableConfigurationProperties(TradeOrderProperties.class) -public class TradeOrderConfig { -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderProperties.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderProperties.java deleted file mode 100644 index 786c0004b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderProperties.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; - -import javax.validation.constraints.NotNull; -import java.time.Duration; - -/** - * 交易订单的配置项 - * - * @author LeeYan9 - * @since 2022-09-15 - */ -@ConfigurationProperties(prefix = "yudao.trade.order") -@Data -@Validated -public class TradeOrderProperties { - - /** - * 应用编号 - */ - @NotNull(message = "应用编号不能为空") - private Long appId; - - /** - * 支付超时时间 - */ - @NotNull(message = "支付超时时间不能为空") - private Duration payExpireTime; - - /** - * 收货超时时间 - */ - @NotNull(message = "收货超时时间不能为空") - private Duration receiveExpireTime; - - /** - * 评论超时时间 - */ - @NotNull(message = "评论超时时间不能为空") - private Duration commentExpireTime; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/annotations/TradeOrderLog.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/annotations/TradeOrderLog.java deleted file mode 100644 index cc023c10d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/annotations/TradeOrderLog.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.core.annotations; - -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderOperateTypeEnum; -import cn.iocoder.yudao.module.trade.framework.order.core.aop.TradeOrderLogAspect; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.METHOD; - -/** - * 交易订单的操作日志 AOP 注解 - * - * @author 陈賝 - * @since 2023/7/6 15:37 - * @see TradeOrderLogAspect - */ -@Target({METHOD, ANNOTATION_TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface TradeOrderLog { - - /** - * 操作类型 - */ - TradeOrderOperateTypeEnum operateType(); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/aop/TradeOrderLogAspect.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/aop/TradeOrderLogAspect.java deleted file mode 100644 index ccdf91c61..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/aop/TradeOrderLogAspect.java +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.core.aop; - - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.framework.order.core.annotations.TradeOrderLog; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderLogService; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeOrderLogCreateReqBO; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.AfterReturning; -import org.aspectj.lang.annotation.Aspect; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static java.util.Collections.emptyMap; - -/** - * 交易订单的操作日志的记录 AOP 切面 - * - * @author 陈賝 - * @since 2023/6/13 13:54 - */ -@Component -@Aspect -@Slf4j -public class TradeOrderLogAspect { - - /** - * 用户编号 - * - * 目前的使用场景:支付回调时,需要强制设置下用户编号 - */ - private static final ThreadLocal USER_ID = new ThreadLocal<>(); - /** - * 用户类型 - */ - private static final ThreadLocal USER_TYPE = new ThreadLocal<>(); - /** - * 订单编号 - */ - private static final ThreadLocal ORDER_ID = new ThreadLocal<>(); - /** - * 操作前的状态 - */ - private static final ThreadLocal BEFORE_STATUS = new ThreadLocal<>(); - /** - * 操作后的状态 - */ - private static final ThreadLocal AFTER_STATUS = new ThreadLocal<>(); - /** - * 拓展参数 Map,用于格式化操作内容 - */ - private static final ThreadLocal> EXTS = new ThreadLocal<>(); - - @Resource - private TradeOrderLogService orderLogService; - - @AfterReturning("@annotation(orderLog)") - public void doAfterReturning(JoinPoint joinPoint, TradeOrderLog orderLog) { - try { - // 1.1 操作用户 - Integer userType = getUserType(); - Long userId = getUserId(); - // 1.2 订单信息 - Long orderId = ORDER_ID.get(); - if (orderId == null) { // 如果未设置,只有注解,说明不需要记录日志 - return; - } - Integer beforeStatus = BEFORE_STATUS.get(); - Integer afterStatus = AFTER_STATUS.get(); - Map exts = ObjectUtil.defaultIfNull(EXTS.get(), emptyMap()); - String content = StrUtil.format(orderLog.operateType().getContent(), exts); - - // 2. 记录日志 - TradeOrderLogCreateReqBO createBO = new TradeOrderLogCreateReqBO() - .setUserId(userId).setUserType(userType) - .setOrderId(orderId).setBeforeStatus(beforeStatus).setAfterStatus(afterStatus) - .setOperateType(orderLog.operateType().getType()).setContent(content); - orderLogService.createOrderLog(createBO); - } catch (Exception ex) { - log.error("[doAfterReturning][orderLog({}) 订单日志错误]", toJsonString(orderLog), ex); - } finally { - clear(); - } - } - - /** - * 获得用户类型 - * - * 如果没有,则约定为 {@link TradeOrderLogDO#getUserType()} 系统 - * - * @return 用户类型 - */ - private static Integer getUserType() { - return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserType(), TradeOrderLogDO.USER_TYPE_SYSTEM); - } - - /** - * 获得用户编号 - * - * 如果没有,则约定为 {@link TradeOrderLogDO#getUserId()} 系统 - * - * @return 用户类型 - */ - private static Long getUserId() { - return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserId(), TradeOrderLogDO.USER_ID_SYSTEM); - } - - public static void setOrderInfo(Long id, Integer beforeStatus, Integer afterStatus, Map exts) { - ORDER_ID.set(id); - BEFORE_STATUS.set(beforeStatus); - AFTER_STATUS.set(afterStatus); - EXTS.set(exts); - } - - public static void setUserInfo(Long userId, Integer userType) { - USER_ID.set(userId); - USER_TYPE.set(userType); - } - - private static void clear() { - USER_ID.remove(); - USER_TYPE.remove(); - ORDER_ID.remove(); - BEFORE_STATUS.remove(); - AFTER_STATUS.remove(); - EXTS.remove(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/utils/TradeOrderLogUtils.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/utils/TradeOrderLogUtils.java deleted file mode 100644 index d134b7573..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/utils/TradeOrderLogUtils.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.order.core.utils; - -import cn.iocoder.yudao.module.trade.framework.order.core.aop.TradeOrderLogAspect; - -import java.util.Map; - -/** - * 交易订单的操作日志 Utils - * - * @author 芋道源码 - */ -public class TradeOrderLogUtils { - - public static void setOrderInfo(Long id, Integer beforeStatus, Integer afterStatus) { - TradeOrderLogAspect.setOrderInfo(id, beforeStatus, afterStatus, null); - } - - public static void setOrderInfo(Long id, Integer beforeStatus, Integer afterStatus, - Map exts) { - TradeOrderLogAspect.setOrderInfo(id, beforeStatus, afterStatus, exts); - } - - public static void setUserInfo(Long userId, Integer userType) { - TradeOrderLogAspect.setUserInfo(userId, userType); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/package-info.java deleted file mode 100644 index 68c67112f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 trade 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.trade.framework; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/rpc/config/RpcConfiguration.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index 2e795cb54..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.rpc.config; - -import cn.iocoder.yudao.module.member.api.address.MemberAddressApi; -import cn.iocoder.yudao.module.member.api.config.MemberConfigApi; -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.point.MemberPointApi; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; -import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; -import cn.iocoder.yudao.module.product.api.category.ProductCategoryApi; -import cn.iocoder.yudao.module.product.api.comment.ProductCommentApi; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.promotion.api.bargain.BargainActivityApi; -import cn.iocoder.yudao.module.promotion.api.bargain.BargainRecordApi; -import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; -import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; -import cn.iocoder.yudao.module.promotion.api.discount.DiscountActivityApi; -import cn.iocoder.yudao.module.promotion.api.reward.RewardActivityApi; -import cn.iocoder.yudao.module.promotion.api.seckill.SeckillActivityApi; -import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = { - BargainActivityApi.class, BargainRecordApi.class, CombinationRecordApi.class, - CouponApi.class, DiscountActivityApi.class, RewardActivityApi.class, SeckillActivityApi.class, - MemberUserApi.class, MemberPointApi.class, MemberLevelApi.class, MemberAddressApi.class, MemberConfigApi.class, - ProductSpuApi.class, ProductSkuApi.class, ProductCommentApi.class, ProductCategoryApi.class, - PayOrderApi.class, PayRefundApi.class, - NotifyMessageSendApi.class -}) -public class RpcConfiguration { -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/rpc/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/rpc/package-info.java deleted file mode 100644 index 42531afa8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.trade.framework.rpc; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/security/config/SecurityConfiguration.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 64c0e3db9..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.trade.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.member.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Trade 模块的 Security 配置 - */ -@Configuration("tradeSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("tradeAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/security/core/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/security/core/package-info.java deleted file mode 100644 index 0ec1e46e7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.trade.framework.security.core; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/BrokerageRecordUnfreezeJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/BrokerageRecordUnfreezeJob.java deleted file mode 100644 index fa968dedc..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/brokerage/BrokerageRecordUnfreezeJob.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.trade.job.brokerage; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 佣金解冻 Job - * - * @author owen - */ -@Component -public class BrokerageRecordUnfreezeJob { - - @Resource - private BrokerageRecordService brokerageRecordService; - - @XxlJob("brokerageRecordUnfreezeJob") - @TenantJob // 多租户 - public String execute(String param) { - int count = brokerageRecordService.unfreezeRecord(); - return StrUtil.format("解冻佣金 {} 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCancelJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCancelJob.java deleted file mode 100644 index cdff918ad..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCancelJob.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.job.order; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 交易订单的自动过期 Job - * - * @author 芋道源码 - */ -@Component -public class TradeOrderAutoCancelJob { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - - @XxlJob("tradeOrderAutoCancelJob") - @TenantJob // 多租户 - public String execute() { - int count = tradeOrderUpdateService.cancelOrderBySystem(); - return String.format("过期订单 %s 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCommentJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCommentJob.java deleted file mode 100644 index 8537bf76b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoCommentJob.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.job.order; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 交易订单的自动评论 Job - * - * @author 芋道源码 - */ -@Component -public class TradeOrderAutoCommentJob { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - - @XxlJob("tradeOrderAutoCommentJob") - @TenantJob // 多租户 - public String execute() { - int count = tradeOrderUpdateService.createOrderItemCommentBySystem(); - return String.format("评论订单 %s 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoReceiveJob.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoReceiveJob.java deleted file mode 100644 index 93e3054dd..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/job/order/TradeOrderAutoReceiveJob.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.trade.job.order; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 交易订单的自动收货 Job - * - * @author 芋道源码 - */ -@Component -public class TradeOrderAutoReceiveJob { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - - @XxlJob("tradeOrderAutoReceiveJob") - @TenantJob // 多租户 - public String execute() { - int count = tradeOrderUpdateService.receiveOrderBySystem(); - return String.format("自动收货 %s 个", count); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/package-info.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/package-info.java deleted file mode 100644 index eba4aa766..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * trade 模块,product 模块,主要实现商品相关功能 - * 例如:品牌、商品分类、spu、sku等功能。 - * - * 1. Controller URL:以 /product/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 product_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.trade; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogService.java deleted file mode 100644 index 2620ca0c6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogService.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - - -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.service.aftersale.bo.AfterSaleLogCreateReqBO; - -import java.util.List; - -/** - * 交易售后日志 Service 接口 - * - * @author 陈賝 - * @since 2023/6/12 14:18 - */ -public interface AfterSaleLogService { - - /** - * 创建售后日志 - * - * @param createReqBO 日志记录 - * @author 陈賝 - * @since 2023/6/12 14:18 - */ - void createAfterSaleLog(AfterSaleLogCreateReqBO createReqBO); - - /** - * 获取售后日志 - * - * @param afterSaleId 售后编号 - * @return 售后日志 - */ - List getAfterSaleLogList(Long afterSaleId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogServiceImpl.java deleted file mode 100644 index 280af9276..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleLogServiceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - -import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleLogConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleLogDO; -import cn.iocoder.yudao.module.trade.dal.mysql.aftersale.AfterSaleLogMapper; -import cn.iocoder.yudao.module.trade.service.aftersale.bo.AfterSaleLogCreateReqBO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 交易售后日志 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class AfterSaleLogServiceImpl implements AfterSaleLogService { - - @Resource - private AfterSaleLogMapper afterSaleLogMapper; - - @Override - public void createAfterSaleLog(AfterSaleLogCreateReqBO createReqBO) { - AfterSaleLogDO afterSaleLog = AfterSaleLogConvert.INSTANCE.convert(createReqBO); - afterSaleLogMapper.insert(afterSaleLog); - } - - @Override - public List getAfterSaleLogList(Long afterSaleId) { - return afterSaleLogMapper.selectListByAfterSaleId(afterSaleId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java deleted file mode 100644 index 1a0c1e95d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleService.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; - -/** - * 售后订单 Service 接口 - * - * @author 芋道源码 - */ -public interface AfterSaleService { - - /** - * 【管理员】获得售后订单分页 - * - * @param pageReqVO 分页查询 - * @return 售后订单分页 - */ - PageResult getAfterSalePage(AfterSalePageReqVO pageReqVO); - - /** - * 【会员】获得售后订单分页 - * - * @param userId 用户编号 - * @param pageParam 分页参数 - * @return 售后订单分页 - */ - PageResult getAfterSalePage(Long userId, PageParam pageParam); - - /** - * 【会员】获得售后单 - * - * @param userId 用户编号 - * @param id 售后编号 - * @return 售后订单 - */ - AfterSaleDO getAfterSale(Long userId, Long id); - - /** - * 【管理员】获得售后单 - * - * @param id 售后编号 - * @return 售后订单 - */ - AfterSaleDO getAfterSale(Long id); - - /** - * 【会员】创建售后订单 - * - * @param userId 会员用户编号 - * @param createReqVO 创建 Request 信息 - * @return 售后编号 - */ - Long createAfterSale(Long userId, AppAfterSaleCreateReqVO createReqVO); - - /** - * 【管理员】同意售后订单 - * - * @param userId 管理员用户编号 - * @param id 售后编号 - */ - void agreeAfterSale(Long userId, Long id); - - /** - * 【管理员】拒绝售后订单 - * - * @param userId 管理员用户编号 - * @param auditReqVO 审批 Request 信息 - */ - void disagreeAfterSale(Long userId, AfterSaleDisagreeReqVO auditReqVO); - - /** - * 【会员】退回货物 - * - * @param userId 会员用户编号 - * @param deliveryReqVO 退货 Request 信息 - */ - void deliveryAfterSale(Long userId, AppAfterSaleDeliveryReqVO deliveryReqVO); - - /** - * 【管理员】确认收货 - * - * @param userId 管理员编号 - * @param id 售后编号 - */ - void receiveAfterSale(Long userId, Long id); - - /** - * 【管理员】拒绝收货 - * - * @param userId 管理员用户编号 - * @param refuseReqVO 拒绝收货 Request 信息 - */ - void refuseAfterSale(Long userId, AfterSaleRefuseReqVO refuseReqVO); - - /** - * 【管理员】确认退款 - * - * @param userId 管理员用户编号 - * @param userIp 管理员用户 IP - * @param id 售后编号 - */ - void refundAfterSale(Long userId, String userIp, Long id); - - /** - * 【会员】取消售后 - * - * @param userId 会员用户编号 - * @param id 售后编号 - */ - void cancelAfterSale(Long userId, Long id); - - /** - * 【会员】获得正在进行中的售后订单数量 - * - * @param userId 用户编号 - * @return 数量 - */ - Long getApplyingAfterSaleCount(Long userId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java deleted file mode 100644 index 3b96fb7ba..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/AfterSaleServiceImpl.java +++ /dev/null @@ -1,415 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleDisagreeReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSalePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.AfterSaleRefuseReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppAfterSaleDeliveryReqVO; -import cn.iocoder.yudao.module.trade.convert.aftersale.AfterSaleConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.aftersale.AfterSaleMapper; -import cn.iocoder.yudao.module.trade.dal.redis.no.TradeNoRedisDAO; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleTypeEnum; -import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleWayEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.framework.aftersale.core.annotations.AfterSaleLog; -import cn.iocoder.yudao.module.trade.framework.aftersale.core.utils.AfterSaleLogUtils; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 售后订单 Service 实现类 - * - * @author 芋道源码 - */ -@Slf4j -@Service -@Validated -public class AfterSaleServiceImpl implements AfterSaleService { - - @Resource - private TradeOrderUpdateService tradeOrderUpdateService; - @Resource - private TradeOrderQueryService tradeOrderQueryService; - @Resource - private DeliveryExpressService deliveryExpressService; - - @Resource - private AfterSaleMapper tradeAfterSaleMapper; - @Resource - private TradeNoRedisDAO tradeNoRedisDAO; - - @Resource - private PayRefundApi payRefundApi; - - @Resource - private TradeOrderProperties tradeOrderProperties; - - @Override - public PageResult getAfterSalePage(AfterSalePageReqVO pageReqVO) { - return tradeAfterSaleMapper.selectPage(pageReqVO); - } - - @Override - public PageResult getAfterSalePage(Long userId, PageParam pageParam) { - return tradeAfterSaleMapper.selectPage(userId, pageParam); - } - - @Override - public AfterSaleDO getAfterSale(Long userId, Long id) { - return tradeAfterSaleMapper.selectByIdAndUserId(id, userId); - } - - @Override - public AfterSaleDO getAfterSale(Long id) { - return tradeAfterSaleMapper.selectById(id); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.MEMBER_CREATE) - public Long createAfterSale(Long userId, AppAfterSaleCreateReqVO createReqVO) { - // 第一步,前置校验 - TradeOrderItemDO tradeOrderItem = validateOrderItemApplicable(userId, createReqVO); - - // 第二步,存储售后订单 - AfterSaleDO afterSale = createAfterSale(createReqVO, tradeOrderItem); - return afterSale.getId(); - } - - /** - * 校验交易订单项是否可以申请售后 - * - * @param userId 用户编号 - * @param createReqVO 售后创建信息 - * @return 交易订单项 - */ - private TradeOrderItemDO validateOrderItemApplicable(Long userId, AppAfterSaleCreateReqVO createReqVO) { - // 校验订单项存在 - TradeOrderItemDO orderItem = tradeOrderQueryService.getOrderItem(userId, createReqVO.getOrderItemId()); - if (orderItem == null) { - throw exception(ORDER_ITEM_NOT_FOUND); - } - // 已申请售后,不允许再发起售后申请 - if (!TradeOrderItemAfterSaleStatusEnum.isNone(orderItem.getAfterSaleStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_ITEM_APPLIED); - } - // 申请的退款金额,不能超过商品的价格 - if (createReqVO.getRefundPrice() > orderItem.getPayPrice()) { - throw exception(AFTER_SALE_CREATE_FAIL_REFUND_PRICE_ERROR); - } - - // 校验订单存在 - TradeOrderDO order = tradeOrderQueryService.getOrder(userId, orderItem.getOrderId()); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // TODO 芋艿:超过一定时间,不允许售后 - // 已取消,无法发起售后 - if (TradeOrderStatusEnum.isCanceled(order.getStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_STATUS_CANCELED); - } - // 未支付,无法发起售后 - if (!TradeOrderStatusEnum.havePaid(order.getStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_PAID); - } - // 如果是【退货退款】的情况,需要额外校验是否发货 - if (createReqVO.getWay().equals(AfterSaleWayEnum.RETURN_AND_REFUND.getWay()) - && !TradeOrderStatusEnum.haveDelivered(order.getStatus())) { - throw exception(AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_DELIVERED); - } - return orderItem; - } - - private AfterSaleDO createAfterSale(AppAfterSaleCreateReqVO createReqVO, - TradeOrderItemDO orderItem) { - // 创建售后单 - AfterSaleDO afterSale = AfterSaleConvert.INSTANCE.convert(createReqVO, orderItem); - afterSale.setNo(tradeNoRedisDAO.generate(TradeNoRedisDAO.AFTER_SALE_NO_PREFIX)); - afterSale.setStatus(AfterSaleStatusEnum.APPLY.getStatus()); - // 标记是售中还是售后 - TradeOrderDO order = tradeOrderQueryService.getOrder(orderItem.getUserId(), orderItem.getOrderId()); - afterSale.setOrderNo(order.getNo()); // 记录 orderNo 订单流水,方便后续检索 - afterSale.setType(TradeOrderStatusEnum.isCompleted(order.getStatus()) - ? AfterSaleTypeEnum.AFTER_SALE.getType() : AfterSaleTypeEnum.IN_SALE.getType()); - tradeAfterSaleMapper.insert(afterSale); - - // 更新交易订单项的售后状态 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleCreate(orderItem.getId(), afterSale.getId()); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), null, - AfterSaleStatusEnum.APPLY.getStatus()); - - // TODO 发送售后消息 - return afterSale; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_AGREE_APPLY) - public void agreeAfterSale(Long userId, Long id) { - // 校验售后单存在,并状态未审批 - AfterSaleDO afterSale = validateAfterSaleAuditable(id); - - // 更新售后单的状态 - // 情况一:退款:标记为 WAIT_REFUND 状态。后续等退款发起成功后,在标记为 COMPLETE 状态 - // 情况二:退货退款:需要等用户退货后,才能发起退款 - Integer newStatus = afterSale.getWay().equals(AfterSaleWayEnum.REFUND.getWay()) ? - AfterSaleStatusEnum.WAIT_REFUND.getStatus() : AfterSaleStatusEnum.SELLER_AGREE.getStatus(); - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.APPLY.getStatus(), new AfterSaleDO() - .setStatus(newStatus).setAuditUserId(userId).setAuditTime(LocalDateTime.now())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), newStatus); - - // TODO 发送售后消息 - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_DISAGREE_APPLY) - public void disagreeAfterSale(Long userId, AfterSaleDisagreeReqVO auditReqVO) { - // 校验售后单存在,并状态未审批 - AfterSaleDO afterSale = validateAfterSaleAuditable(auditReqVO.getId()); - - // 更新售后单的状态 - Integer newStatus = AfterSaleStatusEnum.SELLER_DISAGREE.getStatus(); - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.APPLY.getStatus(), new AfterSaleDO() - .setStatus(newStatus).setAuditUserId(userId).setAuditTime(LocalDateTime.now()) - .setAuditReason(auditReqVO.getAuditReason())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), newStatus); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【未申请】 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId()); - } - - /** - * 校验售后单是否可审批(同意售后、拒绝售后) - * - * @param id 售后编号 - * @return 售后单 - */ - private AfterSaleDO validateAfterSaleAuditable(Long id) { - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.APPLY.getStatus())) { - throw exception(AFTER_SALE_AUDIT_FAIL_STATUS_NOT_APPLY); - } - return afterSale; - } - - private void updateAfterSaleStatus(Long id, Integer status, AfterSaleDO updateObj) { - int updateCount = tradeAfterSaleMapper.updateByIdAndStatus(id, status, updateObj); - if (updateCount == 0) { - throw exception(AFTER_SALE_UPDATE_STATUS_FAIL); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.MEMBER_DELIVERY) - public void deliveryAfterSale(Long userId, AppAfterSaleDeliveryReqVO deliveryReqVO) { - // 校验售后单存在,并状态未退货 - AfterSaleDO afterSale = tradeAfterSaleMapper.selectByIdAndUserId(deliveryReqVO.getId(), userId); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.SELLER_AGREE.getStatus())) { - throw exception(AFTER_SALE_DELIVERY_FAIL_STATUS_NOT_SELLER_AGREE); - } - DeliveryExpressDO express = deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId()); - - // 更新售后单的物流信息 - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.SELLER_AGREE.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.BUYER_DELIVERY.getStatus()) - .setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()) - .setDeliveryTime(LocalDateTime.now())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(), - MapUtil.builder().put("deliveryName", express.getName()) - .put("logisticsNo", deliveryReqVO.getLogisticsNo()).build()); - - // TODO 发送售后消息 - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_AGREE_RECEIVE) - public void receiveAfterSale(Long userId, Long id) { - // 校验售后单存在,并状态为已退货 - AfterSaleDO afterSale = validateAfterSaleReceivable(id); - - // 更新售后单的状态 - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.WAIT_REFUND.getStatus()).setReceiveTime(LocalDateTime.now())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.WAIT_REFUND.getStatus()); - - // TODO 发送售后消息 - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_DISAGREE_RECEIVE) - public void refuseAfterSale(Long userId, AfterSaleRefuseReqVO refuseReqVO) { - // 校验售后单存在,并状态为已退货 - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(refuseReqVO.getId()); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.BUYER_DELIVERY.getStatus())) { - throw exception(AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_DELIVERY); - } - - // 更新售后单的状态 - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.SELLER_REFUSE.getStatus()).setReceiveTime(LocalDateTime.now()) - .setReceiveReason(refuseReqVO.getRefuseMemo())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.SELLER_REFUSE.getStatus(), - MapUtil.of("reason", refuseReqVO.getRefuseMemo())); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【未申请】 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId()); - } - - /** - * 校验售后单是否可收货,即处于买家已发货 - * - * @param id 售后编号 - * @return 售后单 - */ - private AfterSaleDO validateAfterSaleReceivable(Long id) { - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.BUYER_DELIVERY.getStatus())) { - throw exception(AFTER_SALE_CONFIRM_FAIL_STATUS_NOT_BUYER_DELIVERY); - } - return afterSale; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.ADMIN_REFUND) - public void refundAfterSale(Long userId, String userIp, Long id) { - // 校验售后单的状态,并状态待退款 - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (ObjectUtil.notEqual(afterSale.getStatus(), AfterSaleStatusEnum.WAIT_REFUND.getStatus())) { - throw exception(AFTER_SALE_REFUND_FAIL_STATUS_NOT_WAIT_REFUND); - } - - // 发起退款单。注意,需要在事务提交后,再进行发起,避免重复发起 - createPayRefund(userIp, afterSale); - - // 更新售后单的状态为【已完成】 - updateAfterSaleStatus(afterSale.getId(), AfterSaleStatusEnum.WAIT_REFUND.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.COMPLETE.getStatus()).setRefundTime(LocalDateTime.now())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.COMPLETE.getStatus()); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【已完成】 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleSuccess(afterSale.getOrderItemId(), afterSale.getRefundPrice()); - } - - private void createPayRefund(String userIp, AfterSaleDO afterSale) { - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - - @Override - public void afterCommit() { - // 创建退款单 - PayRefundCreateReqDTO createReqDTO = AfterSaleConvert.INSTANCE.convert(userIp, afterSale, tradeOrderProperties) - .setReason(StrUtil.format("退款【{}】", afterSale.getSpuName())); - Long payRefundId = payRefundApi.createRefund(createReqDTO).getCheckedData(); - // 更新售后单的退款单号 - tradeAfterSaleMapper.updateById(new AfterSaleDO().setId(afterSale.getId()).setPayRefundId(payRefundId)); - } - }); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @AfterSaleLog(operateType = AfterSaleOperateTypeEnum.MEMBER_CANCEL) - public void cancelAfterSale(Long userId, Long id) { - // 校验售后单的状态,并状态待退款 - AfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id); - if (afterSale == null) { - throw exception(AFTER_SALE_NOT_FOUND); - } - if (!ObjectUtils.equalsAny(afterSale.getStatus(), AfterSaleStatusEnum.APPLY.getStatus(), - AfterSaleStatusEnum.SELLER_AGREE.getStatus(), - AfterSaleStatusEnum.BUYER_DELIVERY.getStatus())) { - throw exception(AFTER_SALE_CANCEL_FAIL_STATUS_NOT_APPLY_OR_AGREE_OR_BUYER_DELIVERY); - } - - // 更新售后单的状态为【已取消】 - updateAfterSaleStatus(afterSale.getId(), afterSale.getStatus(), new AfterSaleDO() - .setStatus(AfterSaleStatusEnum.BUYER_CANCEL.getStatus())); - - // 记录售后日志 - AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), - AfterSaleStatusEnum.BUYER_CANCEL.getStatus()); - - // TODO 发送售后消息 - - // 更新交易订单项的售后状态为【未申请】 - tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId()); - } - - @Override - public Long getApplyingAfterSaleCount(Long userId) { - return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, AfterSaleStatusEnum.APPLYING_STATUSES); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/bo/AfterSaleLogCreateReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/bo/AfterSaleLogCreateReqBO.java deleted file mode 100644 index 5793fed2b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/bo/AfterSaleLogCreateReqBO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.aftersale.bo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 售后日志的创建 Request BO - * - * @author 陈賝 - * @since 2023/6/19 09:54 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class AfterSaleLogCreateReqBO { - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - /** - * 用户类型 - */ - @NotNull(message = "用户类型不能为空") - private Integer userType; - - /** - * 售后编号 - */ - @NotNull(message = "售后编号不能为空") - private Long afterSaleId; - /** - * 操作前状态 - */ - private Integer beforeStatus; - /** - * 操作后状态 - */ - @NotNull(message = "操作后的状态不能为空") - private Integer afterStatus; - - /** - * 操作类型 - */ - @NotNull(message = "操作类型不能为空") - private Integer operateType; - /** - * 操作明细 - */ - @NotEmpty(message = "操作明细不能为空") - private String content; -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java deleted file mode 100644 index 1cf1e2443..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java +++ /dev/null @@ -1,159 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageAddReqBO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; - -import javax.validation.Valid; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 佣金记录 Service 接口 - * - * @author owen - */ -public interface BrokerageRecordService { - - /** - * 获得佣金记录 - * - * @param id 编号 - * @return 佣金记录 - */ - BrokerageRecordDO getBrokerageRecord(Integer id); - - /** - * 获得佣金记录分页 - * - * @param pageReqVO 分页查询 - * @return 佣金记录分页 - */ - PageResult getBrokerageRecordPage(BrokerageRecordPageReqVO pageReqVO); - - /** - * 增加佣金【多级分佣】 - * - * @param userId 会员编号 - * @param bizType 业务类型 - * @param list 请求参数列表 - */ - void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, @Valid List list); - - /** - * 增加佣金【只针对自己】 - * - * @param userId 会员编号 - * @param bizType 业务类型 - * @param bizId 业务编号 - * @param brokeragePrice 佣金 - * @param title 标题 - */ - void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title); - - /** - * 减少佣金【只针对自己】 - * - * @param userId 会员编号 - * @param bizType 业务类型 - * @param bizId 业务编号 - * @param brokeragePrice 佣金 - * @param title 标题 - */ - default void reduceBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title) { - addBrokerage(userId, bizType, bizId, -brokeragePrice, title); - } - - /** - * 取消佣金:将佣金记录,状态修改为已失效 - * - * @param userId 会员编号 - * @param bizType 业务类型 - * @param bizId 业务编号 - */ - void cancelBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId); - - /** - * 解冻佣金:将待结算的佣金记录,状态修改为已结算 - * - * @return 解冻佣金的数量 - */ - int unfreezeRecord(); - - /** - * 按照 userId,汇总每个用户的佣金 - * - * @param userIds 用户编号 - * @param bizType 业务类型 - * @param status 佣金状态 - * @return 用户佣金汇总 List - */ - List getUserBrokerageSummaryListByUserId(Collection userIds, - Integer bizType, Integer status); - - /** - * 按照 userId,汇总每个用户的佣金 - * - * @param userIds 用户编号 - * @param bizType 业务类型 - * @param status 佣金状态 - * @return 用户佣金汇总 Map - */ - default Map getUserBrokerageSummaryMapByUserId(Collection userIds, - Integer bizType, Integer status) { - return convertMap(getUserBrokerageSummaryListByUserId(userIds, bizType, status), - UserBrokerageSummaryRespBO::getUserId); - } - - /** - * 获得用户佣金合计 - * - * @param userId 用户编号 - * @param bizType 业务类型 - * @param status 状态 - * @param beginTime 开始时间 - * @param endTime 截止时间 - * @return 用户佣金合计 - */ - Integer getSummaryPriceByUserId(Long userId, BrokerageRecordBizTypeEnum bizType, BrokerageRecordStatusEnum status, - LocalDateTime beginTime, LocalDateTime endTime); - - /** - * 获得用户佣金排行分页列表(基于佣金总数) - * - * @param pageReqVO 分页查询 - * @return 排行榜分页 - */ - PageResult getBrokerageUserChildSummaryPageByPrice( - AppBrokerageUserRankPageReqVO pageReqVO); - - /** - * 获取用户的排名(基于佣金总数) - * - * @param userId 用户编号 - * @param times 时间范围 - * @return 用户的排名 - */ - Integer getUserRankByPrice(Long userId, LocalDateTime[] times); - - /** - * 计算商品被购买后,推广员可以得到的佣金 - * - * @param userId 用户编号 - * @param spuId 商品编号 - * @return 用户佣金 - */ - AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long userId, Long spuId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java deleted file mode 100644 index 915bf0bc8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java +++ /dev/null @@ -1,368 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.*; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageRecordMapper; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageAddReqBO; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryRespBO; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import com.baomidou.mybatisplus.core.metadata.IPage; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMaxValue; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH; - -/** - * 佣金记录 Service 实现类 - * - * @author owen - */ -@Slf4j -@Service -@Validated -public class BrokerageRecordServiceImpl implements BrokerageRecordService { - - @Resource - private BrokerageRecordMapper brokerageRecordMapper; - @Resource - private TradeConfigService tradeConfigService; - @Resource - private BrokerageUserService brokerageUserService; - - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Override - public BrokerageRecordDO getBrokerageRecord(Integer id) { - return brokerageRecordMapper.selectById(id); - } - - @Override - public PageResult getBrokerageRecordPage(BrokerageRecordPageReqVO pageReqVO) { - return brokerageRecordMapper.selectPage(pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, List list) { - TradeConfigDO memberConfig = tradeConfigService.getTradeConfig(); - // 0 未启用分销功能 - if (memberConfig == null || !BooleanUtil.isTrue(memberConfig.getBrokerageEnabled())) { - log.warn("[addBrokerage][增加佣金失败:brokerageEnabled 未配置,userId({})", userId); - return; - } - - // 1.1 获得一级推广人 - BrokerageUserDO firstUser = brokerageUserService.getBindBrokerageUser(userId); - if (firstUser == null || !BooleanUtil.isTrue(firstUser.getBrokerageEnabled())) { - return; - } - // 1.2 计算一级分佣 - addBrokerage(firstUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageFirstPercent(), - bizType, 1); - - // 2.1 获得二级推广员 - if (firstUser.getBindUserId() == null) { - return; - } - BrokerageUserDO secondUser = brokerageUserService.getBrokerageUser(firstUser.getBindUserId()); - if (secondUser == null || !BooleanUtil.isTrue(secondUser.getBrokerageEnabled())) { - return; - } - // 2.2 计算二级分佣 - addBrokerage(secondUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageSecondPercent(), - bizType, 2); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void cancelBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId) { - BrokerageRecordDO record = brokerageRecordMapper.selectByBizTypeAndBizIdAndUserId(bizType.getType(), bizId, userId); - if (record == null) { - log.error("[cancelBrokerage][userId({})][bizId({}) 更新为已失效失败:记录不存在]", userId, bizId); - return; - } - - // 1. 更新佣金记录为已失效 - BrokerageRecordDO updateObj = new BrokerageRecordDO().setStatus(BrokerageRecordStatusEnum.CANCEL.getStatus()); - int updateRows = brokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj); - if (updateRows == 0) { - log.error("[cancelBrokerage][record({}) 更新为已失效失败]", record.getId()); - return; - } - - // 2. 更新用户的佣金 - if (BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus().equals(record.getStatus())) { - brokerageUserService.updateUserFrozenPrice(userId, -record.getPrice()); - } else if (BrokerageRecordStatusEnum.SETTLEMENT.getStatus().equals(record.getStatus())) { - brokerageUserService.updateUserPrice(userId, -record.getPrice()); - } - } - - /** - * 计算佣金 - * - * @param basePrice 佣金基数 - * @param percent 佣金比例 - * @param fixedPrice 固定佣金 - * @return 佣金 - */ - int calculatePrice(Integer basePrice, Integer percent, Integer fixedPrice) { - // 1. 优先使用固定佣金 - if (fixedPrice != null && fixedPrice > 0) { - return ObjectUtil.defaultIfNull(fixedPrice, 0); - } - // 2. 根据比例计算佣金 - if (basePrice != null && basePrice > 0 && percent != null && percent > 0) { - return MoneyUtils.calculateRatePriceFloor(basePrice, Double.valueOf(percent)); - } - return 0; - } - - /** - * 增加用户佣金 - * - * @param user 用户 - * @param list 佣金增加参数列表 - * @param brokerageFrozenDays 冻结天数 - * @param brokeragePercent 佣金比例 - * @param bizType 业务类型 - * @param sourceUserLevel 来源用户等级 - */ - private void addBrokerage(BrokerageUserDO user, List list, Integer brokerageFrozenDays, - Integer brokeragePercent, BrokerageRecordBizTypeEnum bizType, Integer sourceUserLevel) { - // 1.1 处理冻结时间 - LocalDateTime unfreezeTime = null; - if (brokerageFrozenDays != null && brokerageFrozenDays > 0) { - unfreezeTime = LocalDateTime.now().plusDays(brokerageFrozenDays); - } - // 1.2 计算分佣 - int totalBrokerage = 0; - List records = new ArrayList<>(); - for (BrokerageAddReqBO item : list) { - // 计算金额 - Integer fixedPrice; - if (Objects.equals(sourceUserLevel, 1)) { - fixedPrice = item.getFirstFixedPrice(); - } else if (Objects.equals(sourceUserLevel, 2)) { - fixedPrice = item.getSecondFixedPrice(); - } else { - throw new IllegalArgumentException(StrUtil.format("用户等级({}) 不合法", sourceUserLevel)); - } - int brokeragePrice = calculatePrice(item.getBasePrice(), brokeragePercent, fixedPrice); - if (brokeragePrice <= 0) { - continue; - } - totalBrokerage += brokeragePrice; - // 创建记录实体 - records.add(BrokerageRecordConvert.INSTANCE.convert(user, bizType, item.getBizId(), - brokerageFrozenDays, brokeragePrice, unfreezeTime, item.getTitle(), - item.getSourceUserId(), sourceUserLevel)); - } - if (CollUtil.isEmpty(records)) { - return; - } - // 1.3 保存佣金记录 - brokerageRecordMapper.insertBatch(records); - - // 2. 更新用户佣金 - if (brokerageFrozenDays != null && brokerageFrozenDays > 0) { // 更新用户冻结佣金 - brokerageUserService.updateUserFrozenPrice(user.getId(), totalBrokerage); - } else { // 更新用户可用佣金 - brokerageUserService.updateUserPrice(user.getId(), totalBrokerage); - } - } - - @Override - public int unfreezeRecord() { - // 1. 查询待结算的佣金记录 - List records = brokerageRecordMapper.selectListByStatusAndUnfreezeTimeLt( - BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus(), LocalDateTime.now()); - if (CollUtil.isEmpty(records)) { - return 0; - } - - // 2. 遍历执行 - int count = 0; - for (BrokerageRecordDO record : records) { - try { - boolean success = getSelf().unfreezeRecord(record); - if (success) { - count++; - } - } catch (Exception e) { - log.error("[unfreezeRecord][record({}) 更新为已结算失败]", record.getId(), e); - } - } - return count; - } - - /** - * 解冻单条佣金记录 - * - * @param record 佣金记录 - * @return 解冻是否成功 - */ - @Transactional(rollbackFor = Exception.class) - public boolean unfreezeRecord(BrokerageRecordDO record) { - // 更新记录状态 - BrokerageRecordDO updateObj = new BrokerageRecordDO() - .setStatus(BrokerageRecordStatusEnum.SETTLEMENT.getStatus()) - .setUnfreezeTime(LocalDateTime.now()); - int updateRows = brokerageRecordMapper.updateByIdAndStatus(record.getId(), record.getStatus(), updateObj); - if (updateRows == 0) { - log.error("[unfreezeRecord][record({}) 更新为已结算失败]", record.getId()); - return false; - } - - // 更新用户冻结佣金 - brokerageUserService.updateFrozenPriceDecrAndPriceIncr(record.getUserId(), -record.getPrice()); - log.info("[unfreezeRecord][record({}) 更新为已结算成功]", record.getId()); - return true; - } - - @Override - public List getUserBrokerageSummaryListByUserId(Collection userIds, - Integer bizType, Integer status) { - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - return brokerageRecordMapper.selectCountAndSumPriceByUserIdInAndBizTypeAndStatus(userIds, bizType, status); - } - - @Override - public Integer getSummaryPriceByUserId(Long userId, BrokerageRecordBizTypeEnum bizType, BrokerageRecordStatusEnum status, - LocalDateTime beginTime, LocalDateTime endTime) { - return brokerageRecordMapper.selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(userId, - bizType.getType(), status.getStatus(), beginTime, endTime); - } - - @Override - public PageResult getBrokerageUserChildSummaryPageByPrice(AppBrokerageUserRankPageReqVO pageReqVO) { - IPage pageResult = brokerageRecordMapper.selectSummaryPricePageGroupByUserId( - MyBatisUtils.buildPage(pageReqVO), - BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), - ArrayUtil.get(pageReqVO.getTimes(), 0), ArrayUtil.get(pageReqVO.getTimes(), 1)); - return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); - } - - @Override - public Integer getUserRankByPrice(Long userId, LocalDateTime[] times) { - // 用户的推广金额 - Integer price = brokerageRecordMapper.selectSummaryPriceByUserIdAndBizTypeAndCreateTimeBetween(userId, - BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), - ArrayUtil.get(times, 0), ArrayUtil.get(times, 1)); - // 排在用户前面的人数 - Integer greaterCount = brokerageRecordMapper.selectCountByPriceGt(price, - BrokerageRecordBizTypeEnum.ORDER.getType(), BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), - ArrayUtil.get(times, 0), ArrayUtil.get(times, 1)); - // 获得排名 - return ObjUtil.defaultIfNull(greaterCount, 0) + 1; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title) { - // 1. 校验佣金余额 - BrokerageUserDO user = brokerageUserService.getBrokerageUser(userId); - int balance = Optional.of(user) - .map(BrokerageUserDO::getBrokeragePrice).orElse(0); - if (balance + brokeragePrice < 0) { - throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance)); - } - - // 2. 更新佣金余额 - boolean success = brokerageUserService.updateUserPrice(userId, brokeragePrice); - if (!success) { - // 失败时,则抛出异常。只会出现扣减佣金时,余额不足的情况 - throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance)); - } - - // 3. 新增记录 - BrokerageRecordDO record = BrokerageRecordConvert.INSTANCE.convert(user, bizType, bizId, 0, brokeragePrice, - null, title, null, null); - brokerageRecordMapper.insert(record); - } - - @Override - public AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long userId, Long spuId) { - // 1. 构建默认的返回值 - AppBrokerageProductPriceRespVO respVO = new AppBrokerageProductPriceRespVO().setEnabled(false) - .setBrokerageMinPrice(0).setBrokerageMaxPrice(0); - - // 2.1 校验分销功能是否开启 - TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); - if (tradeConfig == null || BooleanUtil.isFalse(tradeConfig.getBrokerageEnabled())) { - return respVO; - } - // 2.2 校验用户是否有分销资格 - respVO.setEnabled(brokerageUserService.getUserBrokerageEnabled(getLoginUserId())); - if (BooleanUtil.isFalse(respVO.getEnabled())) { - return respVO; - } - // 2.3 校验商品是否存在 - ProductSpuRespDTO spu = productSpuApi.getSpu(spuId).getCheckedData(); - if (spu == null) { - return respVO; - } - - // 3.1 商品单独分佣模式 - Integer fixedMinPrice = 0; - Integer fixedMaxPrice = 0; - Integer spuMinPrice = 0; - Integer spuMaxPrice = 0; - List skuList = productSkuApi.getSkuListBySpuId(ListUtil.of(spuId)).getCheckedData(); - if (BooleanUtil.isTrue(spu.getSubCommissionType())) { - fixedMinPrice = getMinValue(skuList, ProductSkuRespDTO::getFirstBrokeragePrice); - fixedMaxPrice = getMaxValue(skuList, ProductSkuRespDTO::getFirstBrokeragePrice); - // 3.2 全局分佣模式(根据商品价格比例计算) - } else { - spuMinPrice = getMinValue(skuList, ProductSkuRespDTO::getPrice); - spuMaxPrice = getMaxValue(skuList, ProductSkuRespDTO::getPrice); - } - respVO.setBrokerageMinPrice(calculatePrice(spuMinPrice, tradeConfig.getBrokerageFirstPercent(), fixedMinPrice)); - respVO.setBrokerageMaxPrice(calculatePrice(spuMaxPrice, tradeConfig.getBrokerageFirstPercent(), fixedMaxPrice)); - return respVO; - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private BrokerageRecordServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java deleted file mode 100644 index e5b7e7abf..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; - -import javax.validation.constraints.NotNull; -import java.util.Collection; -import java.util.List; - -/** - * 分销用户 Service 接口 - * - * @author owen - */ -public interface BrokerageUserService { - - /** - * 获得分销用户 - * - * @param id 编号 - * @return 分销用户 - */ - BrokerageUserDO getBrokerageUser(Long id); - - /** - * 获得分销用户列表 - * - * @param ids 编号 - * @return 分销用户列表 - */ - List getBrokerageUserList(Collection ids); - - /** - * 获得分销用户分页 - * - * @param pageReqVO 分页查询 - * @return 分销用户分页 - */ - PageResult getBrokerageUserPage(BrokerageUserPageReqVO pageReqVO); - - /** - * 修改推广员编号 - * - * @param id 用户编号 - * @param bindUserId 推广员编号 - */ - void updateBrokerageUserId(Long id, Long bindUserId); - - /** - * 修改推广资格 - * - * @param id 用户编号 - * @param enabled 推广资格 - */ - void updateBrokerageUserEnabled(Long id, Boolean enabled); - - /** - * 获得用户的推广人 - * - * @param id 用户编号 - * @return 用户的推广人 - */ - BrokerageUserDO getBindBrokerageUser(Long id); - - /** - * 更新用户佣金 - * - * @param id 用户编号 - * @param price 用户可用佣金 - * @return 更新结果 - */ - boolean updateUserPrice(Long id, Integer price); - - /** - * 更新用户冻结佣金 - * - * @param id 用户编号 - * @param frozenPrice 用户冻结佣金 - */ - void updateUserFrozenPrice(Long id, Integer frozenPrice); - - /** - * 更新用户冻结佣金(减少),更新用户佣金(增加) - * - * @param id 用户编号 - * @param frozenPrice 减少冻结佣金(负数) - */ - void updateFrozenPriceDecrAndPriceIncr(Long id, Integer frozenPrice); - - /** - * 获得推广用户数量 - * - * @param bindUserId 绑定的推广员编号 - * @param level 推广用户等级 - * @return 推广用户数量 - */ - Long getBrokerageUserCountByBindUserId(Long bindUserId, Integer level); - - /** - * 【会员】绑定推广员 - * - * @param userId 用户编号 - * @param bindUserId 推广员编号 - * @return 是否绑定 - */ - boolean bindBrokerageUser(@NotNull Long userId, @NotNull Long bindUserId); - - /** - * 获取用户是否有分销资格 - * - * @param userId 用户编号 - * @return 是否有分销资格 - */ - Boolean getUserBrokerageEnabled(Long userId); - - /** - * 获得推广人排行 - * - * @param pageReqVO 分页查询 - * @return 推广人排行 - */ - PageResult getBrokerageUserRankPageByUserCount(AppBrokerageUserRankPageReqVO pageReqVO); - - /** - * 获得下级分销统计分页 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return 下级分销统计分页 - */ - PageResult getBrokerageUserChildSummaryPage(AppBrokerageUserChildSummaryPageReqVO pageReqVO, Long userId); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java deleted file mode 100644 index 2ed9ec2de..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java +++ /dev/null @@ -1,356 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageUserConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageUserMapper; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMapByFilter; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 分销用户 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class BrokerageUserServiceImpl implements BrokerageUserService { - - @Resource - private BrokerageUserMapper brokerageUserMapper; - - @Resource - private TradeConfigService tradeConfigService; - - @Resource - private MemberUserApi memberUserApi; - - @Override - public BrokerageUserDO getBrokerageUser(Long id) { - return brokerageUserMapper.selectById(id); - } - - @Override - public List getBrokerageUserList(Collection ids) { - return brokerageUserMapper.selectBatchIds(ids); - } - - @Override - public PageResult getBrokerageUserPage(BrokerageUserPageReqVO pageReqVO) { - List childIds = getChildUserIdsByLevel(pageReqVO.getBindUserId(), pageReqVO.getLevel()); - // 有”绑定用户编号“查询条件时,没有查到下级会员,直接返回空 - if (pageReqVO.getBindUserId() != null && CollUtil.isEmpty(childIds)) { - return PageResult.empty(); - } - return brokerageUserMapper.selectPage(pageReqVO, childIds); - } - - @Override - public void updateBrokerageUserId(Long id, Long bindUserId) { - // 校验存在 - BrokerageUserDO brokerageUser = validateBrokerageUserExists(id); - // 绑定关系未发生变化 - if (Objects.equals(brokerageUser.getBindUserId(), bindUserId)) { - return; - } - - // 情况一:清除推广员 - if (bindUserId == null) { - // 清除推广员 - brokerageUserMapper.updateBindUserIdAndBindUserTimeToNull(id); - return; - } - - // 情况二:修改推广员 - validateCanBindUser(brokerageUser, bindUserId); - brokerageUserMapper.updateById(fillBindUserData(bindUserId, new BrokerageUserDO().setId(id))); - } - - @Override - public void updateBrokerageUserEnabled(Long id, Boolean enabled) { - // 校验存在 - validateBrokerageUserExists(id); - if (BooleanUtil.isTrue(enabled)) { - // 开通推广资格 - brokerageUserMapper.updateById(new BrokerageUserDO().setId(id) - .setBrokerageEnabled(true).setBrokerageTime(LocalDateTime.now())); - } else { - // 取消推广资格 - brokerageUserMapper.updateEnabledFalseAndBrokerageTimeToNull(id); - } - } - - private BrokerageUserDO validateBrokerageUserExists(Long id) { - BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(id); - if (brokerageUserDO == null) { - throw exception(BROKERAGE_USER_NOT_EXISTS); - } - - return brokerageUserDO; - } - - @Override - public BrokerageUserDO getBindBrokerageUser(Long id) { - return Optional.ofNullable(id) - .map(this::getBrokerageUser) - .map(BrokerageUserDO::getBindUserId) - .map(this::getBrokerageUser) - .orElse(null); - } - - @Override - public boolean updateUserPrice(Long id, Integer price) { - if (price > 0) { - brokerageUserMapper.updatePriceIncr(id, price); - } else if (price < 0) { - return brokerageUserMapper.updatePriceDecr(id, price) > 0; - } - return true; - } - - @Override - public void updateUserFrozenPrice(Long id, Integer frozenPrice) { - if (frozenPrice > 0) { - brokerageUserMapper.updateFrozenPriceIncr(id, frozenPrice); - } else if (frozenPrice < 0) { - brokerageUserMapper.updateFrozenPriceDecr(id, frozenPrice); - } - } - - @Override - public void updateFrozenPriceDecrAndPriceIncr(Long id, Integer frozenPrice) { - Assert.isTrue(frozenPrice < 0); - int updateRows = brokerageUserMapper.updateFrozenPriceDecrAndPriceIncr(id, frozenPrice); - if (updateRows == 0) { - throw exception(BROKERAGE_USER_FROZEN_PRICE_NOT_ENOUGH); - } - } - - @Override - public Long getBrokerageUserCountByBindUserId(Long bindUserId, Integer level) { - List childIds = getChildUserIdsByLevel(bindUserId, level); - return (long) CollUtil.size(childIds); - } - - @Override - public boolean bindBrokerageUser(Long userId, Long bindUserId) { - // 1. 获得分销用户 - boolean isNewBrokerageUser = false; - BrokerageUserDO brokerageUser = brokerageUserMapper.selectById(userId); - if (brokerageUser == null) { // 分销用户不存在的情况:1. 新注册;2. 旧数据;3. 分销功能关闭后又打开 - isNewBrokerageUser = true; - brokerageUser = new BrokerageUserDO().setId(userId).setBrokerageEnabled(false).setBrokeragePrice(0).setFrozenPrice(0); - } - - // 2.1 校验是否能绑定用户 - boolean validated = isUserCanBind(brokerageUser); - if (!validated) { - return false; - } - // 2.3 校验能否绑定 - validateCanBindUser(brokerageUser, bindUserId); - // 2.3 绑定用户 - if (isNewBrokerageUser) { - Integer enabledCondition = tradeConfigService.getTradeConfig().getBrokerageEnabledCondition(); - if (BrokerageEnabledConditionEnum.ALL.getCondition().equals(enabledCondition)) { // 人人分销:用户默认就有分销资格 - brokerageUser.setBrokerageEnabled(true).setBrokerageTime(LocalDateTime.now()); - } - brokerageUser.setBindUserId(bindUserId).setBindUserTime(LocalDateTime.now()); - brokerageUserMapper.insert(fillBindUserData(bindUserId, brokerageUser)); - } else { - brokerageUserMapper.updateById(fillBindUserData(bindUserId, new BrokerageUserDO().setId(userId))); - } - return true; - } - - /** - * 补全绑定用户的字段 - * - * @param bindUserId 绑定的用户编号 - * @param brokerageUser update 对象 - * @return 补全后的 update 对象 - */ - private BrokerageUserDO fillBindUserData(Long bindUserId, BrokerageUserDO brokerageUser) { - return brokerageUser.setBindUserId(bindUserId).setBindUserTime(LocalDateTime.now()); - } - - @Override - public Boolean getUserBrokerageEnabled(Long userId) { - // 全局分销功能是否开启 - TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); - if (tradeConfig == null || BooleanUtil.isFalse(tradeConfig.getBrokerageEnabled())) { - return false; - } - - // 用户是否有分销资格 - return Optional.ofNullable(getBrokerageUser(userId)) - .map(BrokerageUserDO::getBrokerageEnabled) - .orElse(false); - } - - @Override - public PageResult getBrokerageUserRankPageByUserCount(AppBrokerageUserRankPageReqVO pageReqVO) { - IPage pageResult = brokerageUserMapper.selectCountPageGroupByBindUserId(MyBatisUtils.buildPage(pageReqVO), - ArrayUtil.get(pageReqVO.getTimes(), 0), ArrayUtil.get(pageReqVO.getTimes(), 1)); - return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); - } - - @Override - public PageResult getBrokerageUserChildSummaryPage(AppBrokerageUserChildSummaryPageReqVO pageReqVO, Long userId) { - // 1.1 查询下级用户编号列表 - List childIds = getChildUserIdsByLevel(userId, pageReqVO.getLevel()); - if (CollUtil.isEmpty(childIds)) { - return PageResult.empty(); - } - // 1.2 根据昵称过滤下级用户 - List users = memberUserApi.getUserList(childIds).getCheckedData(); - Map userMap = convertMapByFilter(users, - user -> StrUtil.contains(user.getNickname(), pageReqVO.getNickname()), - MemberUserRespDTO::getId); - if (CollUtil.isEmpty(userMap)) { - return PageResult.empty(); - } - - // 2. 分页查询 - IPage pageResult = brokerageUserMapper.selectSummaryPageByUserId( - MyBatisUtils.buildPage(pageReqVO), BrokerageRecordBizTypeEnum.ORDER.getType(), - BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), userMap.keySet(), pageReqVO.getSortingField() - ); - - // 3. 拼接数据并返回 - BrokerageUserConvert.INSTANCE.copyTo(pageResult.getRecords(), userMap); - return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); - } - - private boolean isUserCanBind(BrokerageUserDO user) { - // 校验分销功能是否启用 - TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); - if (tradeConfig == null || !BooleanUtil.isTrue(tradeConfig.getBrokerageEnabled())) { - return false; - } - - // 校验分佣模式:仅可后台手动设置推广员 - if (BrokerageEnabledConditionEnum.ADMIN.getCondition().equals(tradeConfig.getBrokerageEnabledCondition())) { - throw exception(BROKERAGE_BIND_CONDITION_ADMIN); - } - - // 校验分销关系绑定模式 - if (BrokerageBindModeEnum.REGISTER.getMode().equals(tradeConfig.getBrokerageBindMode())) { - // 判断是否为新用户:注册时间在 30 秒内的,都算新用户 - if (!isNewRegisterUser(user.getId())) { - throw exception(BROKERAGE_BIND_MODE_REGISTER); // 只有在注册时可以绑定 - } - } else if (BrokerageBindModeEnum.ANYTIME.getMode().equals(tradeConfig.getBrokerageBindMode())) { - if (user.getBindUserId() != null) { - throw exception(BROKERAGE_BIND_OVERRIDE); // 已绑定了推广人 - } - } - return true; - } - - /** - * 判断是否为新用户 - *

- * 标准:注册时间在 30 秒内的,都算新用户 - *

- * 疑问:为什么通过这样的方式实现? - * 回答:因为注册在 member 模块,希望它和 trade 模块解耦,所以只能用这种约定的逻辑。 - * - * @param userId 用户编号 - * @return 是否新用户 - */ - private boolean isNewRegisterUser(Long userId) { - MemberUserRespDTO user = memberUserApi.getUser(userId).getCheckedData(); - return user != null && LocalDateTimeUtils.beforeNow(user.getCreateTime().plusSeconds(30)); - } - - private void validateCanBindUser(BrokerageUserDO user, Long bindUserId) { - // 校验要绑定的用户有无推广资格 - BrokerageUserDO bindUser = brokerageUserMapper.selectById(bindUserId); - if (bindUser == null || BooleanUtil.isFalse(bindUser.getBrokerageEnabled())) { - throw exception(BROKERAGE_BIND_USER_NOT_ENABLED); - } - - // 校验绑定自己 - if (Objects.equals(user.getId(), bindUserId)) { - throw exception(BROKERAGE_BIND_SELF); - } - - // 下级不能绑定自己的上级 - for (int i = 0; i <= Short.MAX_VALUE; i++) { - if (Objects.equals(bindUser.getBindUserId(), user.getId())) { - throw exception(BROKERAGE_BIND_LOOP); - } - bindUser = getBrokerageUser(bindUser.getBindUserId()); - // 找到根节点,结束循环 - if (bindUser == null || bindUser.getBindUserId() == null) { - break; - } - } - } - - /** - * 根据绑定用户编号,获得下级用户编号列表 - * - * @param bindUserId 绑定用户编号 - * @param level 下级用户的层级。 - * 如果 level 为空,则查询 1+2 两个层级 - * @return 下级用户编号列表 - */ - private List getChildUserIdsByLevel(Long bindUserId, Integer level) { - if (bindUserId == null) { - return Collections.emptyList(); - } - // 先查第 1 级 - List bindUserIds = brokerageUserMapper.selectIdListByBindUserIdIn(Collections.singleton(bindUserId)); - if (CollUtil.isEmpty(bindUserIds)) { - return Collections.emptyList(); - } - - // 情况一:level 为空,查询所有级别 - if (level == null) { - // 再查第 2 级,并合并结果 - bindUserIds.addAll(brokerageUserMapper.selectIdListByBindUserIdIn(bindUserIds)); - return bindUserIds; - } - // 情况二:level 为 1,只查询第 1 级 - if (level == 1) { - return bindUserIds; - } - // 情况三:level 为 1,只查询第 2 级 - if (level == 2) { - return brokerageUserMapper.selectIdListByBindUserIdIn(bindUserIds); - } - throw exception(BROKERAGE_USER_LEVEL_NOT_SUPPORT); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java deleted file mode 100644 index 04ea9c49b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; - -/** - * 佣金提现 Service 接口 - * - * @author 芋道源码 - */ -public interface BrokerageWithdrawService { - - /** - * 【管理员】审核佣金提现 - * - * @param id 佣金编号 - * @param status 审核状态 - * @param auditReason 驳回原因 - */ - void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason); - - /** - * 获得佣金提现 - * - * @param id 编号 - * @return 佣金提现 - */ - BrokerageWithdrawDO getBrokerageWithdraw(Integer id); - - /** - * 获得佣金提现分页 - * - * @param pageReqVO 分页查询 - * @return 佣金提现分页 - */ - PageResult getBrokerageWithdrawPage(BrokerageWithdrawPageReqVO pageReqVO); - - /** - * 【会员】创建佣金提现 - * - * @param userId 会员用户编号 - * @param createReqVO 创建信息 - * @return 佣金提现编号 - */ - Long createBrokerageWithdraw(Long userId, AppBrokerageWithdrawCreateReqVO createReqVO); - - /** - * 按照 userId,汇总每个用户的提现 - * - * @param userIds 用户编号 - * @param status 提现状态 - * @return 用户提现汇总 List - */ - List getWithdrawSummaryListByUserId(Collection userIds, - BrokerageWithdrawStatusEnum status); - - /** - * 按照 userId,汇总每个用户的提现 - * - * @param userIds 用户编号 - * @param status 提现状态 - * @return 用户提现汇总 Map - */ - default Map getWithdrawSummaryMapByUserId(Set userIds, - BrokerageWithdrawStatusEnum status) { - return convertMap(getWithdrawSummaryListByUserId(userIds, status), BrokerageWithdrawSummaryRespBO::getUserId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java deleted file mode 100644 index b6b4034ce..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; -import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; -import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; -import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawCreateReqVO; -import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageWithdrawMapper; -import cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageWithdrawSummaryRespBO; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Validator; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 佣金提现 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { - - @Resource - private BrokerageWithdrawMapper brokerageWithdrawMapper; - - @Resource - private BrokerageRecordService brokerageRecordService; - @Resource - private TradeConfigService tradeConfigService; - - @Resource - private NotifyMessageSendApi notifyMessageSendApi; - - @Resource - private Validator validator; - - @Override - @Transactional(rollbackFor = Exception.class) - public void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason) { - // 1.1 校验存在 - BrokerageWithdrawDO withdraw = validateBrokerageWithdrawExists(id); - // 1.2 校验状态为审核中 - if (ObjectUtil.notEqual(BrokerageWithdrawStatusEnum.AUDITING.getStatus(), withdraw.getStatus())) { - throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); - } - - // 2. 更新 - int rows = brokerageWithdrawMapper.updateByIdAndStatus(id, BrokerageWithdrawStatusEnum.AUDITING.getStatus(), - new BrokerageWithdrawDO().setStatus(status.getStatus()).setAuditReason(auditReason).setAuditTime(LocalDateTime.now())); - if (rows == 0) { - throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); - } - - String templateCode; - if (BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.equals(status)) { - templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_APPROVE; - // 3.1 通过时佣金转余额 - if (BrokerageWithdrawTypeEnum.WALLET.getType().equals(withdraw.getType())) { - // todo 疯狂: - } - // TODO 疯狂:调用转账接口 - } else if (BrokerageWithdrawStatusEnum.AUDIT_FAIL.equals(status)) { - templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_REJECT; - // 3.2 驳回时需要退还用户佣金 - brokerageRecordService.addBrokerage(withdraw.getUserId(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT, - String.valueOf(withdraw.getId()), withdraw.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT.getTitle()); - } else { - throw new IllegalArgumentException("不支持的提现状态:" + status); - } - - // 4. 通知用户 - Map templateParams = MapUtil.builder() - .put("createTime", LocalDateTimeUtil.formatNormal(withdraw.getCreateTime())) - .put("price", MoneyUtils.fenToYuanStr(withdraw.getPrice())) - .put("reason", withdraw.getAuditReason()) - .build(); - notifyMessageSendApi.sendSingleMessageToMember(new NotifySendSingleToUserReqDTO() - .setUserId(withdraw.getUserId()).setTemplateCode(templateCode).setTemplateParams(templateParams)); - } - - private BrokerageWithdrawDO validateBrokerageWithdrawExists(Integer id) { - BrokerageWithdrawDO withdraw = brokerageWithdrawMapper.selectById(id); - if (withdraw == null) { - throw exception(BROKERAGE_WITHDRAW_NOT_EXISTS); - } - return withdraw; - } - - @Override - public BrokerageWithdrawDO getBrokerageWithdraw(Integer id) { - return brokerageWithdrawMapper.selectById(id); - } - - @Override - public PageResult getBrokerageWithdrawPage(BrokerageWithdrawPageReqVO pageReqVO) { - return brokerageWithdrawMapper.selectPage(pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createBrokerageWithdraw(Long userId, AppBrokerageWithdrawCreateReqVO createReqVO) { - // 1.1 校验提现金额 - TradeConfigDO tradeConfig = validateWithdrawPrice(createReqVO.getPrice()); - // 1.2 校验提现参数 - createReqVO.validate(validator); - - // 2.1 计算手续费 - Integer feePrice = calculateFeePrice(createReqVO.getPrice(), tradeConfig.getBrokerageWithdrawFeePercent()); - // 2.2 创建佣金提现记录 - BrokerageWithdrawDO withdraw = BrokerageWithdrawConvert.INSTANCE.convert(createReqVO, userId, feePrice); - brokerageWithdrawMapper.insert(withdraw); - - // 3. 创建用户佣金记录 - // 注意,佣金是否充足,reduceBrokerage 已经进行校验 - brokerageRecordService.reduceBrokerage(userId, BrokerageRecordBizTypeEnum.WITHDRAW, String.valueOf(withdraw.getId()), - createReqVO.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW.getTitle()); - return withdraw.getId(); - } - - @Override - public List getWithdrawSummaryListByUserId(Collection userIds, - BrokerageWithdrawStatusEnum status) { - if (CollUtil.isEmpty(userIds)) { - return Collections.emptyList(); - } - return brokerageWithdrawMapper.selectCountAndSumPriceByUserIdAndStatus(userIds, status.getStatus()); - } - - /** - * 计算提现手续费 - * - * @param withdrawPrice 提现金额 - * @param percent 手续费百分比 - * @return 提现手续费 - */ - Integer calculateFeePrice(Integer withdrawPrice, Integer percent) { - Integer feePrice = 0; - if (percent != null && percent > 0) { - feePrice = MoneyUtils.calculateRatePrice(withdrawPrice, Double.valueOf(percent)); - } - return feePrice; - } - - /** - * 校验提现金额要求 - * - * @param withdrawPrice 提现金额 - * @return 分销配置 - */ - TradeConfigDO validateWithdrawPrice(Integer withdrawPrice) { - TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); - if (tradeConfig.getBrokerageWithdrawMinPrice() != null && withdrawPrice < tradeConfig.getBrokerageWithdrawMinPrice()) { - throw exception(BROKERAGE_WITHDRAW_MIN_PRICE, MoneyUtils.fenToYuanStr(tradeConfig.getBrokerageWithdrawMinPrice())); - } - return tradeConfig; - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageAddReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageAddReqBO.java deleted file mode 100644 index 1b5de5431..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageAddReqBO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage.bo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 佣金 增加 Request BO - * - * @author owen - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageAddReqBO { - - /** - * 业务编号 - */ - @NotBlank(message = "业务编号不能为空") - private String bizId; - /** - * 佣金基数 - */ - @NotNull(message = "佣金基数不能为空") - private Integer basePrice; - /** - * 一级佣金(固定) - */ - @NotNull(message = "一级佣金(固定)不能为空") - private Integer firstFixedPrice; - /** - * 二级佣金(固定) - */ - private Integer secondFixedPrice; - - /** - * 来源用户编号 - */ - @NotNull(message = "来源用户编号不能为空") - private Long sourceUserId; - - /** - * 佣金记录标题 - */ - @NotEmpty(message = "佣金记录标题不能为空") - private String title; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageWithdrawSummaryRespBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageWithdrawSummaryRespBO.java deleted file mode 100644 index 1c3a3c991..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/BrokerageWithdrawSummaryRespBO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage.bo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 佣金提现合计 BO - * - * @author owen - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class BrokerageWithdrawSummaryRespBO { - - /** - * 用户编号 - */ - private Long userId; - - /** - * 提现次数 - */ - private Integer count; - /** - * 提现金额 - */ - private Integer price; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/UserBrokerageSummaryRespBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/UserBrokerageSummaryRespBO.java deleted file mode 100644 index 3e677b96a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/bo/UserBrokerageSummaryRespBO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.brokerage.bo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 用户佣金合计 BO - * - * @author owen - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class UserBrokerageSummaryRespBO { - - /** - * 用户编号 - */ - private Long userId; - /** - * 推广数量 - */ - private Integer count; - /** - * 佣金总额 - */ - private Integer price; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartService.java deleted file mode 100644 index 6130614e0..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartService.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.cart; - -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.*; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -/** - * 购物车 Service 接口 - * - * @author 芋道源码 - */ -public interface CartService { - - /** - * 添加商品到购物车 - * - * @param userId 用户编号 - * @param addReqVO 添加信息 - * @return 购物项的编号 - */ - Long addCart(Long userId, @Valid AppCartAddReqVO addReqVO); - - /** - * 更新购物车商品数量 - * - * @param userId 用户编号 - * @param updateCountReqVO 更新信息 - */ - void updateCartCount(Long userId, AppCartUpdateCountReqVO updateCountReqVO); - - /** - * 更新购物车选中状态 - * - * @param userId 用户编号 - * @param updateSelectedReqVO 更新信息 - */ - void updateCartSelected(Long userId, @Valid AppCartUpdateSelectedReqVO updateSelectedReqVO); - - /** - * 重置购物车商品 - * - * 使用场景:在一个购物车项对应的商品失效(例如说 SPU 被下架),可以重新选择对应的 SKU - * - * @param userId 用户编号 - * @param updateReqVO 重置信息 - */ - void resetCart(Long userId, AppCartResetReqVO updateReqVO); - - /** - * 删除购物车商品 - * - * @param userId 用户编号 - * @param ids 购物项的编号 - */ - void deleteCart(Long userId, Collection ids); - - /** - * 查询用户在购物车中的商品数量 - * - * @param userId 用户编号 - * @return 商品数量 - */ - Integer getCartCount(Long userId); - - /** - * 查询用户的购物车列表 - * - * @param userId 用户编号 - * @return 购物车列表 - */ - AppCartListRespVO getCartList(Long userId); - - /** - * 查询用户的购物车列表 - * - * @param userId 用户编号 - * @param ids 购物项的编号 - * @return 购物车列表 - */ - List getCartList(Long userId, Set ids); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartServiceImpl.java deleted file mode 100644 index e402aee3a..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/cart/CartServiceImpl.java +++ /dev/null @@ -1,196 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.cart; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.controller.app.cart.vo.*; -import cn.iocoder.yudao.module.trade.convert.cart.TradeCartConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import cn.iocoder.yudao.module.trade.dal.mysql.cart.CartMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_STOCK_NOT_ENOUGH; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.CARD_ITEM_NOT_FOUND; -import static java.util.Collections.emptyList; - -/** - * 购物车 Service 实现类 - * - * // TODO 芋艿:未来优化:购物车的价格计算,支持营销信息;目前不支持的原因,前端界面需要前端 pr 支持下;例如说:会员价格; - * - * @author 芋道源码 - */ -@Service -@Validated -public class CartServiceImpl implements CartService { - - @Resource - private CartMapper cartMapper; - - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Override - public Long addCart(Long userId, AppCartAddReqVO addReqVO) { - // 查询 TradeCartDO - CartDO cart = cartMapper.selectByUserIdAndSkuId(userId, addReqVO.getSkuId()); - // 校验 SKU - Integer count = addReqVO.getCount(); - ProductSkuRespDTO sku = checkProductSku(addReqVO.getSkuId(), count); - - // 情况一:存在,则进行数量更新 - if (cart != null) { - cartMapper.updateById(new CartDO().setId(cart.getId()).setSelected(true) - .setCount(cart.getCount() + count)); - return cart.getId(); - // 情况二:不存在,则进行插入 - } else { - cart = new CartDO().setUserId(userId).setSelected(true) - .setSpuId(sku.getSpuId()).setSkuId(sku.getId()).setCount(count); - cartMapper.insert(cart); - } - return cart.getId(); - } - - @Override - public void updateCartCount(Long userId, AppCartUpdateCountReqVO updateReqVO) { - // 校验 TradeCartDO 存在 - CartDO cart = cartMapper.selectById(updateReqVO.getId(), userId); - if (cart == null) { - throw exception(CARD_ITEM_NOT_FOUND); - } - // 校验商品 SKU - checkProductSku(cart.getSkuId(), updateReqVO.getCount()); - - // 更新数量 - cartMapper.updateById(new CartDO().setId(cart.getId()) - .setCount(updateReqVO.getCount())); - } - - @Override - public void updateCartSelected(Long userId, AppCartUpdateSelectedReqVO updateSelectedReqVO) { - cartMapper.updateByIds(updateSelectedReqVO.getIds(), userId, - new CartDO().setSelected(updateSelectedReqVO.getSelected())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void resetCart(Long userId, AppCartResetReqVO resetReqVO) { - // 第一步:删除原本的购物项 - CartDO oldCart = cartMapper.selectById(resetReqVO.getId(), userId); - if (oldCart == null) { - throw exception(CARD_ITEM_NOT_FOUND); - } - cartMapper.deleteById(oldCart.getId()); - - // 第二步:添加新的购物项 - CartDO newCart = cartMapper.selectByUserIdAndSkuId(userId, resetReqVO.getSkuId()); - if (newCart != null) { - updateCartCount(userId, new AppCartUpdateCountReqVO() - .setId(newCart.getId()).setCount(resetReqVO.getCount())); - } else { - addCart(userId, new AppCartAddReqVO().setSkuId(resetReqVO.getSkuId()) - .setCount(resetReqVO.getCount())); - } - } - - /** - * 购物车删除商品 - * - * @param userId 用户编号 - * @param ids 商品 SKU 编号的数组 - */ - @Override - public void deleteCart(Long userId, Collection ids) { - // 查询 TradeCartDO 列表 - List carts = cartMapper.selectListByIds(ids, userId); - if (CollUtil.isEmpty(carts)) { - return; - } - - // 批量标记删除 - cartMapper.deleteBatchIds(ids); - } - - @Override - public Integer getCartCount(Long userId) { - // TODO 芋艿:需要算上 selected - return cartMapper.selectSumByUserId(userId); - } - - @Override - public AppCartListRespVO getCartList(Long userId) { - // 获得购物车的商品 - List carts = cartMapper.selectListByUserId(userId); - carts.sort(Comparator.comparing(CartDO::getId).reversed()); - // 如果未空,则返回空结果 - if (CollUtil.isEmpty(carts)) { - return new AppCartListRespVO().setValidList(emptyList()) - .setInvalidList(emptyList()); - } - - // 查询 SPU、SKU 列表 - List spus = productSpuApi.getSpuList(convertSet(carts, CartDO::getSpuId)).getCheckedData(); - List skus = productSkuApi.getSkuList(convertSet(carts, CartDO::getSkuId)).getCheckedData(); - - // 如果 SPU 被删除,则删除购物车对应的商品。延迟删除 - // 为什么不是 SKU 被删除呢?因为 SKU 被删除时,还可以通过 SPU 选择其它 SKU - deleteCartIfSpuDeleted(carts, spus); - - // 拼接数据 - return TradeCartConvert.INSTANCE.convertList(carts, spus, skus); - } - - @Override - public List getCartList(Long userId, Set ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return cartMapper.selectListByUserId(userId, ids); - } - - private void deleteCartIfSpuDeleted(List carts, List spus) { - // 如果 SPU 被删除,则删除购物车对应的商品。延迟删除 - carts.removeIf(cart -> { - if (spus.stream().noneMatch(spu -> spu.getId().equals(cart.getSpuId()))) { - cartMapper.deleteById(cart.getId()); - return true; - } - return false; - }); - } - - /** - * 校验商品 SKU 是否合法 - * 1. 是否存在 - * 2. 是否下架 - * 3. 库存不足 - * - * @param skuId 商品 SKU 编号 - * @param count 商品数量 - * @return 商品 SKU - */ - private ProductSkuRespDTO checkProductSku(Long skuId, Integer count) { - ProductSkuRespDTO sku = productSkuApi.getSku(skuId).getCheckedData(); - if (sku == null) { - throw exception(SKU_NOT_EXISTS); - } - if (count > sku.getStock()) { - throw exception(SKU_STOCK_NOT_ENOUGH); - } - return sku; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigService.java deleted file mode 100644 index 1edb4f30b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigService.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.config; - -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; - -import javax.validation.Valid; - -/** - * 交易中心配置 Service 接口 - * - * @author owen - */ -public interface TradeConfigService { - - /** - * 更新交易中心配置 - * - * @param updateReqVO 更新信息 - */ - void saveTradeConfig(@Valid TradeConfigSaveReqVO updateReqVO); - - /** - * 获得交易中心配置 - * - * @return 交易中心配置 - */ - TradeConfigDO getTradeConfig(); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigServiceImpl.java deleted file mode 100644 index c859cdee6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/config/TradeConfigServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.config; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; -import cn.iocoder.yudao.module.trade.convert.config.TradeConfigConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.mysql.config.TradeConfigMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 交易中心配置 Service 实现类 - * - * @author owen - */ -@Service -@Validated -public class TradeConfigServiceImpl implements TradeConfigService { - - @Resource - private TradeConfigMapper tradeConfigMapper; - - @Override - public void saveTradeConfig(TradeConfigSaveReqVO saveReqVO) { - // 存在,则进行更新 - TradeConfigDO dbConfig = getTradeConfig(); - if (dbConfig != null) { - tradeConfigMapper.updateById(TradeConfigConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId())); - return; - } - // 不存在,则进行插入 - tradeConfigMapper.insert(TradeConfigConvert.INSTANCE.convert(saveReqVO)); - } - - @Override - public TradeConfigDO getTradeConfig() { - List list = tradeConfigMapper.selectList(); - return CollectionUtils.getFirst(list); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java deleted file mode 100644 index c504b3053..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressService.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 快递公司 Service 接口 - * - * @author jason - */ -public interface DeliveryExpressService { - - /** - * 创建快递公司 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDeliveryExpress(@Valid DeliveryExpressCreateReqVO createReqVO); - - /** - * 更新快递公司 - * - * @param updateReqVO 更新信息 - */ - void updateDeliveryExpress(@Valid DeliveryExpressUpdateReqVO updateReqVO); - - /** - * 删除快递公司 - * - * @param id 编号 - */ - void deleteDeliveryExpress(Long id); - - /** - * 获得快递公司 - * - * @param id 编号 - * @return 快递公司 - */ - DeliveryExpressDO getDeliveryExpress(Long id); - - /** - * 校验快递公司是否合法 - * - * @param id 编号 - * @return 快递公司 - */ - DeliveryExpressDO validateDeliveryExpress(Long id); - - /** - * 获得快递公司分页 - * - * @param pageReqVO 分页查询 - * @return 快递公司分页 - */ - PageResult getDeliveryExpressPage(DeliveryExpressPageReqVO pageReqVO); - - /** - * 获得快递公司列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 快递公司列表 - */ - List getDeliveryExpressList(DeliveryExpressExportReqVO exportReqVO); - - /** - * 获取指定状态的快递公司列表 - * - * @param status 状态 - * @return 快递公司列表 - */ - List getDeliveryExpressListByStatus(Integer status); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java deleted file mode 100644 index ec787af6d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressServiceImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressExportReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.express.DeliveryExpressUpdateReqVO; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 快递公司 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class DeliveryExpressServiceImpl implements DeliveryExpressService { - - @Resource - private DeliveryExpressMapper deliveryExpressMapper; - - @Override - public Long createDeliveryExpress(DeliveryExpressCreateReqVO createReqVO) { - //校验编码是否唯一 - validateExpressCodeUnique(createReqVO.getCode(), null); - // 插入 - DeliveryExpressDO deliveryExpress = DeliveryExpressConvert.INSTANCE.convert(createReqVO); - deliveryExpressMapper.insert(deliveryExpress); - // 返回 - return deliveryExpress.getId(); - } - - @Override - public void updateDeliveryExpress(DeliveryExpressUpdateReqVO updateReqVO) { - // 校验存在 - validateDeliveryExpressExists(updateReqVO.getId()); - //校验编码是否唯一 - validateExpressCodeUnique(updateReqVO.getCode(), updateReqVO.getId()); - // 更新 - DeliveryExpressDO updateObj = DeliveryExpressConvert.INSTANCE.convert(updateReqVO); - deliveryExpressMapper.updateById(updateObj); - } - - @Override - public void deleteDeliveryExpress(Long id) { - // 校验存在 - validateDeliveryExpressExists(id); - // 删除 - deliveryExpressMapper.deleteById(id); - } - - private void validateExpressCodeUnique(String code, Long id) { - DeliveryExpressDO express = deliveryExpressMapper.selectByCode(code); - if (express == null) { - return; - } - // 如果 id 为空,说明不用比较是否为相同 id 的快递公司 - if (id == null) { - throw exception(EXPRESS_CODE_DUPLICATE); - } - if (!express.getId().equals(id)) { - throw exception(EXPRESS_CODE_DUPLICATE); - } - } - private void validateDeliveryExpressExists(Long id) { - if (deliveryExpressMapper.selectById(id) == null) { - throw exception(EXPRESS_NOT_EXISTS); - } - } - - @Override - public DeliveryExpressDO getDeliveryExpress(Long id) { - return deliveryExpressMapper.selectById(id); - } - - @Override - public DeliveryExpressDO validateDeliveryExpress(Long id) { - DeliveryExpressDO deliveryExpress = deliveryExpressMapper.selectById(id); - if (deliveryExpress == null) { - throw exception(EXPRESS_NOT_EXISTS); - } - if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) { - throw exception(EXPRESS_STATUS_NOT_ENABLE); - } - return deliveryExpress; - } - - @Override - public PageResult getDeliveryExpressPage(DeliveryExpressPageReqVO pageReqVO) { - return deliveryExpressMapper.selectPage(pageReqVO); - } - - @Override - public List getDeliveryExpressList(DeliveryExpressExportReqVO exportReqVO) { - return deliveryExpressMapper.selectList(exportReqVO); - } - - @Override - public List getDeliveryExpressListByStatus(Integer status) { - return deliveryExpressMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateService.java deleted file mode 100644 index c455701b2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateService.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplateCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplateDetailRespVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplatePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.DeliveryExpressTemplateUpdateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplateRespBO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 快递运费模板 Service 接口 - * - * @author jason - */ -public interface DeliveryExpressTemplateService { - - /** - * 创建快递运费模板 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDeliveryExpressTemplate(@Valid DeliveryExpressTemplateCreateReqVO createReqVO); - - /** - * 更新快递运费模板 - * - * @param updateReqVO 更新信息 - */ - void updateDeliveryExpressTemplate(@Valid DeliveryExpressTemplateUpdateReqVO updateReqVO); - - /** - * 删除快递运费模板 - * - * @param id 编号 - */ - void deleteDeliveryExpressTemplate(Long id); - - /** - * 获得快递运费模板 - * - * @param id 编号 - * @return 快递运费模板详情 - */ - DeliveryExpressTemplateDetailRespVO getDeliveryExpressTemplate(Long id); - - /** - * 获得快递运费模板列表 - * - * @param ids 编号 - * @return 快递运费模板列表 - */ - List getDeliveryExpressTemplateList(Collection ids); - - /** - * 获得快递运费模板列表 - * - * @return 快递运费模板列表 - */ - List getDeliveryExpressTemplateList(); - - /** - * 获得快递运费模板分页 - * - * @param pageReqVO 分页查询 - * @return 快递运费模板分页 - */ - PageResult getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO); - - /** - * 校验快递运费模板 - * - * 如果校验不通过,抛出 {@link cn.iocoder.yudao.framework.common.exception.ServiceException} 异常 - * - * @param templateId 模板编号 - * @return 快递运费模板 - */ - DeliveryExpressTemplateDO validateDeliveryExpressTemplate(Long templateId); - - /** - * 基于运费模板编号数组和收件人地址区域编号,获取匹配运费模板 - * - * @param ids 编号列表 - * @param areaId 区域编号 - * @return Map (templateId -> 运费模板设置) - */ - Map getExpressTemplateMapByIdsAndArea(Collection ids, Integer areaId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateServiceImpl.java deleted file mode 100644 index 92e6d91ff..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryExpressTemplateServiceImpl.java +++ /dev/null @@ -1,218 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.expresstemplate.*; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateChargeDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressTemplateFreeDO; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressTemplateChargeMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressTemplateFreeMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryExpressTemplateMapper; -import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplateRespBO; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.trade.convert.delivery.DeliveryExpressTemplateConvert.INSTANCE; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_TEMPLATE_NAME_DUPLICATE; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_TEMPLATE_NOT_EXISTS; - -/** - * 快递运费模板 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class DeliveryExpressTemplateServiceImpl implements DeliveryExpressTemplateService { - - @Resource - private DeliveryExpressTemplateMapper expressTemplateMapper; - @Resource - private DeliveryExpressTemplateChargeMapper expressTemplateChargeMapper; - @Resource - private DeliveryExpressTemplateFreeMapper expressTemplateFreeMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createDeliveryExpressTemplate(DeliveryExpressTemplateCreateReqVO createReqVO) { - // 校验模板名是否唯一 - validateTemplateNameUnique(createReqVO.getName(), null); - - // 插入 - DeliveryExpressTemplateDO template = INSTANCE.convert(createReqVO); - expressTemplateMapper.insert(template); - // 插入运费模板计费表 - if (CollUtil.isNotEmpty(createReqVO.getCharges())) { - expressTemplateChargeMapper.insertBatch( - INSTANCE.convertTemplateChargeList(template.getId(), createReqVO.getChargeMode(), createReqVO.getCharges()) - ); - } - // 插入运费模板包邮表 - if (CollUtil.isNotEmpty(createReqVO.getFrees())) { - expressTemplateFreeMapper.insertBatch( - INSTANCE.convertTemplateFreeList(template.getId(), createReqVO.getFrees()) - ); - } - return template.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateDeliveryExpressTemplate(DeliveryExpressTemplateUpdateReqVO updateReqVO) { - // 校验存在 - validateDeliveryExpressTemplateExists(updateReqVO.getId()); - // 校验模板名是否唯一 - validateTemplateNameUnique(updateReqVO.getName(), updateReqVO.getId()); - - // 更新运费从表 - updateExpressTemplateCharge(updateReqVO.getId(), updateReqVO.getChargeMode(), updateReqVO.getCharges()); - // 更新包邮从表 - updateExpressTemplateFree(updateReqVO.getId(), updateReqVO.getFrees()); - // 更新模板主表 - DeliveryExpressTemplateDO updateObj = INSTANCE.convert(updateReqVO); - expressTemplateMapper.updateById(updateObj); - } - - private void updateExpressTemplateFree(Long templateId, List frees) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = expressTemplateFreeMapper.selectListByTemplateId(templateId); - List newList = INSTANCE.convertTemplateFreeList(templateId, frees); - List> diffList = CollectionUtils.diffList(oldList, newList, - (oldVal, newVal) -> ObjectUtil.equal(oldVal.getId(), newVal.getId())); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - expressTemplateFreeMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - expressTemplateFreeMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - expressTemplateFreeMapper.deleteBatchIds(convertList(diffList.get(2), DeliveryExpressTemplateFreeDO::getId)); - } - } - - private void updateExpressTemplateCharge(Long templateId, Integer chargeMode, List charges) { - // 第一步,对比新老数据,获得添加、修改、删除的列表 - List oldList = expressTemplateChargeMapper.selectListByTemplateId(templateId); - List newList = INSTANCE.convertTemplateChargeList(templateId, chargeMode, charges); - List> diffList = diffList(oldList, newList, (oldVal, newVal) -> { - boolean same = ObjectUtil.equal(oldVal.getId(), newVal.getId()); - if (same) { - newVal.setChargeMode(chargeMode); // 更新下收费模式 - } - return same; - }); - - // 第二步,批量添加、修改、删除 - if (CollUtil.isNotEmpty(diffList.get(0))) { - expressTemplateChargeMapper.insertBatch(diffList.get(0)); - } - if (CollUtil.isNotEmpty(diffList.get(1))) { - expressTemplateChargeMapper.updateBatch(diffList.get(1)); - } - if (CollUtil.isNotEmpty(diffList.get(2))) { - expressTemplateChargeMapper.deleteBatchIds(convertList(diffList.get(2), DeliveryExpressTemplateChargeDO::getId)); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteDeliveryExpressTemplate(Long id) { - // 校验存在 - validateDeliveryExpressTemplateExists(id); - - // 删除主表 - expressTemplateMapper.deleteById(id); - // 删除运费从表 - expressTemplateChargeMapper.deleteByTemplateId(id); - // 删除包邮从表 - expressTemplateFreeMapper.deleteByTemplateId(id); - } - - /** - * 校验运费模板名是否唯一 - * - * @param name 模板名称 - * @param id 运费模板编号,可以为 null - */ - private void validateTemplateNameUnique(String name, Long id) { - DeliveryExpressTemplateDO template = expressTemplateMapper.selectByName(name); - if (template == null) { - return; - } - // 如果 id 为空 - if (id == null) { - throw exception(EXPRESS_TEMPLATE_NAME_DUPLICATE); - } - if (!template.getId().equals(id)) { - throw exception(EXPRESS_TEMPLATE_NAME_DUPLICATE); - } - } - - private void validateDeliveryExpressTemplateExists(Long id) { - if (expressTemplateMapper.selectById(id) == null) { - throw exception(EXPRESS_TEMPLATE_NOT_EXISTS); - } - } - - @Override - public DeliveryExpressTemplateDetailRespVO getDeliveryExpressTemplate(Long id) { - List chargeList = expressTemplateChargeMapper.selectListByTemplateId(id); - List freeList = expressTemplateFreeMapper.selectListByTemplateId(id); - DeliveryExpressTemplateDO template = expressTemplateMapper.selectById(id); - return INSTANCE.convert(template, chargeList, freeList); - } - - @Override - public List getDeliveryExpressTemplateList(Collection ids) { - return expressTemplateMapper.selectBatchIds(ids); - } - - @Override - public List getDeliveryExpressTemplateList() { - return expressTemplateMapper.selectList(); - } - - @Override - public PageResult getDeliveryExpressTemplatePage(DeliveryExpressTemplatePageReqVO pageReqVO) { - return expressTemplateMapper.selectPage(pageReqVO); - } - - @Override - public DeliveryExpressTemplateDO validateDeliveryExpressTemplate(Long templateId) { - DeliveryExpressTemplateDO template = expressTemplateMapper.selectById(templateId); - if (template == null) { - throw exception(EXPRESS_TEMPLATE_NOT_EXISTS); - } - return template; - } - - @Override - public Map getExpressTemplateMapByIdsAndArea(Collection ids, Integer areaId) { - Assert.notNull(areaId, "区域编号 {} 不能为空", areaId); - // 查询 template 数组 - if (CollUtil.isEmpty(ids)) { - return Collections.emptyMap(); - } - List templateList = expressTemplateMapper.selectBatchIds(ids); - // 查询 templateCharge 数组 - List chargeList = expressTemplateChargeMapper.selectByTemplateIds(ids); - // 查询 templateFree 数组 - List freeList = expressTemplateFreeMapper.selectListByTemplateIds(ids); - - // 组合运费模板配置 RespBO - return INSTANCE.convertMap(areaId, templateList, chargeList, freeList); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java deleted file mode 100644 index 8cfdb2220..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreService.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 自提门店 Service 接口 - * - * @author jason - */ -public interface DeliveryPickUpStoreService { - - /** - * 创建自提门店 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDeliveryPickUpStore(@Valid DeliveryPickUpStoreCreateReqVO createReqVO); - - /** - * 更新自提门店 - * - * @param updateReqVO 更新信息 - */ - void updateDeliveryPickUpStore(@Valid DeliveryPickUpStoreUpdateReqVO updateReqVO); - - /** - * 删除自提门店 - * - * @param id 编号 - */ - void deleteDeliveryPickUpStore(Long id); - - /** - * 获得自提门店 - * - * @param id 编号 - * @return 自提门店 - */ - DeliveryPickUpStoreDO getDeliveryPickUpStore(Long id); - - /** - * 获得自提门店列表 - * - * @param ids 编号 - * @return 自提门店列表 - */ - List getDeliveryPickUpStoreList(Collection ids); - - /** - * 获得自提门店分页 - * - * @param pageReqVO 分页查询 - * @return 自提门店分页 - */ - PageResult getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO); - - /** - * 获得指定状态的自提门店列表 - * - * @param status 状态 - * @return 自提门店列表 - */ - List getDeliveryPickUpStoreListByStatus(Integer status); -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java deleted file mode 100644 index 4e31839b8..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStorePageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.delivery.vo.pickup.DeliveryPickUpStoreUpdateReqVO; -import cn.iocoder.yudao.module.trade.convert.delivery.DeliveryPickUpStoreConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.dal.mysql.delivery.DeliveryPickUpStoreMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PICK_UP_STORE_NOT_EXISTS; - -/** - * 自提门店 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreService { - - @Resource - private DeliveryPickUpStoreMapper deliveryPickUpStoreMapper; - - @Override - public Long createDeliveryPickUpStore(DeliveryPickUpStoreCreateReqVO createReqVO) { - // 插入 - DeliveryPickUpStoreDO deliveryPickUpStore = DeliveryPickUpStoreConvert.INSTANCE.convert(createReqVO); - deliveryPickUpStoreMapper.insert(deliveryPickUpStore); - // 返回 - return deliveryPickUpStore.getId(); - } - - @Override - public void updateDeliveryPickUpStore(DeliveryPickUpStoreUpdateReqVO updateReqVO) { - // 校验存在 - validateDeliveryPickUpStoreExists(updateReqVO.getId()); - // 更新 - DeliveryPickUpStoreDO updateObj = DeliveryPickUpStoreConvert.INSTANCE.convert(updateReqVO); - deliveryPickUpStoreMapper.updateById(updateObj); - } - - @Override - public void deleteDeliveryPickUpStore(Long id) { - // 校验存在 - validateDeliveryPickUpStoreExists(id); - // 删除 - deliveryPickUpStoreMapper.deleteById(id); - } - - private void validateDeliveryPickUpStoreExists(Long id) { - if (deliveryPickUpStoreMapper.selectById(id) == null) { - throw exception(PICK_UP_STORE_NOT_EXISTS); - } - } - - @Override - public DeliveryPickUpStoreDO getDeliveryPickUpStore(Long id) { - return deliveryPickUpStoreMapper.selectById(id); - } - - @Override - public List getDeliveryPickUpStoreList(Collection ids) { - return deliveryPickUpStoreMapper.selectBatchIds(ids); - } - - @Override - public PageResult getDeliveryPickUpStorePage(DeliveryPickUpStorePageReqVO pageReqVO) { - return deliveryPickUpStoreMapper.selectPage(pageReqVO); - } - - @Override - public List getDeliveryPickUpStoreListByStatus(Integer status) { - return deliveryPickUpStoreMapper.selectListByStatus(status); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/bo/DeliveryExpressTemplateRespBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/bo/DeliveryExpressTemplateRespBO.java deleted file mode 100644 index db0af04eb..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/bo/DeliveryExpressTemplateRespBO.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.delivery.bo; - -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryExpressChargeModeEnum; -import lombok.Data; - -/** - * 运费模板配置 Resp BO - * - * @author jason - */ -@Data -public class DeliveryExpressTemplateRespBO { - - /** - * 配送计费方式 - * - * 枚举 {@link DeliveryExpressChargeModeEnum} - */ - private Integer chargeMode; - - /** - * 运费模板快递运费设置 - */ - private Charge charge; - - /** - * 运费模板包邮设置 - */ - private Free free; - - /** - * 快递运费模板费用配置 BO - * - * @author jason - */ - @Data - public static class Charge { - - /** - * 首件数量(件数,重量,或体积) - */ - private Double startCount; - /** - * 起步价,单位:分 - */ - private Integer startPrice; - /** - * 续件数量(件, 重量,或体积) - */ - private Double extraCount; - /** - * 额外价,单位:分 - */ - private Integer extraPrice; - } - - /** - * 快递运费模板包邮配置 BO - * - * @author jason - */ - @Data - public static class Free { - - /** - * 包邮金额,单位:分 - * - * 订单总金额 > 包邮金额时,才免运费 - */ - private Integer freePrice; - - /** - * 包邮件数 - * - * 订单总件数 > 包邮件数时,才免运费 - */ - private Integer freeCount; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageService.java deleted file mode 100644 index dce5faf0e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageService.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.message; - -import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; - -/** - * Trade 消息 service 接口 - * - * @author HUIHUI - */ -public interface TradeMessageService { - - /** - * 订单发货时发送通知 - * - * @param reqBO 发送消息 - */ - void sendMessageWhenDeliveryOrder(TradeOrderMessageWhenDeliveryOrderReqBO reqBO); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java deleted file mode 100644 index b9cdf9476..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.message; - -import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; -import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; -import cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants; -import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - -/** - * Trade 消息 service 实现类 - * - * @author HUIHUI - */ -@Service -@Validated -public class TradeMessageServiceImpl implements TradeMessageService { - - @Resource - private NotifyMessageSendApi notifyMessageSendApi; - - @Override - public void sendMessageWhenDeliveryOrder(TradeOrderMessageWhenDeliveryOrderReqBO reqBO) { - if (true) { - return; - } - // 1、构造消息 - Map msgMap = new HashMap<>(2); - msgMap.put("orderId", reqBO.getOrderId()); - msgMap.put("deliveryMessage", reqBO.getMessage()); - // TODO 芋艿:看下模版 - // 2、发送站内信 - notifyMessageSendApi.sendSingleMessageToMember( - new NotifySendSingleToUserReqDTO() - .setUserId(reqBO.getUserId()) - .setTemplateCode(MessageTemplateConstants.ORDER_DELIVERY) - .setTemplateParams(msgMap)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/bo/TradeOrderMessageWhenDeliveryOrderReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/bo/TradeOrderMessageWhenDeliveryOrderReqBO.java deleted file mode 100644 index 7fe987391..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/bo/TradeOrderMessageWhenDeliveryOrderReqBO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.message.bo; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 订单发货时通知创建 Req BO - * - * @author HUIHUI - */ -@Data -public class TradeOrderMessageWhenDeliveryOrderReqBO { - - /** - * 订单编号 - */ - @NotNull(message = "订单编号不能为空") - private Long orderId; - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - /** - * 消息 - */ - @NotEmpty(message = "发送消息不能为空") - private String message; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogService.java deleted file mode 100644 index a08f01398..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogService.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeOrderLogCreateReqBO; -import org.springframework.scheduling.annotation.Async; - -import java.util.List; - -/** - * 交易下单日志 Service 接口 - * - * @author 陈賝 - * @since 2023/7/6 15:44 - */ -public interface TradeOrderLogService { - - /** - * 创建交易下单日志 - * - * @param logDTO 日志记录 - * @author 陈賝 - * @since 2023/7/6 15:45 - */ - @Async - void createOrderLog(TradeOrderLogCreateReqBO logDTO); - - /** - * 获得交易订单日志列表 - * - * @param orderId 订单编号 - * @return 交易订单日志列表 - */ - List getOrderLogListByOrderId(Long orderId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogServiceImpl.java deleted file mode 100644 index 7c79c9fd4..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogServiceImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderLogConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderLogMapper; -import cn.iocoder.yudao.module.trade.service.order.bo.TradeOrderLogCreateReqBO; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 交易下单日志 Service 实现类 - * - * @author 陈賝 - * @since 2023/7/6 15:44 - */ -@Service -public class TradeOrderLogServiceImpl implements TradeOrderLogService { - - @Resource - private TradeOrderLogMapper tradeOrderLogMapper; - - @Override - public void createOrderLog(TradeOrderLogCreateReqBO createReqBO) { - tradeOrderLogMapper.insert(TradeOrderLogConvert.INSTANCE.convert(createReqBO)); - } - - @Override - public List getOrderLogListByOrderId(Long orderId) { - return tradeOrderLogMapper.selectListByOrderId(orderId); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java deleted file mode 100644 index 445792232..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java +++ /dev/null @@ -1,158 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; - -import java.util.Collection; -import java.util.List; - -import static java.util.Collections.singleton; - -/** - * 交易订单【读】 Service 接口 - * - * @author 芋道源码 - */ -public interface TradeOrderQueryService { - - // =================== Order =================== - - /** - * 获得指定编号的交易订单 - * - * @param id 交易订单编号 - * @return 交易订单 - */ - TradeOrderDO getOrder(Long id); - - /** - * 获得指定用户,指定的交易订单 - * - * @param userId 用户编号 - * @param id 交易订单编号 - * @return 交易订单 - */ - TradeOrderDO getOrder(Long userId, Long id); - - /** - * 获得指定用户,指定活动,指定状态的交易订单 - * - * @param userId 用户编号 - * @param combinationActivityId 活动编号 - * @param status 订单状态 - * @return 交易订单 - */ - TradeOrderDO getOrderByUserIdAndStatusAndCombination(Long userId, Long combinationActivityId, Integer status); - - /** - * 获得订单列表 - * - * @param ids 订单编号数组 - * @return 订单列表 - */ - List getOrderList(Collection ids); - - /** - * 【管理员】获得交易订单分页 - * - * @param reqVO 分页请求 - * @return 交易订单 - */ - PageResult getOrderPage(TradeOrderPageReqVO reqVO); - - /** - * 获得订单统计 - * - * @param reqVO 请求参数 - * @return 订单统计 - */ - TradeOrderSummaryRespVO getOrderSummary(TradeOrderPageReqVO reqVO); - - /** - * 【会员】获得交易订单分页 - * - * @param userId 用户编号 - * @param reqVO 分页请求 - * @return 交易订单 - */ - PageResult getOrderPage(Long userId, AppTradeOrderPageReqVO reqVO); - - /** - * 【会员】获得交易订单数量 - * - * @param userId 用户编号 - * @param status 订单状态。如果为空,则不进行筛选 - * @param commonStatus 评价状态。如果为空,则不进行筛选 - * @return 订单数量 - */ - Long getOrderCount(Long userId, Integer status, Boolean commonStatus); - - /** - * 【前台】获得订单的物流轨迹 - * - * @param id 订单编号 - * @param userId 用户编号 - * @return 物流轨迹数组 - */ - List getExpressTrackList(Long id, Long userId); - - /** - * 【后台】获得订单的物流轨迹 - * - * @param id 订单编号 - * @return 物流轨迹数组 - */ - List getExpressTrackList(Long id); - - /** - * 【会员】在指定秒杀活动下,用户购买的商品数量 - * - * @param userId 用户编号 - * @param activityId 活动编号 - * @return 秒杀商品数量 - */ - int getSeckillProductCount(Long userId, Long activityId); - - // =================== Order Item =================== - - /** - * 获得指定用户,指定的交易订单项 - * - * @param userId 用户编号 - * @param itemId 交易订单项编号 - * @return 交易订单项 - */ - TradeOrderItemDO getOrderItem(Long userId, Long itemId); - - /** - * 获得交易订单项 - * - * @param id 交易订单项编号 itemId - * @return 交易订单项 - */ - TradeOrderItemDO getOrderItem(Long id); - - /** - * 根据交易订单编号,查询交易订单项 - * - * @param orderId 交易订单编号 - * @return 交易订单项数组 - */ - default List getOrderItemListByOrderId(Long orderId) { - return getOrderItemListByOrderId(singleton(orderId)); - } - - /** - * 根据交易订单编号数组,查询交易订单项 - * - * @param orderIds 交易订单编号数组 - * @return 交易订单项数组 - */ - List getOrderItemListByOrderId(Collection orderIds); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java deleted file mode 100644 index ed5b712fa..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java +++ /dev/null @@ -1,260 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderSummaryRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper; -import cn.iocoder.yudao.module.trade.dal.redis.RedisKeyConstants; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderRefundStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClientFactory; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO; -import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_NOT_EXISTS; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND; - -/** - * 交易订单【读】 Service 实现类 - * - * @author 芋道源码 - */ -@Service -public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { - - @Resource - private ExpressClientFactory expressClientFactory; - - @Resource - private TradeOrderMapper tradeOrderMapper; - @Resource - private TradeOrderItemMapper tradeOrderItemMapper; - - @Resource - private DeliveryExpressService deliveryExpressService; - - @Resource - private MemberUserApi memberUserApi; - - // =================== Order =================== - - @Override - public TradeOrderDO getOrder(Long id) { - return tradeOrderMapper.selectById(id); - } - - @Override - public TradeOrderDO getOrder(Long userId, Long id) { - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order != null - && ObjectUtil.notEqual(order.getUserId(), userId)) { - return null; - } - return order; - } - - @Override - public TradeOrderDO getOrderByUserIdAndStatusAndCombination(Long userId, Long combinationActivityId, Integer status) { - return tradeOrderMapper.selectByUserIdAndCombinationActivityIdAndStatus(userId, combinationActivityId, status); - } - - @Override - public List getOrderList(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return Collections.emptyList(); - } - return tradeOrderMapper.selectBatchIds(ids); - } - - @Override - public PageResult getOrderPage(TradeOrderPageReqVO reqVO) { - // 根据用户查询条件构建用户编号列表 - Set userIds = buildQueryConditionUserIds(reqVO); - if (userIds == null) { // 没查询到用户,说明肯定也没他的订单 - return PageResult.empty(); - } - // 分页查询 - return tradeOrderMapper.selectPage(reqVO, userIds); - } - - private Set buildQueryConditionUserIds(TradeOrderPageReqVO reqVO) { - // 获得 userId 相关的查询 - Set userIds = new HashSet<>(); - if (StrUtil.isNotEmpty(reqVO.getUserMobile())) { - MemberUserRespDTO user = memberUserApi.getUserByMobile(reqVO.getUserMobile()).getCheckedData(); - if (user == null) { // 没查询到用户,说明肯定也没他的订单 - return null; - } - userIds.add(user.getId()); - } - if (StrUtil.isNotEmpty(reqVO.getUserNickname())) { - List users = memberUserApi.getUserListByNickname(reqVO.getUserNickname()).getCheckedData(); - if (CollUtil.isEmpty(users)) { // 没查询到用户,说明肯定也没他的订单 - return null; - } - userIds.addAll(convertSet(users, MemberUserRespDTO::getId)); - } - return userIds; - } - - @Override - public TradeOrderSummaryRespVO getOrderSummary(TradeOrderPageReqVO reqVO) { - // 根据用户查询条件构建用户编号列表 - Set userIds = buildQueryConditionUserIds(reqVO); - if (userIds == null) { // 没查询到用户,说明肯定也没他的订单 - return new TradeOrderSummaryRespVO(); - } - // 查询每个售后状态对应的数量、金额 - List> list = tradeOrderMapper.selectOrderSummaryGroupByRefundStatus(reqVO, null); - - TradeOrderSummaryRespVO vo = new TradeOrderSummaryRespVO().setAfterSaleCount(0L).setAfterSalePrice(0L); - for (Map map : list) { - Long count = MapUtil.getLong(map, "count", 0L); - Long price = MapUtil.getLong(map, "price", 0L); - // 未退款的计入订单,部分退款、全部退款计入售后 - if (TradeOrderRefundStatusEnum.NONE.getStatus().equals(MapUtil.getInt(map, "refundStatus"))) { - vo.setOrderCount(count).setOrderPayPrice(price); - } else { - vo.setAfterSaleCount(vo.getAfterSaleCount() + count).setAfterSalePrice(vo.getAfterSalePrice() + price); - } - } - return vo; - } - - @Override - public PageResult getOrderPage(Long userId, AppTradeOrderPageReqVO reqVO) { - return tradeOrderMapper.selectPage(reqVO, userId); - } - - @Override - public Long getOrderCount(Long userId, Integer status, Boolean commentStatus) { - return tradeOrderMapper.selectCountByUserIdAndStatus(userId, status, commentStatus); - } - - @Override - public List getExpressTrackList(Long id, Long userId) { - // 查询订单 - TradeOrderDO order = tradeOrderMapper.selectByIdAndUserId(id, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 查询物流 - return getExpressTrackList(order); - } - - @Override - public List getExpressTrackList(Long id) { - // 查询订单 - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 查询物流 - return getExpressTrackList(order); - } - - @Override - public int getSeckillProductCount(Long userId, Long activityId) { - // 获得订单列表 - List orders = tradeOrderMapper.selectListByUserIdAndSeckillActivityId(userId, activityId); - orders.removeIf(order -> TradeOrderStatusEnum.isCanceled(order.getStatus())); // 过滤掉【已取消】的订单 - if (CollUtil.isEmpty(orders)) { - return 0; - } - // 获得订单项列表 - return tradeOrderItemMapper.selectProductSumByOrderId(convertSet(orders, TradeOrderDO::getId)); - } - - /** - * 获得订单的物流轨迹 - * - * @param order 订单 - * @return 物流轨迹 - */ - private List getExpressTrackList(TradeOrderDO order) { - if (order.getLogisticsId() == null) { - return Collections.emptyList(); - } - // 查询物流公司 - DeliveryExpressDO express = deliveryExpressService.getDeliveryExpress(order.getLogisticsId()); - if (express == null) { - throw exception(EXPRESS_NOT_EXISTS); - } - // 查询物流轨迹 - return getSelf().getExpressTrackList(express.getCode(), order.getLogisticsNo(), order.getReceiverMobile()); - } - - /** - * 查询物流轨迹 - * - * 缓存的目的:考虑及时性要求不高,但是每次调用需要钱 - * - * @param code 快递公司编码 - * @param logisticsNo 发货快递单号 - * @param receiverMobile 收、寄件人的电话号码 - * @return 物流轨迹 - */ - @Cacheable(cacheNames = RedisKeyConstants.EXPRESS_TRACK, key = "#code + '-' + #logisticsNo + '-' + #receiverMobile", - condition = "#result != null") - public List getExpressTrackList(String code, String logisticsNo, String receiverMobile) { - return expressClientFactory.getDefaultExpressClient().getExpressTrackList( - new ExpressTrackQueryReqDTO().setExpressCode(code).setLogisticsNo(logisticsNo) - .setPhone(receiverMobile)); - } - - - // =================== Order Item =================== - - @Override - public TradeOrderItemDO getOrderItem(Long userId, Long itemId) { - TradeOrderItemDO orderItem = tradeOrderItemMapper.selectById(itemId); - if (orderItem != null - && ObjectUtil.notEqual(orderItem.getUserId(), userId)) { - return null; - } - return orderItem; - } - - @Override - public TradeOrderItemDO getOrderItem(Long id) { - return tradeOrderItemMapper.selectById(id); - } - - @Override - public List getOrderItemListByOrderId(Collection orderIds) { - if (CollUtil.isEmpty(orderIds)) { - return Collections.emptyList(); - } - return tradeOrderItemMapper.selectListByOrderId(orderIds); - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private TradeOrderQueryServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java deleted file mode 100644 index 9f3c6cf93..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java +++ /dev/null @@ -1,199 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdatePriceReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; - -import javax.validation.constraints.NotNull; - -/** - * 交易订单【写】Service 接口 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -public interface TradeOrderUpdateService { - - // =================== Order =================== - - /** - * 获得订单结算信息 - * - * @param userId 登录用户 - * @param settlementReqVO 订单结算请求 - * @return 订单结算结果 - */ - AppTradeOrderSettlementRespVO settlementOrder(Long userId, AppTradeOrderSettlementReqVO settlementReqVO); - - /** - * 【会员】创建交易订单 - * - * @param userId 登录用户 - * @param createReqVO 创建交易订单请求模型 - * @return 交易订单的 - */ - TradeOrderDO createOrder(Long userId, AppTradeOrderCreateReqVO createReqVO); - - /** - * 更新交易订单已支付 - * - * @param id 交易订单编号 - * @param payOrderId 支付订单编号 - */ - void updateOrderPaid(Long id, Long payOrderId); - - /** - * 【管理员】发货交易订单 - * - * @param deliveryReqVO 发货请求 - */ - void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO); - - /** - * 【会员】收货交易订单 - * - * @param userId 用户编号 - * @param id 订单编号 - */ - void receiveOrderByMember(Long userId, Long id); - - /** - * 【系统】自动收货交易订单 - * - * @return 收货数量 - */ - int receiveOrderBySystem(); - - /** - * 【会员】取消交易订单 - * - * @param userId 用户编号 - * @param id 订单编号 - */ - void cancelOrderByMember(Long userId, Long id); - - /** - * 【系统】自动取消订单 - * - * @return 取消数量 - */ - int cancelOrderBySystem(); - - /** - * 【会员】删除订单 - * - * @param userId 用户编号 - * @param id 订单编号 - */ - void deleteOrder(Long userId, Long id); - - /** - * 【管理员】交易订单备注 - * - * @param reqVO 请求 - */ - void updateOrderRemark(TradeOrderRemarkReqVO reqVO); - - /** - * 【管理员】调整价格 - * - * @param reqVO 请求 - */ - void updateOrderPrice(TradeOrderUpdatePriceReqVO reqVO); - - /** - * 【管理员】调整地址 - * - * @param reqVO 请求 - */ - void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO); - - /** - * 【管理员】核销订单 - * - * @param id 订单编号 - */ - void pickUpOrderByAdmin(Long id); - - /** - * 【管理员】核销订单 - * - * @param pickUpVerifyCode 自提核销码 - */ - void pickUpOrderByAdmin(String pickUpVerifyCode); - - /** - * 【管理员】根据自提核销码,查询订单 - * - * @param pickUpVerifyCode 自提核销码 - */ - TradeOrderDO getByPickUpVerifyCode(String pickUpVerifyCode); - - // =================== Order Item =================== - - /** - * 当售后申请后,更新交易订单项的售后状态 - * - * @param id 交易订单项编号 - * @param afterSaleId 售后单编号 - */ - void updateOrderItemWhenAfterSaleCreate(@NotNull Long id, @NotNull Long afterSaleId); - - /** - * 当售后完成后,更新交易订单项的售后状态 - * - * @param id 交易订单项编号 - * @param refundPrice 退款金额 - */ - void updateOrderItemWhenAfterSaleSuccess(@NotNull Long id, @NotNull Integer refundPrice); - - /** - * 当售后取消(用户取消、管理员驳回、管理员拒绝收货)后,更新交易订单项的售后状态 - * - * @param id 交易订单项编号 - */ - void updateOrderItemWhenAfterSaleCancel(@NotNull Long id); - - /** - * 【会员】创建订单项的评论 - * - * @param userId 用户编号 - * @param createReqVO 创建请求 - * @return 得到评价 id - */ - Long createOrderItemCommentByMember(Long userId, AppTradeOrderItemCommentCreateReqVO createReqVO); - - /** - * 【系统】创建订单项的评论 - * - * @return 被评论的订单数 - */ - int createOrderItemCommentBySystem(); - - /** - * 更新拼团相关信息到订单 - * - * @param orderId 订单编号 - * @param activityId 拼团活动编号 - * @param combinationRecordId 拼团记录编号 - * @param headId 团长编号 - */ - void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId); - - // TODO 芋艿:拼团取消,不调这个接口哈; - /** - * 取消支付订单 - * - * @param userId 用户编号 - * @param orderId 订单编号 - */ - void cancelPaidOrder(Long userId, Long orderId); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java deleted file mode 100644 index 2b7b4596f..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java +++ /dev/null @@ -1,903 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.RandomUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.module.member.api.address.MemberAddressApi; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.product.api.comment.ProductCommentApi; -import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO; -import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdatePriceReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementReqVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderSettlementRespVO; -import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderItemCommentCreateReqVO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; -import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper; -import cn.iocoder.yudao.module.trade.dal.redis.no.TradeNoRedisDAO; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.*; -import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; -import cn.iocoder.yudao.module.trade.framework.order.core.annotations.TradeOrderLog; -import cn.iocoder.yudao.module.trade.framework.order.core.utils.TradeOrderLogUtils; -import cn.iocoder.yudao.module.trade.service.cart.CartService; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; -import cn.iocoder.yudao.module.trade.service.message.TradeMessageService; -import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; -import cn.iocoder.yudao.module.trade.service.order.handler.TradeOrderHandler; -import cn.iocoder.yudao.module.trade.service.price.TradePriceService; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.minusTime; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getTerminal; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 交易订单【写】Service 实现类 - * - * @author LeeYan9 - * @since 2022-08-26 - */ -@Service -@Slf4j -public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { - - @Resource - private TradeOrderMapper tradeOrderMapper; - @Resource - private TradeOrderItemMapper tradeOrderItemMapper; - @Resource - private TradeNoRedisDAO tradeNoRedisDAO; - - @Resource - private List tradeOrderHandlers; - - @Resource - private CartService cartService; - @Resource - private TradePriceService tradePriceService; - @Resource - private DeliveryExpressService deliveryExpressService; - @Resource - private TradeMessageService tradeMessageService; - - @Resource - private PayOrderApi payOrderApi; - @Resource - private MemberAddressApi addressApi; - @Resource - private ProductCommentApi productCommentApi; - - @Resource - private TradeOrderProperties tradeOrderProperties; - - // =================== Order =================== - - @Override - public AppTradeOrderSettlementRespVO settlementOrder(Long userId, AppTradeOrderSettlementReqVO settlementReqVO) { - // 1. 获得收货地址 - MemberAddressRespDTO address = getAddress(userId, settlementReqVO.getAddressId()); - if (address != null) { - settlementReqVO.setAddressId(address.getId()); - } - - // 2. 计算价格 - TradePriceCalculateRespBO calculateRespBO = calculatePrice(userId, settlementReqVO); - - // 3. 拼接返回 - return TradeOrderConvert.INSTANCE.convert(calculateRespBO, address); - } - - /** - * 获得用户地址 - * - * @param userId 用户编号 - * @param addressId 地址编号 - * @return 地址 - */ - private MemberAddressRespDTO getAddress(Long userId, Long addressId) { - if (addressId != null) { - return addressApi.getAddress(addressId, userId).getCheckedData(); - } - return addressApi.getDefaultAddress(userId).getCheckedData(); - } - - /** - * 计算订单价格 - * - * @param userId 用户编号 - * @param settlementReqVO 结算信息 - * @return 订单价格 - */ - private TradePriceCalculateRespBO calculatePrice(Long userId, AppTradeOrderSettlementReqVO settlementReqVO) { - // 1. 如果来自购物车,则获得购物车的商品 - List cartList = cartService.getCartList(userId, - convertSet(settlementReqVO.getItems(), AppTradeOrderSettlementReqVO.Item::getCartId)); - - // 2. 计算价格 - TradePriceCalculateReqBO calculateReqBO = TradeOrderConvert.INSTANCE.convert(userId, settlementReqVO, cartList); - calculateReqBO.getItems().forEach(item -> Assert.isTrue(item.getSelected(), // 防御性编程,保证都是选中的 - "商品({}) 未设置为选中", item.getSkuId())); - return tradePriceService.calculatePrice(calculateReqBO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CREATE) - public TradeOrderDO createOrder(Long userId, AppTradeOrderCreateReqVO createReqVO) { - // 1.1 价格计算 - TradePriceCalculateRespBO calculateRespBO = calculatePrice(userId, createReqVO); - // 1.2 构建订单 - TradeOrderDO order = buildTradeOrder(userId, createReqVO, calculateRespBO); - List orderItems = buildTradeOrderItems(order, calculateRespBO); - - // 2. 订单创建前的逻辑 - tradeOrderHandlers.forEach(handler -> handler.beforeOrderCreate(order, orderItems)); - - // 3. 保存订单 - tradeOrderMapper.insert(order); - orderItems.forEach(orderItem -> orderItem.setOrderId(order.getId())); - tradeOrderItemMapper.insertBatch(orderItems); - - // 4. 订单创建后的逻辑 - afterCreateTradeOrder(order, orderItems, createReqVO); - return order; - } - - private TradeOrderDO buildTradeOrder(Long userId, AppTradeOrderCreateReqVO createReqVO, - TradePriceCalculateRespBO calculateRespBO) { - TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(userId, createReqVO, calculateRespBO); - order.setType(calculateRespBO.getType()); - order.setNo(tradeNoRedisDAO.generate(TradeNoRedisDAO.TRADE_ORDER_NO_PREFIX)); - order.setStatus(TradeOrderStatusEnum.UNPAID.getStatus()); - order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()); - order.setProductCount(getSumValue(calculateRespBO.getItems(), TradePriceCalculateRespBO.OrderItem::getCount, Integer::sum)); - order.setUserIp(getClientIP()).setTerminal(getTerminal()); - // 支付 + 退款信息 - order.setAdjustPrice(0).setPayStatus(false); - order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0); - // 物流信息 - order.setDeliveryType(createReqVO.getDeliveryType()); - if (Objects.equals(createReqVO.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getType())) { - MemberAddressRespDTO address = addressApi.getAddress(createReqVO.getAddressId(), userId).getCheckedData(); - Assert.notNull(address, "地址({}) 不能为空", createReqVO.getAddressId()); // 价格计算时,已经计算 - order.setReceiverName(address.getName()).setReceiverMobile(address.getMobile()) - .setReceiverAreaId(address.getAreaId()).setReceiverDetailAddress(address.getDetailAddress()); - } else if (Objects.equals(createReqVO.getDeliveryType(), DeliveryTypeEnum.PICK_UP.getType())) { - order.setReceiverName(createReqVO.getReceiverName()).setReceiverMobile(createReqVO.getReceiverMobile()); - order.setPickUpVerifyCode(RandomUtil.randomNumbers(8)); // 随机一个核销码,长度为 8 位 - } - return order; - } - - private List buildTradeOrderItems(TradeOrderDO tradeOrderDO, - TradePriceCalculateRespBO calculateRespBO) { - return TradeOrderConvert.INSTANCE.convertList(tradeOrderDO, calculateRespBO); - } - - /** - * 订单创建后,执行后置逻辑 - *

- * 例如说:优惠劵的扣减、积分的扣减、支付单的创建等等 - * - * @param order 订单 - * @param orderItems 订单项 - * @param createReqVO 创建订单请求 - */ - private void afterCreateTradeOrder(TradeOrderDO order, List orderItems, - AppTradeOrderCreateReqVO createReqVO) { - // 1. 执行订单创建后置处理器 - tradeOrderHandlers.forEach(handler -> handler.afterOrderCreate(order, orderItems)); - - // 2. 删除购物车商品 - Set cartIds = convertSet(createReqVO.getItems(), AppTradeOrderSettlementReqVO.Item::getCartId); - if (CollUtil.isNotEmpty(cartIds)) { - cartService.deleteCart(order.getUserId(), cartIds); - } - - // 3. 生成预支付 - createPayOrder(order, orderItems); - - // 4. 插入订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), null, order.getStatus()); - - // TODO @LeeYan9: 是可以思考下, 订单的营销优惠记录, 应该记录在哪里, 微信讨论起来! - } - - private void createPayOrder(TradeOrderDO order, List orderItems) { - // 创建支付单,用于后续的支付 - PayOrderCreateReqDTO payOrderCreateReqDTO = TradeOrderConvert.INSTANCE.convert( - order, orderItems, tradeOrderProperties); - Long payOrderId = payOrderApi.createOrder(payOrderCreateReqDTO).getCheckedData(); - - // 更新到交易单上 - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setPayOrderId(payOrderId)); - order.setPayOrderId(payOrderId); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_PAY) - public void updateOrderPaid(Long id, Long payOrderId) { - // 1. 校验并获得交易订单(可支付) - KeyValue orderResult = validateOrderPayable(id, payOrderId); - TradeOrderDO order = orderResult.getKey(); - PayOrderRespDTO payOrder = orderResult.getValue(); - - // 2. 更新 TradeOrderDO 状态为已支付,等待发货 - int updateCount = tradeOrderMapper.updateByIdAndStatus(id, order.getStatus(), - new TradeOrderDO().setStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()).setPayStatus(true) - .setPayTime(LocalDateTime.now()).setPayChannelCode(payOrder.getChannelCode())); - if (updateCount == 0) { - throw exception(ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - - // 3. 执行 TradeOrderHandler 的后置处理 - List orderItems = tradeOrderItemMapper.selectListByOrderId(id); - tradeOrderHandlers.forEach(handler -> handler.afterPayOrder(order, orderItems)); - - // 4. 记录订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.UNDELIVERED.getStatus()); - TradeOrderLogUtils.setUserInfo(order.getUserId(), UserTypeEnum.MEMBER.getValue()); - } - - /** - * 校验交易订单满足被支付的条件 - *

- * 1. 交易订单未支付 - * 2. 支付单已支付 - * - * @param id 交易订单编号 - * @param payOrderId 支付订单编号 - * @return 交易订单 - */ - private KeyValue validateOrderPayable(Long id, Long payOrderId) { - // 校验订单是否存在 - TradeOrderDO order = validateOrderExists(id); - // 校验订单未支付 - if (!TradeOrderStatusEnum.isUnpaid(order.getStatus()) || order.getPayStatus()) { - log.error("[validateOrderPaid][order({}) 不处于待支付状态,请进行处理!order 数据是:{}]", - id, JsonUtils.toJsonString(order)); - throw exception(ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - // 校验支付订单匹配 - if (ObjectUtil.notEqual(order.getPayOrderId(), payOrderId)) { // 支付单号 - log.error("[validateOrderPaid][order({}) 支付单不匹配({}),请进行处理!order 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(order)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - - // 校验支付单是否存在 - PayOrderRespDTO payOrder = payOrderApi.getOrder(payOrderId).getCheckedData(); - if (payOrder == null) { - log.error("[validateOrderPaid][order({}) payOrder({}) 不存在,请进行处理!]", id, payOrderId); - throw exception(ORDER_NOT_FOUND); - } - // 校验支付单已支付 - if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) { - log.error("[validateOrderPaid][order({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(payOrder)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS); - } - // 校验支付金额一致 - if (ObjectUtil.notEqual(payOrder.getPrice(), order.getPayPrice())) { - log.error("[validateOrderPaid][order({}) payOrder({}) 支付金额不匹配,请进行处理!order 数据是:{},payOrder 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(order), JsonUtils.toJsonString(payOrder)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH); - } - // 校验支付订单匹配(二次) - if (ObjectUtil.notEqual(payOrder.getMerchantOrderId(), id.toString())) { - log.error("[validateOrderPaid][order({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]", - id, payOrderId, JsonUtils.toJsonString(payOrder)); - throw exception(ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - return new KeyValue<>(order, payOrder); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_DELIVERY) - public void deliveryOrder(TradeOrderDeliveryReqVO deliveryReqVO) { - // 1.1 校验并获得交易订单(可发货) - TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId()); - // 1.2 校验 deliveryType 是否为快递,是快递才可以发货 - if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getType())) { - throw exception(ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS); - } - - // 2. 更新订单为已发货 - TradeOrderDO updateOrderObj = new TradeOrderDO(); - // 2.1 快递发货 - DeliveryExpressDO express = null; - if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), TradeOrderDO.LOGISTICS_ID_NULL)) { - express = deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId()); - updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()); - } else { - // 2.2 无需发货 - updateOrderObj.setLogisticsId(0L).setLogisticsNo(""); - } - // 执行更新 - updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now()); - int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj); - if (updateCount == 0) { - throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED); - } - - // 3. 记录订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.DELIVERED.getStatus(), - MapUtil.builder().put("expressName", express != null ? express.getName() : "") - .put("logisticsNo", express != null ? deliveryReqVO.getLogisticsNo() : "").build()); - - // 4. 发送站内信 - tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqBO() - .setOrderId(order.getId()).setUserId(order.getUserId()).setMessage(null)); - } - - /** - * 校验交易订单满足被发货的条件 - *

- * 1. 交易订单未发货 - * - * @param id 交易订单编号 - * @return 交易订单 - */ - private TradeOrderDO validateOrderDeliverable(Long id) { - TradeOrderDO order = validateOrderExists(id); - // 1. 校验订单是否未发货 - if (ObjectUtil.notEqual(TradeOrderRefundStatusEnum.NONE.getStatus(), order.getRefundStatus())) { - throw exception(ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE); - } - - // 2. 执行 TradeOrderHandler 前置处理 - tradeOrderHandlers.forEach(handler -> handler.beforeDeliveryOrder(order)); - return order; - } - - @NotNull - private TradeOrderDO validateOrderExists(Long id) { - // 校验订单是否存在 - TradeOrderDO order = tradeOrderMapper.selectById(id); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - return order; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_RECEIVE) - public void receiveOrderByMember(Long userId, Long id) { - // 校验并获得交易订单(可收货) - TradeOrderDO order = validateOrderReceivable(userId, id); - - // 收货订单 - receiveOrder0(order); - } - - @Override - public int receiveOrderBySystem() { - // 1. 查询过期的待支付订单 - LocalDateTime expireTime = minusTime(tradeOrderProperties.getReceiveExpireTime()); - List orders = tradeOrderMapper.selectListByStatusAndDeliveryTimeLt( - TradeOrderStatusEnum.DELIVERED.getStatus(), expireTime); - if (CollUtil.isEmpty(orders)) { - return 0; - } - - // 2. 遍历执行,逐个取消 - int count = 0; - for (TradeOrderDO order : orders) { - try { - getSelf().receiveOrderBySystem(order); - count++; - } catch (Throwable e) { - log.error("[receiveOrderBySystem][order({}) 自动收货订单异常]", order.getId(), e); - } - } - return count; - } - - /** - * 自动收货单个订单 - * - * @param order 订单 - */ - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_RECEIVE) - public void receiveOrderBySystem(TradeOrderDO order) { - receiveOrder0(order); - } - - /** - * 收货订单的核心实现 - * - * @param order 订单 - */ - private void receiveOrder0(TradeOrderDO order) { - // 更新 TradeOrderDO 状态为已完成 - int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), - new TradeOrderDO().setStatus(TradeOrderStatusEnum.COMPLETED.getStatus()).setReceiveTime(LocalDateTime.now())); - if (updateCount == 0) { - throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED); - } - - // 插入订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus()); - } - - /** - * 校验交易订单满足可售货的条件 - *

- * 1. 交易订单待收货 - * - * @param userId 用户编号 - * @param id 交易订单编号 - * @return 交易订单 - */ - private TradeOrderDO validateOrderReceivable(Long userId, Long id) { - // 校验订单是否存在 - TradeOrderDO order = tradeOrderMapper.selectByIdAndUserId(id, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 校验订单是否是待收货状态 - if (!TradeOrderStatusEnum.isDelivered(order.getStatus())) { - throw exception(ORDER_RECEIVE_FAIL_STATUS_NOT_DELIVERED); - } - return order; - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CANCEL) - public void cancelOrderByMember(Long userId, Long id) { - // 1.1 校验存在 - TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(id, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 1.2 校验状态 - if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.UNPAID.getStatus())) { - throw exception(ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID); - } - - // 2. 取消订单 - cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL); - } - - @Override - public int cancelOrderBySystem() { - // 1. 查询过期的待支付订单 - LocalDateTime expireTime = minusTime(tradeOrderProperties.getPayExpireTime()); - List orders = tradeOrderMapper.selectListByStatusAndCreateTimeLt( - TradeOrderStatusEnum.UNPAID.getStatus(), expireTime); - if (CollUtil.isEmpty(orders)) { - return 0; - } - - // 2. 遍历执行,逐个取消 - int count = 0; - for (TradeOrderDO order : orders) { - try { - getSelf().cancelOrderBySystem(order); - count++; - } catch (Throwable e) { - log.error("[cancelOrderBySystem][order({}) 过期订单异常]", order.getId(), e); - } - } - return count; - } - - /** - * 自动取消单个订单 - * - * @param order 订单 - */ - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_CANCEL) - public void cancelOrderBySystem(TradeOrderDO order) { - cancelOrder0(order, TradeOrderCancelTypeEnum.PAY_TIMEOUT); - } - - /** - * 取消订单的核心实现 - * - * @param order 订单 - * @param cancelType 取消类型 - */ - private void cancelOrder0(TradeOrderDO order, TradeOrderCancelTypeEnum cancelType) { - // 1. 更新 TradeOrderDO 状态为已取消 - int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), - new TradeOrderDO().setStatus(TradeOrderStatusEnum.CANCELED.getStatus()) - .setCancelType(cancelType.getType()).setCancelTime(LocalDateTime.now())); - if (updateCount == 0) { - throw exception(ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID); - } - - // 2. 执行 TradeOrderHandler 的后置处理 - List orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId()); - tradeOrderHandlers.forEach(handler -> handler.afterCancelOrder(order, orderItems)); - - // 3. 增加订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.CANCELED.getStatus()); - } - - /** - * 如果金额全部被退款,则取消订单 - * 如果还有未被退款的金额,则无需取消订单 - * - * @param order 订单 - * @param refundPrice 退款金额 - */ - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_CANCEL_AFTER_SALE) - public void cancelOrderByAfterSale(TradeOrderDO order, Integer refundPrice) { - // 1. 更新订单 - if (refundPrice < order.getPayPrice()) { - return; - } - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()) - .setStatus(TradeOrderStatusEnum.CANCELED.getStatus()) - .setCancelType(TradeOrderCancelTypeEnum.AFTER_SALE_CLOSE.getType()).setCancelTime(LocalDateTime.now())); - - // 2. 执行 TradeOrderHandler 的后置处理 - List orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId()); - tradeOrderHandlers.forEach(handler -> handler.afterCancelOrder(order, orderItems)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_DELETE) - public void deleteOrder(Long userId, Long id) { - // 1.1 校验存在 - TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(id, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - // 1.2 校验状态 - if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.CANCELED.getStatus())) { - throw exception(ORDER_DELETE_FAIL_STATUS_NOT_CANCEL); - } - // 2. 删除订单 - tradeOrderMapper.deleteById(id); - - // 3. 记录日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus()); - } - - @Override - public void updateOrderRemark(TradeOrderRemarkReqVO reqVO) { - // 校验并获得交易订单 - validateOrderExists(reqVO.getId()); - - // 更新 - TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(reqVO); - tradeOrderMapper.updateById(order); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_PRICE) - public void updateOrderPrice(TradeOrderUpdatePriceReqVO reqVO) { - // 1.1 校验交易订单 - TradeOrderDO order = validateOrderExists(reqVO.getId()); - if (order.getPayStatus()) { - throw exception(ORDER_UPDATE_PRICE_FAIL_PAID); - } - // 1.2 校验调价金额是否变化 - if (order.getAdjustPrice() > 0) { - throw exception(ORDER_UPDATE_PRICE_FAIL_ALREADY); - } - // 1.3 支付价格不能为 0 - int newPayPrice = order.getPayPrice() + reqVO.getAdjustPrice(); - if (newPayPrice <= 0) { - throw exception(ORDER_UPDATE_PRICE_FAIL_PRICE_ERROR); - } - - // 2. 更新订单 - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()) - .setAdjustPrice(reqVO.getAdjustPrice() + order.getAdjustPrice()).setPayPrice(newPayPrice)); - - // 3. 更新 TradeOrderItem,需要做 adjustPrice 的分摊 - List orderOrderItems = tradeOrderItemMapper.selectListByOrderId(order.getId()); - List dividePrices = TradePriceCalculatorHelper.dividePrice2(orderOrderItems, reqVO.getAdjustPrice()); - List updateItems = new ArrayList<>(); - for (int i = 0; i < orderOrderItems.size(); i++) { - TradeOrderItemDO item = orderOrderItems.get(i); - updateItems.add(new TradeOrderItemDO().setId(item.getId()).setAdjustPrice(item.getAdjustPrice() + dividePrices.get(i)) - .setPayPrice((item.getPayPrice() - item.getAdjustPrice()) + dividePrices.get(i))); - } - tradeOrderItemMapper.updateBatch(updateItems); - - // 4. 更新支付订单 - payOrderApi.updatePayOrderPrice(order.getPayOrderId(), newPayPrice); - - // 5. 记录订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus(), - MapUtil.builder().put("oldPayPrice", MoneyUtils.fenToYuanStr(order.getPayPrice())) - .put("adjustPrice", MoneyUtils.fenToYuanStr(reqVO.getAdjustPrice())) - .put("newPayPrice", MoneyUtils.fenToYuanStr(newPayPrice)).build()); - } - - @Override - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_UPDATE_ADDRESS) - public void updateOrderAddress(TradeOrderUpdateAddressReqVO reqVO) { - // 校验交易订单 - TradeOrderDO order = validateOrderExists(reqVO.getId()); - // 只有待发货状态,才可以修改订单收货地址; - if (!TradeOrderStatusEnum.isUndelivered(order.getStatus())) { - throw exception(ORDER_UPDATE_ADDRESS_FAIL_STATUS_NOT_DELIVERED); - } - - // 更新 - tradeOrderMapper.updateById(TradeOrderConvert.INSTANCE.convert(reqVO)); - - // 记录订单日志 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus()); - } - - @Override - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE) - public void pickUpOrderByAdmin(Long id) { - getSelf().pickUpOrder(tradeOrderMapper.selectById(id)); - } - - @Override - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE) - public void pickUpOrderByAdmin(String pickUpVerifyCode) { - getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode)); - } - - @Override - public TradeOrderDO getByPickUpVerifyCode(String pickUpVerifyCode) { - return tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode); - } - - @Transactional(rollbackFor = Exception.class) - public void pickUpOrder(TradeOrderDO order) { - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - if (ObjUtil.notEqual(DeliveryTypeEnum.PICK_UP.getType(), order.getDeliveryType())) { - throw exception(ORDER_RECEIVE_FAIL_DELIVERY_TYPE_NOT_PICK_UP); - } - receiveOrder0(order); - } - - // =================== Order Item =================== - - @Override - public void updateOrderItemWhenAfterSaleCreate(Long id, Long afterSaleId) { - // 更新订单项 - updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), - TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), afterSaleId); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateOrderItemWhenAfterSaleSuccess(Long id, Integer refundPrice) { - // 1.1 更新订单项 - updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), - TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus(), null); - // 1.2 执行 TradeOrderHandler 的后置处理 - TradeOrderItemDO orderItem = tradeOrderItemMapper.selectById(id); - TradeOrderDO order = tradeOrderMapper.selectById(orderItem.getOrderId()); - tradeOrderHandlers.forEach(handler -> handler.afterCancelOrderItem(order, orderItem)); - - // 2.1 更新订单的退款金额、积分 - Integer orderRefundPrice = order.getRefundPrice() + refundPrice; - Integer orderRefundPoint = order.getRefundPoint() + orderItem.getUsePoint(); - Integer refundStatus = isAllOrderItemAfterSaleSuccess(order.getId()) ? - TradeOrderRefundStatusEnum.ALL.getStatus() // 如果都售后成功,则需要取消订单 - : TradeOrderRefundStatusEnum.PART.getStatus(); - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()) - .setRefundStatus(refundStatus) - .setRefundPrice(orderRefundPrice).setRefundPoint(orderRefundPoint)); - // 2.2 如果全部退款,则进行取消订单 - getSelf().cancelOrderByAfterSale(order, orderRefundPrice); - } - - @Override - public void updateOrderItemWhenAfterSaleCancel(Long id) { - // 更新订单项 - updateOrderItemAfterSaleStatus(id, TradeOrderItemAfterSaleStatusEnum.APPLY.getStatus(), - TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), null); - } - - private void updateOrderItemAfterSaleStatus(Long id, Integer oldAfterSaleStatus, Integer newAfterSaleStatus, - Long afterSaleId) { - // 更新订单项 - int updateCount = tradeOrderItemMapper.updateAfterSaleStatus(id, oldAfterSaleStatus, newAfterSaleStatus, afterSaleId); - if (updateCount <= 0) { - throw exception(ORDER_ITEM_UPDATE_AFTER_SALE_STATUS_FAIL); - } - - } - - /** - * 判断指定订单的所有订单项,是不是都售后成功 - * - * @param id 订单编号 - * @return 是否都售后成功 - */ - private boolean isAllOrderItemAfterSaleSuccess(Long id) { - List orderItems = tradeOrderItemMapper.selectListByOrderId(id); - return orderItems.stream().allMatch(orderItem -> Objects.equals(orderItem.getAfterSaleStatus(), - TradeOrderItemAfterSaleStatusEnum.SUCCESS.getStatus())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_COMMENT) - public Long createOrderItemCommentByMember(Long userId, AppTradeOrderItemCommentCreateReqVO createReqVO) { - // 1.1 先通过订单项 ID,查询订单项是否存在 - TradeOrderItemDO orderItem = tradeOrderItemMapper.selectByIdAndUserId(createReqVO.getOrderItemId(), userId); - if (orderItem == null) { - throw exception(ORDER_ITEM_NOT_FOUND); - } - // 1.2 校验订单相关状态 - TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderItem.getOrderId(), userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.COMPLETED.getStatus())) { - throw exception(ORDER_COMMENT_FAIL_STATUS_NOT_COMPLETED); - } - if (ObjectUtil.notEqual(order.getCommentStatus(), Boolean.FALSE)) { - throw exception(ORDER_COMMENT_STATUS_NOT_FALSE); - } - - // 2. 创建评价 - Long commentId = createOrderItemComment0(orderItem, createReqVO); - - // 3. 如果订单项都评论了,则更新订单评价状态 - List orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId()); - if (!anyMatch(orderItems, item -> Objects.equals(item.getCommentStatus(), Boolean.FALSE))) { - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE) - .setFinishTime(LocalDateTime.now())); - // 增加订单日志。注意:只有在所有订单项都评价后,才会增加 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus()); - } - return commentId; - } - - @Override - public int createOrderItemCommentBySystem() { - // 1. 查询过期的待支付订单 - LocalDateTime expireTime = minusTime(tradeOrderProperties.getCommentExpireTime()); - List orders = tradeOrderMapper.selectListByStatusAndReceiveTimeLt( - TradeOrderStatusEnum.COMPLETED.getStatus(), expireTime, false); - if (CollUtil.isEmpty(orders)) { - return 0; - } - - // 2. 遍历执行,逐个取消 - int count = 0; - for (TradeOrderDO order : orders) { - try { - getSelf().createOrderItemCommentBySystemBySystem(order); - count++; - } catch (Throwable e) { - log.error("[createOrderItemCommentBySystem][order({}) 过期订单异常]", order.getId(), e); - } - } - return count; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId) { - tradeOrderMapper.updateById( - new TradeOrderDO().setId(orderId).setCombinationActivityId(activityId) - .setCombinationRecordId(combinationRecordId).setCombinationHeadId(headId)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void cancelPaidOrder(Long userId, Long orderId) { - // TODO 芋艿:这里实现要优化下; - TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId); - if (order == null) { - throw exception(ORDER_NOT_FOUND); - } - cancelOrder0(order, TradeOrderCancelTypeEnum.MEMBER_CANCEL); - } - - /** - * 创建单个订单的评论 - * - * @param order 订单 - */ - @Transactional(rollbackFor = Exception.class) - @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.SYSTEM_COMMENT) - public void createOrderItemCommentBySystemBySystem(TradeOrderDO order) { - // 1. 查询未评论的订单项 - List orderItems = tradeOrderItemMapper.selectListByOrderIdAndCommentStatus( - order.getId(), Boolean.FALSE); - if (CollUtil.isEmpty(orderItems)) { - return; - } - - // 2. 逐个评论 - for (TradeOrderItemDO orderItem : orderItems) { - // 2.1 创建评价 - AppTradeOrderItemCommentCreateReqVO commentCreateReqVO = new AppTradeOrderItemCommentCreateReqVO() - .setOrderItemId(orderItem.getId()).setAnonymous(false).setContent("") - .setBenefitScores(5).setDescriptionScores(5); - createOrderItemComment0(orderItem, commentCreateReqVO); - - // 2.2 更新订单项评价状态 - tradeOrderItemMapper.updateById(new TradeOrderItemDO().setId(orderItem.getId()).setCommentStatus(Boolean.TRUE)); - } - - // 3. 所有订单项都评论了,则更新订单评价状态 - tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE) - .setFinishTime(LocalDateTime.now())); - // 增加订单日志。注意:只有在所有订单项都评价后,才会增加 - TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), order.getStatus()); - } - - /** - * 创建订单项的评论的核心实现 - * - * @param orderItem 订单项 - * @param createReqVO 评论内容 - * @return 评论编号 - */ - private Long createOrderItemComment0(TradeOrderItemDO orderItem, AppTradeOrderItemCommentCreateReqVO createReqVO) { - // 1. 创建评价 - ProductCommentCreateReqDTO productCommentCreateReqDTO = TradeOrderConvert.INSTANCE.convert04(createReqVO, orderItem); - Long commentId = productCommentApi.createComment(productCommentCreateReqDTO).getCheckedData(); - - // 2. 更新订单项评价状态 - tradeOrderItemMapper.updateById(new TradeOrderItemDO().setId(orderItem.getId()).setCommentStatus(Boolean.TRUE)); - return commentId; - } - - // =================== 营销相关的操作 =================== - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private TradeOrderUpdateServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeOrderLogCreateReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeOrderLogCreateReqBO.java deleted file mode 100644 index e0a9e1e02..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeOrderLogCreateReqBO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.bo; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 订单日志的创建 Request BO - * - * @author 陈賝 - * @since 2023/7/6 15:27 - */ -@Data -public class TradeOrderLogCreateReqBO { - - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - /** - * 用户类型 - */ - @NotNull(message = "用户类型不能为空") - private Integer userType; - - /** - * 订单编号 - */ - @NotNull(message = "订单编号不能为空") - private Long orderId; - /** - * 操作前状态 - */ - private Integer beforeStatus; - /** - * 操作后状态 - */ - @NotNull(message = "操作后的状态不能为空") - private Integer afterStatus; - - /** - * 操作类型 - */ - @NotNull(message = "操作类型不能为空") - private Integer operateType; - /** - * 操作明细 - */ - @NotEmpty(message = "操作明细不能为空") - private String content; - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainOrderHandler.java deleted file mode 100644 index 9af7be670..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBargainOrderHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.promotion.api.bargain.BargainActivityApi; -import cn.iocoder.yudao.module.promotion.api.bargain.BargainRecordApi; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 砍价订单的 {@link TradeOrderHandler} 实现类 - * - * @author HUIHUI - */ -@Component -public class TradeBargainOrderHandler implements TradeOrderHandler { - - @Resource - private BargainActivityApi bargainActivityApi; - @Resource - private BargainRecordApi bargainRecordApi; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isBargain(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "砍价时,只允许选择一个商品"); - - // 扣减砍价活动的库存 - bargainActivityApi.updateBargainActivityStock(order.getBargainActivityId(), - -orderItems.get(0).getCount()); - } - - @Override - public void afterOrderCreate(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isBargain(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "砍价时,只允许选择一个商品"); - - // 记录砍价记录对应的订单编号 - bargainRecordApi.updateBargainRecordOrderId(order.getBargainRecordId(), order.getId()); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isBargain(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "砍价时,只允许选择一个商品"); - - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - afterCancelOrderItem(order, orderItems.get(0)); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - if (!TradeOrderTypeEnum.isBargain(order.getType())) { - return; - } - // 恢复(增加)砍价活动的库存 - bargainActivityApi.updateBargainActivityStock(order.getBargainActivityId(), orderItem.getCount()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBrokerageOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBrokerageOrderHandler.java deleted file mode 100644 index 930ed2160..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeBrokerageOrderHandler.java +++ /dev/null @@ -1,118 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; -import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService; -import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageAddReqBO; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -/** - * 订单分销的 {@link TradeOrderHandler} 实现类 - * - * @author 芋道源码 - */ -@Component -public class TradeBrokerageOrderHandler implements TradeOrderHandler { - - @Resource - private MemberUserApi memberUserApi; - @Resource - private ProductSpuApi productSpuApi; - @Resource - private ProductSkuApi productSkuApi; - - @Resource - private BrokerageRecordService brokerageRecordService; - @Resource - private BrokerageUserService brokerageUserService; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - // 设置订单推广人 - BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(order.getUserId()); - if (brokerageUser != null && brokerageUser.getBindUserId() != null) { - order.setBrokerageUserId(brokerageUser.getBindUserId()); - } - } - - @Override - public void afterPayOrder(TradeOrderDO order, List orderItems) { - if (order.getBrokerageUserId() == null) { - return; - } - addBrokerage(order.getUserId(), orderItems); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - // 如果是未支付的订单,不会产生分销结果,所以直接 return - if (!order.getPayStatus()) { - return; - } - if (order.getBrokerageUserId() == null) { - return; - } - - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - orderItems.forEach(orderItem -> afterCancelOrderItem(order, orderItem)); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - if (order.getBrokerageUserId() == null) { - return; - } - cancelBrokerage(order.getBrokerageUserId(), orderItem.getId()); - } - - /** - * 创建分销记录 - *

- * 目前是支付成功后,就会创建分销记录。 - *

- * 业内还有两种做法,可以根据自己的业务调整: - * 1. 确认收货后,才创建分销记录 - * 2. 支付 or 下单成功时,创建分销记录(冻结),确认收货解冻或者 n 天后解冻 - * - * @param userId 用户编号 - * @param orderItems 订单项 - */ - protected void addBrokerage(Long userId, List orderItems) { - MemberUserRespDTO user = memberUserApi.getUser(userId).getCheckedData(); - Assert.notNull(user); - ProductSpuRespDTO spu = productSpuApi.getSpu(orderItems.get(0).getSpuId()).getCheckedData(); - Assert.notNull(spu); - ProductSkuRespDTO sku = productSkuApi.getSku(orderItems.get(0).getSkuId()).getCheckedData(); - - // 每一个订单项,都会去生成分销记录 - List addList = convertList(orderItems, - item -> TradeOrderConvert.INSTANCE.convert(user, item, spu, sku)); - brokerageRecordService.addBrokerage(userId, BrokerageRecordBizTypeEnum.ORDER, addList); - } - - protected void cancelBrokerage(Long userId, Long orderItemId) { - brokerageRecordService.cancelBrokerage(userId, BrokerageRecordBizTypeEnum.ORDER, String.valueOf(orderItemId)); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java deleted file mode 100644 index 435b6e7ae..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateRespDTO; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_CREATE_FAIL_EXIST_UNPAID; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS; - -/** - * 拼团订单的 {@link TradeOrderHandler} 实现类 - * - * @author HUIHUI - */ -@Component -public class TradeCombinationOrderHandler implements TradeOrderHandler { - - @Resource - private TradeOrderUpdateService orderUpdateService; - @Resource - private TradeOrderQueryService orderQueryService; - - @Resource - private CombinationRecordApi combinationRecordApi; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - // 如果不是拼团订单则结束 - if (!TradeOrderTypeEnum.isCombination(order.getType())) { - return; - } - Assert.isTrue(orderItems.size() == 1, "拼团时,只允许选择一个商品"); - - // 1. 校验是否满足拼团活动相关限制 - TradeOrderItemDO item = orderItems.get(0); - combinationRecordApi.validateCombinationRecord(order.getUserId(), order.getCombinationActivityId(), - order.getCombinationHeadId(), item.getSkuId(), item.getCount()); - - // 2. 校验该用户是否存在未支付的拼团活动订单,避免一个拼团可以下多个单子了 - TradeOrderDO activityOrder = orderQueryService.getOrderByUserIdAndStatusAndCombination( - order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus()); - if (activityOrder != null) { - throw exception(ORDER_CREATE_FAIL_EXIST_UNPAID); - } - } - - @Override - public void afterPayOrder(TradeOrderDO order, List orderItems) { - // 1.如果不是拼团订单则结束 - if (!TradeOrderTypeEnum.isCombination(order.getType())) { - return; - } - Assert.isTrue(orderItems.size() == 1, "拼团时,只允许选择一个商品"); - - // 2. 创建拼团记录 - TradeOrderItemDO item = orderItems.get(0); - CombinationRecordCreateRespDTO combinationRecord = combinationRecordApi.createCombinationRecord( - TradeOrderConvert.INSTANCE.convert(order, item)).getCheckedData(); - - // 3. 更新拼团相关信息到订单。为什么几个字段都要更新? - // 原因是:如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 的,设置团长编号这个操作时在订单是否后创建拼团记录时才设置的。 - orderUpdateService.updateOrderCombinationInfo(order.getId(), order.getCombinationActivityId(), - combinationRecord.getCombinationRecordId(), combinationRecord.getCombinationHeadId()); - } - - @Override - public void beforeDeliveryOrder(TradeOrderDO order) { - if (!TradeOrderTypeEnum.isCombination(order.getType())) { - return; - } - // 校验订单拼团是否成功 - if (!combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId()).getCheckedData()) { - throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS); - } - } - -} - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCouponOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCouponOrderHandler.java deleted file mode 100644 index 0f953fec7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCouponOrderHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 优惠劵的 {@link TradeOrderHandler} 实现类 - * - * @author 芋道源码 - */ -@Component -public class TradeCouponOrderHandler implements TradeOrderHandler { - - @Resource - private CouponApi couponApi; - - @Override - public void afterOrderCreate(TradeOrderDO order, List orderItems) { - if (order.getCouponId() == null || order.getCouponId() <= 0) { - return; - } - // 不在前置扣减的原因,是因为优惠劵要记录使用的订单号 - couponApi.useCoupon(new CouponUseReqDTO().setId(order.getCouponId()).setUserId(order.getUserId()) - .setOrderId(order.getId())); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - if (order.getCouponId() == null || order.getCouponId() <= 0) { - return; - } - // 退回优惠劵 - couponApi.returnUsedCoupon(order.getCouponId()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeMemberPointOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeMemberPointOrderHandler.java deleted file mode 100644 index 0c1f9d497..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeMemberPointOrderHandler.java +++ /dev/null @@ -1,120 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.point.MemberPointApi; -import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; -import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; -import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.service.aftersale.AfterSaleService; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; - -/** - * 会员积分、等级的 {@link TradeOrderHandler} 实现类 - * - * @author owen - */ -@Component -public class TradeMemberPointOrderHandler implements TradeOrderHandler { - - @Resource - private MemberPointApi memberPointApi; - @Resource - private MemberLevelApi memberLevelApi; - - @Resource - private AfterSaleService afterSaleService; - - @Override - public void afterOrderCreate(TradeOrderDO order, List orderItems) { - // 扣减用户积分(订单抵扣)。不在前置扣减的原因,是因为积分扣减时,需要记录关联业务 - reducePoint(order.getUserId(), order.getUsePoint(), MemberPointBizTypeEnum.ORDER_USE, order.getId()); - } - - @Override - public void afterPayOrder(TradeOrderDO order, List orderItems) { - // 增加用户积分(订单赠送) - addPoint(order.getUserId(), order.getGivePoint(), MemberPointBizTypeEnum.ORDER_GIVE, - order.getId()); - - // 增加用户经验 - memberLevelApi.addExperience(order.getUserId(), order.getPayPrice(), - MemberExperienceBizTypeEnum.ORDER_GIVE.getType(), String.valueOf(order.getId())); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - - // 增加(回滚)用户积分(订单抵扣) - Integer usePoint = getSumValue(orderItems, TradeOrderItemDO::getUsePoint, Integer::sum); - addPoint(order.getUserId(), usePoint, MemberPointBizTypeEnum.ORDER_USE_CANCEL, - order.getId()); - - // 如下的返还,需要经过支持,也就是经历 afterPayOrder 流程 - if (!order.getPayStatus()) { - return; - } - // 扣减(回滚)积分(订单赠送) - Integer givePoint = getSumValue(orderItems, TradeOrderItemDO::getGivePoint, Integer::sum); - reducePoint(order.getUserId(), givePoint, MemberPointBizTypeEnum.ORDER_GIVE_CANCEL, - order.getId()); - // 扣减(回滚)用户经验 - int payPrice = order.getPayPrice() - order.getRefundPrice(); - memberLevelApi.addExperience(order.getUserId(), payPrice, - MemberExperienceBizTypeEnum.ORDER_GIVE_CANCEL.getType(), String.valueOf(order.getId())); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - // 扣减(回滚)积分(订单赠送) - reducePoint(order.getUserId(), orderItem.getGivePoint(), MemberPointBizTypeEnum.ORDER_GIVE_CANCEL_ITEM, - orderItem.getId()); - // 增加(回滚)积分(订单抵扣) - addPoint(order.getUserId(), orderItem.getUsePoint(), MemberPointBizTypeEnum.ORDER_USE_CANCEL_ITEM, - orderItem.getId()); - - // 扣减(回滚)用户经验 - AfterSaleDO afterSale = afterSaleService.getAfterSale(orderItem.getAfterSaleId()); - memberLevelApi.reduceExperience(order.getUserId(), afterSale.getRefundPrice(), - MemberExperienceBizTypeEnum.ORDER_GIVE_CANCEL_ITEM.getType(), String.valueOf(orderItem.getId())); - } - - /** - * 添加用户积分 - *

- * 目前是支付成功后,就会创建积分记录。 - *

- * 业内还有两种做法,可以根据自己的业务调整: - * 1. 确认收货后,才创建积分记录 - * 2. 支付 or 下单成功时,创建积分记录(冻结),确认收货解冻或者 n 天后解冻 - * - * @param userId 用户编号 - * @param point 增加积分数量 - * @param bizType 业务编号 - * @param bizId 业务编号 - */ - protected void addPoint(Long userId, Integer point, MemberPointBizTypeEnum bizType, Long bizId) { - if (point != null && point > 0) { - memberPointApi.addPoint(userId, point, bizType.getType(), String.valueOf(bizId)); - } - } - - protected void reducePoint(Long userId, Integer point, MemberPointBizTypeEnum bizType, Long bizId) { - if (point != null && point > 0) { - memberPointApi.reducePoint(userId, point, bizType.getType(), String.valueOf(bizId)); - } - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java deleted file mode 100644 index 4cc5c69a3..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeOrderHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; - -import java.util.List; - -/** - * 订单活动特殊逻辑处理器 handler 接口 - * 提供订单生命周期钩子接口;订单创建前、订单创建后、订单支付后、订单取消 - * - * @author HUIHUI - */ -public interface TradeOrderHandler { - - /** - * 订单创建前 - * - * @param order 订单 - * @param orderItems 订单项 - */ - default void beforeOrderCreate(TradeOrderDO order, List orderItems) {} - - /** - * 订单创建后 - * - * @param order 订单 - * @param orderItems 订单项 - */ - default void afterOrderCreate(TradeOrderDO order, List orderItems) {} - - /** - * 支付订单后 - * - * @param order 订单 - * @param orderItems 订单项 - */ - default void afterPayOrder(TradeOrderDO order, List orderItems) {} - - /** - * 订单取消后 - * - * @param order 订单 - * @param orderItems 订单项 - */ - default void afterCancelOrder(TradeOrderDO order, List orderItems) {} - - /** - * 订单项取消后 - * - * @param order 订单 - * @param orderItem 订单项 - */ - default void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) {} - - /** - * 订单发货前 - * - * @param order 订单 - */ - default void beforeDeliveryOrder(TradeOrderDO order) {} - - // ========== 公用方法 ========== - - /** - * 过滤“未售后”的订单项列表 - * - * @param orderItems 订单项列表 - * @return 过滤后的订单项列表 - */ - default List filterOrderItemListByNoneAfterSale(List orderItems) { - return CollectionUtils.filterList(orderItems, - item -> TradeOrderItemAfterSaleStatusEnum.isNone(item.getAfterSaleStatus())); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeProductSkuOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeProductSkuOrderHandler.java deleted file mode 100644 index d28a643c6..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeProductSkuOrderHandler.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -import static java.util.Collections.singletonList; - -/** - * 商品 SKU 库存的 {@link TradeOrderHandler} 实现类 - * - * @author 芋道源码 - */ -@Component -public class TradeProductSkuOrderHandler implements TradeOrderHandler { - - @Resource - private ProductSkuApi productSkuApi; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - productSkuApi.updateSkuStock(TradeOrderConvert.INSTANCE.convertNegative(orderItems)); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - productSkuApi.updateSkuStock(TradeOrderConvert.INSTANCE.convert(orderItems)); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - productSkuApi.updateSkuStock(TradeOrderConvert.INSTANCE.convert(singletonList(orderItem))); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillOrderHandler.java deleted file mode 100644 index 68227df7d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeSeckillOrderHandler.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.order.handler; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.promotion.api.seckill.SeckillActivityApi; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 秒杀订单的 {@link TradeOrderHandler} 实现类 - * - * @author HUIHUI - */ -@Component -public class TradeSeckillOrderHandler implements TradeOrderHandler { - - @Resource - private SeckillActivityApi seckillActivityApi; - - @Override - public void beforeOrderCreate(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isSeckill(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "秒杀时,只允许选择一个商品"); - - // 扣减秒杀活动的库存 - seckillActivityApi.updateSeckillStockDecr(order.getSeckillActivityId(), - orderItems.get(0).getSkuId(), orderItems.get(0).getCount()); - } - - @Override - public void afterCancelOrder(TradeOrderDO order, List orderItems) { - if (!TradeOrderTypeEnum.isSeckill(order.getType())) { - return; - } - // 明确校验一下 - Assert.isTrue(orderItems.size() == 1, "秒杀时,只允许选择一个商品"); - - // 售后的订单项,已经在 afterCancelOrderItem 回滚库存,所以这里不需要重复回滚 - orderItems = filterOrderItemListByNoneAfterSale(orderItems); - if (CollUtil.isEmpty(orderItems)) { - return; - } - afterCancelOrderItem(order, orderItems.get(0)); - } - - @Override - public void afterCancelOrderItem(TradeOrderDO order, TradeOrderItemDO orderItem) { - if (!TradeOrderTypeEnum.isSeckill(order.getType())) { - return; - } - // 恢复秒杀活动的库存 - seckillActivityApi.updateSeckillStockIncr(order.getSeckillActivityId(), - orderItem.getSkuId(), orderItem.getCount()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceService.java deleted file mode 100644 index d12451b22..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceService.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price; - -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; - -import javax.validation.Valid; - -/** - * 价格计算 Service 接口 - * - * @author 芋道源码 - */ -public interface TradePriceService { - - /** - * 价格计算 - * - * @param calculateReqDTO 计算信息 - * @return 计算结果 - */ - TradePriceCalculateRespBO calculatePrice(@Valid TradePriceCalculateReqBO calculateReqDTO); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImpl.java deleted file mode 100644 index c6e170fc3..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/TradePriceServiceImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price; - -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculator; -import cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_STOCK_NOT_ENOUGH; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_PAY_PRICE_ILLEGAL; - -/** - * 价格计算 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class TradePriceServiceImpl implements TradePriceService { - - @Resource - private ProductSkuApi productSkuApi; - @Resource - private ProductSpuApi productSpuApi; - - @Resource - private List priceCalculators; - - @Override - public TradePriceCalculateRespBO calculatePrice(TradePriceCalculateReqBO calculateReqBO) { - // 1.1 获得商品 SKU 数组 - List skuList = checkSkuList(calculateReqBO); - // 1.2 获得商品 SPU 数组 - List spuList = checkSpuList(skuList); - - // 2.1 计算价格 - TradePriceCalculateRespBO calculateRespBO = TradePriceCalculatorHelper - .buildCalculateResp(calculateReqBO, spuList, skuList); - priceCalculators.forEach(calculator -> calculator.calculate(calculateReqBO, calculateRespBO)); - // 2.2 如果最终支付金额小于等于 0,则抛出业务异常 - if (calculateRespBO.getPrice().getPayPrice() <= 0) { - log.error("[calculatePrice][价格计算不正确,请求 calculateReqDTO({}),结果 priceCalculate({})]", - calculateReqBO, calculateRespBO); - throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL); - } - return calculateRespBO; - } - - private List checkSkuList(TradePriceCalculateReqBO reqBO) { - // 获得商品 SKU 数组 - Map skuIdCountMap = convertMap(reqBO.getItems(), - TradePriceCalculateReqBO.Item::getSkuId, TradePriceCalculateReqBO.Item::getCount); - List skus = productSkuApi.getSkuList(skuIdCountMap.keySet()).getCheckedData(); - - // 校验商品 SKU - skus.forEach(sku -> { - Integer count = skuIdCountMap.get(sku.getId()); - if (count == null) { - throw exception(SKU_NOT_EXISTS); - } - if (count > sku.getStock()) { - throw exception(SKU_STOCK_NOT_ENOUGH); - } - }); - return skus; - } - - private List checkSpuList(List skuList) { - // 获得商品 SPU 数组 - return productSpuApi.validateSpuList(convertSet(skuList, ProductSkuRespDTO::getSpuId)).getCheckedData(); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateReqBO.java deleted file mode 100644 index 295dcd3bc..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateReqBO.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.bo; - -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 价格计算 Request BO - * - * @author yudao源码 - */ -@Data -public class TradePriceCalculateReqBO { - - /** - * 用户编号 - * - * 对应 MemberUserDO 的 id 编号 - */ - private Long userId; - - /** - * 优惠劵编号 - * - * 对应 CouponDO 的 id 编号 - */ - private Long couponId; - - /** - * 是否使用积分 - */ - @NotNull(message = "是否使用积分不能为空") - private Boolean pointStatus; - - /** - * 配送方式 - * - * 枚举 {@link DeliveryTypeEnum} - */ - private Integer deliveryType; - /** - * 收货地址编号 - * - * 对应 MemberAddressDO 的 id 编号 - */ - private Long addressId; - /** - * 自提门店编号 - * - * 对应 PickUpStoreDO 的 id 编号 - */ - private Long pickUpStoreId; - - /** - * 商品 SKU 数组 - */ - @NotNull(message = "商品数组不能为空") - private List items; - - // ========== 秒杀活动相关字段 ========== - /** - * 秒杀活动编号 - */ - private Long seckillActivityId; - - // ========== 拼团活动相关字段 ========== - /** - * 拼团活动编号 - */ - private Long combinationActivityId; - - /** - * 拼团团长编号 - */ - private Long combinationHeadId; - - // ========== 砍价活动相关字段 ========== - /** - * 砍价记录编号 - */ - private Long bargainRecordId; - - /** - * 商品 SKU - */ - @Data - @Valid - public static class Item { - - /** - * SKU 编号 - */ - @NotNull(message = "商品 SKU 编号不能为空") - private Long skuId; - - /** - * SKU 数量 - */ - @NotNull(message = "商品 SKU 数量不能为空") - @Min(value = 0L, message = "商品 SKU 数量必须大于等于 0") - private Integer count; - - /** - * 购物车项的编号 - */ - private Long cartId; - - /** - * 是否选中 - */ - @NotNull(message = "是否选中不能为空") - private Boolean selected; - - } -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateRespBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateRespBO.java deleted file mode 100644 index 93867f1e4..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/bo/TradePriceCalculateRespBO.java +++ /dev/null @@ -1,311 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.bo; - -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import lombok.Data; - -import java.util.List; - -/** - * 价格计算 Response BO - * - * 整体设计,参考 taobao 的技术文档: - * 1. 订单管理 - * 2. 常用订单金额说明 - * - * @author 芋道源码 - */ -@Data -public class TradePriceCalculateRespBO { - - /** - * 订单类型 - * - * 枚举 {@link TradeOrderTypeEnum} - */ - private Integer type; - - /** - * 订单价格 - */ - private Price price; - - /** - * 订单项数组 - */ - private List items; - - /** - * 营销活动数组 - * - * 只对应 {@link Price#items} 商品匹配的活动 - */ - private List promotions; - - /** - * 优惠劵编号 - */ - private Long couponId; - - /** - * 使用的积分 - */ - private Integer usePoint; - - /** - * 使用的积分 - */ - private Integer givePoint; - - /** - * 砍价活动编号 - */ - private Long bargainActivityId; - - /** - * 订单价格 - */ - @Data - public static class Price { - - /** - * 商品原价(总),单位:分 - * - * 基于 {@link OrderItem#getPrice()} * {@link OrderItem#getCount()} 求和 - * - * 对应 taobao 的 trade.total_fee 字段 - */ - private Integer totalPrice; - /** - * 订单优惠(总),单位:分 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 运费金额,单位:分 - */ - private Integer deliveryPrice; - /** - * 优惠劵减免金额(总),单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 积分抵扣的金额,单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - /** - * VIP 减免金额,单位:分 - */ - private Integer vipPrice; - /** - * 最终购买金额(总),单位:分 - * - * = {@link #totalPrice} - * - {@link #couponPrice} - * - {@link #pointPrice} - * - {@link #discountPrice} - * + {@link #deliveryPrice} - * - {@link #vipPrice} - */ - private Integer payPrice; - - } - - /** - * 订单商品 SKU - */ - @Data - public static class OrderItem { - - /** - * SPU 编号 - */ - private Long spuId; - /** - * SKU 编号 - */ - private Long skuId; - /** - * 购买数量 - */ - private Integer count; - /** - * 购物车项的编号 - */ - private Long cartId; - /** - * 是否选中 - */ - private Boolean selected; - - /** - * 商品原价(单),单位:分 - * - * 对应 ProductSkuDO 的 price 字段 - * 对应 taobao 的 order.price 字段 - */ - private Integer price; - /** - * 优惠金额(总),单位:分 - * - * 对应 taobao 的 order.discount_fee 字段 - */ - private Integer discountPrice; - /** - * 运费金额(总),单位:分 - */ - private Integer deliveryPrice; - /** - * 优惠劵减免金额,单位:分 - * - * 对应 taobao 的 trade.coupon_fee 字段 - */ - private Integer couponPrice; - /** - * 积分抵扣的金额,单位:分 - * - * 对应 taobao 的 trade.point_fee 字段 - */ - private Integer pointPrice; - /** - * 使用的积分 - */ - private Integer usePoint; - /** - * VIP 减免金额,单位:分 - */ - private Integer vipPrice; - /** - * 应付金额(总),单位:分 - * - * = {@link #price} * {@link #count} - * - {@link #couponPrice} - * - {@link #pointPrice} - * - {@link #discountPrice} - * + {@link #deliveryPrice} - * - {@link #vipPrice} - */ - private Integer payPrice; - - // ========== 商品 SPU 信息 ========== - /** - * 商品名 - */ - private String spuName; - /** - * 商品图片 - * - * 优先级:SKU.picUrl > SPU.picUrl - */ - private String picUrl; - /** - * 分类编号 - */ - private Long categoryId; - - /** - * 运费模板 Id - */ - private Long deliveryTemplateId; - - // ========== 商品 SKU 信息 ========== - /** - * 商品重量,单位:kg 千克 - */ - private Double weight; - /** - * 商品体积,单位:m^3 平米 - */ - private Double volume; - - /** - * 商品属性数组 - */ - private List properties; - - /** - * 使用的积分 - */ - private Integer givePoint; - - } - - /** - * 营销明细 - */ - @Data - public static class Promotion { - - /** - * 营销编号 - * - * 例如说:营销活动的编号、优惠劵的编号 - */ - private Long id; - /** - * 营销名字 - */ - private String name; - /** - * 营销类型 - * - * 枚举 {@link PromotionTypeEnum} - */ - private Integer type; - /** - * 计算时的原价(总),单位:分 - */ - private Integer totalPrice; - /** - * 计算时的优惠(总),单位:分 - */ - private Integer discountPrice; - /** - * 匹配的商品 SKU 数组 - */ - private List items; - - // ========== 匹配情况 ========== - - /** - * 是否满足优惠条件 - */ - private Boolean match; - /** - * 满足条件的提示 - * - * 如果 {@link #match} = true 满足,则提示“圣诞价:省 150.00 元” - * 如果 {@link #match} = false 不满足,则提示“购满 85 元,可减 40 元” - */ - private String description; - - } - - /** - * 营销匹配的商品 SKU - */ - @Data - public static class PromotionItem { - - /** - * 商品 SKU 编号 - */ - private Long skuId; - /** - * 计算时的原价(总),单位:分 - */ - private Integer totalPrice; - /** - * 计算时的优惠(总),单位:分 - */ - private Integer discountPrice; - - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeBargainActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeBargainActivityPriceCalculator.java deleted file mode 100644 index a0cd38844..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeBargainActivityPriceCalculator.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.bargain.BargainRecordApi; -import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -// TODO huihui:单测需要补充 -/** - * 砍价活动的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_BARGAIN_ACTIVITY) -public class TradeBargainActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private BargainRecordApi bargainRecordApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1. 判断订单类型和是否具有拼团记录编号 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.BARGAIN.getType())) { - return; - } - Assert.isTrue(param.getItems().size() == 1, "砍价时,只允许选择一个商品"); - Assert.isTrue(param.getItems().get(0).getCount() == 1, "砍价时,只允许选择一个商品"); - // 2. 校验是否可以参与砍价 - TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0); - BargainValidateJoinRespDTO bargainActivity = bargainRecordApi.validateJoinBargain( - param.getUserId(), param.getBargainRecordId(), orderItem.getSkuId()).getCheckedData(); - - // 3.1 记录优惠明细 - Integer discountPrice = orderItem.getPayPrice() - bargainActivity.getBargainPrice() * orderItem.getCount(); - // TODO 芋艿:极端情况,优惠金额为负数,需要处理 - TradePriceCalculatorHelper.addPromotion(result, orderItem, - param.getSeckillActivityId(), bargainActivity.getName(), PromotionTypeEnum.BARGAIN_ACTIVITY.getType(), - StrUtil.format("砍价活动:省 {} 元", TradePriceCalculatorHelper.formatPrice(discountPrice)), - discountPrice); - // 3.2 更新 SKU 优惠金额 - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + discountPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - TradePriceCalculatorHelper.recountAllPrice(result); - // 4. 特殊:设置对应的砍价活动编号 - result.setBargainActivityId(bargainActivity.getActivityId()); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCombinationActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCombinationActivityPriceCalculator.java deleted file mode 100644 index 4ca8f4608..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCombinationActivityPriceCalculator.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi; -import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -// TODO @puhui999:单测可以后补下 - -/** - * 拼团活动的 {@link TradePriceCalculator} 实现类 - * - * @author HUIHUI - */ -@Component -@Order(TradePriceCalculator.ORDER_COMBINATION_ACTIVITY) -public class TradeCombinationActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private CombinationRecordApi combinationRecordApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1. 判断订单类型和是否具有拼团活动编号 - if (param.getCombinationActivityId() == null) { - return; - } - Assert.isTrue(param.getItems().size() == 1, "拼团时,只允许选择一个商品"); - // 2. 校验是否可以参与拼团 - TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0); - CombinationValidateJoinRespDTO combinationActivity = combinationRecordApi.validateJoinCombination( - param.getUserId(), param.getCombinationActivityId(), param.getCombinationHeadId(), - orderItem.getSkuId(), orderItem.getCount()).getCheckedData(); - - // 3.1 记录优惠明细 - Integer discountPrice = orderItem.getPayPrice() - combinationActivity.getCombinationPrice() * orderItem.getCount(); - TradePriceCalculatorHelper.addPromotion(result, orderItem, - param.getCombinationActivityId(), combinationActivity.getName(), PromotionTypeEnum.COMBINATION_ACTIVITY.getType(), - StrUtil.format("拼团活动:省 {} 元", TradePriceCalculatorHelper.formatPrice(discountPrice)), - discountPrice); - // 3.2 更新 SKU 优惠金额 - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + discountPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - TradePriceCalculatorHelper.recountAllPrice(result); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculator.java deleted file mode 100644 index bb2c35f76..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculator.java +++ /dev/null @@ -1,120 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponValidReqDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.function.Predicate; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_NO_MATCH_MIN_PRICE; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_NO_MATCH_SPU; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER; - -/** - * 优惠劵的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_COUPON) -public class TradeCouponPriceCalculator implements TradePriceCalculator { - - @Resource - private CouponApi couponApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1.1 校验优惠劵 - if (param.getCouponId() == null) { - return; - } - CouponRespDTO coupon = couponApi.validateCoupon(new CouponValidReqDTO() - .setId(param.getCouponId()).setUserId(param.getUserId())).getCheckedData(); - Assert.notNull(coupon, "校验通过的优惠劵({}),不能为空", param.getCouponId()); - // 1.2 只有【普通】订单,才允许使用优惠劵 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) { - throw exception(PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER); - } - - // 2.1 获得匹配的商品 SKU 数组 - List orderItems = filterMatchCouponOrderItems(result, coupon); - if (CollUtil.isEmpty(orderItems)) { - throw exception(COUPON_NO_MATCH_SPU); - } - // 2.2 计算是否满足优惠劵的使用金额 - Integer totalPayPrice = TradePriceCalculatorHelper.calculateTotalPayPrice(orderItems); - if (totalPayPrice < coupon.getUsePrice()) { - throw exception(COUPON_NO_MATCH_MIN_PRICE); - } - - // 3.1 计算可以优惠的金额 - Integer couponPrice = getCouponPrice(coupon, totalPayPrice); - Assert.isTrue(couponPrice < totalPayPrice, - "优惠劵({}) 的优惠金额({}),不能大于订单总金额({})", coupon.getId(), couponPrice, totalPayPrice); - // 3.2 计算分摊的优惠金额 - List divideCouponPrices = TradePriceCalculatorHelper.dividePrice(orderItems, couponPrice); - - // 4.1 记录使用的优惠劵 - result.setCouponId(param.getCouponId()); - // 4.2 记录优惠明细 - TradePriceCalculatorHelper.addPromotion(result, orderItems, - param.getCouponId(), coupon.getName(), PromotionTypeEnum.COUPON.getType(), - StrUtil.format("优惠劵:省 {} 元", TradePriceCalculatorHelper.formatPrice(couponPrice)), - divideCouponPrices); - // 4.3 更新 SKU 优惠金额 - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - orderItem.setCouponPrice(divideCouponPrices.get(i)); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - } - TradePriceCalculatorHelper.recountAllPrice(result); - } - - private Integer getCouponPrice(CouponRespDTO coupon, Integer totalPayPrice) { - if (PromotionDiscountTypeEnum.PRICE.getType().equals(coupon.getDiscountType())) { // 减价 - return coupon.getDiscountPrice(); - } else if (PromotionDiscountTypeEnum.PERCENT.getType().equals(coupon.getDiscountType())) { // 打折 - int couponPrice = totalPayPrice * coupon.getDiscountPercent() / 100; - return coupon.getDiscountLimitPrice() == null ? couponPrice - : Math.min(couponPrice, coupon.getDiscountLimitPrice()); // 优惠上限 - } - throw new IllegalArgumentException(String.format("优惠劵(%s) 的优惠类型不正确", coupon)); - } - - /** - * 获得优惠劵可使用的订单项(商品)列表 - * - * @param result 计算结果 - * @param coupon 优惠劵 - * @return 订单项(商品)列表 - */ - private List filterMatchCouponOrderItems(TradePriceCalculateRespBO result, - CouponRespDTO coupon) { - Predicate matchPredicate = TradePriceCalculateRespBO.OrderItem::getSelected; - if (PromotionProductScopeEnum.SPU.getScope().equals(coupon.getProductScope())) { - matchPredicate = matchPredicate // 额外加如下条件 - .and(orderItem -> coupon.getProductScopeValues().contains(orderItem.getSpuId())); - } else if (PromotionProductScopeEnum.CATEGORY.getScope().equals(coupon.getProductScope())) { - matchPredicate = matchPredicate // 额外加如下条件 - .and(orderItem -> coupon.getProductScopeValues().contains(orderItem.getCategoryId())); - } - return filterList(result.getItems(), matchPredicate); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDeliveryPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDeliveryPriceCalculator.java deleted file mode 100644 index 798aff9f9..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDeliveryPriceCalculator.java +++ /dev/null @@ -1,226 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.module.member.api.address.MemberAddressApi; -import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO; -import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; -import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryPickUpStoreDO; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryExpressChargeModeEnum; -import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; -import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressTemplateService; -import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService; -import cn.iocoder.yudao.module.trade.service.delivery.bo.DeliveryExpressTemplateRespBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO.OrderItem; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; - -/** - * 运费的 {@link TradePriceCalculator} 实现类 - * - * @author jason - */ -@Component -@Order(TradePriceCalculator.ORDER_DELIVERY) -@Slf4j -public class TradeDeliveryPriceCalculator implements TradePriceCalculator { - - @Resource - private MemberAddressApi addressApi; - - @Resource - private DeliveryPickUpStoreService deliveryPickUpStoreService; - @Resource - private DeliveryExpressTemplateService deliveryExpressTemplateService; - @Resource - private TradeConfigService tradeConfigService; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - if (param.getDeliveryType() == null) { - return; - } - if (DeliveryTypeEnum.PICK_UP.getType().equals(param.getDeliveryType())) { - calculateByPickUp(param); - } else if (DeliveryTypeEnum.EXPRESS.getType().equals(param.getDeliveryType())) { - calculateExpress(param, result); - } - } - - private void calculateByPickUp(TradePriceCalculateReqBO param) { - if (param.getPickUpStoreId() == null) { - // 价格计算时,如果为空就不算~最终下单,会校验该字段不允许空 - return; - } - DeliveryPickUpStoreDO pickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(param.getPickUpStoreId()); - if (pickUpStore == null || CommonStatusEnum.DISABLE.getStatus().equals(pickUpStore.getStatus())) { - throw exception(PICK_UP_STORE_NOT_EXISTS); - } - } - - // ========= 快递发货 ========== - - private void calculateExpress(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 0. 得到收件地址区域 - if (param.getAddressId() == null) { - // 价格计算时,如果为空就不算~最终下单,会校验该字段不允许空 - return; - } - MemberAddressRespDTO address = addressApi.getAddress(param.getAddressId(), param.getUserId()).getCheckedData(); - Assert.notNull(address, "收件人({})的地址,不能为空", param.getUserId()); - - // 情况一:全局包邮 - if (isGlobalExpressFree(result)) { - return; - } - - // 情况二:快递模版 - // 2.1 过滤出已选中的商品 SKU - List selectedItem = filterList(result.getItems(), OrderItem::getSelected); - Set deliveryTemplateIds = convertSet(selectedItem, OrderItem::getDeliveryTemplateId); - Map expressTemplateMap = - deliveryExpressTemplateService.getExpressTemplateMapByIdsAndArea(deliveryTemplateIds, address.getAreaId()); - // 2.2 计算配送费用 - if (CollUtil.isEmpty(expressTemplateMap)) { - log.error("[calculate][找不到商品 templateIds {} areaId{} 对应的运费模板]", deliveryTemplateIds, address.getAreaId()); - throw exception(PRICE_CALCULATE_DELIVERY_PRICE_TEMPLATE_NOT_FOUND); - } - calculateDeliveryPrice(selectedItem, expressTemplateMap, result); - } - - /** - * 是否全局包邮 - * - * @param result 计算结果 - * @return 是否包邮 - */ - private boolean isGlobalExpressFree(TradePriceCalculateRespBO result) { - TradeConfigDO config = tradeConfigService.getTradeConfig(); - return config != null - && Boolean.TRUE.equals(config.getDeliveryExpressFreeEnabled()) // 开启包邮 - && result.getPrice().getPayPrice() >= config.getDeliveryExpressFreePrice(); // 满足包邮的价格 - } - - private void calculateDeliveryPrice(List selectedSkus, - Map expressTemplateMap, - TradePriceCalculateRespBO result) { - // 按商品运费模板来计算商品的运费:相同的运费模板可能对应多条订单商品 SKU - Map> template2ItemMap = convertMultiMap(selectedSkus, OrderItem::getDeliveryTemplateId); - // 依次计算快递运费 - for (Map.Entry> entry : template2ItemMap.entrySet()) { - Long templateId = entry.getKey(); - List orderItems = entry.getValue(); - DeliveryExpressTemplateRespBO templateBO = expressTemplateMap.get(templateId); - if (templateBO == null) { - log.error("[calculateDeliveryPrice][不能计算快递运费,找不到 templateId({}) 对应的运费模板配置]", templateId); - continue; - } - // 1. 优先判断是否包邮。如果包邮不计算快递运费 - if (isExpressTemplateFree(orderItems, templateBO.getChargeMode(), templateBO.getFree())) { - continue; - } - // 2. 计算快递运费 - calculateExpressFeeByChargeMode(orderItems, templateBO.getChargeMode(), templateBO.getCharge()); - } - TradePriceCalculatorHelper.recountAllPrice(result); - } - - /** - * 按配送方式来计算运费 - * - * @param orderItems SKU 商品项目 - * @param chargeMode 配送计费方式 - * @param templateCharge 快递运费配置 - */ - private void calculateExpressFeeByChargeMode(List orderItems, Integer chargeMode, - DeliveryExpressTemplateRespBO.Charge templateCharge) { - if (templateCharge == null) { - log.error("[calculateExpressFeeByChargeMode][计算快递运费时,找不到 SKU({}) 对应的运费模版]", orderItems); - return; - } - double totalChargeValue = getTotalChargeValue(orderItems, chargeMode); - // 1. 计算 SKU 商品快递费用 - int deliveryPrice; - if (totalChargeValue <= templateCharge.getStartCount()) { - deliveryPrice = templateCharge.getStartPrice(); - } else { - double remainWeight = totalChargeValue - templateCharge.getStartCount(); - // 剩余重量/ 续件 = 续件的次数. 向上取整 - int extraNum = (int) Math.ceil(remainWeight / templateCharge.getExtraCount()); - int extraPrice = templateCharge.getExtraPrice() * extraNum; - deliveryPrice = templateCharge.getStartPrice() + extraPrice; - } - - // 2. 分摊快递费用到 SKU. 退费的时候,可能按照 SKU 考虑退费金额 - int remainPrice = deliveryPrice; - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem item = orderItems.get(i); - int partPrice; - double chargeValue = getChargeValue(item, chargeMode); - if (i < orderItems.size() - 1) { // 减一的原因,是因为拆分时,如果按照比例,可能会出现.所以最后一个,使用反减 - partPrice = (int) (deliveryPrice * (chargeValue / totalChargeValue)); - remainPrice -= partPrice; - } else { - partPrice = remainPrice; - } - Assert.isTrue(partPrice >= 0, "分摊金额必须大于等于 0"); - // 更新快递运费 - item.setDeliveryPrice(partPrice); - TradePriceCalculatorHelper.recountPayPrice(item); - } - } - - /** - * 检查是否包邮 - * - * @param chargeMode 配送计费方式 - * @param templateFree 包邮配置 - */ - private boolean isExpressTemplateFree(List orderItems, Integer chargeMode, - DeliveryExpressTemplateRespBO.Free templateFree) { - if (templateFree == null) { - return false; - } - double totalChargeValue = getTotalChargeValue(orderItems, chargeMode); - double totalPrice = TradePriceCalculatorHelper.calculateTotalPayPrice(orderItems); - return totalChargeValue >= templateFree.getFreeCount() && totalPrice >= templateFree.getFreePrice(); - } - - private double getTotalChargeValue(List orderItems, Integer chargeMode) { - double total = 0; - for (OrderItem orderItem : orderItems) { - total += getChargeValue(orderItem, chargeMode); - } - return total; - } - - private double getChargeValue(OrderItem orderItem, Integer chargeMode) { - DeliveryExpressChargeModeEnum chargeModeEnum = DeliveryExpressChargeModeEnum.valueOf(chargeMode); - switch (chargeModeEnum) { - case COUNT: - return orderItem.getCount(); - case WEIGHT: - return orderItem.getWeight() != null ? orderItem.getWeight() * orderItem.getCount() : 0; - case VOLUME: - return orderItem.getVolume() != null ? orderItem.getVolume() * orderItem.getCount() : 0; - default: - throw new IllegalArgumentException(StrUtil.format("未知的计费模式({})", chargeMode)); - } - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDiscountActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDiscountActivityPriceCalculator.java deleted file mode 100644 index b63cfaae2..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeDiscountActivityPriceCalculator.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.discount.DiscountActivityApi; -import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper.formatPrice; - -/** - * 限时折扣的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_DISCOUNT_ACTIVITY) -public class TradeDiscountActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private DiscountActivityApi discountActivityApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 0. 只有【普通】订单,才计算该优惠 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) { - return; - } - // 获得 SKU 对应的限时折扣活动 - List discountProducts = discountActivityApi.getMatchDiscountProductList( - convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSkuId)).getCheckedData(); - if (CollUtil.isEmpty(discountProducts)) { - return; - } - Map discountProductMap = convertMap(discountProducts, DiscountProductRespDTO::getSkuId); - - // 处理每个 SKU 的限时折扣 - result.getItems().forEach(orderItem -> { - // 1. 获取该 SKU 的优惠信息 - DiscountProductRespDTO discountProduct = discountProductMap.get(orderItem.getSkuId()); - if (discountProduct == null) { - return; - } - // 2. 计算优惠金额 - Integer newPayPrice = calculatePayPrice(discountProduct, orderItem); - Integer newDiscountPrice = orderItem.getPayPrice() - newPayPrice; - - // 3.1 记录优惠明细 - if (orderItem.getSelected()) { - // 注意,只有在选中的情况下,才会记录到优惠明细。否则仅仅是更新 SKU 优惠金额,用于展示 - TradePriceCalculatorHelper.addPromotion(result, orderItem, - discountProduct.getActivityId(), discountProduct.getActivityName(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType(), - StrUtil.format("限时折扣:省 {} 元", formatPrice(newDiscountPrice)), - newDiscountPrice); - } - // 3.2 更新 SKU 优惠金额 - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + newDiscountPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - }); - TradePriceCalculatorHelper.recountAllPrice(result); - } - - private Integer calculatePayPrice(DiscountProductRespDTO discountProduct, - TradePriceCalculateRespBO.OrderItem orderItem) { - Integer price = orderItem.getPayPrice(); - if (PromotionDiscountTypeEnum.PRICE.getType().equals(discountProduct.getDiscountType())) { // 减价 - price -= discountProduct.getDiscountPrice() * orderItem.getCount(); - } else if (PromotionDiscountTypeEnum.PERCENT.getType().equals(discountProduct.getDiscountType())) { // 打折 - price = price * discountProduct.getDiscountPercent() / 100; - } else { - throw new IllegalArgumentException(String.format("优惠活动的商品(%s) 的优惠类型不正确", discountProduct)); - } - return price; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeMemberLevelPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeMemberLevelPriceCalculator.java deleted file mode 100644 index 3db99fd80..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeMemberLevelPriceCalculator.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; -import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper.formatPrice; - -/** - * 会员 VIP 折扣的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_MEMBER_LEVEL) -public class TradeMemberLevelPriceCalculator implements TradePriceCalculator { - - @Resource - private MemberLevelApi memberLevelApi; - @Resource - private MemberUserApi memberUserApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 0. 只有【普通】订单,才计算该优惠 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) { - return; - } - // 1. 获得用户的会员等级 - MemberUserRespDTO user = memberUserApi.getUser(param.getUserId()).getCheckedData(); - if (user.getLevelId() == null || user.getLevelId() <= 0) { - return; - } - MemberLevelRespDTO level = memberLevelApi.getMemberLevel(user.getLevelId()).getCheckedData(); - if (level == null || level.getDiscountPercent() == null) { - return; - } - - // 2. 计算每个 SKU 的优惠金额 - result.getItems().forEach(orderItem -> { - // 2.1 计算优惠金额 - Integer vipPrice = calculateVipPrice(orderItem.getPayPrice(), level.getDiscountPercent()); - if (vipPrice <= 0) { - return; - } - - // 2.2 记录优惠明细 - if (orderItem.getSelected()) { - // 注意,只有在选中的情况下,才会记录到优惠明细。否则仅仅是更新 SKU 优惠金额,用于展示 - TradePriceCalculatorHelper.addPromotion(result, orderItem, - level.getId(), level.getName(), PromotionTypeEnum.MEMBER_LEVEL.getType(), - String.format("会员等级折扣:省 %s 元", formatPrice(vipPrice)), - vipPrice); - } - - // 2.3 更新 SKU 的优惠金额 - orderItem.setVipPrice(vipPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - }); - TradePriceCalculatorHelper.recountAllPrice(result); - } - - /** - * 计算会员 VIP 优惠价格 - * - * @param price 原价 - * @param discountPercent 折扣 - * @return 优惠价格 - */ - public Integer calculateVipPrice(Integer price, Integer discountPercent) { - if (discountPercent == null) { - return 0; - } - Integer newPrice = price * discountPercent / 100; - return price - newPrice; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointGiveCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointGiveCalculator.java deleted file mode 100644 index 18cb7be09..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointGiveCalculator.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.util.BooleanUtil; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.module.member.api.config.MemberConfigApi; -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Optional; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; - -/** - * 赠送积分的 {@link TradePriceCalculator} 实现类 - * - * @author owen - */ -@Component -@Order(TradePriceCalculator.ORDER_POINT_GIVE) -@Slf4j -public class TradePointGiveCalculator implements TradePriceCalculator { - - @Resource - private MemberConfigApi memberConfigApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1.1 校验积分功能是否开启 - int givePointPerYuan = Optional.ofNullable(memberConfigApi.getConfig().getCheckedData()) - .filter(config -> BooleanUtil.isTrue(config.getPointTradeDeductEnable())) - .map(MemberConfigRespDTO::getPointTradeGivePoint) - .orElse(0); - if (givePointPerYuan <= 0) { - return; - } - // 1.2 校验支付金额 - if (result.getPrice().getPayPrice() <= 0) { - return; - } - - // 2.1 计算赠送积分 - int givePoint = MoneyUtils.calculateRatePriceFloor(result.getPrice().getPayPrice(), (double) givePointPerYuan); - // 2.2 计算分摊的赠送积分 - List orderItems = filterList(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSelected); - List dividePoints = TradePriceCalculatorHelper.dividePrice(orderItems, givePoint); - - // 3.2 更新 SKU 赠送积分 - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - // 商品可能赠送了积分,所以这里要加上 - orderItem.setGivePoint(orderItem.getGivePoint() + dividePoints.get(i)); - } - // 3.3 更新订单赠送积分 - TradePriceCalculatorHelper.recountAllGivePoint(result); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointUsePriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointUsePriceCalculator.java deleted file mode 100644 index 080879772..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePointUsePriceCalculator.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.member.api.config.MemberConfigApi; -import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_PAY_PRICE_ILLEGAL; - -/** - * 使用积分的 {@link TradePriceCalculator} 实现类 - * - * @author owen - */ -@Component -@Order(TradePriceCalculator.ORDER_POINT_USE) -@Slf4j -public class TradePointUsePriceCalculator implements TradePriceCalculator { - - @Resource - private MemberConfigApi memberConfigApi; - @Resource - private MemberUserApi memberUserApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 默认使用积分为 0 - result.setUsePoint(0); - // 1.1 校验是否使用积分 - if (!BooleanUtil.isTrue(param.getPointStatus())) { - result.setUsePoint(0); - return; - } - // 1.2 校验积分抵扣是否开启 - MemberConfigRespDTO config = memberConfigApi.getConfig().getCheckedData(); - if (!isDeductPointEnable(config)) { - return; - } - // 1.3 校验用户积分余额 - MemberUserRespDTO user = memberUserApi.getUser(param.getUserId()).getCheckedData(); - if (user.getPoint() == null || user.getPoint() <= 0) { - return; - } - - // 2.1 计算积分优惠金额 - int pointPrice = calculatePointPrice(config, user.getPoint(), result); - // 2.2 计算分摊的积分、抵扣金额 - List orderItems = filterList(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSelected); - List dividePointPrices = TradePriceCalculatorHelper.dividePrice(orderItems, pointPrice); - List divideUsePoints = TradePriceCalculatorHelper.dividePrice(orderItems, result.getUsePoint()); - - // 3.1 记录优惠明细 - TradePriceCalculatorHelper.addPromotion(result, orderItems, - param.getUserId(), "积分抵扣", PromotionTypeEnum.POINT.getType(), - StrUtil.format("积分抵扣:省 {} 元", TradePriceCalculatorHelper.formatPrice(pointPrice)), - dividePointPrices); - // 3.2 更新 SKU 优惠金额 - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - orderItem.setPointPrice(dividePointPrices.get(i)); - orderItem.setUsePoint(divideUsePoints.get(i)); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - } - TradePriceCalculatorHelper.recountAllPrice(result); - } - - private boolean isDeductPointEnable(MemberConfigRespDTO config) { - return config != null && - BooleanUtil.isTrue(config.getPointTradeDeductEnable()) && // 积分功能是否启用 - config.getPointTradeDeductUnitPrice() != null && config.getPointTradeDeductUnitPrice() > 0; // 有没有配置:1 积分抵扣多少分 - } - - private Integer calculatePointPrice(MemberConfigRespDTO config, Integer usePoint, TradePriceCalculateRespBO result) { - // 每个订单最多可以使用的积分数量 - if (config.getPointTradeDeductMaxPrice() != null && config.getPointTradeDeductMaxPrice() > 0) { - usePoint = Math.min(usePoint, config.getPointTradeDeductMaxPrice()); - } - // TODO @疯狂:这里应该是,抵扣到只剩下 0.01; - // 积分优惠金额(分) - int pointPrice = usePoint * config.getPointTradeDeductUnitPrice(); - if (result.getPrice().getPayPrice() <= pointPrice) { - // 禁止 0 元购 - throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL); - } -// // 允许0 元购!!!:用户积分比较多时,积分可以抵扣的金额要大于支付金额,这时需要根据支付金额反推使用多少积分 -// if (result.getPrice().getPayPrice() < pointPrice) { -// pointPrice = result.getPrice().getPayPrice(); -// // 反推需要扣除的积分 -// usePoint = NumberUtil.toBigDecimal(pointPrice) -// .divide(NumberUtil.toBigDecimal(config.getPointTradeDeductUnitPrice()), 0, RoundingMode.HALF_UP) -// .intValue(); -// } - // 记录使用的积分 - result.setUsePoint(usePoint); - return pointPrice; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculator.java deleted file mode 100644 index 1fc7e6915..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculator.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; - -/** - * 价格计算的计算器接口 - * - * 优惠计算顺序: - * 1. 积分抵现、会员价、优惠券、粉丝专享价、满减送哪个优先计算? - * - * @author 芋道源码 - */ -public interface TradePriceCalculator { - - int ORDER_MEMBER_LEVEL = 5; - - int ORDER_SECKILL_ACTIVITY = 8; - int ORDER_BARGAIN_ACTIVITY = 8; - int ORDER_COMBINATION_ACTIVITY = 8; - - int ORDER_DISCOUNT_ACTIVITY = 10; - int ORDER_REWARD_ACTIVITY = 20; - int ORDER_COUPON = 30; - int ORDER_POINT_USE = 40; - /** - * 快递运费的计算 - * - * 放在各种营销活动、优惠劵后面 - */ - int ORDER_DELIVERY = 50; - /** - * 赠送积分,放最后 - * - * 放在 {@link #ORDER_DELIVERY} 后面的原因,是运费也会产生费用,需要赠送对应积分 - */ - int ORDER_POINT_GIVE = 999; - - void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result); - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java deleted file mode 100644 index 2862012af..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java +++ /dev/null @@ -1,341 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; -import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; -import static java.util.Collections.singletonList; - -/** - * {@link TradePriceCalculator} 的工具类 - * - * 主要实现对 {@link TradePriceCalculateRespBO} 计算结果的操作 - * - * @author 芋道源码 - */ -public class TradePriceCalculatorHelper { - - public static TradePriceCalculateRespBO buildCalculateResp(TradePriceCalculateReqBO param, - List spuList, List skuList) { - // 创建 PriceCalculateRespDTO 对象 - TradePriceCalculateRespBO result = new TradePriceCalculateRespBO(); - result.setType(getOrderType(param)); - result.setPromotions(new ArrayList<>()); - - // 创建它的 OrderItem 属性 - result.setItems(new ArrayList<>(param.getItems().size())); - Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); - Map skuMap = convertMap(skuList, ProductSkuRespDTO::getId); - param.getItems().forEach(item -> { - ProductSkuRespDTO sku = skuMap.get(item.getSkuId()); - if (sku == null) { - return; - } - ProductSpuRespDTO spu = spuMap.get(sku.getSpuId()); - if (spu == null) { - return; - } - // 商品项 - TradePriceCalculateRespBO.OrderItem orderItem = new TradePriceCalculateRespBO.OrderItem(); - result.getItems().add(orderItem); - orderItem.setSpuId(sku.getSpuId()).setSkuId(sku.getId()) - .setCount(item.getCount()).setCartId(item.getCartId()).setSelected(item.getSelected()); - // sku 价格 - orderItem.setPrice(sku.getPrice()).setPayPrice(sku.getPrice() * item.getCount()) - .setDiscountPrice(0).setDeliveryPrice(0).setCouponPrice(0).setPointPrice(0).setVipPrice(0); - // sku 信息 - orderItem.setPicUrl(sku.getPicUrl()).setProperties(sku.getProperties()) - .setWeight(sku.getWeight()).setVolume(sku.getVolume()); - // spu 信息 - orderItem.setSpuName(spu.getName()).setCategoryId(spu.getCategoryId()) - .setDeliveryTemplateId(spu.getDeliveryTemplateId()) - .setGivePoint(spu.getGiveIntegral()).setUsePoint(0); - if (orderItem.getPicUrl() == null) { - orderItem.setPicUrl(spu.getPicUrl()); - } - }); - - // 创建它的 Price 属性 - result.setPrice(new TradePriceCalculateRespBO.Price()); - recountAllPrice(result); - recountAllGivePoint(result); - return result; - } - - /** - * 计算订单类型 - * - * @param param 计算参数 - * @return 订单类型 - */ - private static Integer getOrderType(TradePriceCalculateReqBO param) { - if (param.getSeckillActivityId() != null) { - return TradeOrderTypeEnum.SECKILL.getType(); - } - if (param.getCombinationActivityId() != null) { - return TradeOrderTypeEnum.COMBINATION.getType(); - } - if (param.getBargainRecordId() != null) { - return TradeOrderTypeEnum.BARGAIN.getType(); - } - return TradeOrderTypeEnum.NORMAL.getType(); - } - - /** - * 基于订单项,重新计算 price 总价 - * - * @param result 计算结果 - */ - public static void recountAllPrice(TradePriceCalculateRespBO result) { - // 先重置 - TradePriceCalculateRespBO.Price price = result.getPrice(); - price.setTotalPrice(0).setDiscountPrice(0).setDeliveryPrice(0) - .setCouponPrice(0).setPointPrice(0).setVipPrice(0).setPayPrice(0); - // 再合计 item - result.getItems().forEach(item -> { - if (!item.getSelected()) { - return; - } - price.setTotalPrice(price.getTotalPrice() + item.getPrice() * item.getCount()); - price.setDiscountPrice(price.getDiscountPrice() + item.getDiscountPrice()); - price.setDeliveryPrice(price.getDeliveryPrice() + item.getDeliveryPrice()); - price.setCouponPrice(price.getCouponPrice() + item.getCouponPrice()); - price.setPointPrice(price.getPointPrice() + item.getPointPrice()); - price.setVipPrice(price.getVipPrice() + item.getVipPrice()); - price.setPayPrice(price.getPayPrice() + item.getPayPrice()); - }); - } - - /** - * 基于订单项,重新计算赠送积分 - * - * @param result 计算结果 - */ - public static void recountAllGivePoint(TradePriceCalculateRespBO result) { - result.setGivePoint(getSumValue(result.getItems(), item -> item.getSelected() ? item.getGivePoint() : 0, Integer::sum)); - } - - /** - * 重新计算单个订单项的支付金额 - * - * @param orderItem 订单项 - */ - public static void recountPayPrice(TradePriceCalculateRespBO.OrderItem orderItem) { - orderItem.setPayPrice(orderItem.getPrice() * orderItem.getCount() - - orderItem.getDiscountPrice() - + orderItem.getDeliveryPrice() - - orderItem.getCouponPrice() - - orderItem.getPointPrice() - - orderItem.getVipPrice() - ); - } - - /** - * 重新计算每个订单项的支付金额 - * - * 【目前主要是单测使用】 - * - * @param orderItems 订单项数组 - */ - public static void recountPayPrice(List orderItems) { - orderItems.forEach(orderItem -> { - if (orderItem.getDiscountPrice() == null) { - orderItem.setDiscountPrice(0); - } - if (orderItem.getDeliveryPrice() == null) { - orderItem.setDeliveryPrice(0); - } - if (orderItem.getCouponPrice() == null) { - orderItem.setCouponPrice(0); - } - if (orderItem.getPointPrice() == null) { - orderItem.setPointPrice(0); - } - if (orderItem.getUsePoint() == null) { - orderItem.setUsePoint(0); - } - if (orderItem.getGivePoint() == null) { - orderItem.setGivePoint(0); - } - if (orderItem.getVipPrice() == null) { - orderItem.setVipPrice(0); - } - recountPayPrice(orderItem); - }); - } - - /** - * 计算已选中的订单项,总支付金额 - * - * @param orderItems 订单项数组 - * @return 总支付金额 - */ - public static Integer calculateTotalPayPrice(List orderItems) { - return getSumValue(orderItems, - orderItem -> orderItem.getSelected() ? orderItem.getPayPrice() : 0, // 未选中的情况下,不计算支付金额 - Integer::sum); - } - - /** - * 计算已选中的订单项,总商品数 - * - * @param orderItems 订单项数组 - * @return 总商品数 - */ - public static Integer calculateTotalCount(List orderItems) { - return getSumValue(orderItems, - orderItem -> orderItem.getSelected() ? orderItem.getCount() : 0, // 未选中的情况下,不计算数量 - Integer::sum); - } - - /** - * 按照支付金额,返回每个订单项的分摊金额数组 - * - * 实际上 price 不仅仅可以传递的是金额,也可以是积分。因为它的实现逻辑,就是根据 payPrice 做分摊而已 - * - * @param orderItems 订单项数组 - * @param price 金额 - * @return 分摊金额数组,和传入的 orderItems 一一对应 - */ - public static List dividePrice(List orderItems, Integer price) { - Integer total = calculateTotalPayPrice(orderItems); - assert total != null; - // 遍历每一个,进行分摊 - List prices = new ArrayList<>(orderItems.size()); - int remainPrice = price; - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - // 1. 如果是未选中,则分摊为 0 - if (!orderItem.getSelected()) { - prices.add(0); - continue; - } - // 2. 如果选中,则按照百分比,进行分摊 - int partPrice; - if (i < orderItems.size() - 1) { // 减一的原因,是因为拆分时,如果按照比例,可能会出现.所以最后一个,使用反减 - partPrice = (int) (price * (1.0D * orderItem.getPayPrice() / total)); - remainPrice -= partPrice; - } else { - partPrice = remainPrice; - } - Assert.isTrue(partPrice >= 0, "分摊金额必须大于等于 0"); - prices.add(partPrice); - } - return prices; - } - - /** - * 计算订单调价价格分摊 - * - * 和 {@link #dividePrice(List, Integer)} 逻辑一致,只是传入的是 TradeOrderItemDO 对象 - * - * @param items 订单项 - * @param price 订单支付金额 - * @return 分摊金额数组,和传入的 orderItems 一一对应 - */ - public static List dividePrice2(List items, Integer price) { - Integer total = getSumValue(items, TradeOrderItemDO::getPayPrice, Integer::sum); - assert total != null; - // 遍历每一个,进行分摊 - List prices = new ArrayList<>(items.size()); - int remainPrice = price; - for (int i = 0; i < items.size(); i++) { - TradeOrderItemDO orderItem = items.get(i); - int partPrice; - if (i < items.size() - 1) { // 减一的原因,是因为拆分时,如果按照比例,可能会出现.所以最后一个,使用反减 - partPrice = (int) (price * (1.0D * orderItem.getPrice() / total)); - remainPrice -= partPrice; - } else { - partPrice = remainPrice; - } - prices.add(partPrice); - } - return prices; - } - - /** - * 添加【匹配】单个 OrderItem 的营销明细 - * - * @param result 价格计算结果 - * @param orderItem 单个订单商品 SKU - * @param id 营销编号 - * @param name 营销名字 - * @param description 满足条件的提示 - * @param type 营销类型 - * @param discountPrice 单个订单商品 SKU 的优惠价格(总) - */ - public static void addPromotion(TradePriceCalculateRespBO result, TradePriceCalculateRespBO.OrderItem orderItem, - Long id, String name, Integer type, String description, Integer discountPrice) { - addPromotion(result, singletonList(orderItem), id, name, type, description, singletonList(discountPrice)); - } - - /** - * 添加【匹配】多个 OrderItem 的营销明细 - * - * @param result 价格计算结果 - * @param orderItems 多个订单商品 SKU - * @param id 营销编号 - * @param name 营销名字 - * @param description 满足条件的提示 - * @param type 营销类型 - * @param discountPrices 多个订单商品 SKU 的优惠价格(总),和 orderItems 一一对应 - */ - public static void addPromotion(TradePriceCalculateRespBO result, List orderItems, - Long id, String name, Integer type, String description, List discountPrices) { - // 创建营销明细 Item - List promotionItems = new ArrayList<>(discountPrices.size()); - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - promotionItems.add(new TradePriceCalculateRespBO.PromotionItem().setSkuId(orderItem.getSkuId()) - .setTotalPrice(orderItem.getPayPrice()).setDiscountPrice(discountPrices.get(i))); - } - // 创建营销明细 - TradePriceCalculateRespBO.Promotion promotion = new TradePriceCalculateRespBO.Promotion() - .setId(id).setName(name).setType(type) - .setTotalPrice(calculateTotalPayPrice(orderItems)) - .setDiscountPrice(getSumValue(discountPrices, value -> value, Integer::sum)) - .setItems(promotionItems).setMatch(true).setDescription(description); - result.getPromotions().add(promotion); - } - - /** - * 添加【不匹配】多个 OrderItem 的营销明细 - * - * @param result 价格计算结果 - * @param orderItems 多个订单商品 SKU - * @param id 营销编号 - * @param name 营销名字 - * @param description 满足条件的提示 - * @param type 营销类型 - */ - public static void addNotMatchPromotion(TradePriceCalculateRespBO result, List orderItems, - Long id, String name, Integer type, String description) { - // 创建营销明细 Item - List promotionItems = CollectionUtils.convertList(orderItems, - orderItem -> new TradePriceCalculateRespBO.PromotionItem().setSkuId(orderItem.getSkuId()) - .setTotalPrice(orderItem.getPayPrice()).setDiscountPrice(0)); - // 创建营销明细 - TradePriceCalculateRespBO.Promotion promotion = new TradePriceCalculateRespBO.Promotion() - .setId(id).setName(name).setType(type) - .setTotalPrice(calculateTotalPayPrice(orderItems)) - .setDiscountPrice(0) - .setItems(promotionItems).setMatch(false).setDescription(description); - result.getPromotions().add(promotion); - } - - public static String formatPrice(Integer price) { - return String.format("%.2f", price / 100d); - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java deleted file mode 100644 index b0900b2ea..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeRewardActivityPriceCalculator.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.reward.RewardActivityApi; -import cn.iocoder.yudao.module.promotion.api.reward.dto.RewardActivityMatchRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderTypeEnum; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; -import static cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper.formatPrice; - -/** - * 满减送活动的 {@link TradePriceCalculator} 实现类 - * - * @author 芋道源码 - */ -@Component -@Order(TradePriceCalculator.ORDER_REWARD_ACTIVITY) -public class TradeRewardActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private RewardActivityApi rewardActivityApi; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 0. 只有【普通】订单,才计算该优惠 - if (ObjectUtil.notEqual(result.getType(), TradeOrderTypeEnum.NORMAL.getType())) { - return; - } - // 获得 SKU 对应的满减送活动 - List rewardActivities = rewardActivityApi.getMatchRewardActivityList( - convertSet(result.getItems(), TradePriceCalculateRespBO.OrderItem::getSpuId)).getCheckedData(); - if (CollUtil.isEmpty(rewardActivities)) { - return; - } - - // 处理每个满减送活动 - rewardActivities.forEach(rewardActivity -> calculate(param, result, rewardActivity)); - } - - private void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result, - RewardActivityMatchRespDTO rewardActivity) { - // 1.1 获得满减送的订单项(商品)列表 - List orderItems = filterMatchCouponOrderItems(result, rewardActivity); - if (CollUtil.isEmpty(orderItems)) { - return; - } - // 1.2 获得最大匹配的满减送活动的规则 - RewardActivityMatchRespDTO.Rule rule = getMaxMatchRewardActivityRule(rewardActivity, orderItems); - if (rule == null) { - TradePriceCalculatorHelper.addNotMatchPromotion(result, orderItems, - rewardActivity.getId(), rewardActivity.getName(), PromotionTypeEnum.REWARD_ACTIVITY.getType(), - getRewardActivityNotMeetTip(rewardActivity)); - return; - } - - // 2.1 计算可以优惠的金额 - Integer newDiscountPrice = rule.getDiscountPrice(); - // 2.2 计算分摊的优惠金额 - List divideDiscountPrices = TradePriceCalculatorHelper.dividePrice(orderItems, newDiscountPrice); - - // 3.1 记录使用的优惠劵 - result.setCouponId(param.getCouponId()); - // 3.2 记录优惠明细 - TradePriceCalculatorHelper.addPromotion(result, orderItems, - rewardActivity.getId(), rewardActivity.getName(), PromotionTypeEnum.REWARD_ACTIVITY.getType(), - StrUtil.format("满减送:省 {} 元", formatPrice(rule.getDiscountPrice())), - divideDiscountPrices); - // 3.3 更新 SKU 优惠金额 - for (int i = 0; i < orderItems.size(); i++) { - TradePriceCalculateRespBO.OrderItem orderItem = orderItems.get(i); - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + divideDiscountPrices.get(i)); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - } - TradePriceCalculatorHelper.recountAllPrice(result); - } - - /** - * 获得满减送的订单项(商品)列表 - * - * @param result 计算结果 - * @param rewardActivity 满减送活动 - * @return 订单项(商品)列表 - */ - private List filterMatchCouponOrderItems(TradePriceCalculateRespBO result, - RewardActivityMatchRespDTO rewardActivity) { - return filterList(result.getItems(), - orderItem -> CollUtil.contains(rewardActivity.getSpuIds(), orderItem.getSpuId())); - } - - /** - * 获得最大匹配的满减送活动的规则 - * - * @param rewardActivity 满减送活动 - * @param orderItems 商品项 - * @return 匹配的活动规则 - */ - private RewardActivityMatchRespDTO.Rule getMaxMatchRewardActivityRule(RewardActivityMatchRespDTO rewardActivity, - List orderItems) { - // 1. 计算数量和价格 - Integer count = TradePriceCalculatorHelper.calculateTotalCount(orderItems); - Integer price = TradePriceCalculatorHelper.calculateTotalPayPrice(orderItems); - assert count != null && price != null; - - // 2. 倒序找一个最大优惠的规则 - for (int i = rewardActivity.getRules().size() - 1; i >= 0; i--) { - RewardActivityMatchRespDTO.Rule rule = rewardActivity.getRules().get(i); - if (PromotionConditionTypeEnum.PRICE.getType().equals(rewardActivity.getConditionType()) - && price >= rule.getLimit()) { - return rule; - } - if (PromotionConditionTypeEnum.COUNT.getType().equals(rewardActivity.getConditionType()) - && count >= rule.getLimit()) { - return rule; - } - } - return null; - } - - /** - * 获得满减送活动部匹配时的提示 - * - * @param rewardActivity 满减送活动 - * @return 提示 - */ - private String getRewardActivityNotMeetTip(RewardActivityMatchRespDTO rewardActivity) { - // TODO 芋艿:后面再想想;应该找第一个规则,算下还差多少即可。 - return "TODO"; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeSeckillActivityPriceCalculator.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeSeckillActivityPriceCalculator.java deleted file mode 100644 index ddda8239d..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeSeckillActivityPriceCalculator.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.trade.service.price.calculator; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.promotion.api.seckill.SeckillActivityApi; -import cn.iocoder.yudao.module.promotion.api.seckill.dto.SeckillValidateJoinRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; -import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO; -import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_SECKILL_TOTAL_LIMIT_COUNT; - -// TODO huihui:单测需要补充 -/** - * 秒杀活动的 {@link TradePriceCalculator} 实现类 - * - * @author HUIHUI - */ -@Component -@Order(TradePriceCalculator.ORDER_SECKILL_ACTIVITY) -public class TradeSeckillActivityPriceCalculator implements TradePriceCalculator { - - @Resource - private SeckillActivityApi seckillActivityApi; - - @Resource - private TradeOrderQueryService tradeOrderQueryService; - - @Override - public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { - // 1. 判断订单类型和是否具有秒杀活动编号 - if (param.getSeckillActivityId() == null) { - return; - } - Assert.isTrue(param.getItems().size() == 1, "秒杀时,只允许选择一个商品"); - // 2. 校验是否可以参与秒杀 - TradePriceCalculateRespBO.OrderItem orderItem = result.getItems().get(0); - SeckillValidateJoinRespDTO seckillActivity = validateJoinSeckill( - param.getUserId(), param.getSeckillActivityId(), - orderItem.getSkuId(), orderItem.getCount()); - - // 3.1 记录优惠明细 - Integer discountPrice = orderItem.getPayPrice() - seckillActivity.getSeckillPrice() * orderItem.getCount(); - TradePriceCalculatorHelper.addPromotion(result, orderItem, - param.getSeckillActivityId(), seckillActivity.getName(), PromotionTypeEnum.SECKILL_ACTIVITY.getType(), - StrUtil.format("秒杀活动:省 {} 元", TradePriceCalculatorHelper.formatPrice(discountPrice)), - discountPrice); - // 3.2 更新 SKU 优惠金额 - orderItem.setDiscountPrice(orderItem.getDiscountPrice() + discountPrice); - TradePriceCalculatorHelper.recountPayPrice(orderItem); - TradePriceCalculatorHelper.recountAllPrice(result); - } - - private SeckillValidateJoinRespDTO validateJoinSeckill(Long userId, Long activityId, Long skuId, Integer count) { - // 1. 校验是否可以参与秒杀 - SeckillValidateJoinRespDTO seckillActivity = seckillActivityApi.validateJoinSeckill(activityId, skuId, count).getCheckedData(); - // 2. 校验总限购数量,目前只有 trade 有具体下单的数据,需要交给 trade 价格计算使用 - int seckillProductCount = tradeOrderQueryService.getSeckillProductCount(userId, activityId); - if (seckillProductCount + count > seckillActivity.getTotalLimitCount()) { - throw exception(PRICE_CALCULATE_SECKILL_TOTAL_LIMIT_COUNT); - } - return seckillActivity; - } - -} diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-dev.yaml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index d36082139..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,104 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - # Spring Boot Admin Server 服务端的相关配置 - context-path: /admin # 配置 Spring - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - demo: true # 开启演示模式 - tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-local.yaml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 0eb64a387..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,128 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.system.dal.mysql: debug - cn.iocoder.yudao.module.system.dal.mysql.sensitiveword.SensitiveWordMapper: INFO # 配置 SensitiveWordMapper 的日志级别为 info - cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - security: - mock-enable: true - xss: - enable: false - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 - tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application.yaml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application.yaml deleted file mode 100644 index bc4ff8bc5..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,123 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.trade - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - captcha: - enable: true # 验证码的开关,默认为 true; - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - ignore-tables: - trade: - order: - app-id: 1 # 商户编号 - pay-expire-time: 2h # 支付的过期时间 - receive-expire-time: 14d # 收货的过期时间 - comment-expire-time: 7d # 评论的过期时间 - express: - client: kd_niao - kd-niao: - api-key: cb022f1e-48f1-4c4a-a723-9001ac9676b8 - business-id: 1809751 - kd100: - key: pLXUGAwK5305 - customer: E77DF18BE109F454A5CD319E44BF5177 - -debug: false diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/bootstrap.yaml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 9a19ce79b..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: trade-server - - profiles: - active: local - -server: - port: 48102 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/logback-spring.xml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/mapper/brokerage/BrokerageUserMapper.xml b/yudao-module-mall/yudao-module-trade-biz/src/main/resources/mapper/brokerage/BrokerageUserMapper.xml deleted file mode 100644 index 066f75d4e..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/resources/mapper/brokerage/BrokerageUserMapper.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 8ba2503d9..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,59 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module - trade: - order: - app-id: 1 - merchant-order-id: 1 - express: - kd-niao: - api-key: xxxx - business-id: xxxxx - kd100: - customer: xxxxx - key: xxxxx - client: not_provide \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/logback.xml b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index f7f3477cc..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,7 +0,0 @@ -DELETE FROM trade_order; -DELETE FROM trade_order_item; -DELETE FROM trade_after_sale; -DELETE FROM trade_after_sale_log; -DELETE FROM trade_brokerage_user; -DELETE FROM trade_brokerage_record; -DELETE FROM "trade_brokerage_withdraw"; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index d263fdfb9..000000000 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,191 +0,0 @@ -CREATE TABLE IF NOT EXISTS "trade_order" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "no" varchar NOT NULL, - "type" int NOT NULL, - "terminal" int NOT NULL, - "user_id" bigint NOT NULL, - "user_ip" varchar NOT NULL, - "user_remark" varchar, - "status" int NOT NULL, - "product_count" int NOT NULL, - "cancel_type" int, - "remark" varchar, - "pay_status" bit NOT NULL, - "pay_time" datetime, - "finish_time" datetime, - "cancel_time" datetime, - "original_price" int NOT NULL, - "order_price" int NOT NULL, - "discount_price" int NOT NULL, - "delivery_price" int NOT NULL, - "adjust_price" int NOT NULL, - "pay_price" int NOT NULL, - "pay_order_id" bigint, - "pay_channel_code" varchar, - "delivery_template_id" bigint, - "logistics_id" bigint, - "logistics_no" varchar, - "delivery_time" datetime, - "receive_time" datetime, - "receiver_name" varchar NOT NULL, - "receiver_mobile" varchar NOT NULL, - "receiver_area_id" int NOT NULL, - "receiver_post_code" int, - "receiver_detail_address" varchar NOT NULL, - "after_sale_status" int NOT NULL, - "refund_price" int NOT NULL, - "coupon_id" bigint NOT NULL, - "coupon_price" int NOT NULL, - "point_price" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易订单表'; - -CREATE TABLE IF NOT EXISTS "trade_order_item" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "order_id" bigint NOT NULL, - "spu_id" bigint NOT NULL, - "spu_name" varchar NOT NULL, - "sku_id" bigint NOT NULL, - "properties" varchar, - "pic_url" varchar, - "count" int NOT NULL, - "original_price" int NOT NULL, - "original_unit_price" int NOT NULL, - "discount_price" int NOT NULL, - "pay_price" int NOT NULL, - "order_part_price" int NOT NULL, - "order_divide_price" int NOT NULL, - "after_sale_status" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易订单明细表'; - -CREATE TABLE IF NOT EXISTS "trade_after_sale" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "no" varchar NOT NULL, - "status" int NOT NULL, - "type" int NOT NULL, - "way" int NOT NULL, - "user_id" bigint NOT NULL, - "apply_reason" varchar NOT NULL, - "apply_description" varchar, - "apply_pic_urls" varchar, - "order_id" bigint NOT NULL, - "order_no" varchar NOT NULL, - "order_item_id" bigint NOT NULL, - "spu_id" bigint NOT NULL, - "spu_name" varchar NOT NULL, - "sku_id" bigint NOT NULL, - "properties" varchar, - "pic_url" varchar, - "count" int NOT NULL, - "audit_time" varchar, - "audit_user_id" bigint, - "audit_reason" varchar, - "refund_price" int NOT NULL, - "pay_refund_id" bigint, - "refund_time" varchar, - "logistics_id" bigint, - "logistics_no" varchar, - "delivery_time" varchar, - "receive_time" varchar, - "receive_reason" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易售后表'; - -CREATE TABLE IF NOT EXISTS "trade_after_sale_log" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" int NOT NULL, - "after_sale_id" bigint NOT NULL, - "order_id" bigint NOT NULL, - "order_item_id" bigint NOT NULL, - "before_status" int, - "after_status" int NOT NULL, - "content" varchar NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '交易售后日志'; - -CREATE TABLE IF NOT EXISTS "trade_brokerage_user" -( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "bind_user_id" bigint NOT NULL, - "bind_user_time" varchar, - "brokerage_enabled" bit NOT NULL, - "brokerage_time" varchar, - "price" int NOT NULL, - "frozen_price" int NOT NULL, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint NOT NULL DEFAULT '0', - PRIMARY KEY ("id") -) COMMENT '分销用户'; -CREATE TABLE IF NOT EXISTS "trade_brokerage_record" -( - "id" int NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "biz_id" varchar NOT NULL, - "biz_type" varchar NOT NULL, - "title" varchar NOT NULL, - "price" int NOT NULL, - "total_price" int NOT NULL, - "description" varchar NOT NULL, - "status" varchar NOT NULL, - "frozen_days" int NOT NULL, - "unfreeze_time" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '佣金记录'; -CREATE TABLE IF NOT EXISTS "trade_brokerage_withdraw" -( - "id" int NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "price" int NOT NULL, - "fee_price" int NOT NULL, - "total_price" int NOT NULL, - "type" varchar NOT NULL, - "name" varchar, - "account_no" varchar, - "bank_name" varchar, - "bank_address" varchar, - "account_qr_code_url" varchar, - "status" varchar NOT NULL, - "audit_reason" varchar, - "audit_time" varchar, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '佣金提现'; \ No newline at end of file diff --git a/yudao-module-mp/pom.xml b/yudao-module-mp/pom.xml deleted file mode 100644 index 88735881d..000000000 --- a/yudao-module-mp/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - yudao - cn.iocoder.cloud - ${revision} - - 4.0.0 - - yudao-module-mp - pom - - - wechat 模块,主要实现微信平台的相关业务。 - 例如:微信公众号、企业微信 SCRM 等 - - - yudao-module-mp-api - yudao-module-mp-biz - - - diff --git a/yudao-module-mp/yudao-module-mp-api/pom.xml b/yudao-module-mp/yudao-module-mp-api/pom.xml deleted file mode 100644 index 9cad0d93f..000000000 --- a/yudao-module-mp/yudao-module-mp-api/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - yudao-module-mp - cn.iocoder.cloud - ${revision} - - 4.0.0 - yudao-module-mp-api - jar - - ${project.artifactId} - - mp 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java deleted file mode 100644 index 34c94fd00..000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.mp.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Mp 错误码枚举类 - * - * mp 系统,使用 1-006-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== 公众号账号 1-006-000-000 ============ - ErrorCode ACCOUNT_NOT_EXISTS = new ErrorCode(1_006_000_000, "公众号账号不存在"); - ErrorCode ACCOUNT_GENERATE_QR_CODE_FAIL = new ErrorCode(1_006_000_001, "生成公众号二维码失败,原因:{}"); - ErrorCode ACCOUNT_CLEAR_QUOTA_FAIL = new ErrorCode(1_006_000_002, "清空公众号的 API 配额失败,原因:{}"); - - // ========== 公众号统计 1-006-001-000 ============ - ErrorCode STATISTICS_GET_USER_SUMMARY_FAIL = new ErrorCode(1_006_001_000, "获取粉丝增减数据失败,原因:{}"); - ErrorCode STATISTICS_GET_USER_CUMULATE_FAIL = new ErrorCode(1_006_001_001, "获得粉丝累计数据失败,原因:{}"); - ErrorCode STATISTICS_GET_UPSTREAM_MESSAGE_FAIL = new ErrorCode(1_006_001_002, "获得消息发送概况数据失败,原因:{}"); - ErrorCode STATISTICS_GET_INTERFACE_SUMMARY_FAIL = new ErrorCode(1_006_001_003, "获得接口分析数据失败,原因:{}"); - - // ========== 公众号标签 1-006-002-000 ============ - ErrorCode TAG_NOT_EXISTS = new ErrorCode(1_006_002_000, "标签不存在"); - ErrorCode TAG_CREATE_FAIL = new ErrorCode(1_006_002_001, "创建标签失败,原因:{}"); - ErrorCode TAG_UPDATE_FAIL = new ErrorCode(1_006_002_002, "更新标签失败,原因:{}"); - ErrorCode TAG_DELETE_FAIL = new ErrorCode(1_006_002_003, "删除标签失败,原因:{}"); - ErrorCode TAG_GET_FAIL = new ErrorCode(1_006_002_004, "获得标签失败,原因:{}"); - - // ========== 公众号粉丝 1-006-003-000 ============ - ErrorCode USER_NOT_EXISTS = new ErrorCode(1_006_003_000, "粉丝不存在"); - ErrorCode USER_UPDATE_TAG_FAIL = new ErrorCode(1_006_003_001, "更新粉丝标签失败,原因:{}"); - - // ========== 公众号素材 1-006-004-000 ============ - ErrorCode MATERIAL_NOT_EXISTS = new ErrorCode(1_006_004_000, "素材不存在"); - ErrorCode MATERIAL_UPLOAD_FAIL = new ErrorCode(1_006_004_001, "上传素材失败,原因:{}"); - ErrorCode MATERIAL_IMAGE_UPLOAD_FAIL = new ErrorCode(1_006_004_002, "上传图片失败,原因:{}"); - ErrorCode MATERIAL_DELETE_FAIL = new ErrorCode(1_006_004_003, "删除素材失败,原因:{}"); - - // ========== 公众号消息 1-006-005-000 ============ - ErrorCode MESSAGE_SEND_FAIL = new ErrorCode(1_006_005_000, "发送消息失败,原因:{}"); - - // ========== 公众号发布能力 1-006-006-000 ============ - ErrorCode FREE_PUBLISH_LIST_FAIL = new ErrorCode(1_006_006_000, "获得已成功发布列表失败,原因:{}"); - ErrorCode FREE_PUBLISH_SUBMIT_FAIL = new ErrorCode(1_006_006_001, "提交发布失败,原因:{}"); - ErrorCode FREE_PUBLISH_DELETE_FAIL = new ErrorCode(1_006_006_002, "删除发布失败,原因:{}"); - - // ========== 公众号草稿 1-006-007-000 ============ - ErrorCode DRAFT_LIST_FAIL = new ErrorCode(1_006_007_000, "获得草稿列表失败,原因:{}"); - ErrorCode DRAFT_CREATE_FAIL = new ErrorCode(1_006_007_001, "创建草稿失败,原因:{}"); - ErrorCode DRAFT_UPDATE_FAIL = new ErrorCode(1_006_007_002, "更新草稿失败,原因:{}"); - ErrorCode DRAFT_DELETE_FAIL = new ErrorCode(1_006_007_003, "删除草稿失败,原因:{}"); - - // ========== 公众号菜单 1-006-008-000 ============ - ErrorCode MENU_SAVE_FAIL = new ErrorCode(1_006_008_000, "创建菜单失败,原因:{}"); - ErrorCode MENU_DELETE_FAIL = new ErrorCode(1_006_008_001, "删除菜单失败,原因:{}"); - - // ========== 公众号自动回复 1-006-009-000 ============ - ErrorCode AUTO_REPLY_NOT_EXISTS = new ErrorCode(1_006_009_000, "自动回复不存在"); - ErrorCode AUTO_REPLY_ADD_SUBSCRIBE_FAIL_EXISTS = new ErrorCode(1_006_009_001, "操作失败,原因:已存在关注时的回复"); - ErrorCode AUTO_REPLY_ADD_MESSAGE_FAIL_EXISTS = new ErrorCode(1_006_009_002, "操作失败,原因:已存在该消息类型的回复"); - ErrorCode AUTO_REPLY_ADD_KEYWORD_FAIL_EXISTS = new ErrorCode(1_006_009_003, "操作失败,原因:已关在该关键字的回复"); - -} diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyMatchEnum.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyMatchEnum.java deleted file mode 100644 index a5298dbf3..000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyMatchEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.mp.enums.message; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 公众号消息自动回复的匹配模式 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum MpAutoReplyMatchEnum { - - ALL(1, "完全匹配"), - LIKE(2, "半匹配"), - ; - - /** - * 匹配 - */ - private final Integer match; - /** - * 匹配的名字 - */ - private final String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyTypeEnum.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyTypeEnum.java deleted file mode 100644 index 300f1f2ba..000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpAutoReplyTypeEnum.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.mp.enums.message; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 公众号消息自动回复的类型 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum MpAutoReplyTypeEnum { - - SUBSCRIBE(1, "关注时回复"), - MESSAGE(2, "收到消息回复"), - KEYWORD(3, "关键词回复"), - ; - - /** - * 来源 - */ - private final Integer type; - /** - * 类型的名字 - */ - private final String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpMessageSendFromEnum.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpMessageSendFromEnum.java deleted file mode 100644 index a2af484a5..000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/message/MpMessageSendFromEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.mp.enums.message; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 微信公众号消息的发送来源 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum MpMessageSendFromEnum { - - USER_TO_MP(1, "粉丝发送给公众号"), - MP_TO_USER(2, "公众号发给粉丝"), - ; - - /** - * 来源 - */ - private final Integer from; - /** - * 来源的名字 - */ - private final String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/package-info.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/package-info.java deleted file mode 100644 index 598718088..000000000 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * mp 模块,我们放微信微信公众号。 - * 例如说:提供微信公众号的账号、菜单、粉丝、标签、消息、自动回复、素材、模板通知、运营数据等功能 - * - * 1. Controller URL:以 /mp/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 mp_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.mp; diff --git a/yudao-module-mp/yudao-module-mp-biz/Dockerfile b/yudao-module-mp/yudao-module-mp-biz/Dockerfile deleted file mode 100644 index 2f7efcd78..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-mp-biz -WORKDIR /yudao-module-mp-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-mp-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48086 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-mp/yudao-module-mp-biz/pom.xml b/yudao-module-mp/yudao-module-mp-biz/pom.xml deleted file mode 100644 index 8c9db6e53..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/pom.xml +++ /dev/null @@ -1,136 +0,0 @@ - - - - yudao-module-mp - cn.iocoder.cloud - ${revision} - - 4.0.0 - yudao-module-mp-biz - jar - - ${project.artifactId} - - mp 模块,我们放微信微信公众号。 - 例如说:提供微信公众号的账号、菜单、粉丝、标签、消息、自动回复、素材、模板通知、运营数据等功能 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - - cn.iocoder.cloud - yudao-module-mp-api - ${revision} - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - cn.iocoder.cloud - yudao-module-infra-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - org.springframework.boot - spring-boot-starter-validation - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - com.github.binarywang - wx-java-mp-spring-boot-starter - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/MpServerApplication.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/MpServerApplication.java deleted file mode 100644 index d4c36503a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/MpServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.mp; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class MpServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(MpServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/MpAccountController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/MpAccountController.java deleted file mode 100644 index 62be175ac..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/MpAccountController.java +++ /dev/null @@ -1,98 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.*; -import cn.iocoder.yudao.module.mp.convert.account.MpAccountConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号账号") -@RestController -@RequestMapping("/mp/account") -@Validated -public class MpAccountController { - - @Resource - private MpAccountService mpAccountService; - - @PostMapping("/create") - @Operation(summary = "创建公众号账号") - @PreAuthorize("@ss.hasPermission('mp:account:create')") - public CommonResult createAccount(@Valid @RequestBody MpAccountCreateReqVO createReqVO) { - return success(mpAccountService.createAccount(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新公众号账号") - @PreAuthorize("@ss.hasPermission('mp:account:update')") - public CommonResult updateAccount(@Valid @RequestBody MpAccountUpdateReqVO updateReqVO) { - mpAccountService.updateAccount(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除公众号账号") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:account:delete')") - public CommonResult deleteAccount(@RequestParam("id") Long id) { - mpAccountService.deleteAccount(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得公众号账号") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:account:query')") - public CommonResult getAccount(@RequestParam("id") Long id) { - MpAccountDO wxAccount = mpAccountService.getAccount(id); - return success(MpAccountConvert.INSTANCE.convert(wxAccount)); - } - - @GetMapping("/page") - @Operation(summary = "获得公众号账号分页") - @PreAuthorize("@ss.hasPermission('mp:account:query')") - public CommonResult> getAccountPage(@Valid MpAccountPageReqVO pageVO) { - PageResult pageResult = mpAccountService.getAccountPage(pageVO); - return success(MpAccountConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取公众号账号精简信息列表") - @PreAuthorize("@ss.hasPermission('mp:account:query')") - public CommonResult> getSimpleAccounts() { - List list = mpAccountService.getAccountList(); - return success(MpAccountConvert.INSTANCE.convertList02(list)); - } - - @PutMapping("/generate-qr-code") - @Operation(summary = "生成公众号二维码") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:account:qr-code')") - public CommonResult generateAccountQrCode(@RequestParam("id") Long id) { - mpAccountService.generateAccountQrCode(id); - return success(true); - } - - @PutMapping("/clear-quota") - @Operation(summary = "清空公众号 API 配额") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:account:clear-quota')") - public CommonResult clearAccountQuota(@RequestParam("id") Long id) { - mpAccountService.clearAccountQuota(id); - return success(true); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountBaseVO.java deleted file mode 100644 index 8f688309d..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountBaseVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -/** - * 公众号账号 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author fengdan - */ -@Data -public class MpAccountBaseVO { - - @Schema(description = "公众号名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - @NotEmpty(message = "公众号名称不能为空") - private String name; - - @Schema(description = "公众号微信号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudaoyuanma") - @NotEmpty(message = "公众号微信号不能为空") - private String account; - - @Schema(description = "公众号 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx5b23ba7a5589ecbb") - @NotEmpty(message = "公众号 appId 不能为空") - private String appId; - - @Schema(description = "公众号密钥", requiredMode = Schema.RequiredMode.REQUIRED, example = "3a7b3b20c537e52e74afd395eb85f61f") - @NotEmpty(message = "公众号密钥不能为空") - private String appSecret; - - @Schema(description = "公众号 token", requiredMode = Schema.RequiredMode.REQUIRED, example = "kangdayuzhen") - @NotEmpty(message = "公众号 token 不能为空") - private String token; - - @Schema(description = "加密密钥", example = "gjN+Ksei") - private String aesKey; - - @Schema(description = "备注", example = "请关注芋道源码,学习技术") - private String remark; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountCreateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountCreateReqVO.java deleted file mode 100644 index b864f16c5..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 公众号账号创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAccountCreateReqVO extends MpAccountBaseVO { - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountPageReqVO.java deleted file mode 100644 index 93093dc19..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 公众号账号分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAccountPageReqVO extends PageParam { - - @Schema(name = "公众号名称", description = "模糊匹配") - private String name; - - @Schema(name = "公众号账号", description = "模糊匹配") - private String account; - - @Schema(name = "公众号 appid", description = "模糊匹配") - private String appId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountRespVO.java deleted file mode 100644 index 0f7ca7eba..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 公众号账号 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAccountRespVO extends MpAccountBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "二维码图片URL", example = "https://www.iocoder.cn/1024.png") - private String qrCodeUrl; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountSimpleRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountSimpleRespVO.java deleted file mode 100644 index db4594f6d..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountSimpleRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 公众号账号精简信息 Response VO") -@Data -public class MpAccountSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountUpdateReqVO.java deleted file mode 100644 index e93123e6c..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.account.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号账号更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAccountUpdateReqVO extends MpAccountBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.http deleted file mode 100644 index 74b8f40b6..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.http +++ /dev/null @@ -1,5 +0,0 @@ -### 请求 /mp/material/page 接口 => 成功 -GET {{baseUrl}}/mp/material/page?permanent=true&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.java deleted file mode 100644 index ef175d2af..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/MpMaterialController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.*; -import cn.iocoder.yudao.module.mp.convert.material.MpMaterialConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import cn.iocoder.yudao.module.mp.service.material.MpMaterialService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.io.IOException; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号素材") -@RestController -@RequestMapping("/mp/material") -@Validated -public class MpMaterialController { - - @Resource - private MpMaterialService mpMaterialService; - - @Operation(summary = "上传临时素材") - @PostMapping("/upload-temporary") - @PreAuthorize("@ss.hasPermission('mp:material:upload-temporary')") - public CommonResult uploadTemporaryMaterial( - @Valid MpMaterialUploadTemporaryReqVO reqVO) throws IOException { - MpMaterialDO material = mpMaterialService.uploadTemporaryMaterial(reqVO); - return success(MpMaterialConvert.INSTANCE.convert(material)); - } - - @Operation(summary = "上传永久素材") - @PostMapping("/upload-permanent") - @PreAuthorize("@ss.hasPermission('mp:material:upload-permanent')") - public CommonResult uploadPermanentMaterial( - @Valid MpMaterialUploadPermanentReqVO reqVO) throws IOException { - MpMaterialDO material = mpMaterialService.uploadPermanentMaterial(reqVO); - return success(MpMaterialConvert.INSTANCE.convert(material)); - } - - @Operation(summary = "删除素材") - @DeleteMapping("/delete-permanent") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:material:delete')") - public CommonResult deleteMaterial(@RequestParam("id") Long id) { - mpMaterialService.deleteMaterial(id); - return success(true); - } - - @Operation(summary = "上传图文内容中的图片") - @PostMapping("/upload-news-image") - @PreAuthorize("@ss.hasPermission('mp:material:upload-news-image')") - public CommonResult uploadNewsImage(@Valid MpMaterialUploadNewsImageReqVO reqVO) - throws IOException { - return success(mpMaterialService.uploadNewsImage(reqVO)); - } - - @Operation(summary = "获得素材分页") - @GetMapping("/page") - @PreAuthorize("@ss.hasPermission('mp:material:query')") - public CommonResult> getMaterialPage(@Valid MpMaterialPageReqVO pageReqVO) { - PageResult pageResult = mpMaterialService.getMaterialPage(pageReqVO); - return success(MpMaterialConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialPageReqVO.java deleted file mode 100644 index 8a2b60ff6..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialPageReqVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号素材的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMaterialPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "是否永久", example = "true") - private Boolean permanent; - - @Schema(description = "文件类型 参见 WxConsts.MediaFileType 枚举", example = "image") - private String type; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialRespVO.java deleted file mode 100644 index 5aba24edd..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialRespVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 公众号素材 Response VO") -@Data -public class MpMaterialRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long accountId; - @Schema(description = "公众号账号的 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890") - private String appId; - - @Schema(description = "素材的 media_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "123") - private String mediaId; - - @Schema(description = "文件类型 参见 WxConsts.MediaFileType 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "image") - private String type; - - @Schema(description = "是否永久 true - 永久;false - 临时", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean permanent; - - @Schema(description = "素材的 URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String url; - - - @Schema(description = "名字", example = "yunai.png") - private String name; - - @Schema(description = "公众号文件 URL 只有【永久素材】使用", example = "https://mmbiz.qpic.cn/xxx.mp3") - private String mpUrl; - - @Schema(description = "视频素材的标题 只有【永久素材】使用", example = "我是标题") - private String title; - @Schema(description = "视频素材的描述 只有【永久素材】使用", example = "我是介绍") - private String introduction; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadNewsImageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadNewsImageReqVO.java deleted file mode 100644 index 6ede4c5eb..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadNewsImageReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号素材上传图文内容中的图片 Request VO") -@Data -public class MpMaterialUploadNewsImageReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "文件附件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "文件不能为空") - @JsonIgnore // 避免被操作日志,进行序列化,导致报错 - private MultipartFile file; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadPermanentReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadPermanentReqVO.java deleted file mode 100644 index 9ca8a4ad8..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadPermanentReqVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import cn.hutool.core.util.ObjectUtil; -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号素材上传永久 Request VO") -@Data -public class MpMaterialUploadPermanentReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "文件类型 参见 WxConsts.MediaFileType 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "image") - @NotEmpty(message = "文件类型不能为空") - private String type; - - @Schema(description = "文件附件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "文件不能为空") - @JsonIgnore // 避免被操作日志,进行序列化,导致报错 - private MultipartFile file; - - @Schema(description = "名字 如果 name 为空,则使用 file 文件名", example = "wechat.mp") - private String name; - - @Schema(description = "视频素材的标题 文件类型为 video 时,必填", example = "视频素材的标题") - private String title; - @Schema(description = "视频素材的描述 文件类型为 video 时,必填", example = "视频素材的描述") - private String introduction; - - @AssertTrue(message = "标题不能为空") - public boolean isTitleValid() { - // 生成场景为管理后台时,必须设置上级菜单,不然生成的菜单 SQL 是无父级菜单的 - return ObjectUtil.notEqual(type, WxConsts.MediaFileType.VIDEO) - || title != null; - } - - @AssertTrue(message = "描述不能为空") - public boolean isIntroductionValid() { - // 生成场景为管理后台时,必须设置上级菜单,不然生成的菜单 SQL 是无父级菜单的 - return ObjectUtil.notEqual(type, WxConsts.MediaFileType.VIDEO) - || introduction != null; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadRespVO.java deleted file mode 100644 index 0174cbcc2..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 公众号素材上传结果 Response VO") -@Data -public class MpMaterialUploadRespVO { - - @Schema(description = "素材的 media_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "123") - private String mediaId; - - @Schema(description = "素材的 URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") - private String url; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadTemporaryReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadTemporaryReqVO.java deleted file mode 100644 index abd6d06d1..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/material/vo/MpMaterialUploadTemporaryReqVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.material.vo; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号素材上传临时 Request VO") -@Data -public class MpMaterialUploadTemporaryReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "文件类型 参见 WxConsts.MediaFileType 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "image") - @NotEmpty(message = "文件类型不能为空") - private String type; - - @Schema(description = "文件附件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "文件不能为空") - @JsonIgnore // 避免被操作日志,进行序列化,导致报错 - private MultipartFile file; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http deleted file mode 100644 index 2276b3b4f..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.http +++ /dev/null @@ -1,50 +0,0 @@ -### 请求 /mp/menu/save 接口 => 成功 -POST {{baseUrl}}/mp/menu/save -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "accountId": "1", - "menus": [ - { - "type":"click", - "name":"今日歌曲", - "menuKey":"V1001_TODAY_MUSIC" - }, - { - "name":"搜索", - "type":"view", - "url":"https://www.soso.com/" - }, - { - "name": "父按钮", - "children": [ - { - "type":"click", - "name":"归去来兮", - "menuKey":"MUSIC" - }, - { - "name":"不说", - "type":"view", - "url":"https://www.soso.com/" - }] - }] -} - -### 请求 /mp/menu/save 接口 => 成功(清空) -POST {{baseUrl}}/mp/menu/save -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "accountId": "1", - "menus": [] -} - -### 请求 /mp/menu/list 接口 => 成功 -GET {{baseUrl}}/mp/menu/list?accountId=1 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.java deleted file mode 100644 index b7c883519..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/MpMenuController.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.menu; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuSaveReqVO; -import cn.iocoder.yudao.module.mp.convert.menu.MpMenuConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import cn.iocoder.yudao.module.mp.service.menu.MpMenuService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号菜单") -@RestController -@RequestMapping("/mp/menu") -@Validated -public class MpMenuController { - - @Resource - private MpMenuService mpMenuService; - - @PostMapping("/save") - @Operation(summary = "保存公众号菜单") - @PreAuthorize("@ss.hasPermission('mp:menu:save')") - public CommonResult saveMenu(@Valid @RequestBody MpMenuSaveReqVO createReqVO) { - mpMenuService.saveMenu(createReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除公众号菜单") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "10") - @PreAuthorize("@ss.hasPermission('mp:menu:delete')") - public CommonResult deleteMenu(@RequestParam("accountId") Long accountId) { - mpMenuService.deleteMenuByAccountId(accountId); - return success(true); - } - - @GetMapping("/list") - @Operation(summary = "获得公众号菜单列表") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "10") - @PreAuthorize("@ss.hasPermission('mp:menu:query')") - public CommonResult> getMenuList(@RequestParam("accountId") Long accountId) { - List list = mpMenuService.getMenuListByAccountId(accountId); - return success(MpMenuConvert.INSTANCE.convertList(list)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java deleted file mode 100644 index cd0e5b2e4..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuBaseVO.java +++ /dev/null @@ -1,115 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; -import org.hibernate.validator.constraints.URL; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -import static cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils.*; - -/** - * 公众号菜单 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MpMenuBaseVO { - - /** - * 菜单名称 - */ - private String name; - /** - * 菜单标识 - * - * 支持多 DB 类型时,无法直接使用 key + @TableField("menuKey") 来实现转换,原因是 "menuKey" AS key 而存在报错 - */ - private String menuKey; - /** - * 父菜单编号 - */ - private Long parentId; - - // ========== 按钮操作 ========== - - /** - * 按钮类型 - * - * 枚举 {@link WxConsts.MenuButtonType} - */ - private String type; - - @Schema(description = "网页链接", example = "https://www.iocoder.cn/") - @NotEmpty(message = "网页链接不能为空", groups = {ViewButtonGroup.class, MiniProgramButtonGroup.class}) - @URL(message = "网页链接必须是 URL 格式") - private String url; - - @Schema(description = "小程序的 appId", example = "wx1234567890") - @NotEmpty(message = "小程序的 appId 不能为空", groups = MiniProgramButtonGroup.class) - private String miniProgramAppId; - - @Schema(description = "小程序的页面路径", example = "pages/index/index") - @NotEmpty(message = "小程序的页面路径不能为空", groups = MiniProgramButtonGroup.class) - private String miniProgramPagePath; - - @Schema(description ="跳转图文的媒体编号", example = "jCQk93AIIgp8ixClWcW_NXXqBKInNWNmq2XnPeDZl7IMVqWiNeL4FfELtggRXd83") - @NotEmpty(message = "跳转图文的媒体编号不能为空", groups = ViewLimitedButtonGroup.class) - private String articleId; - - // ========== 消息内容 ========== - - @Schema(description = "回复的消息类型 枚举 TEXT、IMAGE、VOICE、VIDEO、NEWS、MUSIC", example = "text") - @NotEmpty(message = "回复的消息类型不能为空", groups = {ClickButtonGroup.class, ScanCodeWaitMsgButtonGroup.class}) - private String replyMessageType; - - @Schema(description = "回复的消息内容", example = "欢迎关注") - @NotEmpty(message = "回复的消息内容不能为空", groups = TextMessageGroup.class) - private String replyContent; - - @Schema(description = "回复的媒体 id", example = "123456") - @NotEmpty(message = "回复的消息 mediaId 不能为空", - groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String replyMediaId; - @Schema(description = "回复的媒体 URL", example = "https://www.iocoder.cn/xxx.jpg") - @NotEmpty(message = "回复的消息 mediaId 不能为空", - groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String replyMediaUrl; - - @Schema(description = "缩略图的媒体 id", example = "123456") - @NotEmpty(message = "回复的消息 thumbMediaId 不能为空", groups = {MusicMessageGroup.class}) - private String replyThumbMediaId; - @Schema(description = "缩略图的媒体 URL",example = "https://www.iocoder.cn/xxx.jpg") - @NotEmpty(message = "回复的消息 thumbMedia 地址不能为空", groups = {MusicMessageGroup.class}) - private String replyThumbMediaUrl; - - @Schema(description = "回复的标题", example = "视频标题") - @NotEmpty(message = "回复的消息标题不能为空", groups = VideoMessageGroup.class) - private String replyTitle; - @Schema(description = "回复的描述", example = "视频描述") - @NotEmpty(message = "消息描述不能为空", groups = VideoMessageGroup.class) - private String replyDescription; - - /** - * 回复的图文消息数组 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @NotNull(message = "回复的图文消息不能为空", groups = {NewsMessageGroup.class, ViewLimitedButtonGroup.class}) - @Valid - private List replyArticles; - - @Schema(description = "回复的音乐链接", example = "https://www.iocoder.cn/xxx.mp3") - @NotEmpty(message = "回复的音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "回复的高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String replyMusicUrl; - @Schema(description = "高质量音乐链接", example = "https://www.iocoder.cn/xxx.mp3") - @NotEmpty(message = "回复的高质量音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "回复的高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String replyHqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuRespVO.java deleted file mode 100644 index 39c18ae20..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuRespVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.Date; - -@Schema(description = "管理后台 - 公众号菜单 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMenuRespVO extends MpMenuBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long accountId; - - @Schema(description = "公众号 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890ox") - private String appId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java deleted file mode 100644 index 580e62845..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/menu/vo/MpMenuSaveReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.menu.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 公众号菜单保存 Request VO") -@Data -public class MpMenuSaveReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @NotEmpty(message = "菜单不能为空") - @Valid - private List

menus; - - @Schema(description = "管理后台 - 公众号菜单保存时的每个菜单") - @Data - public static class Menu extends MpMenuBaseVO { - - /** - * 子菜单数组 - */ - private List children; - - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.http deleted file mode 100644 index dbb3a7b22..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.http +++ /dev/null @@ -1,5 +0,0 @@ -### 请求 /mp/message/page 接口 => 成功 -GET {{baseUrl}}/mp/auto-reply/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.java deleted file mode 100644 index f6a8b9b38..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpAutoReplyController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyUpdateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.convert.message.MpAutoReplyConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号自动回复") -@RestController -@RequestMapping("/mp/auto-reply") -@Validated -public class MpAutoReplyController { - - @Resource - private MpAutoReplyService mpAutoReplyService; - - @GetMapping("/page") - @Operation(summary = "获得公众号自动回复分页") - @PreAuthorize("@ss.hasPermission('mp:auto-reply:query')") - public CommonResult> getAutoReplyPage(@Valid MpMessagePageReqVO pageVO) { - PageResult pageResult = mpAutoReplyService.getAutoReplyPage(pageVO); - return success(MpAutoReplyConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/get") - @Operation(summary = "获得公众号自动回复") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:auto-reply:query')") - public CommonResult getAutoReply(@RequestParam("id") Long id) { - MpAutoReplyDO autoReply = mpAutoReplyService.getAutoReply(id); - return success(MpAutoReplyConvert.INSTANCE.convert(autoReply)); - } - - @PostMapping("/create") - @Operation(summary = "创建公众号自动回复") - @PreAuthorize("@ss.hasPermission('mp:auto-reply:create')") - public CommonResult createAutoReply(@Valid @RequestBody MpAutoReplyCreateReqVO createReqVO) { - return success(mpAutoReplyService.createAutoReply(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新公众号自动回复") - @PreAuthorize("@ss.hasPermission('mp:auto-reply:update')") - public CommonResult updateAutoReply(@Valid @RequestBody MpAutoReplyUpdateReqVO updateReqVO) { - mpAutoReplyService.updateAutoReply(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除公众号自动回复") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:auto-reply:delete')") - public CommonResult deleteAutoReply(@RequestParam("id") Long id) { - mpAutoReplyService.deleteAutoReply(id); - return success(true); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.http deleted file mode 100644 index b9f9721c9..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.http +++ /dev/null @@ -1,33 +0,0 @@ -### 请求 /mp/message/page 接口 => 成功 -GET {{baseUrl}}/mp/message/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/message/send 接口 => 成功(文本) -POST {{baseUrl}}/mp/message/send -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "userId": 3, - "type": "text", - "content": "测试消息" -} - -### 请求 /mp/message/send 接口 => 成功(音乐) -POST {{baseUrl}}/mp/message/send -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "userId": 3, - "type": "music", - "title": "测试音乐标题", - "description": "测试音乐内容", - "musicUrl": "https://www.iocoder.cn/xx.mp3", - "hqMusicUrl": "https://www.iocoder.cn/xx_high.mp3", - "thumbMediaId": "s98Iveeg9vDVFwa9q0u8-zSfdKe3xIzAm7wCrFE4WKGPIo4d9qAhtC-n6qvnyWyH" -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java deleted file mode 100644 index 66befc65e..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/MpMessageController.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageSendReqVO; -import cn.iocoder.yudao.module.mp.convert.message.MpMessageConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.service.message.MpMessageService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号消息") -@RestController -@RequestMapping("/mp/message") -@Validated -public class MpMessageController { - - @Resource - private MpMessageService mpMessageService; - - @GetMapping("/page") - @Operation(summary = "获得公众号消息分页") - @PreAuthorize("@ss.hasPermission('mp:message:query')") - public CommonResult> getMessagePage(@Valid MpMessagePageReqVO pageVO) { - PageResult pageResult = mpMessageService.getMessagePage(pageVO); - return success(MpMessageConvert.INSTANCE.convertPage(pageResult)); - } - - @PostMapping("/send") - @Operation(summary = "给粉丝发送消息") - @PreAuthorize("@ss.hasPermission('mp:message:send')") - public CommonResult sendMessage(@Valid @RequestBody MpMessageSendReqVO reqVO) { - MpMessageDO message = mpMessageService.sendKefuMessage(reqVO); - return success(MpMessageConvert.INSTANCE.convert(message)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyBaseVO.java deleted file mode 100644 index 4b84254fe..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyBaseVO.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyTypeEnum; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils.*; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; -import org.hibernate.validator.constraints.URL; - -import javax.validation.Valid; -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 公众号自动回复 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class MpAutoReplyBaseVO { - - @Schema(description = "回复类型 参见 MpAutoReplyTypeEnum 枚举", example = "1") - @NotNull(message = "回复类型不能为空") - private Integer type; - - // ==================== 请求消息 ==================== - - @Schema(description = "请求的关键字 当 type 为 MpAutoReplyTypeEnum#KEYWORD 时,必填", example = "关键字") - private String requestKeyword; - @Schema(description = "请求的匹配方式 当 type 为 MpAutoReplyTypeEnum#KEYWORD 时,必填", example = "1") - private Integer requestMatch; - - @Schema(description = "请求的消息类型 当 type 为 MpAutoReplyTypeEnum#MESSAGE 时,必填", example = "text") - private String requestMessageType; - - // ==================== 响应消息 ==================== - - @Schema(description = "回复的消息类型 枚举 TEXT、IMAGE、VOICE、VIDEO、NEWS、MUSIC", example = "text") - @NotEmpty(message = "回复的消息类型不能为空") - private String responseMessageType; - - @Schema(description = "回复的消息内容", example = "欢迎关注") - @NotEmpty(message = "回复的消息内容不能为空", groups = TextMessageGroup.class) - private String responseContent; - - @Schema(description = "回复的媒体 id", example = "123456") - @NotEmpty(message = "回复的消息 mediaId 不能为空", - groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String responseMediaId; - @Schema(description = "回复的媒体 URL", example = "https://www.iocoder.cn/xxx.jpg") - @NotEmpty(message = "回复的消息 mediaId 不能为空", - groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String responseMediaUrl; - - @Schema(description = "缩略图的媒体 id", example = "123456") - @NotEmpty(message = "回复的消息 thumbMediaId 不能为空", groups = {MusicMessageGroup.class}) - private String responseThumbMediaId; - @Schema(description = "缩略图的媒体 URL",example = "https://www.iocoder.cn/xxx.jpg") - @NotEmpty(message = "回复的消息 thumbMedia 地址不能为空", groups = {MusicMessageGroup.class}) - private String responseThumbMediaUrl; - - @Schema(description = "回复的标题", example = "视频标题") - @NotEmpty(message = "回复的消息标题不能为空", groups = VideoMessageGroup.class) - private String responseTitle; - @Schema(description = "回复的描述", example = "视频描述") - @NotEmpty(message = "消息描述不能为空", groups = VideoMessageGroup.class) - private String responseDescription; - - /** - * 回复的图文消息 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @NotNull(message = "回复的图文消息不能为空", groups = {NewsMessageGroup.class, ViewLimitedButtonGroup.class}) - @Valid - private List responseArticles; - - @Schema(description = "回复的音乐链接", example = "https://www.iocoder.cn/xxx.mp3") - @NotEmpty(message = "回复的音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "回复的高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String responseMusicUrl; - @Schema(description = "高质量音乐链接", example = "https://www.iocoder.cn/xxx.mp3") - @NotEmpty(message = "回复的高质量音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "回复的高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String responseHqMusicUrl; - - @AssertTrue(message = "请求的关键字不能为空") - public boolean isRequestKeywordValid() { - return ObjectUtil.notEqual(type, MpAutoReplyTypeEnum.KEYWORD) - || requestKeyword != null; - } - - @AssertTrue(message = "请求的关键字的匹配不能为空") - public boolean isRequestMatchValid() { - return ObjectUtil.notEqual(type, MpAutoReplyTypeEnum.KEYWORD) - || requestMatch != null; - } - - @AssertTrue(message = "请求的消息类型不能为空") - public boolean isRequestMessageTypeValid() { - return ObjectUtil.notEqual(type, MpAutoReplyTypeEnum.MESSAGE) - || requestMessageType != null; - } - - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyCreateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyCreateReqVO.java deleted file mode 100644 index 5eafb3693..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyCreateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号自动回复的创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyCreateReqVO extends MpAutoReplyBaseVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyPageReqVO.java deleted file mode 100644 index a68029e92..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号自动回复的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyRespVO.java deleted file mode 100644 index 4efc97445..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyRespVO.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.Date; - -@Schema(description = "管理后台 - 公众号自动回复 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyRespVO extends MpAutoReplyBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long accountId; - @Schema(description = "公众号 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890") - private String appId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyUpdateReqVO.java deleted file mode 100644 index 92095d773..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/autoreply/MpAutoReplyUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号自动回复的更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyUpdateReqVO extends MpAutoReplyBaseVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "主键不能为空") - private Long id; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessagePageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessagePageReqVO.java deleted file mode 100644 index 3ca643ca6..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessagePageReqVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.message; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 公众号消息分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMessagePageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "消息类型 参见 WxConsts.XmlMsgType 枚举", example = "text") - private String type; - - @Schema(description = "公众号粉丝标识", example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String openid; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageRespVO.java deleted file mode 100644 index 27c85be6b..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageRespVO.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.message; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import com.baomidou.mybatisplus.annotation.TableField; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; - -import java.time.LocalDateTime; -import java.util.Date; -import java.util.List; - -@Schema(description = "管理后台 - 公众号消息 Response VO") -@Data -public class MpMessageRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer id; - - @Schema(description = "微信公众号消息 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23953173569869169") - private Long msgId; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long accountId; - @Schema(description = "公众号账号的 appid", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890") - private String appId; - - @Schema(description = "公众号粉丝编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long userId; - @Schema(description = "公众号粉丝标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String openid; - - @Schema(description = "消息类型 参见 WxConsts.XmlMsgType 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "text") - private String type; - @Schema(description = "消息来源 参见 MpMessageSendFromEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer sendFrom; - - // ========= 普通消息内容 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_standard_messages.html - - @Schema(description = "消息内容 消息类型为 text 时,才有值", example = "你好呀") - private String content; - - @Schema(description = "媒体素材的编号 消息类型为 image、voice、video 时,才有值", example = "1234567890") - private String mediaId; - @Schema(description = "媒体文件的 URL 消息类型为 image、voice、video 时,才有值", example = "https://www.iocoder.cn/xxx.png") - private String mediaUrl; - - @Schema(description = "语音识别后文本 消息类型为 voice 时,才有值", example = "语音识别后文本") - private String recognition; - @Schema(description = "语音格式 消息类型为 voice 时,才有值", example = "amr") - private String format; - - @Schema(description = "标题 消息类型为 video、music、link 时,才有值", example = "我是标题") - private String title; - - @Schema(description = "描述 消息类型为 video、music 时,才有值", example = "我是描述") - private String description; - - @Schema(description = "缩略图的媒体 id 消息类型为 video、music 时,才有值", example = "1234567890") - private String thumbMediaId; - @Schema(description = "缩略图的媒体 URL 消息类型为 video、music 时,才有值", example = "https://www.iocoder.cn/xxx.png") - private String thumbMediaUrl; - - @Schema(description = "点击图文消息跳转链接 消息类型为 link 时,才有值", example = "https://www.iocoder.cn") - private String url; - - @Schema(description = "地理位置维度 消息类型为 location 时,才有值", example = "23.137466") - private Double locationX; - - @Schema(description = "地理位置经度 消息类型为 location 时,才有值", example = "113.352425") - private Double locationY; - - @Schema(description = "地图缩放大小 消息类型为 location 时,才有值", example = "13") - private Double scale; - - @Schema(description = "详细地址 消息类型为 location 时,才有值", example = "杨浦区黄兴路 221-4 号临") - private String label; - - /** - * 图文消息数组 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @TableField(typeHandler = MpMessageDO.ArticleTypeHandler.class) - private List articles; - - @Schema(description = "音乐链接 消息类型为 music 时,才有值", example = "https://www.iocoder.cn/xxx.mp3") - private String musicUrl; - @Schema(description = "高质量音乐链接 消息类型为 music 时,才有值", example = "https://www.iocoder.cn/xxx.mp3") - private String hqMusicUrl; - - // ========= 事件推送 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html - - @Schema(description = "事件类型 参见 WxConsts.EventType 枚举", example = "subscribe") - private String event; - @Schema(description = "事件 Key 参见 WxConsts.EventType 枚举", example = "qrscene_123456") - private String eventKey; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageSendReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageSendReqVO.java deleted file mode 100644 index 8e833d443..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageSendReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.message.vo.message; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils.*; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 公众号消息发送 Request VO") -@Data -public class MpMessageSendReqVO { - - @Schema(description = "公众号粉丝的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号粉丝的编号不能为空") - private Long userId; - - // ========== 消息内容 ========== - - @Schema(description = "消息类型 TEXT/IMAGE/VOICE/VIDEO/NEWS", requiredMode = Schema.RequiredMode.REQUIRED, example = "text") - @NotEmpty(message = "消息类型不能为空") - public String type; - - @Schema(description = "消息内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "你好呀") - @NotEmpty(message = "消息内容不能为空", groups = TextMessageGroup.class) - private String content; - - @Schema(description = "媒体 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "qqc_2Fot30Jse-HDoZmo5RrUDijz2nGUkP") - @NotEmpty(message = "消息内容不能为空", groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String mediaId; - - @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "没有标题") - @NotEmpty(message = "消息内容不能为空", groups = VideoMessageGroup.class) - private String title; - - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") - @NotEmpty(message = "消息描述不能为空", groups = VideoMessageGroup.class) - private String description; - - @Schema(description = "缩略图的媒体 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "qqc_2Fot30Jse-HDoZmo5RrUDijz2nGUkP") - @NotEmpty(message = "缩略图的媒体 id 不能为空", groups = MusicMessageGroup.class) - private String thumbMediaId; - - @Schema(description = "图文消息", requiredMode = Schema.RequiredMode.REQUIRED) - @Valid - @NotNull(message = "图文消息不能为空", groups = NewsMessageGroup.class) - private List articles; - - @Schema(description = "音乐链接 消息类型为 MUSIC 时", example = "https://www.iocoder.cn/music.mp3") - private String musicUrl; - - @Schema(description = "高质量音乐链接 消息类型为 MUSIC 时", example = "https://www.iocoder.cn/music.mp3") - private String hqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.http deleted file mode 100644 index 87f9d432a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.http +++ /dev/null @@ -1,54 +0,0 @@ -### 请求 /mp/draft/page 接口 => 成功 -GET {{baseUrl}}/mp/draft/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/draft/create 接口 => 成功 -POST {{baseUrl}}/mp/draft/create?accountId=1 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "articles": [ - { - "title": "我是标题", - "author": "我是作者", - "digest": "我是摘要", - "content": "我是内容", - "contentSourceUrl": "https://www.iocoder.cn", - "thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn" - }, - { - "title": "我是标题 2", - "author": "我是作者 2", - "digest": "我是摘要 2", - "content": "我是内容 2", - "contentSourceUrl": "https://www.iocoder.cn", - "thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn" - } - ] -} - -### 请求 /mp/draft/create 接口 => 成功 -PUT {{baseUrl}}/mp/draft/update?accountId=1&mediaId=r6ryvl6LrxBU0miaST4Y-q-G9pdsmZw0OYG4FzHQkKfpLfEwIH51wy2bxisx8PvW -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -[{ - "title": "我是标题(OOO)", - "author": "我是作者", - "digest": "我是摘要", - "content": "我是内容", - "contentSourceUrl": "https://www.iocoder.cn", - "thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn" -}, { - "title": "我是标题(XXX)", - "author": "我是作者", - "digest": "我是摘要", - "content": "我是内容", - "contentSourceUrl": "https://www.iocoder.cn", - "thumbMediaId": "r6ryvl6LrxBU0miaST4Y-pIcmK-zAAId-9TGgy-DrSLhjVuWbuT3ZBjk9K1yQ0Dn" -}] diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.java deleted file mode 100644 index c43d6c5d7..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpDraftController.java +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.news; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.module.mp.controller.admin.news.vo.MpDraftPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.material.MpMaterialService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.draft.*; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -@Tag(name = "管理后台 - 公众号草稿") -@RestController -@RequestMapping("/mp/draft") -@Validated -public class MpDraftController { - - @Resource - private MpServiceFactory mpServiceFactory; - - @Resource - private MpMaterialService mpMaterialService; - - @GetMapping("/page") - @Operation(summary = "获得草稿分页") - @PreAuthorize("@ss.hasPermission('mp:draft:query')") - public CommonResult> getDraftPage(MpDraftPageReqVO reqVO) { - // 从公众号查询草稿箱 - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - WxMpDraftList draftList; - try { - draftList = mpService.getDraftService().listDraft(PageUtils.getStart(reqVO), reqVO.getPageSize()); - } catch (WxErrorException e) { - throw exception(DRAFT_LIST_FAIL, e.getError().getErrorMsg()); - } - // 查询对应的图片地址。目的:解决公众号的图片链接无法在我们后台展示 - setDraftThumbUrl(draftList.getItems()); - - // 返回分页 - return success(new PageResult<>(draftList.getItems(), draftList.getTotalCount().longValue())); - } - - private void setDraftThumbUrl(List items) { - // 1.1 获得 mediaId 数组 - Set mediaIds = new HashSet<>(); - items.forEach(item -> item.getContent().getNewsItem().forEach(newsItem -> mediaIds.add(newsItem.getThumbMediaId()))); - if (CollUtil.isEmpty(mediaIds)) { - return; - } - // 1.2 批量查询对应的 Media 素材 - Map materials = CollectionUtils.convertMap(mpMaterialService.getMaterialListByMediaId(mediaIds), - MpMaterialDO::getMediaId); - - // 2. 设置回 WxMpDraftItem 记录 - items.forEach(item -> item.getContent().getNewsItem().forEach(newsItem -> - findAndThen(materials, newsItem.getThumbMediaId(), material -> newsItem.setThumbUrl(material.getUrl())))); - } - - @PostMapping("/create") - @Operation(summary = "创建草稿") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:draft:create')") - public CommonResult deleteDraft(@RequestParam("accountId") Long accountId, - @RequestBody WxMpAddDraft draft) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - String mediaId = mpService.getDraftService().addDraft(draft); - return success(mediaId); - } catch (WxErrorException e) { - throw exception(DRAFT_CREATE_FAIL, e.getError().getErrorMsg()); - } - } - - @PutMapping("/update") - @Operation(summary = "更新草稿") - @Parameters({ - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024"), - @Parameter(name = "mediaId", description = "草稿素材的编号", required = true, example = "xxx") - }) - @PreAuthorize("@ss.hasPermission('mp:draft:update')") - public CommonResult deleteDraft(@RequestParam("accountId") Long accountId, - @RequestParam("mediaId") String mediaId, - @RequestBody List articles) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - for (int i = 0; i < articles.size(); i++) { - WxMpDraftArticles article = articles.get(i); - mpService.getDraftService().updateDraft(new WxMpUpdateDraft(mediaId, i, article)); - } - return success(true); - } catch (WxErrorException e) { - throw exception(DRAFT_UPDATE_FAIL, e.getError().getErrorMsg()); - } - } - - @DeleteMapping("/delete") - @Operation(summary = "删除草稿") - @Parameters({ - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024"), - @Parameter(name = "mediaId", description = "草稿素材的编号", required = true, example = "xxx") - }) - @PreAuthorize("@ss.hasPermission('mp:draft:delete')") - public CommonResult deleteDraft(@RequestParam("accountId") Long accountId, - @RequestParam("mediaId") String mediaId) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - mpService.getDraftService().delDraft(mediaId); - return success(true); - } catch (WxErrorException e) { - throw exception(DRAFT_DELETE_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.http deleted file mode 100644 index 122413200..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.http +++ /dev/null @@ -1,13 +0,0 @@ -### 请求 /mp/free-publish/page 接口 => 成功 -GET {{baseUrl}}/mp/free-publish/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/free-publish/submit 接口 => 成功 -POST {{baseUrl}}/mp/free-publish/submit?accountId=1&mediaId=r6ryvl6LrxBU0miaST4Y-vilmd7iS51D8IPddxflWrau0hIQ2ovY8YanO5jlgUcM -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.java deleted file mode 100644 index e36d7343c..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/MpFreePublishController.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.news; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.module.mp.controller.admin.news.vo.MpFreePublishPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.material.MpMaterialService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishItem; -import me.chanjar.weixin.mp.bean.freepublish.WxMpFreePublishList; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -@Tag(name = "管理后台 - 公众号发布能力") -@RestController -@RequestMapping("/mp/free-publish") -@Validated -public class MpFreePublishController { - - @Resource - private MpServiceFactory mpServiceFactory; - - @Resource - private MpMaterialService mpMaterialService; - - @GetMapping("/page") - @Operation(summary = "获得已发布的图文分页") - @PreAuthorize("@ss.hasPermission('mp:free-publish:query')") - public CommonResult> getFreePublishPage(MpFreePublishPageReqVO reqVO) { - // 从公众号查询已发布的图文列表 - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - WxMpFreePublishList publicationRecords; - try { - publicationRecords = mpService.getFreePublishService().getPublicationRecords( - PageUtils.getStart(reqVO), reqVO.getPageSize()); - } catch (WxErrorException e) { - throw exception(FREE_PUBLISH_LIST_FAIL, e.getError().getErrorMsg()); - } - // 查询对应的图片地址。目的:解决公众号的图片链接无法在我们后台展示 - setFreePublishThumbUrl(publicationRecords.getItems()); - - // 返回分页 - return success(new PageResult<>(publicationRecords.getItems(), publicationRecords.getTotalCount().longValue())); - } - - private void setFreePublishThumbUrl(List items) { - // 1.1 获得 mediaId 数组 - Set mediaIds = new HashSet<>(); - items.forEach(item -> item.getContent().getNewsItem().forEach(newsItem -> mediaIds.add(newsItem.getThumbMediaId()))); - if (CollUtil.isEmpty(mediaIds)) { - return; - } - // 1.2 批量查询对应的 Media 素材 - Map materials = CollectionUtils.convertMap(mpMaterialService.getMaterialListByMediaId(mediaIds), - MpMaterialDO::getMediaId); - - // 2. 设置回 WxMpFreePublishItem 记录 - items.forEach(item -> item.getContent().getNewsItem().forEach(newsItem -> - findAndThen(materials, newsItem.getThumbMediaId(), material -> newsItem.setThumbUrl(material.getUrl())))); - } - - @PostMapping("/submit") - @Operation(summary = "发布草稿") - @Parameters({ - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024"), - @Parameter(name = "mediaId", description = "要发布的草稿的 media_id", required = true, example = "2048") - }) - @PreAuthorize("@ss.hasPermission('mp:free-publish:submit')") - public CommonResult submitFreePublish(@RequestParam("accountId") Long accountId, - @RequestParam("mediaId") String mediaId) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - String publishId = mpService.getFreePublishService().submit(mediaId); - return success(publishId); - } catch (WxErrorException e) { - throw exception(FREE_PUBLISH_SUBMIT_FAIL, e.getError().getErrorMsg()); - } - } - - @DeleteMapping("/delete") - @Operation(summary = "删除草稿") - @Parameters({ - @Parameter(name = "accountId", description = "公众号账号的编号", required = true, example = "1024"), - @Parameter(name = "articleId", description = "发布记录的编号", required = true, example = "2048") - }) - @PreAuthorize("@ss.hasPermission('mp:free-publish:delete')") - public CommonResult deleteFreePublish(@RequestParam("accountId") Long accountId, - @RequestParam("articleId") String articleId) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - mpService.getFreePublishService().deletePushAllArticle(articleId); - return success(true); - } catch (WxErrorException e) { - throw exception(FREE_PUBLISH_DELETE_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpDraftPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpDraftPageReqVO.java deleted file mode 100644 index 62bc6f8e5..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpDraftPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.news.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号草稿的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpDraftPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpFreePublishPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpFreePublishPageReqVO.java deleted file mode 100644 index da36248f0..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/news/vo/MpFreePublishPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.news.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号已发布列表的分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpFreePublishPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/MpOpenController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/MpOpenController.java deleted file mode 100644 index 47e23923d..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/MpOpenController.java +++ /dev/null @@ -1,114 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.open; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.mp.controller.admin.open.vo.MpOpenCheckSignatureReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.open.vo.MpOpenHandleMessageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.mp.api.WxMpMessageRouter; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Objects; - -@Tag(name = "管理后台 - 公众号回调") -@RestController -@RequestMapping("/mp/open") -@Validated -@Slf4j -public class MpOpenController { - - @Resource - private MpServiceFactory mpServiceFactory; - - @Resource - private MpAccountService mpAccountService; - - /** - * 接收微信公众号的校验签名 - * - * 对应 文档 - */ - @Operation(summary = "校验签名") // 参见 - @GetMapping(value = "/{appId}", produces = "text/plain;charset=utf-8") - public String checkSignature(@PathVariable("appId") String appId, - MpOpenCheckSignatureReqVO reqVO) { - log.info("[checkSignature][appId({}) 接收到来自微信服务器的认证消息({})]", appId, reqVO); - // 校验请求签名 - WxMpService wxMpService = mpServiceFactory.getRequiredMpService(appId); - // 校验通过 - if (wxMpService.checkSignature(reqVO.getTimestamp(), reqVO.getNonce(), reqVO.getSignature())) { - return reqVO.getEchostr(); - } - // 校验不通过 - return "非法请求"; - } - - /** - * 接收微信公众号的消息推送 - * - * 文档 - */ - @Operation(summary = "处理消息") - @PostMapping(value = "/{appId}", produces = "application/xml; charset=UTF-8") - public String handleMessage(@PathVariable("appId") String appId, - @RequestBody String content, - MpOpenHandleMessageReqVO reqVO) { - log.info("[handleMessage][appId({}) 推送消息,参数({}) 内容({})]", appId, reqVO, content); - - // 处理 appId + 多租户的上下文 - MpAccountDO account = mpAccountService.getAccountFromCache(appId); - Assert.notNull(account, "公众号 appId({}) 不存在", appId); - try { - MpContextHolder.setAppId(appId); - return TenantUtils.execute(account.getTenantId(), - () -> handleMessage0(appId, content, reqVO)); - } finally { - MpContextHolder.clear(); - } - } - - private String handleMessage0(String appId, String content, MpOpenHandleMessageReqVO reqVO) { - // 校验请求签名 - WxMpService mppService = mpServiceFactory.getRequiredMpService(appId); - Assert.isTrue(mppService.checkSignature(reqVO.getTimestamp(), reqVO.getNonce(), reqVO.getSignature()), - "非法请求"); - - // 第一步,解析消息 - WxMpXmlMessage inMessage = null; - if (StrUtil.isBlank(reqVO.getEncrypt_type())) { // 明文模式 - inMessage = WxMpXmlMessage.fromXml(content); - } else if (Objects.equals(reqVO.getEncrypt_type(), MpOpenHandleMessageReqVO.ENCRYPT_TYPE_AES)) { // AES 加密模式 - inMessage = WxMpXmlMessage.fromEncryptedXml(content, mppService.getWxMpConfigStorage(), - reqVO.getTimestamp(), reqVO.getNonce(), reqVO.getMsg_signature()); - } - Assert.notNull(inMessage, "消息解析失败,原因:消息为空"); - - // 第二步,处理消息 - WxMpMessageRouter mpMessageRouter = mpServiceFactory.getRequiredMpMessageRouter(appId); - WxMpXmlOutMessage outMessage = mpMessageRouter.route(inMessage); - if (outMessage == null) { - return ""; - } - - // 第三步,返回消息 - if (StrUtil.isBlank(reqVO.getEncrypt_type())) { // 明文模式 - return outMessage.toXml(); - } else if (Objects.equals(reqVO.getEncrypt_type(), MpOpenHandleMessageReqVO.ENCRYPT_TYPE_AES)) { // AES 加密模式 - return outMessage.toEncryptedXml(mppService.getWxMpConfigStorage()); - } - return ""; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenCheckSignatureReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenCheckSignatureReqVO.java deleted file mode 100644 index c0c73a8ed..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenCheckSignatureReqVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.open.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 公众号校验签名 Request VO") -@Data -public class MpOpenCheckSignatureReqVO { - - @Schema(description = "微信加密签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "490eb57f448b87bd5f20ccef58aa4de46aa1908e") - @NotEmpty(message = "微信加密签名不能为空") - private String signature; - - @Schema(description = "时间戳", requiredMode = Schema.RequiredMode.REQUIRED, example = "1672587863") - @NotEmpty(message = "时间戳不能为空") - private String timestamp; - - @Schema(description = "随机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1827365808") - @NotEmpty(message = "随机数不能为空") - private String nonce; - - @Schema(description = "随机字符串", requiredMode = Schema.RequiredMode.REQUIRED, example = "2721154047828672511") - @NotEmpty(message = "随机字符串不能为空") - @SuppressWarnings("SpellCheckingInspection") - private String echostr; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenHandleMessageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenHandleMessageReqVO.java deleted file mode 100644 index cb8f9abf2..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/open/vo/MpOpenHandleMessageReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.open.vo; - - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 公众号处理消息 Request VO") -@Data -public class MpOpenHandleMessageReqVO { - - public static final String ENCRYPT_TYPE_AES = "aes"; - - @Schema(description = "微信加密签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "490eb57f448b87bd5f20ccef58aa4de46aa1908e") - @NotEmpty(message = "微信加密签名不能为空") - private String signature; - - @Schema(description = "时间戳", requiredMode = Schema.RequiredMode.REQUIRED, example = "1672587863") - @NotEmpty(message = "时间戳不能为空") - private String timestamp; - - @Schema(description = "随机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1827365808") - @NotEmpty(message = "随机数不能为空") - private String nonce; - - @Schema(description = "粉丝 openid", requiredMode = Schema.RequiredMode.REQUIRED, example = "oz-Jdtyn-WGm4C4I5Z-nvBMO_ZfY") - @NotEmpty(message = "粉丝 openid 不能为空") - private String openid; - - @Schema(description = "消息加密类型", example = "aes") - private String encrypt_type; - - @Schema(description = "微信签名", example = "QW5kcm9pZCBUaGUgQmFzZTY0IGlzIGEgZ2VuZXJhdGVkIHN0cmluZw==") - private String msg_signature; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java deleted file mode 100644 index 8a9df53c3..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.*; -import cn.iocoder.yudao.module.mp.convert.statistics.MpStatisticsConvert; -import cn.iocoder.yudao.module.mp.service.statistics.MpStatisticsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号统计") -@RestController -@RequestMapping("/mp/statistics") -@Validated -public class MpStatisticsController { - - @Resource - private MpStatisticsService mpStatisticsService; - - @GetMapping("/user-summary") - @Operation(summary = "获得粉丝增减数据") - @PreAuthorize("@ss.hasPermission('mp:statistics:query')") - public CommonResult> getUserSummary(MpStatisticsGetReqVO getReqVO) { - List list = mpStatisticsService.getUserSummary( - getReqVO.getAccountId(), getReqVO.getDate()); - return success(MpStatisticsConvert.INSTANCE.convertList01(list)); - } - - @GetMapping("/user-cumulate") - @Operation(summary = "获得粉丝累计数据") - @PreAuthorize("@ss.hasPermission('mp:statistics:query')") - public CommonResult> getUserCumulate(MpStatisticsGetReqVO getReqVO) { - List list = mpStatisticsService.getUserCumulate( - getReqVO.getAccountId(), getReqVO.getDate()); - return success(MpStatisticsConvert.INSTANCE.convertList02(list)); - } - - @GetMapping("/upstream-message") - @Operation(summary = "获取消息发送概况数据") - @PreAuthorize("@ss.hasPermission('mp:statistics:query')") - public CommonResult> getUpstreamMessage(MpStatisticsGetReqVO getReqVO) { - List list = mpStatisticsService.getUpstreamMessage( - getReqVO.getAccountId(), getReqVO.getDate()); - return success(MpStatisticsConvert.INSTANCE.convertList03(list)); - } - - @GetMapping("/interface-summary") - @Operation(summary = "获取消息发送概况数据") - @PreAuthorize("@ss.hasPermission('mp:statistics:query')") - public CommonResult> getInterfaceSummary(MpStatisticsGetReqVO getReqVO) { - List list = mpStatisticsService.getInterfaceSummary( - getReqVO.getAccountId(), getReqVO.getDate()); - return success(MpStatisticsConvert.INSTANCE.convertList04(list)); - } -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java deleted file mode 100644 index f228f7259..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 获得统计数据 Request VO") -@Data -public class MpStatisticsGetReqVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "查询时间范围", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @NotNull(message = "查询时间范围不能为空") - private LocalDateTime[] date; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsInterfaceSummaryRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsInterfaceSummaryRespVO.java deleted file mode 100644 index c7952f42d..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsInterfaceSummaryRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 某一天的接口分析数据 Response VO") -@Data -public class MpStatisticsInterfaceSummaryRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime refDate; - - @Schema(description = "通过服务器配置地址获得消息后,被动回复粉丝消息的次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer callbackCount; - - @Schema(description = "上述动作的失败次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer failCount; - - @Schema(description = "总耗时,除以 callback_count 即为平均耗时", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") - private Integer totalTimeCost; - - @Schema(description = "最大耗时", requiredMode = Schema.RequiredMode.REQUIRED, example = "40") - private Integer maxTimeCost; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUpstreamMessageRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUpstreamMessageRespVO.java deleted file mode 100644 index f9bba2ce2..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUpstreamMessageRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 某一天的粉丝增减数据 Response VO") -@Data -public class MpStatisticsUpstreamMessageRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime refDate; - - @Schema(description = "上行发送了(向公众号发送了)消息的粉丝数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer messageUser; - - @Schema(description = "上行发送了消息的消息总数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer messageCount; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserCumulateRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserCumulateRespVO.java deleted file mode 100644 index 6503c0780..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserCumulateRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 某一天的消息发送概况数据 Response VO") -@Data -public class MpStatisticsUserCumulateRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime refDate; - - @Schema(description = "累计粉丝量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer cumulateUser; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserSummaryRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserSummaryRespVO.java deleted file mode 100644 index f7feb5171..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserSummaryRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Date; - -@Schema(description = "管理后台 - 某一天的粉丝增减数据 Response VO") -@Data -public class MpStatisticsUserSummaryRespVO { - - @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime refDate; - - @Schema(description = "粉丝来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer userSource; - - @Schema(description = "新关注的粉丝数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer newUser; - - @Schema(description = "取消关注的粉丝数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer cancelUser; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.http deleted file mode 100644 index fe79105ba..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.http +++ /dev/null @@ -1,39 +0,0 @@ -### 请求 /mp/tag/create 接口 => 成功 -POST {{baseUrl}}/mp/tag/create -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "accountId": "1", - "name": "测试" -} - -### 请求 /mp/tag/update 接口 => 成功 -PUT {{baseUrl}}/mp/tag/update -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "id": "3", - "name": "测试标签啦" -} - -### 请求 /mp/tag/delete 接口 => 成功 -DELETE {{baseUrl}}/mp/tag/delete?id=3 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/tag/page 接口 => 成功 -GET {{baseUrl}}/mp/tag/page?accountId=1&pageNo=1&pageSize=10 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/tag/sync 接口 => 成功 -POST {{baseUrl}}/mp/tag/sync?accountId=1 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.java deleted file mode 100644 index 96af036dc..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/MpTagController.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.*; -import cn.iocoder.yudao.module.mp.convert.tag.MpTagConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import cn.iocoder.yudao.module.mp.service.tag.MpTagService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号标签") -@RestController -@RequestMapping("/mp/tag") -@Validated -public class MpTagController { - - @Resource - private MpTagService mpTagService; - - @PostMapping("/create") - @Operation(summary = "创建公众号标签") - @PreAuthorize("@ss.hasPermission('mp:tag:create')") - public CommonResult createTag(@Valid @RequestBody MpTagCreateReqVO createReqVO) { - return success(mpTagService.createTag(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新公众号标签") - @PreAuthorize("@ss.hasPermission('mp:tag:update')") - public CommonResult updateTag(@Valid @RequestBody MpTagUpdateReqVO updateReqVO) { - mpTagService.updateTag(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除公众号标签") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:tag:delete')") - public CommonResult deleteTag(@RequestParam("id") Long id) { - mpTagService.deleteTag(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获取公众号标签详情") - @PreAuthorize("@ss.hasPermission('mp:tag:query')") - public CommonResult get(@RequestParam("id") Long id) { - MpTagDO mpTagDO = mpTagService.get(id); - return success(MpTagConvert.INSTANCE.convert(mpTagDO)); - } - - @GetMapping("/page") - @Operation(summary = "获取公众号标签分页") - @PreAuthorize("@ss.hasPermission('mp:tag:query')") - public CommonResult> getTagPage(MpTagPageReqVO pageReqVO) { - PageResult pageResult = mpTagService.getTagPage(pageReqVO); - return success(MpTagConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/list-all-simple") - @Operation(summary = "获取公众号账号精简信息列表") - @PreAuthorize("@ss.hasPermission('mp:account:query')") - public CommonResult> getSimpleTags() { - List list = mpTagService.getTagList(); - return success(MpTagConvert.INSTANCE.convertList02(list)); - } - - @PostMapping("/sync") - @Operation(summary = "同步公众号标签") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:tag:sync')") - public CommonResult syncTag(@RequestParam("accountId") Long accountId) { - mpTagService.syncTag(accountId); - return success(true); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagBaseVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagBaseVO.java deleted file mode 100644 index dc034e3e8..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagBaseVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -/** - * 公众号标签 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author fengdan - */ -@Data -public class MpTagBaseVO { - - @Schema(description = "标签名", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆") - @NotEmpty(message = "标签名不能为空") - private String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagCreateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagCreateReqVO.java deleted file mode 100644 index ba56a0271..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagCreateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号标签创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpTagCreateReqVO extends MpTagBaseVO { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagPageReqVO.java deleted file mode 100644 index 0666b340a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagPageReqVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - 公众号标签分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpTagPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotEmpty(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "标签名,模糊匹配", example = "哈哈") - private String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagRespVO.java deleted file mode 100644 index 0da562dee..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 公众号标签 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpTagRespVO extends MpTagBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "此标签下粉丝数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer count; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagSimpleRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagSimpleRespVO.java deleted file mode 100644 index ca23be1c8..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagSimpleRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 公众号标签精简信息 Response VO") -@Data -public class MpTagSimpleRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号的标签编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long tagId; - - @Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "快乐") - private String name; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagUpdateReqVO.java deleted file mode 100644 index cb61f1afb..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/tag/vo/MpTagUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.tag.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号标签更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpTagUpdateReqVO extends MpTagBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.http b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.http deleted file mode 100644 index 7c615810f..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.http +++ /dev/null @@ -1,18 +0,0 @@ -### 请求 /mp/user/sync 接口 => 成功 -POST {{baseUrl}}/mp/user/sync?accountId=1 -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 请求 /mp/user/update 接口 => 成功 -PUT {{baseUrl}}/mp/user/update -Content-Type: application/json -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -{ - "id": "3", - "nickname": "test", - "remark": "测试备注", - "tagIds": [103, 104] -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.java deleted file mode 100644 index 7098bc57e..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/MpUserController.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.user; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO; -import cn.iocoder.yudao.module.mp.convert.user.MpUserConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.service.user.MpUserService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 公众号粉丝") -@RestController -@RequestMapping("/mp/user") -@Validated -public class MpUserController { - - @Resource - private MpUserService mpUserService; - - @GetMapping("/page") - @Operation(summary = "获得公众号粉丝分页") - @PreAuthorize("@ss.hasPermission('mp:user:query')") - public CommonResult> getUserPage(@Valid MpUserPageReqVO pageVO) { - PageResult pageResult = mpUserService.getUserPage(pageVO); - return success(MpUserConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/get") - @Operation(summary = "获得公众号粉丝") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mp:user:query')") - public CommonResult getUser(@RequestParam("id") Long id) { - return success(MpUserConvert.INSTANCE.convert(mpUserService.getUser(id))); - } - - @PutMapping("/update") - @Operation(summary = "更新公众号粉丝") - @PreAuthorize("@ss.hasPermission('mp:user:update')") - public CommonResult updateUser(@Valid @RequestBody MpUserUpdateReqVO updateReqVO) { - mpUserService.updateUser(updateReqVO); - return success(true); - } - - @PostMapping("/sync") - @Operation(summary = "同步公众号粉丝") - @Parameter(name = "accountId", description = "公众号账号的编号", required = true) - @PreAuthorize("@ss.hasPermission('mp:user:sync')") - public CommonResult syncUser(@RequestParam("accountId") Long accountId) { - mpUserService.syncUser(accountId); - return success(true); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserPageReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserPageReqVO.java deleted file mode 100644 index 93b5ba92c..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.user.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 公众号粉丝分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpUserPageReqVO extends PageParam { - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - @NotNull(message = "公众号账号的编号不能为空") - private Long accountId; - - @Schema(description = "公众号粉丝标识,模糊匹配", example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String openid; - - @Schema(description = "微信生态唯一标识,模糊匹配", example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String unionId; - - @Schema(description = "公众号粉丝昵称,模糊匹配", example = "芋艿") - private String nickname; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserRespVO.java deleted file mode 100644 index 95f919a1b..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserRespVO.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 公众号粉丝 Response VO") -@Data -public class MpUserRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "公众号粉丝标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String openid; - - @Schema(description = "微信生态唯一标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "o6_bmjrPTlm6_2sgVt7hMZOPfL2M") - private String unionId; - - @Schema(description = "关注状态 参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer subscribeStatus; - @Schema(description = "关注时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime subscribeTime; - @Schema(description = "取消关注时间") - private LocalDateTime unsubscribeTime; - - @Schema(description = "昵称", example = "芋道") - private String nickname; - @Schema(description = "头像地址", example = "https://www.iocoder.cn/1.png") - private String headImageUrl; - @Schema(description = "语言", example = "zh_CN") - private String language; - @Schema(description = "国家", example = "中国") - private String country; - @Schema(description = "省份", example = "广东省") - private String province; - @Schema(description = "城市", example = "广州市") - private String city; - @Schema(description = "备注", example = "你是一个芋头嘛") - private String remark; - - @Schema(description = "标签编号数组", example = "1,2,3") - private List tagIds; - - @Schema(description = "公众号账号的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long accountId; - @Schema(description = "公众号账号的 appId", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx1234567890") - private String appId; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserUpdateReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserUpdateReqVO.java deleted file mode 100644 index 3089ed3d3..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/user/vo/MpUserUpdateReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.mp.controller.admin.user.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.util.List; - -@Schema(description = "管理后台 - 公众号粉丝更新 Request VO") -@Data -public class MpUserUpdateReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "昵称", example = "芋道") - private String nickname; - - @Schema(description = "备注", example = "你是一个芋头嘛") - private String remark; - - @Schema(description = "标签编号数组", example = "1,2,3") - private List tagIds; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/package-info.java deleted file mode 100644 index 31a057767..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.mp.controller; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/account/MpAccountConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/account/MpAccountConvert.java deleted file mode 100644 index 5f8fde36a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/account/MpAccountConvert.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.account; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountSimpleRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpAccountConvert { - - MpAccountConvert INSTANCE = Mappers.getMapper(MpAccountConvert.class); - - MpAccountDO convert(MpAccountCreateReqVO bean); - - MpAccountDO convert(MpAccountUpdateReqVO bean); - - MpAccountRespVO convert(MpAccountDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/material/MpMaterialConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/material/MpMaterialConvert.java deleted file mode 100644 index ca4f69c3d..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/material/MpMaterialConvert.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.material; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadRespVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import me.chanjar.weixin.mp.bean.material.WxMpMaterial; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.io.File; - -@Mapper -public interface MpMaterialConvert { - - MpMaterialConvert INSTANCE = Mappers.getMapper(MpMaterialConvert.class); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "account.id", target = "accountId"), - @Mapping(source = "account.appId", target = "appId"), - @Mapping(source = "name", target = "name") - }) - MpMaterialDO convert(String mediaId, String type, String url, MpAccountDO account, - String name); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "account.id", target = "accountId"), - @Mapping(source = "account.appId", target = "appId"), - @Mapping(source = "name", target = "name") - }) - MpMaterialDO convert(String mediaId, String type, String url, MpAccountDO account, - String name, String title, String introduction, String mpUrl); - - MpMaterialUploadRespVO convert(MpMaterialDO bean); - - default WxMpMaterial convert(String name, File file, String title, String introduction) { - return new WxMpMaterial(name, file, title, introduction); - } - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java deleted file mode 100644 index a5ae32a44..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/menu/MpMenuConvert.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.menu; - -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuSaveReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import me.chanjar.weixin.common.bean.menu.WxMenuButton; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpMenuConvert { - - MpMenuConvert INSTANCE = Mappers.getMapper(MpMenuConvert.class); - - MpMenuRespVO convert(MpMenuDO bean); - - List convertList(List list); - - @Mappings({ - @Mapping(source = "menu.appId", target = "appId"), - @Mapping(source = "menu.replyMessageType", target = "type"), - @Mapping(source = "menu.replyContent", target = "content"), - @Mapping(source = "menu.replyMediaId", target = "mediaId"), - @Mapping(source = "menu.replyThumbMediaId", target = "thumbMediaId"), - @Mapping(source = "menu.replyTitle", target = "title"), - @Mapping(source = "menu.replyDescription", target = "description"), - @Mapping(source = "menu.replyArticles", target = "articles"), - @Mapping(source = "menu.replyMusicUrl", target = "musicUrl"), - @Mapping(source = "menu.replyHqMusicUrl", target = "hqMusicUrl"), - }) - MpMessageSendOutReqBO convert(String openid, MpMenuDO menu); - - List convert(List list); - - @Mappings({ - @Mapping(source = "menuKey", target = "key"), - @Mapping(source = "children", target = "subButtons"), - @Mapping(source = "miniProgramAppId", target = "appId"), - @Mapping(source = "miniProgramPagePath", target = "pagePath"), - }) - WxMenuButton convert(MpMenuSaveReqVO.Menu bean); - - MpMenuDO convert02(MpMenuSaveReqVO.Menu menu); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpAutoReplyConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpAutoReplyConvert.java deleted file mode 100644 index c7cf8902e..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpAutoReplyConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface MpAutoReplyConvert { - - MpAutoReplyConvert INSTANCE = Mappers.getMapper(MpAutoReplyConvert.class); - - @Mappings({ - @Mapping(source = "reply.appId", target = "appId"), - @Mapping(source = "reply.responseMessageType", target = "type"), - @Mapping(source = "reply.responseContent", target = "content"), - @Mapping(source = "reply.responseMediaId", target = "mediaId"), - @Mapping(source = "reply.responseTitle", target = "title"), - @Mapping(source = "reply.responseDescription", target = "description"), - @Mapping(source = "reply.responseArticles", target = "articles"), - }) - MpMessageSendOutReqBO convert(String openid, MpAutoReplyDO reply); - - PageResult convertPage(PageResult page); - - MpAutoReplyRespVO convert(MpAutoReplyDO bean); - - MpAutoReplyDO convert(MpAutoReplyCreateReqVO bean); - - MpAutoReplyDO convert(MpAutoReplyUpdateReqVO bean); -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpMessageConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpMessageConvert.java deleted file mode 100644 index 8f31a683a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/message/MpMessageConvert.java +++ /dev/null @@ -1,172 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageSendReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage; -import me.chanjar.weixin.mp.builder.outxml.BaseBuilder; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpMessageConvert { - - MpMessageConvert INSTANCE = Mappers.getMapper(MpMessageConvert.class); - - MpMessageRespVO convert(MpMessageDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default MpMessageDO convert(WxMpXmlMessage wxMessage, MpAccountDO account, MpUserDO user) { - MpMessageDO message = convert(wxMessage); - if (account != null) { - message.setAccountId(account.getId()).setAppId(account.getAppId()); - } - if (user != null) { - message.setUserId(user.getId()).setOpenid(user.getOpenid()); - } - return message; - } - @Mappings(value = { - @Mapping(source = "msgType", target = "type"), - @Mapping(target = "createTime", ignore = true), - }) - MpMessageDO convert(WxMpXmlMessage bean); - - default MpMessageDO convert(MpMessageSendOutReqBO sendReqBO, MpAccountDO account, MpUserDO user) { - // 构建消息 - MpMessageDO message = new MpMessageDO(); - message.setType(sendReqBO.getType()); - switch (sendReqBO.getType()) { - case WxConsts.XmlMsgType.TEXT: // 1. 文本 - message.setContent(sendReqBO.getContent()); - break; - case WxConsts.XmlMsgType.IMAGE: // 2. 图片 - case WxConsts.XmlMsgType.VOICE: // 3. 语音 - message.setMediaId(sendReqBO.getMediaId()); - break; - case WxConsts.XmlMsgType.VIDEO: // 4. 视频 - message.setMediaId(sendReqBO.getMediaId()) - .setTitle(sendReqBO.getTitle()).setDescription(sendReqBO.getDescription()); - break; - case WxConsts.XmlMsgType.NEWS: // 5. 图文 - message.setArticles(sendReqBO.getArticles()); - case WxConsts.XmlMsgType.MUSIC: // 6. 音乐 - message.setTitle(sendReqBO.getTitle()).setDescription(sendReqBO.getDescription()) - .setMusicUrl(sendReqBO.getMusicUrl()).setHqMusicUrl(sendReqBO.getHqMusicUrl()) - .setThumbMediaId(sendReqBO.getThumbMediaId()); - break; - default: - throw new IllegalArgumentException("不支持的消息类型:" + message.getType()); - } - - // 其它字段 - if (account != null) { - message.setAccountId(account.getId()).setAppId(account.getAppId()); - } - if (user != null) { - message.setUserId(user.getId()).setOpenid(user.getOpenid()); - } - return message; - } - - default WxMpXmlOutMessage convert02(MpMessageDO message, MpAccountDO account) { - BaseBuilder builder; - // 个性化字段 - switch (message.getType()) { - case WxConsts.XmlMsgType.TEXT: - builder = WxMpXmlOutMessage.TEXT().content(message.getContent()); - break; - case WxConsts.XmlMsgType.IMAGE: - builder = WxMpXmlOutMessage.IMAGE().mediaId(message.getMediaId()); - break; - case WxConsts.XmlMsgType.VOICE: - builder = WxMpXmlOutMessage.VOICE().mediaId(message.getMediaId()); - break; - case WxConsts.XmlMsgType.VIDEO: - builder = WxMpXmlOutMessage.VIDEO().mediaId(message.getMediaId()) - .title(message.getTitle()).description(message.getDescription()); - break; - case WxConsts.XmlMsgType.NEWS: - builder = WxMpXmlOutMessage.NEWS().articles(convertList02(message.getArticles())); - break; - case WxConsts.XmlMsgType.MUSIC: - builder = WxMpXmlOutMessage.MUSIC().title(message.getTitle()).description(message.getDescription()) - .musicUrl(message.getMusicUrl()).hqMusicUrl(message.getHqMusicUrl()) - .thumbMediaId(message.getThumbMediaId()); - break; - default: - throw new IllegalArgumentException("不支持的消息类型:" + message.getType()); - } - // 通用字段 - builder.fromUser(account.getAccount()); - builder.toUser(message.getOpenid()); - return builder.build(); - } - List convertList02(List list); - - default WxMpKefuMessage convert(MpMessageSendReqVO sendReqVO, MpUserDO user) { - me.chanjar.weixin.mp.builder.kefu.BaseBuilder builder; - // 个性化字段 - switch (sendReqVO.getType()) { - case WxConsts.KefuMsgType.TEXT: - builder = WxMpKefuMessage.TEXT().content(sendReqVO.getContent()); - break; - case WxConsts.KefuMsgType.IMAGE: - builder = WxMpKefuMessage.IMAGE().mediaId(sendReqVO.getMediaId()); - break; - case WxConsts.KefuMsgType.VOICE: - builder = WxMpKefuMessage.VOICE().mediaId(sendReqVO.getMediaId()); - break; - case WxConsts.KefuMsgType.VIDEO: - builder = WxMpKefuMessage.VIDEO().mediaId(sendReqVO.getMediaId()) - .title(sendReqVO.getTitle()).description(sendReqVO.getDescription()); - break; - case WxConsts.KefuMsgType.NEWS: - builder = WxMpKefuMessage.NEWS().articles(convertList03(sendReqVO.getArticles())); - break; - case WxConsts.KefuMsgType.MUSIC: - builder = WxMpKefuMessage.MUSIC().title(sendReqVO.getTitle()).description(sendReqVO.getDescription()) - .thumbMediaId(sendReqVO.getThumbMediaId()) - .musicUrl(sendReqVO.getMusicUrl()).hqMusicUrl(sendReqVO.getHqMusicUrl()); - break; - default: - throw new IllegalArgumentException("不支持的消息类型:" + sendReqVO.getType()); - } - // 通用字段 - builder.toUser(user.getOpenid()); - return builder.build(); - } - List convertList03(List list); - - default MpMessageDO convert(WxMpKefuMessage wxMessage, MpAccountDO account, MpUserDO user) { - MpMessageDO message = convert(wxMessage); - if (account != null) { - message.setAccountId(account.getId()).setAppId(account.getAppId()); - } - if (user != null) { - message.setUserId(user.getId()).setOpenid(user.getOpenid()); - } - return message; - } - @Mappings(value = { - @Mapping(source = "msgType", target = "type"), - @Mapping(target = "createTime", ignore = true), - }) - MpMessageDO convert(WxMpKefuMessage bean); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java deleted file mode 100644 index 9d4d7e3de..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.statistics; - -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsInterfaceSummaryRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUpstreamMessageRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserCumulateRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserSummaryRespVO; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; - -@Mapper -public interface MpStatisticsConvert { - - MpStatisticsConvert INSTANCE = Mappers.getMapper(MpStatisticsConvert.class); - - List convertList01(List list); - - List convertList02(List list); - - List convertList03(List list); - - @Mappings({ - @Mapping(target = "refDate", expression = "java(dateFormat0(bean.getRefDate()))"), - @Mapping(source = "msgUser", target = "messageUser"), - @Mapping(source = "msgCount", target = "messageCount"), - }) - MpStatisticsUpstreamMessageRespVO convert(WxDataCubeMsgResult bean); - - List convertList04(List list); - - @Mapping(target = "refDate", expression = "java(dateFormat0(bean.getRefDate()))") - MpStatisticsInterfaceSummaryRespVO convert(WxDataCubeInterfaceResult bean); - - @Named("dateFormat0") - default LocalDateTime dateFormat0(String date) { - return LocalDate.parse(date, DateTimeFormatter.ofPattern(FORMAT_YEAR_MONTH_DAY)).atStartOfDay(); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/tag/MpTagConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/tag/MpTagConvert.java deleted file mode 100644 index 727ccd314..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/tag/MpTagConvert.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagSimpleRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import me.chanjar.weixin.mp.bean.tag.WxUserTag; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpTagConvert { - - MpTagConvert INSTANCE = Mappers.getMapper(MpTagConvert.class); - - WxUserTag convert(MpTagUpdateReqVO bean); - - MpTagRespVO convert(WxUserTag bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - @Mappings({ - @Mapping(target = "id", ignore = true), - @Mapping(source = "tag.id", target = "tagId"), - @Mapping(source = "tag.name", target = "name"), - @Mapping(source = "tag.count", target = "count"), - @Mapping(source = "account.id", target = "accountId"), - @Mapping(source = "account.appId", target = "appId"), - }) - MpTagDO convert(WxUserTag tag, MpAccountDO account); - - MpTagRespVO convert(MpTagDO mpTagDO); - - List convertList02(List list); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/user/MpUserConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/user/MpUserConvert.java deleted file mode 100644 index 13ed0b34a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/user/MpUserConvert.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.mp.convert.user; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import me.chanjar.weixin.mp.bean.result.WxMpUser; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface MpUserConvert { - - MpUserConvert INSTANCE = Mappers.getMapper(MpUserConvert.class); - - MpUserRespVO convert(MpUserDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - @Mappings(value = { - @Mapping(source = "openId", target = "openid"), - @Mapping(source = "unionId", target = "unionId"), - @Mapping(source = "headImgUrl", target = "headImageUrl"), - @Mapping(target = "subscribeTime", ignore = true), // 单独转换 - }) - MpUserDO convert(WxMpUser wxMpUser); - - default MpUserDO convert(MpAccountDO account, WxMpUser wxMpUser) { - MpUserDO user = convert(wxMpUser); - user.setSubscribeStatus(wxMpUser.getSubscribe() ? CommonStatusEnum.ENABLE.getStatus() - : CommonStatusEnum.DISABLE.getStatus()); - user.setSubscribeTime(LocalDateTimeUtil.of(wxMpUser.getSubscribeTime() * 1000L)); - if (account != null) { - user.setAccountId(account.getId()); - user.setAppId(account.getAppId()); - } - return user; - } - - default List convertList(MpAccountDO account, List wxUsers) { - return CollectionUtils.convertList(wxUsers, wxUser -> convert(account, wxUser)); - } - - MpUserDO convert(MpUserUpdateReqVO bean); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/account/MpAccountDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/account/MpAccountDO.java deleted file mode 100644 index eddf87ba0..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/account/MpAccountDO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.account; - -import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 公众号账号 DO - * - * @author 芋道源码 - */ -@TableName("mp_account") -@KeySequence("mp_account_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MpAccountDO extends TenantBaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 公众号名称 - */ - private String name; - /** - * 公众号账号 - */ - private String account; - /** - * 公众号 appid - */ - private String appId; - /** - * 公众号密钥 - */ - private String appSecret; - /** - * 公众号token - */ - private String token; - /** - * 消息加解密密钥 - */ - private String aesKey; - /** - * 二维码图片 URL - */ - private String qrCodeUrl; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/material/MpMaterialDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/material/MpMaterialDO.java deleted file mode 100644 index 735235e31..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/material/MpMaterialDO.java +++ /dev/null @@ -1,99 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.material; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; -import me.chanjar.weixin.common.api.WxConsts; - -/** - * 公众号素材 DO - * - * 1. 临时素材 - * 2. 永久素材 - * - * @author 芋道源码 - */ -@TableName("mp_material") -@KeySequence("mp_material_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MpMaterialDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - - /** - * 公众号素材 id - */ - private String mediaId; - /** - * 文件类型 - * - * 枚举 {@link WxConsts.MediaFileType} - */ - private String type; - /** - * 是否永久 - * - * true - 永久素材 - * false - 临时素材 - */ - private Boolean permanent; - /** - * 文件服务器的 URL - */ - private String url; - - /** - * 名字 - * - * 永久素材:非空 - * 临时素材:可能为空。 - * 1. 为空的情况:粉丝主动发送的图片、语音等 - * 2. 非空的情况:主动发送给粉丝的图片、语音等 - */ - private String name; - - /** - * 公众号文件 URL - * - * 只有【永久素材】使用 - */ - private String mpUrl; - - /** - * 视频素材的标题 - * - * 只有【永久素材】使用 - */ - private String title; - /** - * 视频素材的描述 - * - * 只有【永久素材】使用 - */ - private String introduction; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java deleted file mode 100644 index 2e6aa73ce..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java +++ /dev/null @@ -1,184 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.menu; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.api.WxConsts.MenuButtonType; - -import java.util.List; - -/** - * 公众号菜单 DO - * - * @author 芋道源码 - */ -@TableName(value = "mp_menu", autoResultMap = true) -@KeySequence("mp_menu_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMenuDO extends BaseDO { - - /** - * 编号 - 顶级菜单 - */ - public static final Long ID_ROOT = 0L; - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - - /** - * 菜单名称 - */ - private String name; - /** - * 菜单标识 - * - * 支持多 DB 类型时,无法直接使用 key + @TableField("menuKey") 来实现转换,原因是 "menuKey" AS key 而存在报错 - */ - private String menuKey; - /** - * 父菜单编号 - */ - private Long parentId; - - // ========== 按钮操作 ========== - - /** - * 按钮类型 - * - * 枚举 {@link MenuButtonType} - */ - private String type; - - /** - * 网页链接 - * - * 粉丝点击菜单可打开链接,不超过 1024 字节 - * - * 类型为 {@link WxConsts.XmlMsgType} 的 VIEW、MINIPROGRAM - */ - private String url; - - /** - * 小程序的 appId - * - * 类型为 {@link MenuButtonType} 的 MINIPROGRAM - */ - private String miniProgramAppId; - /** - * 小程序的页面路径 - * - * 类型为 {@link MenuButtonType} 的 MINIPROGRAM - */ - private String miniProgramPagePath; - - /** - * 跳转图文的媒体编号 - */ - private String articleId; - - // ========== 消息内容 ========== - - /** - * 消息类型 - * - * 当 {@link #type} 为 CLICK、SCANCODE_WAITMSG - * - * 枚举 {@link WxConsts.XmlMsgType} 中的 TEXT、IMAGE、VOICE、VIDEO、NEWS、MUSIC - */ - private String replyMessageType; - - /** - * 回复的消息内容 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 TEXT - */ - private String replyContent; - - /** - * 回复的媒体 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - private String replyMediaId; - /** - * 回复的媒体 URL - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - private String replyMediaUrl; - - /** - * 回复的标题 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - private String replyTitle; - /** - * 回复的描述 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - private String replyDescription; - - /** - * 回复的缩略图的媒体 id,通过素材管理中的接口上传多媒体文件,得到的 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String replyThumbMediaId; - /** - * 回复的缩略图的媒体 URL - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String replyThumbMediaUrl; - - /** - * 回复的图文消息数组 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @TableField(typeHandler = MpMessageDO.ArticleTypeHandler.class) - private List replyArticles; - - /** - * 回复的音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String replyMusicUrl; - /** - * 回复的高质量音乐链接 - * - * WIFI 环境优先使用该链接播放音乐 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String replyHqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java deleted file mode 100644 index 52f4539a4..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java +++ /dev/null @@ -1,164 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.message; - -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyMatchEnum; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.api.WxConsts.XmlMsgType; - -import java.util.List; -import java.util.Set; - -/** - * 公众号消息自动回复 DO - * - * @author 芋道源码 - */ -@TableName(value = "mp_auto_reply", autoResultMap = true) -@KeySequence("mp_auto_reply_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpAutoReplyDO extends BaseDO { - - public static Set REQUEST_MESSAGE_TYPE = SetUtils.asSet(WxConsts.XmlMsgType.TEXT, WxConsts.XmlMsgType.IMAGE, - WxConsts.XmlMsgType.VOICE, WxConsts.XmlMsgType.VIDEO, WxConsts.XmlMsgType.SHORTVIDEO, - WxConsts.XmlMsgType.LOCATION, WxConsts.XmlMsgType.LINK); - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - - /** - * 回复类型 - * - * 枚举 {@link MpAutoReplyTypeEnum} - */ - private Integer type; - - // ==================== 请求消息 ==================== - - /** - * 请求的关键字 - * - * 当 {@link #type} 为 {@link MpAutoReplyTypeEnum#KEYWORD} - */ - private String requestKeyword; - /** - * 请求的关键字的匹配 - * - * 当 {@link #type} 为 {@link MpAutoReplyTypeEnum#KEYWORD} - * - * 枚举 {@link MpAutoReplyMatchEnum} - */ - private Integer requestMatch; - - /** - * 请求的消息类型 - * - * 当 {@link #type} 为 {@link MpAutoReplyTypeEnum#MESSAGE} - * - * 枚举 {@link XmlMsgType} 中的 {@link #REQUEST_MESSAGE_TYPE} - */ - private String requestMessageType; - - // ==================== 响应消息 ==================== - - /** - * 回复的消息类型 - * - * 枚举 {@link XmlMsgType} 中的 TEXT、IMAGE、VOICE、VIDEO、NEWS - */ - private String responseMessageType; - - /** - * 回复的消息内容 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 TEXT - */ - private String responseContent; - - /** - * 回复的媒体 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - private String responseMediaId; - /** - * 回复的媒体 URL - */ - private String responseMediaUrl; - - /** - * 回复的标题 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - private String responseTitle; - /** - * 回复的描述 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - private String responseDescription; - - /** - * 回复的缩略图的媒体 id,通过素材管理中的接口上传多媒体文件,得到的 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String responseThumbMediaId; - /** - * 回复的缩略图的媒体 URL - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String responseThumbMediaUrl; - - /** - * 回复的图文消息 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @TableField(typeHandler = MpMessageDO.ArticleTypeHandler.class) - private List responseArticles; - - /** - * 回复的音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String responseMusicUrl; - /** - * 回复的高质量音乐链接 - * - * WIFI 环境优先使用该链接播放音乐 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String responseHqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpMessageDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpMessageDO.java deleted file mode 100644 index cb1401091..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpMessageDO.java +++ /dev/null @@ -1,255 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.message; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.enums.message.MpMessageSendFromEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.*; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.builder.kefu.NewsBuilder; - -import javax.validation.constraints.NotEmpty; -import java.io.Serializable; -import java.util.List; - -/** - * 公众号消息 DO - * - * @author 芋道源码 - */ -@TableName(value = "mp_message", autoResultMap = true) -@KeySequence("mp_message_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MpMessageDO extends BaseDO { - - /** - * 主键 - */ - @TableId - private Long id; - /** - * 微信公众号消息 id - */ - private Long msgId; - /** - * 公众号账号的 ID - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appid - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - /** - * 公众号粉丝的编号 - * - * 关联 {@link MpUserDO#getId()} - */ - private Long userId; - /** - * 公众号粉丝标志 - * - * 冗余 {@link MpUserDO#getOpenid()} - */ - private String openid; - - /** - * 消息类型 - * - * 枚举 {@link WxConsts.XmlMsgType} - */ - private String type; - /** - * 消息来源 - * - * 枚举 {@link MpMessageSendFromEnum} - */ - private Integer sendFrom; - - // ========= 普通消息内容 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_standard_messages.html - - /** - * 消息内容 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 TEXT - */ - private String content; - - /** - * 媒体文件的编号 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - private String mediaId; - /** - * 媒体文件的 URL - */ - private String mediaUrl; - /** - * 语音识别后文本 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VOICE - */ - private String recognition; - /** - * 语音格式,如 amr,speex 等 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VOICE - */ - private String format; - /** - * 标题 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO、MUSIC、LINK - */ - private String title; - /** - * 描述 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO、MUSIC - */ - private String description; - - /** - * 缩略图的媒体 id,通过素材管理中的接口上传多媒体文件,得到的 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String thumbMediaId; - /** - * 缩略图的媒体 URL - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC、VIDEO - */ - private String thumbMediaUrl; - - /** - * 点击图文消息跳转链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LINK - */ - private String url; - - /** - * 地理位置维度 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LOCATION - */ - private Double locationX; - /** - * 地理位置经度 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LOCATION - */ - private Double locationY; - /** - * 地图缩放大小 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LOCATION - */ - private Double scale; - /** - * 详细地址 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 LOCATION - * - * 例如说杨浦区黄兴路 221-4 号临 - */ - private String label; - - /** - * 图文消息数组 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @TableField(typeHandler = ArticleTypeHandler.class) - private List
articles; - - /** - * 音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String musicUrl; - /** - * 高质量音乐链接 - * - * WIFI 环境优先使用该链接播放音乐 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - private String hqMusicUrl; - - // ========= 事件推送 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html - - /** - * 事件类型 - * - * 枚举 {@link WxConsts.EventType} - */ - private String event; - /** - * 事件 Key - * - * 1. {@link WxConsts.EventType} 的 SCAN:qrscene_ 为前缀,后面为二维码的参数值 - * 2. {@link WxConsts.EventType} 的 CLICK:与自定义菜单接口中 KEY 值对应 - */ - private String eventKey; - - /** - * 文章 - */ - @Data - public static class Article implements Serializable { - - /** - * 图文消息标题 - */ - @NotEmpty(message = "图文消息标题不能为空", groups = NewsBuilder.class) - private String title; - /** - * 图文消息描述 - */ - @NotEmpty(message = "图文消息描述不能为空", groups = NewsBuilder.class) - private String description; - /** - * 图片链接 - * - * 支持 JPG、PNG 格式,较好的效果为大图 360*200,小图 200*200 - */ - @NotEmpty(message = "图片链接不能为空", groups = NewsBuilder.class) - private String picUrl; - /** - * 点击图文消息跳转链接 - */ - @NotEmpty(message = "点击图文消息跳转链接不能为空", groups = NewsBuilder.class) - private String url; - - } - - // TODO @芋艿:可以找一些新的思路 - public static class ArticleTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List
parse(String json) { - return JsonUtils.parseArray(json, Article.class); - } - - @Override - protected String toJson(List
obj) { - return JsonUtils.toJsonString(obj); - } - - } -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/tag/MpTagDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/tag/MpTagDO.java deleted file mode 100644 index 8a5b9f6eb..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/tag/MpTagDO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.tag; - -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import lombok.*; - -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import me.chanjar.weixin.mp.bean.tag.WxUserTag; - -/** - * 公众号标签 DO - * - * @author 芋道源码 - */ -@TableName("mp_tag") -@KeySequence("mp_tag_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MpTagDO extends BaseDO { - - /** - * 主键 - */ - @TableId(type = IdType.INPUT) - private Long id; - /** - * 公众号标签 id - */ - private Long tagId; - /** - * 标签名 - */ - private String name; - /** - * 此标签下粉丝数 - * - * 冗余:{@link WxUserTag#getCount()} 字段,需要管理员点击【同步】后,更新该字段 - */ - private Integer count; - - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/user/MpUserDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/user/MpUserDO.java deleted file mode 100644 index 0eb6a19bc..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/user/MpUserDO.java +++ /dev/null @@ -1,119 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.dataobject.user; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 微信公众号粉丝 DO - * - * @author 芋道源码 - */ -@TableName(value = "mp_user", autoResultMap = true) -@KeySequence("mp_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MpUserDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 粉丝标识 - */ - private String openid; - - /** - * 微信生态唯一标识 - */ - private String unionid; - /** - * 微信生态唯一标识 - */ - private String unionId; - /** - * 关注状态 - * - * 枚举 {@link CommonStatusEnum} - * 1. 开启 - 已关注 - * 2. 禁用 - 取消关注 - */ - private Integer subscribeStatus; - /** - * 关注时间 - */ - private LocalDateTime subscribeTime; - /** - * 取消关注时间 - */ - private LocalDateTime unsubscribeTime; - /** - * 昵称 - * - * 注意,2021-12-27 公众号接口不再返回头像和昵称,只能通过微信公众号的网页登录获取 - */ - private String nickname; - /** - * 头像地址 - * - * 注意,2021-12-27 公众号接口不再返回头像和昵称,只能通过微信公众号的网页登录获取 - */ - private String headImageUrl; - /** - * 语言 - */ - private String language; - /** - * 国家 - */ - private String country; - /** - * 省份 - */ - private String province; - /** - * 城市 - */ - private String city; - /** - * 备注 - */ - private String remark; - /** - * 标签编号数组 - * - * 注意,对应的是 {@link MpTagDO#getTagId()} 字段 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List tagIds; - - /** - * 公众号账号的编号 - * - * 关联 {@link MpAccountDO#getId()} - */ - private Long accountId; - /** - * 公众号 appId - * - * 冗余 {@link MpAccountDO#getAppId()} - */ - private String appId; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/account/MpAccountMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/account/MpAccountMapper.java deleted file mode 100644 index 30c54fd51..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/account/MpAccountMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.account; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Select; - -import java.time.LocalDateTime; - -@Mapper -public interface MpAccountMapper extends BaseMapperX { - - default PageResult selectPage(MpAccountPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(MpAccountDO::getName, reqVO.getName()) - .likeIfPresent(MpAccountDO::getAccount, reqVO.getAccount()) - .likeIfPresent(MpAccountDO::getAppId, reqVO.getAppId()) - .orderByDesc(MpAccountDO::getId)); - } - - default MpAccountDO selectByAppId(String appId) { - return selectOne(MpAccountDO::getAppId, appId); - } - - @Select("SELECT COUNT(*) FROM mp_account WHERE update_time > #{maxUpdateTime}") - Long selectCountByUpdateTimeGt(LocalDateTime maxUpdateTime); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/material/MpMaterialMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/material/MpMaterialMapper.java deleted file mode 100644 index ca3c6b3a9..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/material/MpMaterialMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.material; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface MpMaterialMapper extends BaseMapperX { - - default MpMaterialDO selectByAccountIdAndMediaId(Long accountId, String mediaId) { - return selectOne(MpMaterialDO::getAccountId, accountId, - MpMaterialDO::getMediaId, mediaId); - } - - default PageResult selectPage(MpMaterialPageReqVO pageReqVO) { - return selectPage(pageReqVO, new LambdaQueryWrapperX() - .eq(MpMaterialDO::getAccountId, pageReqVO.getAccountId()) - .eqIfPresent(MpMaterialDO::getPermanent, pageReqVO.getPermanent()) - .eqIfPresent(MpMaterialDO::getType, pageReqVO.getType()) - .orderByDesc(MpMaterialDO::getId)); - } - - default List selectListByMediaId(Collection mediaIds) { - return selectList(MpMaterialDO::getMediaId, mediaIds); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/menu/MpMenuMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/menu/MpMenuMapper.java deleted file mode 100644 index fccd7f2d9..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/menu/MpMenuMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.menu; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MpMenuMapper extends BaseMapperX { - - default MpMenuDO selectByAppIdAndMenuKey(String appId, String menuKey) { - return selectOne(MpMenuDO::getAppId, appId, - MpMenuDO::getMenuKey, menuKey); - } - - default List selectListByAccountId(Long accountId) { - return selectList(MpMenuDO::getAccountId, accountId); - } - - default void deleteByAccountId(Long accountId) { - delete(new LambdaQueryWrapperX().eq(MpMenuDO::getAccountId, accountId)); - } -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpAutoReplyMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpAutoReplyMapper.java deleted file mode 100644 index c8260e8c7..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpAutoReplyMapper.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyMatchEnum; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyTypeEnum; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MpAutoReplyMapper extends BaseMapperX { - - default PageResult selectPage(MpMessagePageReqVO pageVO) { - return selectPage(pageVO, new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAccountId, pageVO.getAccountId()) - .eqIfPresent(MpAutoReplyDO::getType, pageVO.getType())); - } - - default List selectListByAppIdAndKeywordAll(String appId, String requestKeyword) { - return selectList(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAppId, appId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.KEYWORD.getType()) - .eq(MpAutoReplyDO::getRequestMatch, MpAutoReplyMatchEnum.ALL.getMatch()) - .eq(MpAutoReplyDO::getRequestKeyword, requestKeyword)); - } - - default List selectListByAppIdAndKeywordLike(String appId, String requestKeyword) { - return selectList(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAppId, appId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.KEYWORD.getType()) - .eq(MpAutoReplyDO::getRequestMatch, MpAutoReplyMatchEnum.LIKE.getMatch()) - .like(MpAutoReplyDO::getRequestKeyword, requestKeyword)); - } - - default List selectListByAppIdAndMessage(String appId, String requestMessageType) { - return selectList(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAppId, appId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.MESSAGE.getType()) - .eq(MpAutoReplyDO::getRequestMessageType, requestMessageType)); - } - - default List selectListByAppIdAndSubscribe(String appId) { - return selectList(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAppId, appId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.SUBSCRIBE.getType())); - } - - default MpAutoReplyDO selectByAccountIdAndSubscribe(Long accountId) { - return selectOne(MpAutoReplyDO::getAccountId, accountId, - MpAutoReplyDO::getType, MpAutoReplyTypeEnum.SUBSCRIBE.getType()); - } - - default MpAutoReplyDO selectByAccountIdAndMessage(Long accountId, String requestMessageType) { - return selectOne(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAccountId, accountId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.MESSAGE.getType()) - .eq(MpAutoReplyDO::getRequestMessageType, requestMessageType)); - } - - default MpAutoReplyDO selectByAccountIdAndKeyword(Long accountId, String requestKeyword) { - return selectOne(new LambdaQueryWrapperX() - .eq(MpAutoReplyDO::getAccountId, accountId) - .eq(MpAutoReplyDO::getType, MpAutoReplyTypeEnum.KEYWORD.getType()) - .eq(MpAutoReplyDO::getRequestKeyword, requestKeyword)); - } -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpMessageMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpMessageMapper.java deleted file mode 100644 index 72ba56627..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/message/MpMessageMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface MpMessageMapper extends BaseMapperX { - - default PageResult selectPage(MpMessagePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MpMessageDO::getAccountId, reqVO.getAccountId()) - .eqIfPresent(MpMessageDO::getType, reqVO.getType()) - .eqIfPresent(MpMessageDO::getOpenid, reqVO.getOpenid()) - .betweenIfPresent(MpMessageDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(MpMessageDO::getId)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/tag/MpTagMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/tag/MpTagMapper.java deleted file mode 100644 index 760f53aa1..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/tag/MpTagMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MpTagMapper extends BaseMapperX { - - default PageResult selectPage(MpTagPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MpTagDO::getAccountId, reqVO.getAccountId()) - .likeIfPresent(MpTagDO::getName, reqVO.getName()) - .orderByDesc(MpTagDO::getId)); - } - - default List selectListByAccountId(Long accountId) { - return selectList(MpTagDO::getAccountId, accountId); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/user/MpUserMapper.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/user/MpUserMapper.java deleted file mode 100644 index bd13f925a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/mysql/user/MpUserMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.mp.dal.mysql.user; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface MpUserMapper extends BaseMapperX { - - default PageResult selectPage(MpUserPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(MpUserDO::getOpenid, reqVO.getOpenid()) - .likeIfPresent(MpUserDO::getNickname, reqVO.getNickname()) - .eqIfPresent(MpUserDO::getAccountId, reqVO.getAccountId()) - .orderByDesc(MpUserDO::getId)); - } - - default MpUserDO selectByAppIdAndOpenid(String appId, String openid) { - return selectOne(MpUserDO::getAppId, appId, - MpUserDO::getOpenid, openid); - } - - default List selectListByAppIdAndOpenid(String appId, List openids) { - return selectList(new LambdaQueryWrapperX() - .eq(MpUserDO::getAppId, appId) - .in(MpUserDO::getOpenid, openids)); - - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/config/MpConfiguration.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/config/MpConfiguration.java deleted file mode 100644 index c90866066..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/config/MpConfiguration.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.mp.config; - -import cn.iocoder.yudao.module.mp.framework.mp.core.DefaultMpServiceFactory; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.handler.menu.MenuHandler; -import cn.iocoder.yudao.module.mp.service.handler.message.MessageReceiveHandler; -import cn.iocoder.yudao.module.mp.service.handler.message.MessageAutoReplyHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.KfSessionHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.NullHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.ScanHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.StoreCheckNotifyHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.LocationHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.SubscribeHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.UnsubscribeHandler; -import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties; -import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.core.StringRedisTemplate; - -/** - * 微信公众号的配置类 - * - * @author 芋道源码 - */ -@Configuration -public class MpConfiguration { - - @Bean - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") - public RedisTemplateWxRedisOps redisTemplateWxRedisOps(StringRedisTemplate stringRedisTemplate) { - return new RedisTemplateWxRedisOps(stringRedisTemplate); - } - - @Bean - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") - public MpServiceFactory mpServiceFactory(RedisTemplateWxRedisOps redisTemplateWxRedisOps, - WxMpProperties wxMpProperties, - MessageReceiveHandler messageReceiveHandler, - KfSessionHandler kfSessionHandler, - StoreCheckNotifyHandler storeCheckNotifyHandler, - MenuHandler menuHandler, - NullHandler nullHandler, - SubscribeHandler subscribeHandler, - UnsubscribeHandler unsubscribeHandler, - LocationHandler locationHandler, - ScanHandler scanHandler, - MessageAutoReplyHandler messageAutoReplyHandler) { - return new DefaultMpServiceFactory(redisTemplateWxRedisOps, wxMpProperties, - messageReceiveHandler, kfSessionHandler, storeCheckNotifyHandler, menuHandler, - nullHandler, subscribeHandler, unsubscribeHandler, locationHandler, scanHandler, messageAutoReplyHandler); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/DefaultMpServiceFactory.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/DefaultMpServiceFactory.java deleted file mode 100644 index 414f73aa8..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/DefaultMpServiceFactory.java +++ /dev/null @@ -1,177 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.mp.core; - -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.service.handler.menu.MenuHandler; -import cn.iocoder.yudao.module.mp.service.handler.message.MessageReceiveHandler; -import cn.iocoder.yudao.module.mp.service.handler.message.MessageAutoReplyHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.KfSessionHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.NullHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.ScanHandler; -import cn.iocoder.yudao.module.mp.service.handler.other.StoreCheckNotifyHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.LocationHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.SubscribeHandler; -import cn.iocoder.yudao.module.mp.service.handler.user.UnsubscribeHandler; -import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties; -import com.google.common.collect.Maps; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps; -import me.chanjar.weixin.mp.api.WxMpMessageRouter; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; -import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl; -import me.chanjar.weixin.mp.constant.WxMpEventConstants; - -import java.util.List; -import java.util.Map; - -/** - * 默认的 {@link MpServiceFactory} 实现类 - * - * @author 芋道源码 - */ -@Slf4j -@RequiredArgsConstructor -public class DefaultMpServiceFactory implements MpServiceFactory { - - /** - * 微信 appId 与 WxMpService 的映射 - */ - private volatile Map appId2MpServices; - /** - * 公众号账号 id 与 WxMpService 的映射 - */ - private volatile Map id2MpServices; - /** - * 微信 appId 与 WxMpMessageRouter 的映射 - */ - private volatile Map mpMessageRouters; - - private final RedisTemplateWxRedisOps redisTemplateWxRedisOps; - private final WxMpProperties mpProperties; - - // ========== 各种 Handler ========== - - private final MessageReceiveHandler messageReceiveHandler; - private final KfSessionHandler kfSessionHandler; - private final StoreCheckNotifyHandler storeCheckNotifyHandler; - private final MenuHandler menuHandler; - private final NullHandler nullHandler; - private final SubscribeHandler subscribeHandler; - private final UnsubscribeHandler unsubscribeHandler; - private final LocationHandler locationHandler; - private final ScanHandler scanHandler; - private final MessageAutoReplyHandler messageAutoReplyHandler; - - @Override - public void init(List list) { - Map appId2MpServices = Maps.newHashMap(); - Map id2MpServices = Maps.newHashMap(); - Map mpMessageRouters = Maps.newHashMap(); - // 处理 list - list.forEach(account -> { - // 构建 WxMpService 对象 - WxMpService mpService = buildMpService(account); - appId2MpServices.put(account.getAppId(), mpService); - id2MpServices.put(account.getId(), mpService); - // 构建 WxMpMessageRouter 对象 - WxMpMessageRouter mpMessageRouter = buildMpMessageRouter(mpService); - mpMessageRouters.put(account.getAppId(), mpMessageRouter); - }); - - // 设置到缓存 - this.appId2MpServices = appId2MpServices; - this.id2MpServices = id2MpServices; - this.mpMessageRouters = mpMessageRouters; - } - - @Override - public WxMpService getMpService(Long id) { - return id2MpServices.get(id); - } - - @Override - public WxMpService getMpService(String appId) { - return appId2MpServices.get(appId); - } - - @Override - public WxMpMessageRouter getMpMessageRouter(String appId) { - return mpMessageRouters.get(appId); - } - - private WxMpService buildMpService(MpAccountDO account) { - // 第一步,创建 WxMpRedisConfigImpl 对象 - WxMpRedisConfigImpl configStorage = new WxMpRedisConfigImpl( - redisTemplateWxRedisOps, mpProperties.getConfigStorage().getKeyPrefix()); - configStorage.setAppId(account.getAppId()); - configStorage.setSecret(account.getAppSecret()); - configStorage.setToken(account.getToken()); - configStorage.setAesKey(account.getAesKey()); - - // 第二步,创建 WxMpService 对象 - WxMpService service = new WxMpServiceImpl(); - service.setWxMpConfigStorage(configStorage); - return service; - } - - private WxMpMessageRouter buildMpMessageRouter(WxMpService mpService) { - WxMpMessageRouter router = new WxMpMessageRouter(mpService); - // 记录所有事件的日志(异步执行) - router.rule().handler(messageReceiveHandler).next(); - - // 接收客服会话管理事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxMpEventConstants.CustomerService.KF_CREATE_SESSION) - .handler(kfSessionHandler).end(); - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxMpEventConstants.CustomerService.KF_CLOSE_SESSION) - .handler(kfSessionHandler) - .end(); - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxMpEventConstants.CustomerService.KF_SWITCH_SESSION) - .handler(kfSessionHandler).end(); - - // 门店审核事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxMpEventConstants.POI_CHECK_NOTIFY) - .handler(storeCheckNotifyHandler).end(); - - // 自定义菜单事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.MenuButtonType.CLICK).handler(menuHandler).end(); - - // 点击菜单连接事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.MenuButtonType.VIEW).handler(nullHandler).end(); - - // 关注事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.EventType.SUBSCRIBE).handler(subscribeHandler) - .end(); - - // 取消关注事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.EventType.UNSUBSCRIBE) - .handler(unsubscribeHandler).end(); - - // 上报地理位置事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.EventType.LOCATION).handler(locationHandler) - .end(); - - // 接收地理位置消息 - router.rule().async(false).msgType(WxConsts.XmlMsgType.LOCATION) - .handler(locationHandler).end(); - - // 扫码事件 - router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) - .event(WxConsts.EventType.SCAN).handler(scanHandler).end(); - - // 默认 - router.rule().async(false).handler(messageAutoReplyHandler).end(); - return router; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/MpServiceFactory.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/MpServiceFactory.java deleted file mode 100644 index ce017ff64..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/MpServiceFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.mp.core; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import me.chanjar.weixin.mp.api.WxMpMessageRouter; -import me.chanjar.weixin.mp.api.WxMpService; - -import java.util.List; - -/** - * {@link WxMpService} 工厂接口 - * - * @author 芋道源码 - */ -public interface MpServiceFactory { - - /** - * 基于微信公众号的账号,初始化对应的 WxMpService 与 WxMpMessageRouter 实例 - * - * @param list 公众号的账号列表 - */ - void init(List list); - - /** - * 获得 id 对应的 WxMpService 实例 - * - * @param id 微信公众号的编号 - * @return WxMpService 实例 - */ - WxMpService getMpService(Long id); - - default WxMpService getRequiredMpService(Long id) { - WxMpService wxMpService = getMpService(id); - Assert.notNull(wxMpService, "找到对应 id({}) 的 WxMpService,请核实!", id); - return wxMpService; - } - - /** - * 获得 appId 对应的 WxMpService 实例 - * - * @param appId 微信公众号 appId - * @return WxMpService 实例 - */ - WxMpService getMpService(String appId); - - default WxMpService getRequiredMpService(String appId) { - WxMpService wxMpService = getMpService(appId); - Assert.notNull(wxMpService, "找到对应 appId({}) 的 WxMpService,请核实!", appId); - return wxMpService; - } - - /** - * 获得 appId 对应的 WxMpMessageRouter 实例 - * - * @param appId 微信公众号 appId - * @return WxMpMessageRouter 实例 - */ - WxMpMessageRouter getMpMessageRouter(String appId); - - default WxMpMessageRouter getRequiredMpMessageRouter(String appId) { - WxMpMessageRouter wxMpMessageRouter = getMpMessageRouter(appId); - Assert.notNull(wxMpMessageRouter, "找到对应 appId({}) 的 WxMpMessageRouter,请核实!", appId); - return wxMpMessageRouter; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/context/MpContextHolder.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/context/MpContextHolder.java deleted file mode 100644 index e5c45c531..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/context/MpContextHolder.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package cn.iocoder.yudao.module.mp.framework.mp.core.context; - -import cn.iocoder.yudao.module.mp.controller.admin.open.vo.MpOpenHandleMessageReqVO; -import com.alibaba.ttl.TransmittableThreadLocal; -import lombok.experimental.UtilityClass; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; - -/** - * 微信上下文 Context - * - * 目的:解决微信多公众号的问题,在 {@link WxMpMessageHandler} 实现类中,可以通过 {@link #getAppId()} 获取到当前的 appId - * - * @see cn.iocoder.yudao.module.mp.controller.admin.open.MpOpenController#handleMessage(String, String, MpOpenHandleMessageReqVO) - * - * @author 芋道源码 - */ -public class MpContextHolder { - - /** - * 微信公众号的 appId 上下文 - */ - private static final ThreadLocal APPID = new TransmittableThreadLocal<>(); - - public static void setAppId(String appId) { - APPID.set(appId); - } - - public static String getAppId() { - return APPID.get(); - } - - public static void clear() { - APPID.remove(); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/util/MpUtils.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/util/MpUtils.java deleted file mode 100644 index 880d8c8f5..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/mp/core/util/MpUtils.java +++ /dev/null @@ -1,167 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.mp.core.util; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.api.WxConsts; - -import javax.validation.Validator; - -/** - * 公众号工具类 - * - * @author 芋道源码 - */ -@Slf4j -public class MpUtils { - - /** - * 校验消息的格式是否符合要求 - * - * @param type 类型 - * @param message 消息 - */ - public static void validateMessage(Validator validator, String type, Object message) { - // 获得对应的校验 group - Class group; - switch (type) { - case WxConsts.XmlMsgType.TEXT: - group = TextMessageGroup.class; - break; - case WxConsts.XmlMsgType.IMAGE: - group = ImageMessageGroup.class; - break; - case WxConsts.XmlMsgType.VOICE: - group = VoiceMessageGroup.class; - break; - case WxConsts.XmlMsgType.VIDEO: - group = VideoMessageGroup.class; - break; - case WxConsts.XmlMsgType.NEWS: - group = NewsMessageGroup.class; - break; - case WxConsts.XmlMsgType.MUSIC: - group = MusicMessageGroup.class; - break; - default: - log.error("[validateMessage][未知的消息类型({})]", message); - throw new IllegalArgumentException("不支持的消息类型:" + type); - } - // 执行校验 - ValidationUtils.validate(validator, message, group); - } - - public static void validateButton(Validator validator, String type, String messageType, Object button) { - if (StrUtil.isBlank(type)) { - return; - } - // 获得对应的校验 group - Class group; - switch (type) { - case WxConsts.MenuButtonType.CLICK: - group = ClickButtonGroup.class; - validateMessage(validator, messageType, button); // 需要额外校验回复的消息格式 - break; - case WxConsts.MenuButtonType.VIEW: - group = ViewButtonGroup.class; - break; - case WxConsts.MenuButtonType.MINIPROGRAM: - group = MiniProgramButtonGroup.class; - break; - case WxConsts.MenuButtonType.SCANCODE_WAITMSG: - group = ScanCodeWaitMsgButtonGroup.class; - validateMessage(validator, messageType, button); // 需要额外校验回复的消息格式 - break; - case "article_" + WxConsts.MenuButtonType.VIEW_LIMITED: - group = ViewLimitedButtonGroup.class; - break; - case WxConsts.MenuButtonType.SCANCODE_PUSH: // 不用校验,直接 return 即可 - case WxConsts.MenuButtonType.PIC_SYSPHOTO: - case WxConsts.MenuButtonType.PIC_PHOTO_OR_ALBUM: - case WxConsts.MenuButtonType.PIC_WEIXIN: - case WxConsts.MenuButtonType.LOCATION_SELECT: - return; - default: - log.error("[validateButton][未知的按钮({})]", button); - throw new IllegalArgumentException("不支持的按钮类型:" + type); - } - // 执行校验 - ValidationUtils.validate(validator, button, group); - } - - /** - * 根据消息类型,获得对应的媒体文件类型 - * - * 注意,不会返回 WxConsts.MediaFileType.THUMB,因为该类型会有明确标注 - * - * @param messageType 消息类型 {@link WxConsts.XmlMsgType} - * @return 媒体文件类型 {@link WxConsts.MediaFileType} - */ - public static String getMediaFileType(String messageType) { - switch (messageType) { - case WxConsts.XmlMsgType.IMAGE: - return WxConsts.MediaFileType.IMAGE; - case WxConsts.XmlMsgType.VOICE: - return WxConsts.MediaFileType.VOICE; - case WxConsts.XmlMsgType.VIDEO: - return WxConsts.MediaFileType.VIDEO; - default: - return WxConsts.MediaFileType.FILE; - } - } - - /** - * Text 类型的消息,参数校验 Group - */ - public interface TextMessageGroup {} - - /** - * Image 类型的消息,参数校验 Group - */ - public interface ImageMessageGroup {} - - /** - * Voice 类型的消息,参数校验 Group - */ - public interface VoiceMessageGroup {} - - /** - * Video 类型的消息,参数校验 Group - */ - public interface VideoMessageGroup {} - - /** - * News 类型的消息,参数校验 Group - */ - public interface NewsMessageGroup {} - - /** - * Music 类型的消息,参数校验 Group - */ - public interface MusicMessageGroup {} - - /** - * Click 类型的按钮,参数校验 Group - */ - public interface ClickButtonGroup {} - - /** - * View 类型的按钮,参数校验 Group - */ - public interface ViewButtonGroup {} - - /** - * MiniProgram 类型的按钮,参数校验 Group - */ - public interface MiniProgramButtonGroup {} - - /** - * SCANCODE_WAITMSG 类型的按钮,参数校验 Group - */ - public interface ScanCodeWaitMsgButtonGroup {} - - /** - * VIEW_LIMITED 类型的按钮,参数校验 Group - */ - public interface ViewLimitedButtonGroup {} -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/package-info.java deleted file mode 100644 index 112ecdd26..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 mp 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.mp.framework; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/rpc/config/RpcConfiguration.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index d4e85a278..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.rpc.config; - -import cn.iocoder.yudao.module.infra.api.file.FileApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = FileApi.class) -public class RpcConfiguration { -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/rpc/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/rpc/package-info.java deleted file mode 100644 index 147223f74..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.mp.framework.rpc; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/security/config/SecurityConfiguration.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 016c2ffd5..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.mp.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.system.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * System 模块的 Security 配置 - */ -@Configuration(proxyBeanMethods = false, value = "systemSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("systemAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // TODO 芋艿:这个每个项目都需要重复配置,得捉摸有没通用的方案 - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/security/core/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/security/core/package-info.java deleted file mode 100644 index dad146082..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.mp.framework.security.core; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/package-info.java deleted file mode 100644 index 598718088..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * mp 模块,我们放微信微信公众号。 - * 例如说:提供微信公众号的账号、菜单、粉丝、标签、消息、自动回复、素材、模板通知、运营数据等功能 - * - * 1. Controller URL:以 /mp/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 mp_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.mp; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountService.java deleted file mode 100644 index e122c6a98..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountService.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.account; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; - -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.ACCOUNT_NOT_EXISTS; - -/** - * 公众号账号 Service 接口 - * - * @author 芋道源码 - */ -public interface MpAccountService { - - /** - * 初始化缓存 - */ - void initLocalCache(); - - /** - * 创建公众号账号 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createAccount(@Valid MpAccountCreateReqVO createReqVO); - - /** - * 更新公众号账号 - * - * @param updateReqVO 更新信息 - */ - void updateAccount(@Valid MpAccountUpdateReqVO updateReqVO); - - /** - * 删除公众号账号 - * - * @param id 编号 - */ - void deleteAccount(Long id); - - /** - * 获得公众号账号 - * - * @param id 编号 - * @return 公众号账号 - */ - MpAccountDO getAccount(Long id); - - /** - * 获得公众号账号。若不存在,则抛出业务异常 - * - * @param id 编号 - * @return 公众号账号 - */ - default MpAccountDO getRequiredAccount(Long id) { - MpAccountDO account = getAccount(id); - if (account == null) { - throw exception(ACCOUNT_NOT_EXISTS); - } - return account; - } - - /** - * 从缓存中,获得公众号账号 - * - * @param appId 微信公众号 appId - * @return 公众号账号 - */ - MpAccountDO getAccountFromCache(String appId); - - /** - * 获得公众号账号分页 - * - * @param pageReqVO 分页查询 - * @return 公众号账号分页 - */ - PageResult getAccountPage(MpAccountPageReqVO pageReqVO); - - /** - * 获得公众号账号列表 - * - * @return 公众号账号列表 - */ - List getAccountList(); - - /** - * 生成公众号账号的二维码 - * - * @param id 编号 - */ - void generateAccountQrCode(Long id); - - /** - * 清空公众号账号的 API 配额 - * - * 参考文档:接口调用频次限制说明 - * - * @param id 编号 - */ - void clearAccountQuota(Long id); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java deleted file mode 100644 index a8f9b78d1..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java +++ /dev/null @@ -1,229 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.account; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO; -import cn.iocoder.yudao.module.mp.convert.account.MpAccountConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.mysql.account.MpAccountMapper; -import cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import com.google.common.annotations.VisibleForTesting; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket; -import org.springframework.context.annotation.Lazy; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.PostConstruct; -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMaxValue; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_USERNAME_EXISTS; - -/** - * 公众号账号 Service 实现类 - * - * @author fengdan - */ -@Slf4j -@Service -@Validated -public class MpAccountServiceImpl implements MpAccountService { - - /** - * 账号缓存 - * key:账号编号 {@link MpAccountDO#getAppId()} - * - * 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向 - */ - @Getter - private volatile Map accountCache; - - @Resource - private MpAccountMapper mpAccountMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Override - @PostConstruct - public void initLocalCache() { - // 注意:忽略自动多租户,因为要全局初始化缓存 - TenantUtils.executeIgnore(() -> { - // 第一步:查询数据 - List accounts = Collections.emptyList(); - try { - accounts = mpAccountMapper.selectList(); - } catch (Throwable ex) { - if (!ex.getMessage().contains("doesn't exist")) { - throw ex; - } - log.error("[微信公众号 yudao-module-mp - 表结构未导入][参考 https://doc.iocoder.cn/mp/build/ 开启]"); - } - log.info("[initLocalCacheIfUpdate][缓存公众号账号,数量为:{}]", accounts.size()); - - // 第二步:构建缓存。创建或更新支付 Client - mpServiceFactory.init(accounts); - accountCache = convertMap(accounts, MpAccountDO::getAppId); - }); - } - - /** - * 通过定时任务轮询,刷新缓存 - * - * 目的:多节点部署时,通过轮询”通知“所有节点,进行刷新 - */ - @Scheduled(initialDelay = 60, fixedRate = 60, timeUnit = TimeUnit.SECONDS) - public void refreshLocalCache() { - // 注意:忽略自动多租户,因为要全局初始化缓存 - TenantUtils.executeIgnore(() -> { - // 情况一:如果缓存里没有数据,则直接刷新缓存 - if (CollUtil.isEmpty(accountCache)) { - initLocalCache(); - return; - } - - // 情况二,如果缓存里数据,则通过 updateTime 判断是否有数据变更,有变更则刷新缓存 - LocalDateTime maxTime = getMaxValue(accountCache.values(), MpAccountDO::getUpdateTime); - if (mpAccountMapper.selectCountByUpdateTimeGt(maxTime) > 0) { - initLocalCache(); - } - }); - } - - @Override - public Long createAccount(MpAccountCreateReqVO createReqVO) { - // 校验 appId 唯一 - validateAppIdUnique(null, createReqVO.getAppId()); - - // 插入 - MpAccountDO account = MpAccountConvert.INSTANCE.convert(createReqVO); - mpAccountMapper.insert(account); - - // 刷新缓存 - initLocalCache(); - return account.getId(); - } - - @Override - public void updateAccount(MpAccountUpdateReqVO updateReqVO) { - // 校验存在 - validateAccountExists(updateReqVO.getId()); - // 校验 appId 唯一 - validateAppIdUnique(updateReqVO.getId(), updateReqVO.getAppId()); - - // 更新 - MpAccountDO updateObj = MpAccountConvert.INSTANCE.convert(updateReqVO); - mpAccountMapper.updateById(updateObj); - - // 刷新缓存 - initLocalCache(); - } - - @Override - public void deleteAccount(Long id) { - // 校验存在 - validateAccountExists(id); - // 删除 - mpAccountMapper.deleteById(id); - - // 刷新缓存 - initLocalCache(); - } - - private MpAccountDO validateAccountExists(Long id) { - MpAccountDO account = mpAccountMapper.selectById(id); - if (account == null) { - throw ServiceExceptionUtil.exception(ErrorCodeConstants.ACCOUNT_NOT_EXISTS); - } - return account; - } - - @VisibleForTesting - public void validateAppIdUnique(Long id, String appId) { - // 多个租户,appId 是不能重复,否则公众号回调会无法识别 - TenantUtils.executeIgnore(() -> { - MpAccountDO account = mpAccountMapper.selectByAppId(appId); - if (account == null) { - return; - } - // 存在 account 记录的情况下 - if (id == null // 新增时,说明重复 - || ObjUtil.notEqual(id, account.getId())) { // 更新时,如果 id 不一致,说明重复 - throw exception(USER_USERNAME_EXISTS); - } - }); - } - - @Override - public MpAccountDO getAccount(Long id) { - return mpAccountMapper.selectById(id); - } - - @Override - public MpAccountDO getAccountFromCache(String appId) { - return accountCache.get(appId); - } - - @Override - public PageResult getAccountPage(MpAccountPageReqVO pageReqVO) { - return mpAccountMapper.selectPage(pageReqVO); - } - - @Override - public List getAccountList() { - return mpAccountMapper.selectList(); - } - - @Override - public void generateAccountQrCode(Long id) { - // 校验存在 - MpAccountDO account = validateAccountExists(id); - - // 生成二维码 - WxMpService mpService = mpServiceFactory.getRequiredMpService(account.getAppId()); - String qrCodeUrl; - try { - WxMpQrCodeTicket qrCodeTicket = mpService.getQrcodeService().qrCodeCreateLastTicket("default"); - qrCodeUrl = mpService.getQrcodeService().qrCodePictureUrl(qrCodeTicket.getTicket()); - } catch (WxErrorException e) { - throw exception(ErrorCodeConstants.ACCOUNT_GENERATE_QR_CODE_FAIL, e.getError().getErrorMsg()); - } - - // 保存二维码 - mpAccountMapper.updateById(new MpAccountDO().setId(id).setQrCodeUrl(qrCodeUrl)); - } - - @Override - public void clearAccountQuota(Long id) { - // 校验存在 - MpAccountDO account = validateAccountExists(id); - - // 生成二维码 - WxMpService mpService = mpServiceFactory.getRequiredMpService(account.getAppId()); - try { - mpService.clearQuota(account.getAppId()); - } catch (WxErrorException e) { - throw exception(ErrorCodeConstants.ACCOUNT_CLEAR_QUOTA_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/menu/MenuHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/menu/MenuHandler.java deleted file mode 100644 index 039712514..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/menu/MenuHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.menu; - -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.menu.MpMenuService; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMenuService; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -import static me.chanjar.weixin.common.api.WxConsts.MenuButtonType; - -/** - * 自定义菜单的事件处理器 - * - * 逻辑:粉丝点击菜单时,触发对应的回复 - * - * @author 芋道源码 - */ -@Component -public class MenuHandler implements WxMpMessageHandler { - - @Resource - private MpMenuService mpMenuService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService weixinService, WxSessionManager sessionManager) { - return mpMenuService.reply(MpContextHolder.getAppId(), wxMessage.getEventKey(), wxMessage.getFromUser()); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageAutoReplyHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageAutoReplyHandler.java deleted file mode 100644 index 30d94a97c..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageAutoReplyHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.message; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -/** - * 自动回复消息的事件处理器 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class MessageAutoReplyHandler implements WxMpMessageHandler { - - @Resource - private MpAutoReplyService mpAutoReplyService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService weixinService, WxSessionManager sessionManager) { - // 只处理指定类型的消息 - if (!MpAutoReplyDO.REQUEST_MESSAGE_TYPE.contains(wxMessage.getMsgType())) { - return null; - } - - // 自动回复 - return mpAutoReplyService.replyForMessage(MpContextHolder.getAppId(), wxMessage); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageReceiveHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageReceiveHandler.java deleted file mode 100644 index 4e4a4ebf4..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/message/MessageReceiveHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.message; - -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.message.MpMessageService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -/** - * 保存微信消息的事件处理器 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class MessageReceiveHandler implements WxMpMessageHandler { - - @Resource - private MpMessageService mpMessageService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - log.info("[handle][接收到请求消息,内容:{}]", wxMessage); - mpMessageService.receiveMessage(MpContextHolder.getAppId(), wxMessage); - return null; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/KfSessionHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/KfSessionHandler.java deleted file mode 100644 index fca7fab9a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/KfSessionHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.other; - -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 接收客服会话管理的事件处理器 - * - * @author 芋道源码 - */ -@Component -public class KfSessionHandler implements WxMpMessageHandler { - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - throw new UnsupportedOperationException("未实现该处理,请自行重写"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/NullHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/NullHandler.java deleted file mode 100644 index 09b3efbf2..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/NullHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.other; - -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 点击菜单连接的事件处理器 - */ -@Component -public class NullHandler implements WxMpMessageHandler { - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - throw new UnsupportedOperationException("未实现该处理,请自行重写"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/ScanHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/ScanHandler.java deleted file mode 100644 index 54a6bbc32..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/ScanHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.other; - -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 扫码的事件处理器 - */ -@Component -public class ScanHandler implements WxMpMessageHandler { - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map context, - WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException { - throw new UnsupportedOperationException("未实现该处理,请自行重写"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/StoreCheckNotifyHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/StoreCheckNotifyHandler.java deleted file mode 100644 index 475b8ee97..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/StoreCheckNotifyHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.other; - -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 门店审核事件的事件处理器 - */ -@Component -public class StoreCheckNotifyHandler implements WxMpMessageHandler { - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - throw new UnsupportedOperationException("未实现该处理,请自行重写"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/package-info.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/package-info.java deleted file mode 100644 index 7fd662260..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/other/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 本包内的 handler 都是一些不重要的,所以放在 other 其它里 - */ -package cn.iocoder.yudao.module.mp.service.handler.other; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/LocationHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/LocationHandler.java deleted file mode 100644 index 598ebb91a..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/LocationHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.user; - -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -/** - * 上报地理位置的事件处理器 - * - * 触发操作:打开微信公众号 -> 点击 + 号 -> 选择「语音」 - * - * 逻辑:粉丝上传地理位置时,也可以触发自动回复 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class LocationHandler implements WxMpMessageHandler { - - @Resource - private MpAutoReplyService mpAutoReplyService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService wxMpService, WxSessionManager sessionManager) { - // 防御性编程:必须是 LOCATION 消息 - if (ObjectUtil.notEqual(wxMessage.getMsgType(), WxConsts.XmlMsgType.LOCATION)) { - return null; - } - log.info("[handle][上报地理位置,纬度({})、经度({})、精度({})", wxMessage.getLatitude(), - wxMessage.getLongitude(), wxMessage.getPrecision()); - - // 自动回复 - return mpAutoReplyService.replyForMessage(MpContextHolder.getAppId(), wxMessage); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/SubscribeHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/SubscribeHandler.java deleted file mode 100644 index 5f3c3eacd..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/SubscribeHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.user; - -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService; -import cn.iocoder.yudao.module.mp.service.user.MpUserService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import me.chanjar.weixin.mp.bean.result.WxMpUser; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -/** - * 关注的事件处理器 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class SubscribeHandler implements WxMpMessageHandler { - - @Resource - private MpUserService mpUserService; - @Resource - private MpAutoReplyService mpAutoReplyService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, - WxMpService weixinService, WxSessionManager sessionManager) throws WxErrorException { - // 第一步,从公众号平台,获取粉丝信息 - log.info("[handle][粉丝({}) 关注]", wxMessage.getFromUser()); - WxMpUser wxMpUser = null; - try { - wxMpUser = weixinService.getUserService().userInfo(wxMessage.getFromUser()); - } catch (WxErrorException e) { - log.error("[handle][粉丝({})] 获取粉丝信息失败!", wxMessage.getFromUser(), e); - } - - // 第二步,保存粉丝信息 - mpUserService.saveUser(MpContextHolder.getAppId(), wxMpUser); - - // 第三步,回复关注的欢迎语 - return mpAutoReplyService.replyForSubscribe(MpContextHolder.getAppId(), wxMessage); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/UnsubscribeHandler.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/UnsubscribeHandler.java deleted file mode 100644 index 3bf363506..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/handler/user/UnsubscribeHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.handler.user; - -import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder; -import cn.iocoder.yudao.module.mp.service.user.MpUserService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.session.WxSessionManager; -import me.chanjar.weixin.mp.api.WxMpMessageHandler; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Map; - -/** - * 取消关注的事件处理器 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class UnsubscribeHandler implements WxMpMessageHandler { - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpUserService mpUserService; - - @Override - public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, - Map context, WxMpService wxMpService, - WxSessionManager sessionManager) { - log.info("[handle][粉丝({}) 取消关注]", wxMessage.getFromUser()); - mpUserService.updateUserUnsubscribe(MpContextHolder.getAppId(), wxMessage.getFromUser()); - return null; - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialService.java deleted file mode 100644 index 60e4c07b4..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialService.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.material; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadNewsImageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadPermanentReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadTemporaryReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import me.chanjar.weixin.common.api.WxConsts; - -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collection; -import java.util.List; - -/** - * 公众号素材 Service 接口 - * - * @author 芋道源码 - */ -public interface MpMaterialService { - - /** - * 获得素材的 URL - * - * 该 URL 来自我们自己的文件服务器存储的 URL,不是公众号存储的 URL - * - * @param accountId 公众号账号编号 - * @param mediaId 公众号素材 id - * @param type 文件类型 {@link WxConsts.MediaFileType} - * @return 素材的 URL - */ - String downloadMaterialUrl(Long accountId, String mediaId, String type); - - /** - * 上传临时素材 - * - * @param reqVO 请求 - * @return 素材 - * @throws IOException 文件操作发生异常 - */ - MpMaterialDO uploadTemporaryMaterial(@Valid MpMaterialUploadTemporaryReqVO reqVO) throws IOException; - - /** - * 上传永久素材 - * - * @param reqVO 请求 - * @return 素材 - * @throws IOException 文件操作发生异常 - */ - MpMaterialDO uploadPermanentMaterial(@Valid MpMaterialUploadPermanentReqVO reqVO) throws IOException; - - /** - * 上传图文内容中的图片 - * - * @param reqVO 上传请求 - * @return 图片地址 - */ - String uploadNewsImage(MpMaterialUploadNewsImageReqVO reqVO) throws IOException; - - /** - * 获得素材分页 - * - * @param pageReqVO 分页请求 - * @return 素材分页 - */ - PageResult getMaterialPage(MpMaterialPageReqVO pageReqVO); - - /** - * 获得素材列表 - * - * @param mediaIds 素材 mediaId 列表 - * @return 素材列表 - */ - List getMaterialListByMediaId(Collection mediaIds); - - /** - * 删除素材 - * - * @param id 编号 - */ - void deleteMaterial(Long id); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialServiceImpl.java deleted file mode 100644 index 9e48a8f97..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/material/MpMaterialServiceImpl.java +++ /dev/null @@ -1,224 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.material; - -import cn.hutool.core.io.FileTypeUtil; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.infra.api.file.FileApi; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadNewsImageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadPermanentReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.material.vo.MpMaterialUploadTemporaryReqVO; -import cn.iocoder.yudao.module.mp.convert.material.MpMaterialConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.material.MpMaterialDO; -import cn.iocoder.yudao.module.mp.dal.mysql.material.MpMaterialMapper; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 公众号素材 Service 接口 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class MpMaterialServiceImpl implements MpMaterialService { - - @Resource - private MpMaterialMapper mpMaterialMapper; - - @Resource - private FileApi fileApi; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpAccountService mpAccountService; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Override - public String downloadMaterialUrl(Long accountId, String mediaId, String type) { - // 第一步,直接从数据库查询。如果已经下载,直接返回 - MpMaterialDO material = mpMaterialMapper.selectByAccountIdAndMediaId(accountId, mediaId); - if (material != null) { - return material.getUrl(); - } - - // 第二步,尝试从临时素材中下载 - String url = downloadMedia(accountId, mediaId); - if (url == null) { - return null; - } - MpAccountDO account = mpAccountService.getRequiredAccount(accountId); - material = MpMaterialConvert.INSTANCE.convert(mediaId, type, url, account, null) - .setPermanent(false); - mpMaterialMapper.insert(material); - - // 不考虑下载永久素材,因为上传的时候已经保存 - return url; - } - - @Override - public MpMaterialDO uploadTemporaryMaterial(MpMaterialUploadTemporaryReqVO reqVO) throws IOException { - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - // 第一步,上传到公众号 - File file = null; - WxMediaUploadResult result; - String mediaId; - String url; - try { - // 写入到临时文件 - file = FileUtil.newFile(FileUtil.getTmpDirPath() + reqVO.getFile().getOriginalFilename()); - reqVO.getFile().transferTo(file); - // 上传到公众号 - result = mpService.getMaterialService().mediaUpload(reqVO.getType(), file); - // 上传到文件服务 - mediaId = ObjUtil.defaultIfNull(result.getMediaId(), result.getThumbMediaId()); - url = uploadFile(mediaId, file); - } catch (WxErrorException e) { - throw exception(MATERIAL_UPLOAD_FAIL, e.getError().getErrorMsg()); - } finally { - FileUtil.del(file); - } - - // 第二步,存储到数据库 - MpAccountDO account = mpAccountService.getRequiredAccount(reqVO.getAccountId()); - MpMaterialDO material = MpMaterialConvert.INSTANCE.convert(mediaId, reqVO.getType(), url, account, - reqVO.getFile().getName()).setPermanent(false); - mpMaterialMapper.insert(material); - return material; - } - - @Override - public MpMaterialDO uploadPermanentMaterial(MpMaterialUploadPermanentReqVO reqVO) throws IOException { - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - // 第一步,上传到公众号 - String name = StrUtil.blankToDefault(reqVO.getName(), reqVO.getFile().getName()); - File file = null; - WxMpMaterialUploadResult result; - String mediaId; - String url; - try { - // 写入到临时文件 - file = FileUtil.newFile(FileUtil.getTmpDirPath() + reqVO.getFile().getOriginalFilename()); - reqVO.getFile().transferTo(file); - // 上传到公众号 - result = mpService.getMaterialService().materialFileUpload(reqVO.getType(), - MpMaterialConvert.INSTANCE.convert(name, file, reqVO.getTitle(), reqVO.getIntroduction())); - // 上传到文件服务 - mediaId = ObjUtil.defaultIfNull(result.getMediaId(), result.getMediaId()); - url = uploadFile(mediaId, file); - } catch (WxErrorException e) { - throw exception(MATERIAL_UPLOAD_FAIL, e.getError().getErrorMsg()); - } finally { - FileUtil.del(file); - } - - // 第二步,存储到数据库 - MpAccountDO account = mpAccountService.getRequiredAccount(reqVO.getAccountId()); - MpMaterialDO material = MpMaterialConvert.INSTANCE.convert(mediaId, reqVO.getType(), url, account, - name, reqVO.getTitle(), reqVO.getIntroduction(), result.getUrl()).setPermanent(true); - mpMaterialMapper.insert(material); - return material; - } - - @Override - public String uploadNewsImage(MpMaterialUploadNewsImageReqVO reqVO) throws IOException { - WxMpService mpService = mpServiceFactory.getRequiredMpService(reqVO.getAccountId()); - File file = null; - try { - // 写入到临时文件 - file = FileUtil.newFile(FileUtil.getTmpDirPath() + reqVO.getFile().getOriginalFilename()); - reqVO.getFile().transferTo(file); - // 上传到公众号 - return mpService.getMaterialService().mediaImgUpload(file).getUrl(); - } catch (WxErrorException e) { - throw exception(MATERIAL_IMAGE_UPLOAD_FAIL, e.getError().getErrorMsg()); - } finally { - FileUtil.del(file); - } - } - - @Override - public PageResult getMaterialPage(MpMaterialPageReqVO pageReqVO) { - return mpMaterialMapper.selectPage(pageReqVO); - } - - @Override - public List getMaterialListByMediaId(Collection mediaIds) { - return mpMaterialMapper.selectListByMediaId(mediaIds); - } - - @Override - public void deleteMaterial(Long id) { - MpMaterialDO material = mpMaterialMapper.selectById(id); - if (material == null) { - throw exception(MATERIAL_NOT_EXISTS); - } - - // 第一步,从公众号删除 - if (material.getPermanent()) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(material.getAppId()); - try { - mpService.getMaterialService().materialDelete(material.getMediaId()); - } catch (WxErrorException e) { - throw exception(MATERIAL_DELETE_FAIL, e.getError().getErrorMsg()); - } - } - - // 第二步,从数据库中删除 - mpMaterialMapper.deleteById(id); - } - - /** - * 下载微信媒体文件的内容,并上传到文件服务 - * - * 为什么要下载?媒体文件在微信后台保存时间为 3 天,即 3 天后 media_id 失效。 - * - * @param accountId 公众号账号的编号 - * @param mediaId 媒体文件编号 - * @return 上传后的 URL - */ - public String downloadMedia(Long accountId, String mediaId) { - WxMpService mpService = mpServiceFactory.getMpService(accountId); - for (int i = 0; i < 3; i++) { - try { - // 第一步,从公众号下载媒体文件 - File file = mpService.getMaterialService().mediaDownload(mediaId); - // 第二步,上传到文件服务 - return uploadFile(mediaId, file); - } catch (WxErrorException e) { - log.error("[mediaDownload][media({}) 第 ({}) 次下载失败]", mediaId, i); - } - } - return null; - } - - private String uploadFile(String mediaId, File file) { - String path = mediaId + "." + FileTypeUtil.getType(file); - return fileApi.createFile(path, FileUtil.readBytes(file)); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuService.java deleted file mode 100644 index 19f3b1458..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuService.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.menu; - -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuSaveReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; - -import javax.validation.Valid; -import java.util.List; - -/** - * 公众号菜单 Service 接口 - * - * @author 芋道源码 - */ -public interface MpMenuService { - - /** - * 保存公众号菜单 - * - * @param createReqVO 创建信息 - */ - void saveMenu(@Valid MpMenuSaveReqVO createReqVO); - - /** - * 删除公众号菜单 - * - * @param accountId 公众号账号的编号 - */ - void deleteMenuByAccountId(Long accountId); - - /** - * 粉丝点击菜单按钮时,回复对应的消息 - * - * @param appId 公众号 AppId - * @param key 菜单按钮的标识 - * @param openid 粉丝的 openid - * @return 消息 - */ - WxMpXmlOutMessage reply(String appId, String key, String openid); - - /** - * 获得公众号菜单列表 - * - * @param accountId 公众号账号的编号 - * @return 公众号菜单列表 - */ - List getMenuListByAccountId(Long accountId); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuServiceImpl.java deleted file mode 100644 index eb9ceba89..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/menu/MpMenuServiceImpl.java +++ /dev/null @@ -1,171 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.menu; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.mp.controller.admin.menu.vo.MpMenuSaveReqVO; -import cn.iocoder.yudao.module.mp.convert.menu.MpMenuConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.menu.MpMenuDO; -import cn.iocoder.yudao.module.mp.dal.mysql.menu.MpMenuMapper; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import cn.iocoder.yudao.module.mp.service.message.MpMessageService; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.bean.menu.WxMenu; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Validator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.MENU_DELETE_FAIL; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.MENU_SAVE_FAIL; - -/** - * 公众号菜单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class MpMenuServiceImpl implements MpMenuService { - - @Resource - private MpMessageService mpMessageService; - @Resource - @Lazy // 延迟加载,避免循环引用报错 - private MpAccountService mpAccountService; - - @Resource - @Lazy // 延迟加载,避免循环引用报错 - private MpServiceFactory mpServiceFactory; - - @Resource - private Validator validator; - - @Resource - private MpMenuMapper mpMenuMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public void saveMenu(MpMenuSaveReqVO createReqVO) { - MpAccountDO account = mpAccountService.getRequiredAccount(createReqVO.getAccountId()); - WxMpService mpService = mpServiceFactory.getRequiredMpService(createReqVO.getAccountId()); - - // 参数校验 - createReqVO.getMenus().forEach(this::validateMenu); - - // 第一步,同步公众号 - WxMenu wxMenu = new WxMenu(); - wxMenu.setButtons(MpMenuConvert.INSTANCE.convert(createReqVO.getMenus())); - try { - mpService.getMenuService().menuCreate(wxMenu); - } catch (WxErrorException e) { - throw exception(MENU_SAVE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,存储到数据库 - mpMenuMapper.deleteByAccountId(createReqVO.getAccountId()); - createReqVO.getMenus().forEach(menu -> { - // 先保存顶级菜单 - MpMenuDO menuDO = createMenu(menu, null, account); - // 再保存子菜单 - if (CollUtil.isEmpty(menu.getChildren())) { - return; - } - menu.getChildren().forEach(childMenu -> createMenu(childMenu, menuDO, account)); - }); - } - - /** - * 校验菜单的格式是否正确 - * - * @param menu 菜单 - */ - private void validateMenu(MpMenuSaveReqVO.Menu menu) { - MpUtils.validateButton(validator, menu.getType(), menu.getReplyMessageType(), menu); - // 子菜单 - if (CollUtil.isEmpty(menu.getChildren())) { - return; - } - menu.getChildren().forEach(this::validateMenu); - } - - /** - * 创建菜单,并存储到数据库 - * - * @param wxMenu 菜单信息 - * @param parentMenu 父菜单 - * @param account 公众号账号 - * @return 创建后的菜单 - */ - private MpMenuDO createMenu(MpMenuSaveReqVO.Menu wxMenu, MpMenuDO parentMenu, MpAccountDO account) { - // 创建菜单 - MpMenuDO menu = CollUtil.isNotEmpty(wxMenu.getChildren()) - ? new MpMenuDO().setName(wxMenu.getName()) - : MpMenuConvert.INSTANCE.convert02(wxMenu); - // 设置菜单的公众号账号信息 - if (account != null) { - menu.setAccountId(account.getId()).setAppId(account.getAppId()); - } - // 设置父编号 - if (parentMenu != null) { - menu.setParentId(parentMenu.getId()); - } else { - menu.setParentId(MpMenuDO.ID_ROOT); - } - - // 插入到数据库 - mpMenuMapper.insert(menu); - return menu; - } - - @Override - public void deleteMenuByAccountId(Long accountId) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - // 第一步,同步公众号 - try { - mpService.getMenuService().menuDelete(); - } catch (WxErrorException e) { - throw exception(MENU_DELETE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,存储到数据库 - mpMenuMapper.deleteByAccountId(accountId); - } - - @Override - public WxMpXmlOutMessage reply(String appId, String key, String openid) { - // 第一步,获得菜单 - MpMenuDO menu = mpMenuMapper.selectByAppIdAndMenuKey(appId, key); - if (menu == null) { - log.error("[reply][appId({}) key({}) 找不到对应的菜单]", appId, key); - return null; - } - // 按钮必须要有消息类型,不然后续无法回复消息 - if (StrUtil.isEmpty(menu.getReplyMessageType())) { - log.error("[reply][menu({}) 不存在对应的消息类型]", menu); - return null; - } - - // 第二步,回复消息 - MpMessageSendOutReqBO sendReqBO = MpMenuConvert.INSTANCE.convert(openid, menu); - return mpMessageService.sendOutMessage(sendReqBO); - } - - @Override - public List getMenuListByAccountId(Long accountId) { - return mpMenuMapper.selectListByAccountId(accountId); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyService.java deleted file mode 100644 index fc125d06d..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyService.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyUpdateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; - -/** - * 公众号的自动回复 Service 接口 - * - * @author 芋道源码 - */ -public interface MpAutoReplyService { - - /** - * 获得公众号自动回复分页 - * - * @param pageVO 分页请求 - * @return 自动回复分页结果 - */ - PageResult getAutoReplyPage(MpMessagePageReqVO pageVO); - - /** - * 获得公众号自动回复 - * - * @param id 编号 - * @return 自动回复 - */ - MpAutoReplyDO getAutoReply(Long id); - - - /** - * 创建公众号自动回复 - * - * @param createReqVO 创建请求 - * @return 自动回复的编号 - */ - Long createAutoReply(MpAutoReplyCreateReqVO createReqVO); - - /** - * 更新公众号自动回复 - * - * @param updateReqVO 更新请求 - */ - void updateAutoReply(MpAutoReplyUpdateReqVO updateReqVO); - - /** - * 删除公众号自动回复 - * - * @param id 自动回复的编号 - */ - void deleteAutoReply(Long id); - - /** - * 当收到消息时,自动回复 - * - * @param appId 微信公众号 appId - * @param wxMessage 消息 - * @return 回复的消息 - */ - WxMpXmlOutMessage replyForMessage(String appId, WxMpXmlMessage wxMessage); - - /** - * 当粉丝关注时,自动回复 - * - * @param appId 微信公众号 appId - * @param wxMessage 消息 - * @return 回复的消息 - */ - WxMpXmlOutMessage replyForSubscribe(String appId, WxMpXmlMessage wxMessage); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyServiceImpl.java deleted file mode 100644 index b90b82e96..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpAutoReplyServiceImpl.java +++ /dev/null @@ -1,202 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.exception.ErrorCode; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.autoreply.MpAutoReplyUpdateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.convert.message.MpAutoReplyConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpAutoReplyDO; -import cn.iocoder.yudao.module.mp.dal.mysql.message.MpAutoReplyMapper; -import cn.iocoder.yudao.module.mp.enums.message.MpAutoReplyTypeEnum; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Validator; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 公众号的自动回复 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class MpAutoReplyServiceImpl implements MpAutoReplyService { - - @Resource - private MpMessageService mpMessageService; - @Resource - @Lazy // 延迟加载,避免循环依赖 - private MpAccountService mpAccountService; - - @Resource - private Validator validator; - - @Resource - private MpAutoReplyMapper mpAutoReplyMapper; - - @Override - public PageResult getAutoReplyPage(MpMessagePageReqVO pageVO) { - return mpAutoReplyMapper.selectPage(pageVO); - } - - @Override - public MpAutoReplyDO getAutoReply(Long id) { - return mpAutoReplyMapper.selectById(id); - } - - @Override - public Long createAutoReply(MpAutoReplyCreateReqVO createReqVO) { - // 第一步,校验数据 - if (createReqVO.getResponseMessageType() != null) { - MpUtils.validateMessage(validator, createReqVO.getResponseMessageType(), createReqVO); - } - validateAutoReplyConflict(null, createReqVO.getAccountId(), createReqVO.getType(), - createReqVO.getRequestKeyword(), createReqVO.getRequestMessageType()); - - // 第二步,插入数据 - MpAccountDO account = mpAccountService.getRequiredAccount(createReqVO.getAccountId()); - MpAutoReplyDO autoReply = MpAutoReplyConvert.INSTANCE.convert(createReqVO) - .setAppId(account.getAppId()); - mpAutoReplyMapper.insert(autoReply); - return autoReply.getId(); - } - - @Override - public void updateAutoReply(MpAutoReplyUpdateReqVO updateReqVO) { - // 第一步,校验数据 - if (updateReqVO.getResponseMessageType() != null) { - MpUtils.validateMessage(validator, updateReqVO.getResponseMessageType(), updateReqVO); - } - MpAutoReplyDO autoReply = validateAutoReplyExists(updateReqVO.getId()); - validateAutoReplyConflict(updateReqVO.getId(), autoReply.getAccountId(), updateReqVO.getType(), - updateReqVO.getRequestKeyword(), updateReqVO.getRequestMessageType()); - - // 第二步,更新数据 - MpAutoReplyDO updateObj = MpAutoReplyConvert.INSTANCE.convert(updateReqVO) - .setAccountId(null).setAppId(null); // 避免前端传递,更新着两个字段 - mpAutoReplyMapper.updateById(updateObj); - } - - /** - * 校验自动回复是否冲突 - * - * 不同的 type,会有不同的逻辑: - * 1. type = SUBSCRIBE 时,不允许有其他的自动回复 - * 2. type = MESSAGE 时,校验 requestMessageType 已经存在自动回复 - * 3. type = KEYWORD 时,校验 keyword 已经存在自动回复 - * - * @param id 自动回复编号 - * @param accountId 公众号账号的编号 - * @param type 类型 - * @param requestKeyword 请求关键词 - * @param requestMessageType 请求消息类型 - */ - private void validateAutoReplyConflict(Long id, Long accountId, Integer type, - String requestKeyword, String requestMessageType) { - // 获得已经存在的自动回复 - MpAutoReplyDO autoReply = null; - ErrorCode errorCode = null; - if (MpAutoReplyTypeEnum.SUBSCRIBE.getType().equals(type)) { - autoReply = mpAutoReplyMapper.selectByAccountIdAndSubscribe(accountId); - errorCode = AUTO_REPLY_ADD_SUBSCRIBE_FAIL_EXISTS; - } else if (MpAutoReplyTypeEnum.MESSAGE.getType().equals(type)) { - autoReply = mpAutoReplyMapper.selectByAccountIdAndMessage(accountId, requestMessageType); - errorCode = AUTO_REPLY_ADD_MESSAGE_FAIL_EXISTS; - } else if (MpAutoReplyTypeEnum.KEYWORD.getType().equals(type)) { - autoReply = mpAutoReplyMapper.selectByAccountIdAndKeyword(accountId, requestKeyword); - errorCode = AUTO_REPLY_ADD_KEYWORD_FAIL_EXISTS; - } - if (autoReply == null) { - return; - } - - // 存在冲突,抛出业务异常 - if (id == null // 情况一,新增(id == null),存在记录,说明冲突 - || ObjUtil.notEqual(id, autoReply.getId())) { // 情况二,修改(id != null),id 不匹配,说明冲突 - throw exception(errorCode); - } - } - - @Override - public void deleteAutoReply(Long id) { - // 校验粉丝存在 - validateAutoReplyExists(id); - - // 删除自动回复 - mpAutoReplyMapper.deleteById(id); - } - - private MpAutoReplyDO validateAutoReplyExists(Long id) { - MpAutoReplyDO autoReply = mpAutoReplyMapper.selectById(id); - if (autoReply == null) { - throw exception(AUTO_REPLY_NOT_EXISTS); - } - return autoReply; - } - - @Override - public WxMpXmlOutMessage replyForMessage(String appId, WxMpXmlMessage wxMessage) { - // 第一步,匹配自动回复 - List replies = null; - // 1.1 关键字 - if (wxMessage.getMsgType().equals(WxConsts.XmlMsgType.TEXT)) { - // 完全匹配 - replies = mpAutoReplyMapper.selectListByAppIdAndKeywordAll(appId, wxMessage.getContent()); - if (CollUtil.isEmpty(replies)) { - // 模糊匹配 - replies = mpAutoReplyMapper.selectListByAppIdAndKeywordLike(appId, wxMessage.getContent()); - } - } - // 1.2 消息类型 - if (CollUtil.isEmpty(replies)) { - replies = mpAutoReplyMapper.selectListByAppIdAndMessage(appId, wxMessage.getMsgType()); - } - if (CollUtil.isEmpty(replies)) { - return null; - } - MpAutoReplyDO reply = CollUtil.getFirst(replies); - - // 第二步,基于自动回复,创建消息 - MpMessageSendOutReqBO sendReqBO = MpAutoReplyConvert.INSTANCE.convert(wxMessage.getFromUser(), reply); - return mpMessageService.sendOutMessage(sendReqBO); - } - - @Override - public WxMpXmlOutMessage replyForSubscribe(String appId, WxMpXmlMessage wxMessage) { - // 第一步,匹配自动回复 - List replies = mpAutoReplyMapper.selectListByAppIdAndSubscribe(appId); - MpAutoReplyDO reply = CollUtil.isNotEmpty(replies) ? CollUtil.getFirst(replies) - : buildDefaultSubscribeAutoReply(appId); // 如果不存在,提供一个默认末班 - - // 第二步,基于自动回复,创建消息 - MpMessageSendOutReqBO sendReqBO = MpAutoReplyConvert.INSTANCE.convert(wxMessage.getFromUser(), reply); - return mpMessageService.sendOutMessage(sendReqBO); - } - - private MpAutoReplyDO buildDefaultSubscribeAutoReply(String appId) { - MpAccountDO account = mpAccountService.getAccountFromCache(appId); - Assert.notNull(account, "公众号账号({}) 不存在", appId); - // 构建默认的【关注】自动回复 - return new MpAutoReplyDO().setAppId(appId).setAccountId(account.getId()) - .setType(MpAutoReplyTypeEnum.SUBSCRIBE.getType()) - .setResponseMessageType(WxConsts.XmlMsgType.TEXT).setResponseContent("感谢关注"); - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java deleted file mode 100644 index 01c691a34..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageService.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageSendReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; - -import javax.validation.Valid; - -/** - * 公众号消息 Service 接口 - * - * @author 芋道源码 - */ -public interface MpMessageService { - - /** - * 获得公众号消息分页 - * - * @param pageReqVO 分页查询 - * @return 公众号消息分页 - */ - PageResult getMessagePage(MpMessagePageReqVO pageReqVO); - - /** - * 从公众号,接收到粉丝消息 - * - * @param appId 微信公众号 appId - * @param wxMessage 消息 - */ - void receiveMessage(String appId, WxMpXmlMessage wxMessage); - - /** - * 使用公众号,给粉丝回复消息 - * - * 例如说:自动回复、客服消息、菜单回复消息等场景 - * - * 注意,该方法只是返回 WxMpXmlOutMessage 对象,不会真的发送消息 - * - * @param sendReqBO 消息内容 - * @return 微信回复消息 XML - */ - WxMpXmlOutMessage sendOutMessage(@Valid MpMessageSendOutReqBO sendReqBO); - - /** - * 使用公众号,给粉丝发送【客服】消息 - * - * 注意,该方法会真实发送消息 - * - * @param sendReqVO 消息内容 - * @return 消息 - */ - MpMessageDO sendKefuMessage(MpMessageSendReqVO sendReqVO); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java deleted file mode 100644 index 07553c764..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java +++ /dev/null @@ -1,156 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessagePageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.message.vo.message.MpMessageSendReqVO; -import cn.iocoder.yudao.module.mp.convert.message.MpMessageConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.dal.mysql.message.MpMessageMapper; -import cn.iocoder.yudao.module.mp.enums.message.MpMessageSendFromEnum; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import cn.iocoder.yudao.module.mp.service.material.MpMaterialService; -import cn.iocoder.yudao.module.mp.service.message.bo.MpMessageSendOutReqBO; -import cn.iocoder.yudao.module.mp.service.user.MpUserService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.api.WxConsts; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; -import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Validator; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.MESSAGE_SEND_FAIL; - -/** - * 粉丝消息 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class MpMessageServiceImpl implements MpMessageService { - - @Resource - @Lazy // 延迟加载,避免循环依赖 - private MpAccountService mpAccountService; - @Resource - private MpUserService mpUserService; - @Resource - private MpMaterialService mpMaterialService; - - @Resource - private MpMessageMapper mpMessageMapper; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Resource - private Validator validator; - - @Override - public PageResult getMessagePage(MpMessagePageReqVO pageReqVO) { - return mpMessageMapper.selectPage(pageReqVO); - } - - @Override - public void receiveMessage(String appId, WxMpXmlMessage wxMessage) { - // 获得关联信息 - MpAccountDO account = mpAccountService.getAccountFromCache(appId); - Assert.notNull(account, "公众号账号({}) 不存在", appId); - - // 订阅事件不记录,因为此时公众号粉丝表中还没有此粉丝的数据 - // TODO @芋艿:这个修复,后续看看还有啥问题 - if (ObjUtil.equal(wxMessage.getEvent(), WxConsts.EventType.SUBSCRIBE)) { - return; - } - - MpUserDO user = mpUserService.getUser(appId, wxMessage.getFromUser()); - Assert.notNull(user, "公众号粉丝({}/{}) 不存在", appId, wxMessage.getFromUser()); - - // 记录消息 - MpMessageDO message = MpMessageConvert.INSTANCE.convert(wxMessage, account, user) - .setSendFrom(MpMessageSendFromEnum.USER_TO_MP.getFrom()); - downloadMessageMedia(message); - mpMessageMapper.insert(message); - } - - @Override - public WxMpXmlOutMessage sendOutMessage(MpMessageSendOutReqBO sendReqBO) { - // 校验消息格式 - MpUtils.validateMessage(validator, sendReqBO.getType(), sendReqBO); - - // 获得关联信息 - MpAccountDO account = mpAccountService.getAccountFromCache(sendReqBO.getAppId()); - Assert.notNull(account, "公众号账号({}) 不存在", sendReqBO.getAppId()); - MpUserDO user = mpUserService.getUser(sendReqBO.getAppId(), sendReqBO.getOpenid()); - Assert.notNull(user, "公众号粉丝({}/{}) 不存在", sendReqBO.getAppId(), sendReqBO.getOpenid()); - - // 记录消息 - MpMessageDO message = MpMessageConvert.INSTANCE.convert(sendReqBO, account, user). - setSendFrom(MpMessageSendFromEnum.MP_TO_USER.getFrom()); - downloadMessageMedia(message); - mpMessageMapper.insert(message); - - // 转换返回 WxMpXmlOutMessage 对象 - return MpMessageConvert.INSTANCE.convert02(message, account); - } - - @Override - public MpMessageDO sendKefuMessage(MpMessageSendReqVO sendReqVO) { - // 校验消息格式 - MpUtils.validateMessage(validator, sendReqVO.getType(), sendReqVO); - - // 获得关联信息 - MpUserDO user = mpUserService.getRequiredUser(sendReqVO.getUserId()); - MpAccountDO account = mpAccountService.getRequiredAccount(user.getAccountId()); - - // 发送客服消息 - WxMpKefuMessage wxMessage = MpMessageConvert.INSTANCE.convert(sendReqVO, user); - WxMpService mpService = mpServiceFactory.getRequiredMpService(user.getAppId()); - try { - mpService.getKefuService().sendKefuMessageWithResponse(wxMessage); - } catch (WxErrorException e) { - throw exception(MESSAGE_SEND_FAIL, e.getError().getErrorMsg()); - } - - // 记录消息 - MpMessageDO message = MpMessageConvert.INSTANCE.convert(wxMessage, account, user) - .setSendFrom(MpMessageSendFromEnum.MP_TO_USER.getFrom()); - downloadMessageMedia(message); - mpMessageMapper.insert(message); - return message; - } - - /** - * 下载消息使用到的媒体文件,并上传到文件服务 - * - * @param message 消息 - */ - private void downloadMessageMedia(MpMessageDO message) { - if (StrUtil.isNotEmpty(message.getMediaId())) { - message.setMediaUrl(mpMaterialService.downloadMaterialUrl(message.getAccountId(), - message.getMediaId(), MpUtils.getMediaFileType(message.getType()))); - } - if (StrUtil.isNotEmpty(message.getThumbMediaId())) { - message.setThumbMediaUrl(mpMaterialService.downloadMaterialUrl(message.getAccountId(), - message.getThumbMediaId(), WxConsts.MediaFileType.THUMB)); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/bo/MpMessageSendOutReqBO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/bo/MpMessageSendOutReqBO.java deleted file mode 100644 index 9da709050..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/bo/MpMessageSendOutReqBO.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.message.bo; - -import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; -import cn.iocoder.yudao.module.mp.framework.mp.core.util.MpUtils.*; -import lombok.Data; -import me.chanjar.weixin.common.api.WxConsts; -import org.hibernate.validator.constraints.URL; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 公众号消息发送 Request BO - * - * 为什么要有该 BO 呢?在自动回复、客服消息、菜单回复消息等场景,都涉及到 MP 给粉丝发送消息,所以使用该 BO 统一承接 - * - * @author 芋道源码 - */ -@Data -public class MpMessageSendOutReqBO { - - /** - * 公众号 appId - */ - @NotEmpty(message = "公众号 appId 不能为空") - private String appId; - /** - * 公众号粉丝 openid - */ - @NotEmpty(message = "公众号粉丝 openid 不能为空") - private String openid; - - // ========== 消息内容 ========== - /** - * 消息类型 - * - * 枚举 {@link WxConsts.XmlMsgType} 中的 TEXT、IMAGE、VOICE、VIDEO、NEWS、MUSIC - */ - @NotEmpty(message = "消息类型不能为空") - public String type; - - /** - * 消息内容 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 TEXT - */ - @NotEmpty(message = "消息内容不能为空", groups = TextMessageGroup.class) - private String content; - - /** - * 媒体 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 IMAGE、VOICE、VIDEO - */ - @NotEmpty(message = "消息 mediaId 不能为空", groups = {ImageMessageGroup.class, VoiceMessageGroup.class, VideoMessageGroup.class}) - private String mediaId; - - /** - * 缩略图的媒体 id - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO、MUSIC - */ - @NotEmpty(message = "消息 thumbMediaId 不能为空", groups = {MusicMessageGroup.class}) - private String thumbMediaId; - - /** - * 标题 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - @NotEmpty(message = "消息标题不能为空", groups = VideoMessageGroup.class) - private String title; - /** - * 描述 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 VIDEO - */ - @NotEmpty(message = "消息描述不能为空", groups = VideoMessageGroup.class) - private String description; - - /** - * 图文消息 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS - */ - @Valid - @NotNull(message = "图文消息不能为空", groups = NewsMessageGroup.class) - private List articles; - - /** - * 音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - @NotEmpty(message = "音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String musicUrl; - - /** - * 高质量音乐链接 - * - * 消息类型为 {@link WxConsts.XmlMsgType} 的 MUSIC - */ - @NotEmpty(message = "高质量音乐链接不能为空", groups = MusicMessageGroup.class) - @URL(message = "高质量音乐链接格式不正确", groups = MusicMessageGroup.class) - private String hqMusicUrl; - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java deleted file mode 100644 index 08e5c35bb..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.statistics; - -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; - -import java.time.LocalDateTime; -import java.util.List; - -/** - * 公众号统计 Service 接口 - * - * @author 芋道源码 - */ -public interface MpStatisticsService { - - /** - * 获取粉丝增减数据 - * - * @param accountId 公众号账号编号 - * @param date 时间区间 - * @return 粉丝增减数据 - */ - List getUserSummary(Long accountId, LocalDateTime[] date); - - /** - * 获取粉丝累计数据 - * - * @param accountId 公众号账号编号 - * @param date 时间区间 - * @return 粉丝累计数据 - */ - List getUserCumulate(Long accountId, LocalDateTime[] date); - - /** - * 获取消息发送概况数据 - * - * @param accountId 公众号账号编号 - * @param date 时间区间 - * @return 消息发送概况数据 - */ - List getUpstreamMessage(Long accountId, LocalDateTime[] date); - - /** - * 获取接口分析数据 - * - * @param accountId 公众号账号编号 - * @param date 时间区间 - * @return 接口分析数据 - */ - List getInterfaceSummary(Long accountId, LocalDateTime[] date); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java deleted file mode 100644 index 4c3b37413..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.statistics; - -import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; -import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 公众号统计 Service 实现类 - * - * @author 芋道源码 - */ -@Service -public class MpStatisticsServiceImpl implements MpStatisticsService { - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Override - public List getUserSummary(Long accountId, LocalDateTime[] date) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - return mpService.getDataCubeService().getUserSummary( - DateUtil.date(date[0]), DateUtil.date(date[1])); - } catch (WxErrorException e) { - throw exception(STATISTICS_GET_USER_SUMMARY_FAIL, e.getError().getErrorMsg()); - } - } - - @Override - public List getUserCumulate(Long accountId, LocalDateTime[] date) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - return mpService.getDataCubeService().getUserCumulate( - DateUtil.date(date[0]), DateUtil.date(date[1])); - } catch (WxErrorException e) { - throw exception(STATISTICS_GET_USER_CUMULATE_FAIL, e.getError().getErrorMsg()); - } - } - - @Override - public List getUpstreamMessage(Long accountId, LocalDateTime[] date) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - return mpService.getDataCubeService().getUpstreamMsg( - DateUtil.date(date[0]), DateUtil.date(date[1])); - } catch (WxErrorException e) { - throw exception(STATISTICS_GET_UPSTREAM_MESSAGE_FAIL, e.getError().getErrorMsg()); - } - } - - @Override - public List getInterfaceSummary(Long accountId, LocalDateTime[] date) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - try { - return mpService.getDataCubeService().getInterfaceSummary( - DateUtil.date(date[0]), DateUtil.date(date[1])); - } catch (WxErrorException e) { - throw exception(STATISTICS_GET_INTERFACE_SUMMARY_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagService.java deleted file mode 100644 index 77dbf338f..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagService.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.tag; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; - -import javax.validation.Valid; -import java.util.List; - -/** - * 公众号标签 Service 接口 - * - * @author fengdan - */ -public interface MpTagService { - - /** - * 创建公众号标签 - * - * @param createReqVO 创建标签信息 - * @return 标签编号 - */ - Long createTag(@Valid MpTagCreateReqVO createReqVO); - - /** - * 更新公众号标签 - * - * @param updateReqVO 更新标签信息 - */ - void updateTag(@Valid MpTagUpdateReqVO updateReqVO); - - /** - * 删除公众号标签 - * - * @param id 编号 - */ - void deleteTag(Long id); - - /** - * 获得公众号标签分页 - * - * @param pageReqVO 分页查询 - * @return 公众号标签分页 - */ - PageResult getTagPage(MpTagPageReqVO pageReqVO); - - /** - * 获得公众号标签详情 - * @param id id查询 - * @return 公众号标签详情 - */ - MpTagDO get(Long id); - - List getTagList(); - - /** - * 同步公众号标签 - * - * @param accountId 公众号账号的编号 - */ - void syncTag(Long accountId); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagServiceImpl.java deleted file mode 100644 index a4fa50923..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/tag/MpTagServiceImpl.java +++ /dev/null @@ -1,164 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.tag; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.tag.vo.MpTagUpdateReqVO; -import cn.iocoder.yudao.module.mp.convert.tag.MpTagConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.tag.MpTagDO; -import cn.iocoder.yudao.module.mp.dal.mysql.tag.MpTagMapper; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.tag.WxUserTag; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*; - -/** - * 公众号标签 Service 实现类 - * - * @author fengdan - */ -@Slf4j -@Service -@Validated -public class MpTagServiceImpl implements MpTagService { - - @Resource - private MpTagMapper mpTagMapper; - - @Resource - private MpAccountService mpAccountService; - - @Resource - @Lazy // 延迟加载,为了解决延迟加载 - private MpServiceFactory mpServiceFactory; - - @Override - public Long createTag(MpTagCreateReqVO createReqVO) { - // 获得公众号账号 - MpAccountDO account = mpAccountService.getRequiredAccount(createReqVO.getAccountId()); - - // 第一步,新增标签到公众号平台。标签名的唯一,交给公众号平台 - WxMpService mpService = mpServiceFactory.getRequiredMpService(createReqVO.getAccountId()); - WxUserTag wxTag; - try { - wxTag = mpService.getUserTagService().tagCreate(createReqVO.getName()); - } catch (WxErrorException e) { - throw exception(TAG_CREATE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,新增标签到数据库 - MpTagDO tag = MpTagConvert.INSTANCE.convert(wxTag, account); - mpTagMapper.insert(tag); - return tag.getId(); - } - - @Override - public void updateTag(MpTagUpdateReqVO updateReqVO) { - // 校验标签存在 - MpTagDO tag = validateTagExists(updateReqVO.getId()); - - // 第一步,更新标签到公众号平台。标签名的唯一,交给公众号平台 - WxMpService mpService = mpServiceFactory.getRequiredMpService(tag.getAccountId()); - try { - mpService.getUserTagService().tagUpdate(tag.getTagId(), updateReqVO.getName()); - } catch (WxErrorException e) { - throw exception(TAG_UPDATE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,更新标签到数据库 - mpTagMapper.updateById(new MpTagDO().setId(tag.getId()).setName(updateReqVO.getName())); - } - - @Override - public void deleteTag(Long id) { - // 校验标签存在 - MpTagDO tag = validateTagExists(id); - - // 第一步,删除标签到公众号平台。 - WxMpService mpService = mpServiceFactory.getRequiredMpService(tag.getAccountId()); - try { - mpService.getUserTagService().tagDelete(tag.getTagId()); - } catch (WxErrorException e) { - throw exception(TAG_DELETE_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,删除标签到数据库 - mpTagMapper.deleteById(tag.getId()); - } - - private MpTagDO validateTagExists(Long id) { - MpTagDO tag = mpTagMapper.selectById(id); - if (tag == null) { - throw exception(TAG_NOT_EXISTS); - } - return tag; - } - - @Override - public PageResult getTagPage(MpTagPageReqVO pageReqVO) { - return mpTagMapper.selectPage(pageReqVO); - } - - @Override - public MpTagDO get(Long id) { - return mpTagMapper.selectById(id); - } - - @Override - public List getTagList() { - return mpTagMapper.selectList(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void syncTag(Long accountId) { - MpAccountDO account = mpAccountService.getRequiredAccount(accountId); - - // 第一步,从公众号平台获取最新的标签列表 - WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); - List wxTags; - try { - wxTags = mpService.getUserTagService().tagGet(); - } catch (WxErrorException e) { - throw exception(TAG_GET_FAIL, e.getError().getErrorMsg()); - } - - // 第二步,合并更新回自己的数据库;由于标签只有 100 个,所以直接 for 循环操作 - Map tagMap = convertMap(mpTagMapper.selectListByAccountId(accountId), - MpTagDO::getTagId); - wxTags.forEach(wxTag -> { - MpTagDO tag = tagMap.remove(wxTag.getId()); - // 情况一,不存在,新增 - if (tag == null) { - tag = MpTagConvert.INSTANCE.convert(wxTag, account); - mpTagMapper.insert(tag); - return; - } - // 情况二,存在,则更新 - mpTagMapper.updateById(new MpTagDO().setId(tag.getId()) - .setName(wxTag.getName()).setCount(wxTag.getCount())); - }); - // 情况三,部分标签已经不存在了,删除 - if (CollUtil.isNotEmpty(tagMap)) { - mpTagMapper.deleteBatchIds(convertList(tagMap.values(), MpTagDO::getId)); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserService.java deleted file mode 100644 index bdefc0e60..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserService.java +++ /dev/null @@ -1,102 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.user; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import me.chanjar.weixin.mp.bean.result.WxMpUser; - -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.USER_NOT_EXISTS; - -/** - * 公众号粉丝 Service 接口 - * - * @author 芋道源码 - */ -public interface MpUserService { - - /** - * 获得公众号粉丝 - * - * @param id 编号 - * @return 公众号粉丝 - */ - MpUserDO getUser(Long id); - - /** - * 使用 appId + openId,获得公众号粉丝 - * - * @param appId 公众号 appId - * @param openId 公众号 openId - * @return 公众号粉丝 - */ - MpUserDO getUser(String appId, String openId); - - /** - * 获得公众号粉丝 - * - * @param id 编号 - * @return 公众号粉丝 - */ - default MpUserDO getRequiredUser(Long id) { - MpUserDO user = getUser(id); - if (user == null) { - throw exception(USER_NOT_EXISTS); - } - return user; - } - - /** - * 获得公众号粉丝列表 - * - * @param ids 编号 - * @return 公众号粉丝列表 - */ - List getUserList(Collection ids); - - /** - * 获得公众号粉丝分页 - * - * @param pageReqVO 分页查询 - * @return 公众号粉丝分页 - */ - PageResult getUserPage(MpUserPageReqVO pageReqVO); - - /** - * 保存公众号粉丝 - * - * 新增或更新,根据是否存在数据库中 - * - * @param appId 公众号 appId - * @param wxMpUser 公众号粉丝的信息 - * @return 公众号粉丝 - */ - MpUserDO saveUser(String appId, WxMpUser wxMpUser); - - /** - * 同步一个公众号粉丝 - * - * @param accountId 公众号账号的编号 - */ - void syncUser(Long accountId); - - /** - * 更新公众号粉丝,取消关注 - * - * @param appId 公众号 appId - * @param openId 公众号粉丝的 openid - */ - void updateUserUnsubscribe(String appId, String openId); - - /** - * 更新公众号粉丝 - * - * @param updateReqVO 更新信息 - */ - void updateUser(MpUserUpdateReqVO updateReqVO); - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserServiceImpl.java deleted file mode 100644 index 0cef919d9..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/user/MpUserServiceImpl.java +++ /dev/null @@ -1,215 +0,0 @@ -package cn.iocoder.yudao.module.mp.service.user; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.user.vo.MpUserUpdateReqVO; -import cn.iocoder.yudao.module.mp.convert.user.MpUserConvert; -import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; -import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; -import cn.iocoder.yudao.module.mp.dal.mysql.user.MpUserMapper; -import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; -import cn.iocoder.yudao.module.mp.service.account.MpAccountService; -import lombok.extern.slf4j.Slf4j; -import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.mp.api.WxMpService; -import me.chanjar.weixin.mp.bean.result.WxMpUser; -import me.chanjar.weixin.mp.bean.result.WxMpUserList; -import org.springframework.context.annotation.Lazy; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.USER_NOT_EXISTS; -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.USER_UPDATE_TAG_FAIL; - -/** - * 微信公众号粉丝 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class MpUserServiceImpl implements MpUserService { - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpAccountService mpAccountService; - - @Resource - @Lazy // 延迟加载,解决循环依赖的问题 - private MpServiceFactory mpServiceFactory; - - @Resource - private MpUserMapper mpUserMapper; - - @Override - public MpUserDO getUser(Long id) { - return mpUserMapper.selectById(id); - } - - @Override - public MpUserDO getUser(String appId, String openId) { - return mpUserMapper.selectByAppIdAndOpenid(appId, openId); - } - - @Override - public List getUserList(Collection ids) { - return mpUserMapper.selectBatchIds(ids); - } - - @Override - public PageResult getUserPage(MpUserPageReqVO pageReqVO) { - return mpUserMapper.selectPage(pageReqVO); - } - - @Override - public MpUserDO saveUser(String appId, WxMpUser wxMpUser) { - // 构建保存的 MpUserDO 对象 - MpAccountDO account = mpAccountService.getAccountFromCache(appId); - MpUserDO user = MpUserConvert.INSTANCE.convert(account, wxMpUser); - - // 根据情况,插入或更新 - MpUserDO dbUser = mpUserMapper.selectByAppIdAndOpenid(appId, wxMpUser.getOpenId()); - if (dbUser == null) { - mpUserMapper.insert(user); - } else { - user.setId(dbUser.getId()); - mpUserMapper.updateById(user); - } - return user; - } - - @Override - @Async - public void syncUser(Long accountId) { - MpAccountDO account = mpAccountService.getRequiredAccount(accountId); - // for 循环,避免递归出意外问题,导致死循环 - String nextOpenid = null; - for (int i = 0; i < Short.MAX_VALUE; i++) { - log.info("[syncUser][第({}) 次加载公众号粉丝列表,nextOpenid({})]", i, nextOpenid); - try { - nextOpenid = syncUser0(account, nextOpenid); - } catch (WxErrorException e) { - log.error("[syncUser][第({}) 次同步粉丝异常]", i, e); - break; - } - // 如果 nextOpenid 为空,表示已经同步完毕 - if (StrUtil.isEmpty(nextOpenid)) { - break; - } - } - } - - private String syncUser0(MpAccountDO account, String nextOpenid) throws WxErrorException { - // 第一步,从公众号流式加载粉丝 - WxMpService mpService = mpServiceFactory.getRequiredMpService(account.getId()); - WxMpUserList wxUserList = mpService.getUserService().userList(nextOpenid); - if (CollUtil.isEmpty(wxUserList.getOpenids())) { - return null; - } - - // 第二步,分批加载粉丝信息 - List> openidsList = CollUtil.split(wxUserList.getOpenids(), 100); - for (List openids : openidsList) { - log.info("[syncUser][批量加载粉丝信息,openids({})]", openids); - List wxUsers = mpService.getUserService().userInfoList(openids); - batchSaveUser(account, wxUsers); - } - - // 返回下一次的 nextOpenId - return wxUserList.getNextOpenid(); - } - - private void batchSaveUser(MpAccountDO account, List wxUsers) { - if (CollUtil.isEmpty(wxUsers)) { - return; - } - // 1. 获得数据库已保存的粉丝列表 - List dbUsers = mpUserMapper.selectListByAppIdAndOpenid(account.getAppId(), - CollectionUtils.convertList(wxUsers, WxMpUser::getOpenId)); - Map openId2Users = CollectionUtils.convertMap(dbUsers, MpUserDO::getOpenid); - - // 2.1 根据情况,插入或更新 - List users = MpUserConvert.INSTANCE.convertList(account, wxUsers); - List newUsers = new ArrayList<>(); - for (MpUserDO user : users) { - MpUserDO dbUser = openId2Users.get(user.getOpenid()); - if (dbUser == null) { // 新增:稍后批量插入 - newUsers.add(user); - } else { // 更新:直接执行更新 - user.setId(dbUser.getId()); - mpUserMapper.updateById(user); - } - } - // 2.2 批量插入 - if (CollUtil.isNotEmpty(newUsers)) { - mpUserMapper.insertBatch(newUsers); - } - } - - @Override - public void updateUserUnsubscribe(String appId, String openid) { - MpUserDO dbUser = mpUserMapper.selectByAppIdAndOpenid(appId, openid); - if (dbUser == null) { - log.error("[updateUserUnsubscribe][微信公众号粉丝 appId({}) openid({}) 不存在]", appId, openid); - return; - } - mpUserMapper.updateById(new MpUserDO().setId(dbUser.getId()).setSubscribeStatus(CommonStatusEnum.DISABLE.getStatus()) - .setUnsubscribeTime(LocalDateTime.now())); - } - - @Override - public void updateUser(MpUserUpdateReqVO updateReqVO) { - // 校验存在 - MpUserDO user = validateUserExists(updateReqVO.getId()); - - // 第一步,更新标签到公众号 - updateUserTag(user.getAppId(), user.getOpenid(), updateReqVO.getTagIds()); - - // 第二步,更新基本信息到数据库 - MpUserDO updateObj = MpUserConvert.INSTANCE.convert(updateReqVO).setId(user.getId()); - mpUserMapper.updateById(updateObj); - } - - private MpUserDO validateUserExists(Long id) { - MpUserDO user = mpUserMapper.selectById(id); - if (user == null) { - throw exception(USER_NOT_EXISTS); - } - return user; - } - - private void updateUserTag(String appId, String openid, List tagIds) { - WxMpService mpService = mpServiceFactory.getRequiredMpService(appId); - try { - // 第一步,先取消原来的标签 - List oldTagIds = mpService.getUserTagService().userTagList(openid); - for (Long tagId : oldTagIds) { - mpService.getUserTagService().batchUntagging(tagId, new String[]{openid}); - } - // 第二步,再设置新的标签 - if (CollUtil.isEmpty(tagIds)) { - return; - } - for (Long tagId: tagIds) { - mpService.getUserTagService().batchTagging(tagId, new String[]{openid}); - } - } catch (WxErrorException e) { - throw exception(USER_UPDATE_TAG_FAIL, e.getError().getErrorMsg()); - } - } - -} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application-dev.yaml b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index 0a3975f46..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,99 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application-local.yaml b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application-local.yaml deleted file mode 100644 index d4dabc22c..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,119 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.mp.dal.mysql: debug - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - security: - mock-enable: true - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application.yaml b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application.yaml deleted file mode 100644 index 509722ed5..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,114 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 微信公众号相关配置 #################### -wx: - mp: # 公众号配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 - # 存储配置,解决 AccessToken 的跨节点的共享 - config-storage: - type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 - key-prefix: wx # Redis Key 的前缀 - http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台 - app-id: null # 避免 weixin-java-mp starter 报错 - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.mp - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - security: - permit-all_urls: - - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录 - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号 - -debug: false diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/bootstrap.yaml b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index a4f9d0821..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: mp-server - - profiles: - active: local - -server: - port: 48086 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/logback-spring.xml b/yudao-module-mp/yudao-module-mp-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-pay/pom.xml b/yudao-module-pay/pom.xml deleted file mode 100644 index 3a735b8bd..000000000 --- a/yudao-module-pay/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - cn.iocoder.cloud - yudao - ${revision} - - 4.0.0 - yudao-module-pay - pom - - yudao-module-pay-api - yudao-module-pay-biz - yudao-spring-boot-starter-biz-pay - - - ${project.artifactId} - - pay 模块,我们放支付业务,提供业务的支付能力。 - 例如说:商户、应用、支付、退款等等 - - - - diff --git a/yudao-module-pay/yudao-module-pay-api/pom.xml b/yudao-module-pay/yudao-module-pay-api/pom.xml deleted file mode 100644 index d517fa95c..000000000 --- a/yudao-module-pay/yudao-module-pay-api/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - yudao-module-pay - cn.iocoder.cloud - ${revision} - - 4.0.0 - yudao-module-pay-api - jar - - ${project.artifactId} - - pay 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayOrderNotifyReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayOrderNotifyReqDTO.java deleted file mode 100644 index 291b364d9..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayOrderNotifyReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.notify.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "RPC 服务 - 支付单的通知 Request DTO") -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayOrderNotifyReqDTO { - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "M101") - @NotEmpty(message = "商户订单号不能为空") - private String merchantOrderId; - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "P202") - @NotNull(message = "支付订单编号不能为空") - private Long payOrderId; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayRefundNotifyReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayRefundNotifyReqDTO.java deleted file mode 100644 index d92ad994f..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/dto/PayRefundNotifyReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.notify.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "RPC 服务 - 退款单的通知 Request DTO") -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayRefundNotifyReqDTO { - - @Schema(description = "商户退款单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "MR101") - @NotEmpty(message = "商户退款单编号不能为空") - private String merchantOrderId; - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "R303") - @NotNull(message = "支付退款编号不能为空") - private Long payRefundId; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/package-info.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/package-info.java deleted file mode 100644 index 60c4ca883..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/notify/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位符,无特殊作用 - */ -package cn.iocoder.yudao.module.pay.api.notify; diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApi.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApi.java deleted file mode 100644 index 8e5bf3776..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApi.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.tags.Tag; -import javax.annotation.security.PermitAll; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 支付单") -public interface PayOrderApi { - - String PREFIX = ApiConstants.PREFIX + "/order"; - - @PostMapping(PREFIX + "/create") - @Operation(summary = "创建支付单") - CommonResult createOrder(@Valid @RequestBody PayOrderCreateReqDTO reqDTO); - - @GetMapping(PREFIX + "/get") - @Operation(summary = "获得支付单") - @Parameter(name = "id", description = "支付单编号", example = "1", required = true) - @PermitAll - CommonResult getOrder(@RequestParam("id") Long id); - - @PutMapping(PREFIX + "/update-price") - @Operation(summary = "更新支付订单价格") - @Parameters({ - @Parameter(name = "id", description = "支付单编号", example = "1", required = true), - @Parameter(name = "payPrice", description = "支付单价格", example = "100", required = true) - }) - CommonResult updatePayOrderPrice(@RequestParam("id") Long id, - @RequestParam("payPrice") Integer payPrice); - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderCreateReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderCreateReqDTO.java deleted file mode 100644 index c862e338d..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderCreateReqDTO.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.order.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.DecimalMin; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.io.Serializable; -import java.time.LocalDateTime; - -@Schema(description = "RPC 服务 - 支付单创建 Request DTO") -@Data -public class PayOrderCreateReqDTO implements Serializable { - - public static final int SUBJECT_MAX_LENGTH = 32; - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long appId; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - // ========== 商户相关字段 ========== - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "M101") // 例如说,内部系统 A 的订单号。需要保证每个 PayMerchantDO 唯一 - @NotEmpty(message = "商户订单编号不能为空") - private String merchantOrderId; - - @Schema(description = "商品标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是标题") - @NotEmpty(message = "商品标题不能为空") - @Length(max = 32, message = "商品标题不能超过 32") - private String subject; - - @Schema(description = "商品描述", example = "我是描述") - @Length(max = 128, message = "商品描述信息长度不能超过128") - private String body; - - // ========== 订单相关字段 ========== - - @Schema(description = "支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "80") - @NotNull(message = "支付金额不能为空") - @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") - private Integer price; - - @Schema(description = "支付过期时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "支付过期时间不能为空") - private LocalDateTime expireTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderRespDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderRespDTO.java deleted file mode 100644 index 7bf9e6167..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderRespDTO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.order.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "RPC 服务 - 支付单信息 Response DTO") -@Data -public class PayOrderRespDTO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx_pub") // PayChannelEnum 枚举 - private String channelCode; - - // ========== 商户相关字段 ========== - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "M101") // 例如说,内部系统 A 的订单号。需要保证每个 PayMerchantDO 唯一 - private String merchantOrderId; - - // ========== 订单相关字段 ========== - - @Schema(description = "支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "101") - private Integer price; - - @Schema(description = "支付状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") // PayOrderStatusEnum 枚举 - private Integer status; - - // ========== 渠道相关字段 ========== - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApi.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApi.java deleted file mode 100644 index 9bdb25af8..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApi.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.refund; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 退款单") -public interface PayRefundApi { - - String PREFIX = ApiConstants.PREFIX + "/refund"; - - @PostMapping(PREFIX + "/create") - @Operation(summary = "创建退款单") - CommonResult createRefund(@Valid @RequestBody PayRefundCreateReqDTO reqDTO); - - @GetMapping(PREFIX + "/get") - @Operation(summary = "获得退款单") - @Parameter(name = "id", description = "退款单编号", example = "1", required = true) - CommonResult getRefund(@RequestParam("id") Long id); - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundCreateReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundCreateReqDTO.java deleted file mode 100644 index c03bc5368..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundCreateReqDTO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.refund.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "RPC 服务 - 退款单创建 Request DTO") -@Data -public class PayRefundCreateReqDTO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long appId; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - // ========== 商户相关字段 ========== - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "M101") // 例如说,内部系统 A 的订单号。需要保证每个 PayMerchantDO 唯一 - @NotEmpty(message = "商户订单编号不能为空") - private String merchantOrderId; - - @Schema(description = "商户退款编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "MR101") - @NotEmpty(message = "商户退款编号不能为空") - private String merchantRefundId; - - @Schema(description = "退款描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是退款描述") - @NotEmpty(message = "退款描述不能为空") - @Length(max = 128, message = "退款描述长度不能超过 128") - private String reason; - - // ========== 订单相关字段 ========== - - @Schema(description = "退款金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "60") - @NotNull(message = "退款金额不能为空") - @Min(value = 1, message = "退款金额必须大于零") - private Integer price; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundRespDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundRespDTO.java deleted file mode 100644 index a562f581e..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundRespDTO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.refund.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "RPC 服务 - 退款单信息 Response DTO") -@Data -public class PayRefundRespDTO { - - @Schema(description = "退款单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - // ========== 退款相关字段 ========== - - @Schema(description = "退款状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") // PayRefundStatusEnum 枚举 - private Integer status; - - @Schema(description = "退款金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "101") - private Integer refundPrice; - - // ========== 商户相关字段 ========== - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "M101") // 例如说,内部系统 A 的订单号。需要保证每个 PayMerchantDO 唯一 - private String merchantOrderId; - - @Schema(description = "退款成功时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime successTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java deleted file mode 100644 index 3661fdc39..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApi.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.transfer; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.enums.ApiConstants; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -import javax.validation.Valid; - -@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = -@Tag(name = "RPC 服务 - 转账单") -public interface PayTransferApi { - - String PREFIX = ApiConstants.PREFIX + "/transfer"; - - @PostMapping(PREFIX + "/create") - @Operation(summary = "创建转账单") - CommonResult createTransfer(@Valid @RequestBody PayTransferCreateReqDTO reqDTO); - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java deleted file mode 100644 index 17a611172..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.transfer.dto; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@Schema(description = "RPC 服务 - 转账单创建 Request DTO") -@Data -public class PayTransferCreateReqDTO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long appId; - - @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "转账类型不能为空") - @InEnum(PayTransferTypeEnum.class) - private Integer type; - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "M101") // 例如说,内部系统 A 的订单号。需要保证每个 PayMerchantDO 唯一 - @NotEmpty(message = "商户订单编号不能为空") - private String merchantOrderId; - - @Schema(description = "转账金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "80") - @Min(value = 1, message = "转账金额必须大于零") - @NotNull(message = "转账金额不能为空") - private Integer price; - - @Schema(description = "转账标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是标题") - @NotEmpty(message = "转账标题不能为空") - private String title; - - @Schema(description = "收款方信息", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "收款方信息不能为空") - private Map payeeInfo; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ApiConstants.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ApiConstants.java deleted file mode 100644 index 72b040248..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ApiConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums; - -import cn.iocoder.yudao.framework.common.enums.RpcConstants; - -/** - * API 相关的枚举 - * - * @author 芋道源码 - */ -public class ApiConstants { - - /** - * 服务名 - * - * 注意,需要保证和 spring.application.name 保持一致 - */ - public static final String NAME = "pay-server"; - - public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/pay"; - - public static final String VERSION = "1.0.0"; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/DictTypeConstants.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/DictTypeConstants.java deleted file mode 100644 index 8f0d9b718..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/DictTypeConstants.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums; - -/** - * Pay 字典类型的枚举类 - * - * @author 芋道源码 - */ -public interface DictTypeConstants { - - String CHANNEL_CODE = "pay_channel_code"; // 支付渠道编码 - - String ORDER_STATUS = "pay_order_status"; // 支付渠道 - - String REFUND_STATUS = "pay_order_status"; // 退款状态 - - String NOTIFY_STATUS = "pay_notify_status"; // 回调状态 - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java deleted file mode 100644 index 476d7417b..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Pay 错误码 Core 枚举类 - * - * pay 系统,使用 1-007-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== APP 模块 1-007-000-000 ========== - ErrorCode APP_NOT_FOUND = new ErrorCode(1_007_000_000, "App 不存在"); - ErrorCode APP_IS_DISABLE = new ErrorCode(1_007_000_002, "App 已经被禁用"); - ErrorCode APP_EXIST_ORDER_CANT_DELETE = new ErrorCode(1_007_000_003, "支付应用存在支付订单,无法删除"); - ErrorCode APP_EXIST_REFUND_CANT_DELETE = new ErrorCode(1_007_000_004, "支付应用存在退款订单,无法删除"); - - // ========== CHANNEL 模块 1-007-001-000 ========== - ErrorCode CHANNEL_NOT_FOUND = new ErrorCode(1_007_001_000, "支付渠道的配置不存在"); - ErrorCode CHANNEL_IS_DISABLE = new ErrorCode(1_007_001_001, "支付渠道已经禁用"); - ErrorCode CHANNEL_EXIST_SAME_CHANNEL_ERROR = new ErrorCode(1_007_001_004, "已存在相同的渠道"); - - // ========== ORDER 模块 1-007-002-000 ========== - ErrorCode PAY_ORDER_NOT_FOUND = new ErrorCode(1_007_002_000, "支付订单不存在"); - ErrorCode PAY_ORDER_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_002_001, "支付订单不处于待支付"); - ErrorCode PAY_ORDER_STATUS_IS_SUCCESS = new ErrorCode(1_007_002_002, "订单已支付,请刷新页面"); - ErrorCode PAY_ORDER_IS_EXPIRED = new ErrorCode(1_007_002_003, "支付订单已经过期"); - ErrorCode PAY_ORDER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_002_004, "发起支付报错,错误码:{},错误提示:{}"); - ErrorCode PAY_ORDER_REFUND_FAIL_STATUS_ERROR = new ErrorCode(1_007_002_005, "支付订单退款失败,原因:状态不是已支付或已退款"); - - // ========== ORDER 模块(拓展单) 1-007-003-000 ========== - ErrorCode PAY_ORDER_EXTENSION_NOT_FOUND = new ErrorCode(1_007_003_000, "支付交易拓展单不存在"); - ErrorCode PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_003_001, "支付交易拓展单不处于待支付"); - ErrorCode PAY_ORDER_EXTENSION_IS_PAID = new ErrorCode(1_007_003_002, "订单已支付,请等待支付结果"); - - // ========== 支付模块(退款) 1-007-006-000 ========== - ErrorCode REFUND_PRICE_EXCEED = new ErrorCode(1_007_006_000, "退款金额超过订单可退款金额"); - ErrorCode REFUND_HAS_REFUNDING = new ErrorCode(1_007_006_002, "已经有退款在处理中"); - ErrorCode REFUND_EXISTS = new ErrorCode(1_007_006_003, "已经存在退款单"); - ErrorCode REFUND_NOT_FOUND = new ErrorCode(1_007_006_004, "支付退款单不存在"); - ErrorCode REFUND_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_006_005, "支付退款单不处于待退款"); - - // ========== 钱包模块 1-007-007-000 ========== - ErrorCode WALLET_NOT_FOUND = new ErrorCode(1_007_007_000, "用户钱包不存在"); - ErrorCode WALLET_BALANCE_NOT_ENOUGH = new ErrorCode(1_007_007_001, "钱包余额不足"); - ErrorCode WALLET_TRANSACTION_NOT_FOUND = new ErrorCode(1_007_007_002, "未找到对应的钱包交易"); - ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1_007_007_003, "已经存在钱包退款"); - ErrorCode WALLET_FREEZE_PRICE_NOT_ENOUGH = new ErrorCode(1_007_007_004, "钱包冻结余额不足"); - - // ========== 钱包充值模块 1-007-008-000 ========== - ErrorCode WALLET_RECHARGE_NOT_FOUND = new ErrorCode(1_007_008_000, "钱包充值记录不存在"); - ErrorCode WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_007_008_001, "钱包充值更新支付状态失败,钱包充值记录不是【未支付】状态"); - ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR = new ErrorCode(1_007_008_002, "钱包充值更新支付状态失败,支付单编号不匹配"); - ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1_007_008_003, "钱包充值更新支付状态失败,支付单状态不是【支付成功】状态"); - ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH = new ErrorCode(1_007_008_004, "钱包充值更新支付状态失败,支付单金额不匹配"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_NOT_PAID = new ErrorCode(1_007_008_005, "钱包发起退款失败,钱包充值订单未支付"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUNDED = new ErrorCode(1_007_008_006, "钱包发起退款失败,钱包充值订单已退款"); - ErrorCode WALLET_RECHARGE_REFUND_BALANCE_NOT_ENOUGH = new ErrorCode(1_007_008_007, "钱包发起退款失败,钱包余额不足"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR = new ErrorCode(1_007_008_008, "钱包退款更新失败,钱包退款单编号不匹配"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_NOT_FOUND = new ErrorCode(1_007_008_009, "钱包退款更新失败,退款订单不存在"); - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_PRICE_NOT_MATCH = new ErrorCode(1_007_008_010, "钱包退款更新失败,退款单金额不匹配"); - ErrorCode WALLET_RECHARGE_PACKAGE_AND_PRICE_IS_EMPTY = new ErrorCode(1_007_008_011, "充值金额和充钱套餐不能同时为空"); - ErrorCode WALLET_RECHARGE_PACKAGE_NOT_FOUND = new ErrorCode(1_007_008_012, "钱包充值套餐不存在"); - ErrorCode WALLET_RECHARGE_PACKAGE_IS_DISABLE = new ErrorCode(1_007_008_013, "钱包充值套餐已禁用"); - ErrorCode WALLET_RECHARGE_PACKAGE_NAME_EXISTS = new ErrorCode(1_007_008_014, "钱包充值套餐名称已存在"); - - // ========== 转账模块 1-007-009-000 ========== - ErrorCode PAY_TRANSFER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_009_000, "发起转账报错,错误码:{},错误提示:{}"); - ErrorCode PAY_TRANSFER_ALIPAY_LOGIN_ID_IS_EMPTY = new ErrorCode(1_007_009_001, "支付宝登录 ID 不能为空"); - ErrorCode PAY_TRANSFER_ALIPAY_ACCOUNT_NAME_IS_EMPTY = new ErrorCode(1_007_009_002, "支付宝账号名称不能为空"); - ErrorCode PAY_TRANSFER_NOT_FOUND = new ErrorCode(1_007_009_003, "转账交易单不存在"); - ErrorCode PAY_TRANSFER_STATUS_IS_SUCCESS = new ErrorCode(1_007_009_004, "转账单已成功转账"); - ErrorCode PAY_TRANSFER_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_009_005, "转账单不处于待转账"); - ErrorCode PAY_TRANSFER_STATUS_IS_NOT_PENDING = new ErrorCode(1_007_009_006, "转账单不处于待转账或转账中"); - ErrorCode PAY_TRANSFER_EXTENSION_NOT_FOUND = new ErrorCode(1_007_009_007, "转账交易拓展单不存在"); - ErrorCode PAY_TRANSFER_TYPE_AND_CHANNEL_NOT_MATCH = new ErrorCode(1_007_009_008, "转账类型和转账渠道不匹配"); - ErrorCode PAY_TRANSFER_EXTENSION_STATUS_IS_NOT_PENDING = new ErrorCode(1_007_009_009, "转账拓展单不处于待转账或转账中"); - - // ========== 示例订单 1-007-900-000 ========== - ErrorCode DEMO_ORDER_NOT_FOUND = new ErrorCode(1_007_900_000, "示例订单不存在"); - ErrorCode DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_007_900_001, "示例订单更新支付状态失败,订单不是【未支付】状态"); - ErrorCode DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR = new ErrorCode(1_007_900_002, "示例订单更新支付状态失败,支付单编号不匹配"); - ErrorCode DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1_007_900_003, "示例订单更新支付状态失败,支付单状态不是【支付成功】状态"); - ErrorCode DEMO_ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH = new ErrorCode(1_007_900_004, "示例订单更新支付状态失败,支付单金额不匹配"); - ErrorCode DEMO_ORDER_REFUND_FAIL_NOT_PAID = new ErrorCode(1_007_900_005, "发起退款失败,示例订单未支付"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUNDED = new ErrorCode(1_007_900_006, "发起退款失败,示例订单已退款"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_NOT_FOUND = new ErrorCode(1_007_900_007, "发起退款失败,退款订单不存在"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_NOT_SUCCESS = new ErrorCode(1_007_900_008, "发起退款失败,退款订单未退款成功"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_ORDER_ID_ERROR = new ErrorCode(1_007_900_009, "发起退款失败,退款单编号不匹配"); - ErrorCode DEMO_ORDER_REFUND_FAIL_REFUND_PRICE_NOT_MATCH = new ErrorCode(1_007_900_010, "发起退款失败,退款单金额不匹配"); - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyStatusEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyStatusEnum.java deleted file mode 100644 index b735598d5..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyStatusEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.notify; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 支付通知状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayNotifyStatusEnum { - - WAITING(0, "等待通知"), - SUCCESS(10, "通知成功"), - FAILURE(20, "通知失败"), // 多次尝试,彻底失败 - REQUEST_SUCCESS(21, "请求成功,但是结果失败"), - REQUEST_FAILURE(22, "请求失败"), - - ; - - /** - * 状态 - */ - private final Integer status; - /** - * 名字 - */ - private final String name; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyTypeEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyTypeEnum.java deleted file mode 100644 index 8c259d93c..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/notify/PayNotifyTypeEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.notify; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 支付通知类型 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayNotifyTypeEnum { - - ORDER(1, "支付单"), - REFUND(2, "退款单"), - ; - - /** - * 类型 - */ - private final Integer type; - /** - * 名字 - */ - private final String name; - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/order/PayOrderStatusEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/order/PayOrderStatusEnum.java deleted file mode 100644 index 86a9e1704..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/order/PayOrderStatusEnum.java +++ /dev/null @@ -1,64 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.order; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 支付订单的状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayOrderStatusEnum implements IntArrayValuable { - - WAITING(0, "未支付"), - SUCCESS(10, "支付成功"), - REFUND(20, "已退款"), - CLOSED(30, "支付关闭"), // 注意:全部退款后,还是 REFUND 状态 - ; - - private final Integer status; - private final String name; - - @Override - public int[] array() { - return new int[0]; - } - - /** - * 判断是否支付成功 - * - * @param status 状态 - * @return 是否支付成功 - */ - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - /** - * 判断是否支付成功或者已退款 - * - * @param status 状态 - * @return 是否支付成功或者已退款 - */ - public static boolean isSuccessOrRefund(Integer status) { - return ObjectUtils.equalsAny(status, - SUCCESS.getStatus(), REFUND.getStatus()); - } - - /** - * 判断是否支付关闭 - * - * @param status 状态 - * @return 是否支付关闭 - */ - public static boolean isClosed(Integer status) { - return Objects.equals(status, CLOSED.getStatus()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/refund/PayRefundStatusEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/refund/PayRefundStatusEnum.java deleted file mode 100644 index 4ae14cc67..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/refund/PayRefundStatusEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.refund; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 渠道的退款状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayRefundStatusEnum { - - WAITING(0, "未退款"), - SUCCESS(10, "退款成功"), - FAILURE(20, "退款失败"); - - private final Integer status; - private final String name; - - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - public static boolean isFailure(Integer status) { - return Objects.equals(status, FAILURE.getStatus()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferStatusEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferStatusEnum.java deleted file mode 100644 index f3eff1495..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferStatusEnum.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.transfer; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * @author jason - */ -@Getter -@AllArgsConstructor -public enum PayTransferStatusEnum { - - WAITING(0, "待转账"), - /** - * TODO 转账到银行卡. 会有T+0 T+1 到账的请情况。 还未实现 - */ - IN_PROGRESS(10, "转账进行中"), - - SUCCESS(20, "转账成功"), - /** - * 转账关闭 (失败,或者其它情况) - */ - CLOSED(30, "转账关闭"); - - /** - * 状态 - */ - private final Integer status; - /** - * 状态名 - */ - private final String name; - - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - public static boolean isClosed(Integer status) { - return Objects.equals(status, CLOSED.getStatus()); - } - public static boolean isWaiting(Integer status) { - return Objects.equals(status, WAITING.getStatus()); - } - - /** - * 是否处于待转账或者转账中的状态 - * @param status 状态 - */ - public static boolean isPendingStatus(Integer status) { - return Objects.equals(status, WAITING.getStatus()) || Objects.equals(status, IN_PROGRESS.status); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferTypeEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferTypeEnum.java deleted file mode 100644 index b86b37384..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/transfer/PayTransferTypeEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.transfer; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 转账类型枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum PayTransferTypeEnum implements IntArrayValuable { - - ALIPAY_BALANCE(1, "支付宝余额"), - WX_BALANCE(2, "微信余额"), - BANK_CARD(3, "银行卡"), - WALLET_BALANCE(4, "钱包余额"); - - public static final String ALIPAY_LOGON_ID = "ALIPAY_LOGON_ID"; - public static final String ALIPAY_ACCOUNT_NAME = "ALIPAY_ACCOUNT_NAME"; - - private final Integer type; - private final String name; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PayTransferTypeEnum::getType).toArray(); - - @Override - public int[] array() { - return ARRAYS; - } - - public static PayTransferTypeEnum typeOf(Integer type) { - return ArrayUtil.firstMatch(item -> item.getType().equals(type), values()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java deleted file mode 100644 index 20e0a8b09..000000000 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.enums.wallet; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 钱包交易业务分类 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum PayWalletBizTypeEnum implements IntArrayValuable { - - RECHARGE(1, "充值"), - RECHARGE_REFUND(2, "充值退款"), - PAYMENT(3, "支付"), - PAYMENT_REFUND(4, "支付退款"); - - // TODO 后续增加 - - /** - * 业务分类 - */ - private final Integer type; - /** - * 说明 - */ - private final String description; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PayWalletBizTypeEnum::getType).toArray(); - - @Override - public int[] array() { - return ARRAYS; - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/Dockerfile b/yudao-module-pay/yudao-module-pay-biz/Dockerfile deleted file mode 100644 index 0942ae0da..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-pay-biz -WORKDIR /yudao-module-pay-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-pay-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48085 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-pay/yudao-module-pay-biz/pom.xml b/yudao-module-pay/yudao-module-pay-biz/pom.xml deleted file mode 100644 index bcd5d1ea4..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/pom.xml +++ /dev/null @@ -1,132 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-pay - ${revision} - - 4.0.0 - yudao-module-pay-biz - jar - - ${project.artifactId} - - pay 模块,我们放支付业务,提供业务的支付能力。 - 例如说:商户、应用、支付、退款等等 - - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - - cn.iocoder.cloud - yudao-module-pay-api - ${revision} - - - cn.iocoder.cloud - yudao-module-member-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-pay - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-job - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/PayServerApplication.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/PayServerApplication.java deleted file mode 100644 index dc67f2da3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/PayServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class PayServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(PayServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApiImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApiImpl.java deleted file mode 100644 index a0c0042e3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/order/PayOrderApiImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class PayOrderApiImpl implements PayOrderApi { - - @Resource - private PayOrderService payOrderService; - - @Override - public CommonResult createOrder(PayOrderCreateReqDTO reqDTO) { - return success(payOrderService.createOrder(reqDTO)); - } - - @Override - public CommonResult getOrder(Long id) { - PayOrderDO order = payOrderService.getOrder(id); - return success(PayOrderConvert.INSTANCE.convert2(order)); - } - - @Override - public CommonResult updatePayOrderPrice(Long id, Integer payPrice) { - payOrderService.updatePayOrderPrice(id, payPrice); - return success(true); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApiImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApiImpl.java deleted file mode 100644 index d88fb8dd1..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/refund/PayRefundApiImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.refund; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.convert.refund.PayRefundConvert; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class PayRefundApiImpl implements PayRefundApi { - - @Resource - private PayRefundService payRefundService; - - @Override - public CommonResult createRefund(PayRefundCreateReqDTO reqDTO) { - return success(payRefundService.createPayRefund(reqDTO)); - } - - @Override - public CommonResult getRefund(Long id) { - return success(PayRefundConvert.INSTANCE.convert02(payRefundService.getRefund(id))); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java deleted file mode 100644 index 592a213b3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/PayTransferApiImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay.api.transfer; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -/** - * 转账单 API 实现类 - * - * @author jason - */ -@RestController // 提供 RESTful API 接口,给 Feign 调用 -@Validated -public class PayTransferApiImpl implements PayTransferApi { - - @Resource - private PayTransferService payTransferService; - - @Override - public CommonResult createTransfer(PayTransferCreateReqDTO reqDTO) { - return success(payTransferService.createTransfer(reqDTO)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/PayAppController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/PayAppController.java deleted file mode 100644 index b0d80eac3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/PayAppController.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.*; -import cn.iocoder.yudao.module.pay.convert.app.PayAppConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.*; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Slf4j -@Tag(name = "管理后台 - 支付应用信息") -@RestController -@RequestMapping("/pay/app") -@Validated -public class PayAppController { - - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - - @PostMapping("/create") - @Operation(summary = "创建支付应用信息") - @PreAuthorize("@ss.hasPermission('pay:app:create')") - public CommonResult createApp(@Valid @RequestBody PayAppCreateReqVO createReqVO) { - return success(appService.createApp(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新支付应用信息") - @PreAuthorize("@ss.hasPermission('pay:app:update')") - public CommonResult updateApp(@Valid @RequestBody PayAppUpdateReqVO updateReqVO) { - appService.updateApp(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "更新支付应用状态") - @PreAuthorize("@ss.hasPermission('pay:app:update')") - public CommonResult updateAppStatus(@Valid @RequestBody PayAppUpdateStatusReqVO updateReqVO) { - appService.updateAppStatus(updateReqVO.getId(), updateReqVO.getStatus()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除支付应用信息") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('pay:app:delete')") - public CommonResult deleteApp(@RequestParam("id") Long id) { - appService.deleteApp(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得支付应用信息") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:app:query')") - public CommonResult getApp(@RequestParam("id") Long id) { - PayAppDO app = appService.getApp(id); - return success(PayAppConvert.INSTANCE.convert(app)); - } - - @GetMapping("/page") - @Operation(summary = "获得支付应用信息分页") - @PreAuthorize("@ss.hasPermission('pay:app:query')") - public CommonResult> getAppPage(@Valid PayAppPageReqVO pageVO) { - // 得到应用分页列表 - PageResult pageResult = appService.getAppPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - - // 得到所有的应用编号,查出所有的渠道 - Collection appIds = convertList(pageResult.getList(), PayAppDO::getId); - List channels = channelService.getChannelListByAppIds(appIds); - - // 拼接后返回 - return success(PayAppConvert.INSTANCE.convertPage(pageResult, channels)); - } - - @GetMapping("/list") - @Operation(summary = "获得应用列表") - @PreAuthorize("@ss.hasPermission('pay:merchant:query')") - public CommonResult> getAppList() { - List appListDO = appService.getAppList(); - return success(PayAppConvert.INSTANCE.convertList(appListDO)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java deleted file mode 100644 index 45f29360f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import org.hibernate.validator.constraints.URL; - -import javax.validation.constraints.*; - -/** -* 支付应用信息 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class PayAppBaseVO { - - @Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "小豆") - @NotNull(message = "应用名不能为空") - private String name; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - @NotNull(message = "开启状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "备注", example = "我是一个测试应用") - private String remark; - - @Schema(description = "支付结果的回调地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "http://127.0.0.1:48080/pay-callback") - @NotNull(message = "支付结果的回调地址不能为空") - @URL(message = "支付结果的回调地址必须为 URL 格式") - private String orderNotifyUrl; - - @Schema(description = "退款结果的回调地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "http://127.0.0.1:48080/refund-callback") - @NotNull(message = "退款结果的回调地址不能为空") - @URL(message = "退款结果的回调地址必须为 URL 格式") - private String refundNotifyUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppCreateReqVO.java deleted file mode 100644 index 03cab7d3e..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppCreateReqVO.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -@Schema(description = "管理后台 - 支付应用信息创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppCreateReqVO extends PayAppBaseVO { - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java deleted file mode 100644 index 76b62003c..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.Set; - -@Schema(description = "管理后台 - 支付应用信息分页查询 Response VO,相比于支付信息,还会多出应用渠道的开关信息") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppPageItemRespVO extends PayAppBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "已配置的支付渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "[alipay_pc, alipay_wap]") - private Set channelCodes; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java deleted file mode 100644 index 94ade7ce6..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 支付应用信息分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppPageReqVO extends PageParam { - - @Schema(description = "应用名", example = "小豆") - private String name; - - @Schema(description = "开启状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppRespVO.java deleted file mode 100644 index 9471a2f01..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付应用信息 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppRespVO extends PayAppBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.java deleted file mode 100644 index 5edf2290a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - 支付应用信息更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayAppUpdateReqVO extends PayAppBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long id; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateStatusReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateStatusReqVO.java deleted file mode 100644 index 9b8dad6e1..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateStatusReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.app.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 应用更新状态 Request VO") -@Data -public class PayAppUpdateStatusReqVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long id; - - @Schema(description = "状态,见 SysCommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/PayChannelController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/PayChannelController.java deleted file mode 100644 index 37927a799..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/PayChannelController.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.channel.PayChannelConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 支付渠道") -@RestController -@RequestMapping("/pay/channel") -@Validated -public class PayChannelController { - - @Resource - private PayChannelService channelService; - - @PostMapping("/create") - @Operation(summary = "创建支付渠道 ") - @PreAuthorize("@ss.hasPermission('pay:channel:create')") - public CommonResult createChannel(@Valid @RequestBody PayChannelCreateReqVO createReqVO) { - return success(channelService.createChannel(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新支付渠道 ") - @PreAuthorize("@ss.hasPermission('pay:channel:update')") - public CommonResult updateChannel(@Valid @RequestBody PayChannelUpdateReqVO updateReqVO) { - channelService.updateChannel(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除支付渠道 ") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('pay:channel:delete')") - public CommonResult deleteChannel(@RequestParam("id") Long id) { - channelService.deleteChannel(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得支付渠道") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:channel:query')") - public CommonResult getChannel(@RequestParam(value = "id", required = false) Long id, - @RequestParam(value = "appId", required = false) Long appId, - @RequestParam(value = "code", required = false) String code) { - PayChannelDO channel = null; - if (id != null) { - channel = channelService.getChannel(id); - } else if (appId != null && code != null) { - channel = channelService.getChannelByAppIdAndCode(appId, code); - } - return success(PayChannelConvert.INSTANCE.convert(channel)); - } - - @GetMapping("/get-enable-code-list") - @Operation(summary = "获得指定应用的开启的支付渠道编码列表") - @Parameter(name = "appId", description = "应用编号", required = true, example = "1") - public CommonResult> getEnableChannelCodeList(@RequestParam("appId") Long appId) { - List channels = channelService.getEnableChannelList(appId); - return success(convertSet(channels, PayChannelDO::getCode)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelBaseVO.java deleted file mode 100644 index 1416c9790..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelBaseVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -/** -* 支付渠道 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class PayChannelBaseVO { - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "开启状态不能为空") - @InEnum(CommonStatusEnum.class) - private Integer status; - - @Schema(description = "备注", example = "我是小备注") - private String remark; - - @Schema(description = "渠道费率,单位:百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "渠道费率,单位:百分比不能为空") - private Double feeRate; - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long appId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelCreateReqVO.java deleted file mode 100644 index 08073827a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 支付渠道 创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayChannelCreateReqVO extends PayChannelBaseVO { - - @Schema(description = "渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "alipay_pc") - @NotNull(message = "渠道编码不能为空") - private String code; - - @Schema(description = "渠道配置的 json 字符串") - @NotBlank(message = "渠道配置不能为空") - private String config; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelRespVO.java deleted file mode 100644 index dafd29ec9..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付渠道 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayChannelRespVO extends PayChannelBaseVO { - - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private LocalDateTime createTime; - - @Schema(description = "渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "alipay_pc") - private String code; - - @Schema(description = "配置", requiredMode = Schema.RequiredMode.REQUIRED) - private String config; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelUpdateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelUpdateReqVO.java deleted file mode 100644 index 39bf83eb0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - 支付渠道 更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayChannelUpdateReqVO extends PayChannelBaseVO { - - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "商户编号不能为空") - private Long id; - - @Schema(description = "渠道配置的json字符串") - @NotBlank(message = "渠道配置不能为空") - private String config; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoOrderController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoOrderController.java deleted file mode 100644 index 59edf04e6..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoOrderController.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.PayDemoOrderCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.PayDemoOrderRespVO; -import cn.iocoder.yudao.module.pay.convert.demo.PayDemoOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; -import cn.iocoder.yudao.module.pay.service.demo.PayDemoOrderService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.annotation.security.PermitAll; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 示例订单") -@RestController -@RequestMapping("/pay/demo-order") -@Validated -public class PayDemoOrderController { - - @Resource - private PayDemoOrderService payDemoOrderService; - - @PostMapping("/create") - @Operation(summary = "创建示例订单") - public CommonResult createDemoOrder(@Valid @RequestBody PayDemoOrderCreateReqVO createReqVO) { - return success(payDemoOrderService.createDemoOrder(getLoginUserId(), createReqVO)); - } - - @GetMapping("/page") - @Operation(summary = "获得示例订单分页") - public CommonResult> getDemoOrderPage(@Valid PageParam pageVO) { - PageResult pageResult = payDemoOrderService.getDemoOrderPage(pageVO); - return success(PayDemoOrderConvert.INSTANCE.convertPage(pageResult)); - } - - @PostMapping("/update-paid") - @Operation(summary = "更新示例订单为已支付") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录,安全由 PayDemoOrderService 内部校验实现 - public CommonResult updateDemoOrderPaid(@RequestBody PayOrderNotifyReqDTO notifyReqDTO) { - payDemoOrderService.updateDemoOrderPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), - notifyReqDTO.getPayOrderId()); - return success(true); - } - - @PutMapping("/refund") - @Operation(summary = "发起示例订单的退款") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult refundDemoOrder(@RequestParam("id") Long id) { - payDemoOrderService.refundDemoOrder(id, getClientIP()); - return success(true); - } - - @PostMapping("/update-refunded") - @Operation(summary = "更新示例订单为已退款") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录,安全由 PayDemoOrderService 内部校验实现 - public CommonResult updateDemoOrderRefunded(@RequestBody PayRefundNotifyReqDTO notifyReqDTO) { - payDemoOrderService.updateDemoOrderRefunded(Long.valueOf(notifyReqDTO.getMerchantOrderId()), - notifyReqDTO.getPayRefundId()); - return success(true); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoTransferController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoTransferController.java deleted file mode 100644 index e3411d40c..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/PayDemoTransferController.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.service.demo.PayDemoTransferService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - 示例转账单") -@RestController -@RequestMapping("/pay/demo-transfer") -@Validated -public class PayDemoTransferController { - @Resource - private PayDemoTransferService demoTransferService; - - @PostMapping("/create") - @Operation(summary = "创建示例转账订单") - public CommonResult createDemoOrder(@Valid @RequestBody PayDemoTransferCreateReqVO createReqVO) { - return success(demoTransferService.createDemoTransfer(getLoginUserId(), createReqVO)); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/PayDemoOrderCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/PayDemoOrderCreateReqVO.java deleted file mode 100644 index 9960ada48..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/PayDemoOrderCreateReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo.vo; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 示例订单创建 Request VO") -@Data -public class PayDemoOrderCreateReqVO { - - @Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17682") - @NotNull(message = "商品编号不能为空") - private Long spuId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/PayDemoOrderRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/PayDemoOrderRespVO.java deleted file mode 100644 index 3404844dc..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/PayDemoOrderRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -/** -* 示例订单 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class PayDemoOrderRespVO { - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23199") - private Long userId; - - @Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17682") - private Long spuId; - - @Schema(description = "商家备注", example = "李四") - private String spuName; - - @Schema(description = "价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "30381") - private Integer price; - - @Schema(description = "是否已支付", requiredMode = Schema.RequiredMode.REQUIRED) - private Boolean payStatus; - - @Schema(description = "支付订单编号", example = "16863") - private Long payOrderId; - - @Schema(description = "订单支付时间") - private LocalDateTime payTime; - - @Schema(description = "支付渠道", example = "alipay_qr") - private String payChannelCode; - - @Schema(description = "支付退款编号", example = "23366") - private Long payRefundId; - - @Schema(description = "退款金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "14039") - private Integer refundPrice; - - @Schema(description = "退款时间") - private LocalDateTime refundTime; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java deleted file mode 100644 index 41bafe676..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/demo/vo/transfer/PayDemoTransferCreateReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -/** - * @author jason - */ -@Schema(description = "管理后台 - 示例转账单创建 Request VO") -@Data -public class PayDemoTransferCreateReqVO { - - @Schema(description = "转账类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "转账类型不能为空") - @InEnum(PayTransferTypeEnum.class) - private Integer type; - - @NotNull(message = "转账金额不能为空") - @Min(value = 1, message = "转账金额必须大于零") - private Integer price; - - // TODO @jason:感觉这个动态字段,晚点改;可能要讨论下怎么搞好; - @Schema(description = "收款方信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "{'ALIPAY_LOGON_ID':'xxxx'}") - @NotEmpty(message = "收款方信息不能为空") - private Map payeeInfo; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java deleted file mode 100644 index f74daa5fc..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.notify; - -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskDetailRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskRespVO; -import cn.iocoder.yudao.module.pay.convert.notify.PayNotifyTaskConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.annotation.security.PermitAll; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.CHANNEL_NOT_FOUND; - -@Tag(name = "管理后台 - 回调通知") -@RestController -@RequestMapping("/pay/notify") -@Validated -@Slf4j -public class PayNotifyController { - - @Resource - private PayOrderService orderService; - @Resource - private PayRefundService refundService; - @Resource - private PayNotifyService notifyService; - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - - @PostMapping(value = "/order/{channelId}") - @Operation(summary = "支付渠道的统一【支付】回调") - @PermitAll - public String notifyOrder(@PathVariable("channelId") Long channelId, - @RequestParam(required = false) Map params, - @RequestBody(required = false) String body) { - log.info("[notifyOrder][channelId({}) 回调数据({}/{})]", channelId, params, body); - // 1. 校验支付渠道是否存在 - PayClient payClient = channelService.getPayClient(channelId); - if (payClient == null) { - log.error("[notifyCallback][渠道编号({}) 找不到对应的支付客户端]", channelId); - throw exception(CHANNEL_NOT_FOUND); - } - - // 2. 解析通知数据 - PayOrderRespDTO notify = payClient.parseOrderNotify(params, body); - orderService.notifyOrder(channelId, notify); - return "success"; - } - - @PostMapping(value = "/refund/{channelId}") - @Operation(summary = "支付渠道的统一【退款】回调") - @PermitAll - public String notifyRefund(@PathVariable("channelId") Long channelId, - @RequestParam(required = false) Map params, - @RequestBody(required = false) String body) { - log.info("[notifyRefund][channelId({}) 回调数据({}/{})]", channelId, params, body); - // 1. 校验支付渠道是否存在 - PayClient payClient = channelService.getPayClient(channelId); - if (payClient == null) { - log.error("[notifyCallback][渠道编号({}) 找不到对应的支付客户端]", channelId); - throw exception(CHANNEL_NOT_FOUND); - } - - // 2. 解析通知数据 - PayRefundRespDTO notify = payClient.parseRefundNotify(params, body); - refundService.notifyRefund(channelId, notify); - return "success"; - } - - @GetMapping("/get-detail") - @Operation(summary = "获得回调通知的明细") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:notify:query')") - public CommonResult getNotifyTaskDetail(@RequestParam("id") Long id) { - PayNotifyTaskDO task = notifyService.getNotifyTask(id); - if (task == null) { - return success(null); - } - // 拼接返回 - PayAppDO app = appService.getApp(task.getAppId()); - List logs = notifyService.getNotifyLogList(id); - return success(PayNotifyTaskConvert.INSTANCE.convert(task, app, logs)); - } - - @GetMapping("/page") - @Operation(summary = "获得回调通知分页") - @PreAuthorize("@ss.hasPermission('pay:notify:query')") - public CommonResult> getNotifyTaskPage(@Valid PayNotifyTaskPageReqVO pageVO) { - PageResult pageResult = notifyService.getNotifyTaskPage(pageVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return success(PageResult.empty()); - } - // 拼接返回 - Map appMap = appService.getAppMap(convertList(pageResult.getList(), PayNotifyTaskDO::getAppId)); - return success(PayNotifyTaskConvert.INSTANCE.convertPage(pageResult, appMap)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskBaseVO.java deleted file mode 100644 index 1e623751b..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskBaseVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.notify.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 回调通知 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class PayNotifyTaskBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10636") - private Long appId; - - @Schema(description = "通知类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Byte type; - - @Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6722") - private Long dataId; - - @Schema(description = "通知状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Byte status; - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "26697") - private String merchantOrderId; - - @Schema(description = "下一次通知时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime nextNotifyTime; - - @Schema(description = "最后一次执行时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime lastExecuteTime; - - @Schema(description = "当前通知次数", requiredMode = Schema.RequiredMode.REQUIRED) - private Byte notifyTimes; - - @Schema(description = "最大可通知次数", requiredMode = Schema.RequiredMode.REQUIRED) - private Byte maxNotifyTimes; - - @Schema(description = "异步通知地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn") - private String notifyUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskDetailRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskDetailRespVO.java deleted file mode 100644 index 7c75613e2..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskDetailRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ - -package cn.iocoder.yudao.module.pay.controller.admin.notify.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; -import java.util.List; - -@Schema(description = "管理后台 - 回调通知的明细 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayNotifyTaskDetailRespVO extends PayNotifyTaskBaseVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3380") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime updateTime; - - @Schema(description = "应用名称", example = "wx_pay") - private String appName; - - @Schema(description = "回调日志列表") - private List logs; - - @Schema(description = "管理后台 - 回调日志") - @Data - public static class Log { - - @Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8848") - private Long id; - - @Schema(description = "通知状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Byte status; - - @Schema(description = "当前通知次数", requiredMode = Schema.RequiredMode.REQUIRED) - private Byte notifyTimes; - - @Schema(description = "HTTP 响应结果", requiredMode = Schema.RequiredMode.REQUIRED) - private String response; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskPageReqVO.java deleted file mode 100644 index 003d2fb33..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskPageReqVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.notify.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 回调通知分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayNotifyTaskPageReqVO extends PageParam { - - @Schema(description = "应用编号", example = "10636") - private Long appId; - - @Schema(description = "通知类型", example = "2") - private Integer type; - - @Schema(description = "数据编号", example = "6722") - private Long dataId; - - @Schema(description = "通知状态", example = "1") - private Integer status; - - @Schema(description = "商户订单编号", example = "26697") - private String merchantOrderId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskRespVO.java deleted file mode 100644 index d7f7fe6fb..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/vo/PayNotifyTaskRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.notify.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 回调通知 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayNotifyTaskRespVO extends PayNotifyTaskBaseVO { - - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3380") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "应用名称", example = "wx_pay") - private String appName; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java deleted file mode 100755 index 55e08ce1d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java +++ /dev/null @@ -1,127 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order; - -import cn.hutool.core.collection.CollectionUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.*; -import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import com.google.common.collect.Maps; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType; - -@Tag(name = "管理后台 - 支付订单") -@RestController -@RequestMapping("/pay/order") -@Validated -public class PayOrderController { - - @Resource - private PayOrderService orderService; - @Resource - private PayAppService appService; - - @GetMapping("/get") - @Operation(summary = "获得支付订单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:order:query')") - public CommonResult getOrder(@RequestParam("id") Long id) { - return success(PayOrderConvert.INSTANCE.convert(orderService.getOrder(id))); - } - - @GetMapping("/get-detail") - @Operation(summary = "获得支付订单详情") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:order:query')") - public CommonResult getOrderDetail(@RequestParam("id") Long id) { - PayOrderDO order = orderService.getOrder(id); - if (order == null) { - return success(null); - } - - // 拼接返回 - PayAppDO app = appService.getApp(order.getAppId()); - PayOrderExtensionDO orderExtension = orderService.getOrderExtension(order.getExtensionId()); - return success(PayOrderConvert.INSTANCE.convert(order, orderExtension, app)); - } - - @PostMapping("/submit") - @Operation(summary = "提交支付订单") - public CommonResult submitPayOrder(@RequestBody PayOrderSubmitReqVO reqVO) { - // 1. 钱包支付事,需要额外传 user_id 和 user_type - if (Objects.equals(reqVO.getChannelCode(), PayChannelEnum.WALLET.getCode())) { - Map channelExtras = reqVO.getChannelExtras() == null ? - Maps.newHashMapWithExpectedSize(2) : reqVO.getChannelExtras(); - channelExtras.put(WalletPayClient.USER_ID_KEY, String.valueOf(getLoginUserId())); - channelExtras.put(WalletPayClient.USER_TYPE_KEY, String.valueOf(getLoginUserType())); - reqVO.setChannelExtras(channelExtras); - } - - // 2. 提交支付 - PayOrderSubmitRespVO respVO = orderService.submitOrder(reqVO, getClientIP()); - return success(respVO); - } - - @GetMapping("/page") - @Operation(summary = "获得支付订单分页") - @PreAuthorize("@ss.hasPermission('pay:order:query')") - public CommonResult> getOrderPage(@Valid PayOrderPageReqVO pageVO) { - PageResult pageResult = orderService.getOrderPage(pageVO); - if (CollectionUtil.isEmpty(pageResult.getList())) { - return success(new PageResult<>(pageResult.getTotal())); - } - - // 拼接返回 - Map appMap = appService.getAppMap(convertList(pageResult.getList(), PayOrderDO::getAppId)); - return success(PayOrderConvert.INSTANCE.convertPage(pageResult, appMap)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出支付订单 Excel") - @PreAuthorize("@ss.hasPermission('pay:order:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportOrderExcel(@Valid PayOrderExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = orderService.getOrderList(exportReqVO); - if (CollectionUtil.isEmpty(list)) { - ExcelUtils.write(response, "支付订单.xls", "数据", - PayOrderExcelVO.class, new ArrayList<>()); - return; - } - - // 拼接返回 - Map appMap = appService.getAppMap(convertList(list, PayOrderDO::getAppId)); - List excelList = PayOrderConvert.INSTANCE.convertList(list, appMap); - // 导出 Excel - ExcelUtils.write(response, "支付订单.xls", "数据", PayOrderExcelVO.class, excelList); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java deleted file mode 100755 index 568f84459..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -/** - * 支付订单 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - * - * @author aquan - */ -@Data -public class PayOrderBaseVO { - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "应用编号不能为空") - private Long appId; - - @Schema(description = "渠道编号", example = "2048") - private Long channelId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") - @NotNull(message = "商户订单编号不能为空") - private String merchantOrderId; - - @Schema(description = "商品标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆") - @NotNull(message = "商品标题不能为空") - private String subject; - - @Schema(description = "商品描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是土豆") - @NotNull(message = "商品描述不能为空") - private String body; - - @Schema(description = "异步通知地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "http://127.0.0.1:48080/pay/notify") - @NotNull(message = "异步通知地址不能为空") - private String notifyUrl; - - @Schema(description = "支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "支付金额,单位:分不能为空") - private Long price; - - @Schema(description = "渠道手续费,单位:百分比", example = "10") - private Double channelFeeRate; - - @Schema(description = "渠道手续金额,单位:分", example = "100") - private Integer channelFeePrice; - - @Schema(description = "支付状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "支付状态不能为空") - private Integer status; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - @NotNull(message = "用户 IP不能为空") - private String userIp; - - @Schema(description = "订单失效时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "订单失效时间不能为空") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime expireTime; - - @Schema(description = "订单支付成功时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime successTime; - - @Schema(description = "支付成功的订单拓展单编号", example = "50") - private Long extensionId; - - @Schema(description = "支付订单号", example = "2048888") - private String no; - - @Schema(description = "退款总金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @NotNull(message = "退款总金额,单位:分不能为空") - private Long refundPrice; - - @Schema(description = "渠道用户编号", example = "2048") - private String channelUserId; - - @Schema(description = "渠道订单号", example = "4096") - private String channelOrderNo; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderDetailsRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderDetailsRespVO.java deleted file mode 100644 index a4fe4632f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderDetailsRespVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付订单详细信息 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayOrderDetailsRespVO extends PayOrderBaseVO { - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") - private String appName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime updateTime; - - /** - * 支付订单扩展 - */ - private PayOrderExtension extension; - - @Data - @Schema(description = "支付订单扩展") - public static class PayOrderExtension { - - @Schema(description = "支付订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String no; - - @Schema(description = "支付异步通知的内容") - private String channelNotifyData; - - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExcelVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExcelVO.java deleted file mode 100755 index 5dc17a0f0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExcelVO.java +++ /dev/null @@ -1,67 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.framework.excel.core.convert.MoneyConvert; -import cn.iocoder.yudao.module.pay.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 支付订单 Excel VO - * - * @author aquan - */ -@Data -public class PayOrderExcelVO { - - @ExcelProperty("编号") - private Long id; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @ExcelProperty(value = "支付金额", converter = MoneyConvert.class) - private Integer price; - - @ExcelProperty(value = "退款金额", converter = MoneyConvert.class) - private Integer refundPrice; - - @ExcelProperty(value = "手续金额", converter = MoneyConvert.class) - private Integer channelFeePrice; - - @ExcelProperty("商户单号") - private String merchantOrderId; - - @ExcelProperty(value = "支付单号") - private String no; - - @ExcelProperty("渠道单号") - private String channelOrderNo; - - @ExcelProperty(value = "支付状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.ORDER_STATUS) - private Integer status; - - @ExcelProperty(value = "渠道编号名称", converter = DictConvert.class) - @DictFormat(DictTypeConstants.CHANNEL_CODE) - private String channelCode; - - @ExcelProperty("订单支付成功时间") - private LocalDateTime successTime; - - @ExcelProperty("订单失效时间") - private LocalDateTime expireTime; - - @ExcelProperty(value = "应用名称") - private String appName; - - @ExcelProperty("商品标题") - private String subject; - - @ExcelProperty("商品描述") - private String body; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExportReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExportReqVO.java deleted file mode 100755 index 9e4d20b91..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExportReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 支付订单 Excel 导出 Request VO,参数和 PayOrderPageReqVO 是一致的") -@Data -public class PayOrderExportReqVO { - - @Schema(description = "应用编号", example = "1024") - private Long appId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户订单编号", example = "4096") - private String merchantOrderId; - - @Schema(description = "渠道编号", example = "1888") - private String channelOrderNo; - - @Schema(description = "支付单号", example = "2014888") - private String no; - - @Schema(description = "支付状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageItemRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageItemRespVO.java deleted file mode 100755 index 05411c913..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageItemRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付订单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayOrderPageItemRespVO extends PayOrderBaseVO { - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "应用名称", example = "wx_pay") - private String appName; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageReqVO.java deleted file mode 100755 index f7ff801cb..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageReqVO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 支付订单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayOrderPageReqVO extends PageParam { - - @Schema(description = "应用编号", example = "1024") - private Long appId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户订单编号", example = "4096") - private String merchantOrderId; - - @Schema(description = "渠道编号", example = "1888") - private String channelOrderNo; - - @Schema(description = "支付单号", example = "2014888") - private String no; - - @Schema(description = "支付状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderRespVO.java deleted file mode 100644 index d48a4db08..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付订单 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayOrderRespVO extends PayOrderBaseVO { - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitReqVO.java deleted file mode 100644 index ffda105b7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.hibernate.validator.constraints.URL; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@Schema(description = "管理后台 - 支付订单提交 Request VO") -@Data -public class PayOrderSubmitReqVO { - - @Schema(description = "支付单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "支付单编号不能为空") - private Long id; - - @Schema(description = "支付渠道", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx_pub") - @NotEmpty(message = "支付渠道不能为空") - private String channelCode; - - @Schema(description = "支付渠道的额外参数,例如说,微信公众号需要传递 openid 参数") - private Map channelExtras; - - @Schema(description = "展示模式", example = "url") // 参见 {@link PayDisplayModeEnum} 枚举。如果不传递,则每个支付渠道使用默认的方式 - private String displayMode; - - @Schema(description = "回跳地址") - @URL(message = "回跳地址的格式必须是 URL") - private String returnUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitRespVO.java deleted file mode 100644 index 8dcd9df2f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderSubmitRespVO.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.order.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 支付订单提交 Response VO") -@Data -public class PayOrderSubmitRespVO { - - @Schema(description = "支付状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") // 参见 PayOrderStatusEnum 枚举 - private Integer status; - - @Schema(description = "展示模式", requiredMode = Schema.RequiredMode.REQUIRED, example = "url") // 参见 PayDisplayModeEnum 枚举 - private String displayMode; - @Schema(description = "展示内容", requiredMode = Schema.RequiredMode.REQUIRED) - private String displayContent; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java deleted file mode 100755 index 7dbef49be..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund; - -import cn.hutool.core.collection.CollectionUtil; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.*; -import cn.iocoder.yudao.module.pay.convert.refund.PayRefundConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -@Tag(name = "管理后台 - 退款订单") -@RestController -@RequestMapping("/pay/refund") -@Validated -public class PayRefundController { - - @Resource - private PayRefundService refundService; - @Resource - private PayAppService appService; - - @GetMapping("/get") - @Operation(summary = "获得退款订单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:refund:query')") - public CommonResult getRefund(@RequestParam("id") Long id) { - PayRefundDO refund = refundService.getRefund(id); - if (refund == null) { - return success(new PayRefundDetailsRespVO()); - } - - // 拼接数据 - PayAppDO app = appService.getApp(refund.getAppId()); - return success(PayRefundConvert.INSTANCE.convert(refund, app)); - } - - @GetMapping("/page") - @Operation(summary = "获得退款订单分页") - @PreAuthorize("@ss.hasPermission('pay:refund:query')") - public CommonResult> getRefundPage(@Valid PayRefundPageReqVO pageVO) { - PageResult pageResult = refundService.getRefundPage(pageVO); - if (CollectionUtil.isEmpty(pageResult.getList())) { - return success(new PageResult<>(pageResult.getTotal())); - } - - // 处理应用ID数据 - Map appMap = appService.getAppMap(convertList(pageResult.getList(), PayRefundDO::getAppId)); - return success(PayRefundConvert.INSTANCE.convertPage(pageResult, appMap)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出退款订单 Excel") - @PreAuthorize("@ss.hasPermission('pay:refund:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportRefundExcel(@Valid PayRefundExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = refundService.getRefundList(exportReqVO); - if (CollectionUtil.isEmpty(list)) { - ExcelUtils.write(response, "退款订单.xls", "数据", - PayRefundExcelVO.class, new ArrayList<>()); - return; - } - - // 拼接返回 - Map appMap = appService.getAppMap(convertList(list, PayRefundDO::getAppId)); - List excelList = PayRefundConvert.INSTANCE.convertList(list, appMap); - // 导出 Excel - ExcelUtils.write(response, "退款订单.xls", "数据", PayRefundExcelVO.class, excelList); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundBaseVO.java deleted file mode 100755 index 25cadf478..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundBaseVO.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -/** -* 退款订单 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class PayRefundBaseVO { - - @Schema(description = "外部退款号", requiredMode = Schema.RequiredMode.REQUIRED, example = "110") - private String no; - - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long appId; - - @Schema(description = "渠道编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") - private Long channelId; - - @Schema(description = "渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx_app") - private String channelCode; - - @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long orderId; - - // ========== 商户相关字段 ========== - - @Schema(description = "商户订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "225") - private String merchantOrderId; - - @Schema(description = "商户退款订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") - private String merchantRefundId; - - @Schema(description = "异步通知地址", requiredMode = Schema.RequiredMode.REQUIRED) - private String notifyUrl; - - // ========== 退款相关字段 ========== - - @Schema(description = "退款状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") - private Integer status; - - @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long payPrice; - - @Schema(description = "退款金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") - private Long refundPrice; - - @Schema(description = "退款原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "我要退了") - private String reason; - - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1") - private String userIp; - - // ========== 渠道相关字段 ========== - - @Schema(description = "渠道订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "233") - private String channelOrderNo; - - @Schema(description = "渠道退款单号", example = "2022") - private String channelRefundNo; - - @Schema(description = "退款成功时间") - private LocalDateTime successTime; - - @Schema(description = "调用渠道的错误码") - private String channelErrorCode; - - @Schema(description = "调用渠道的错误提示") - private String channelErrorMsg; - - @Schema(description = "支付渠道的额外参数") - private String channelNotifyData; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundDetailsRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundDetailsRespVO.java deleted file mode 100755 index 8f50a3a13..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundDetailsRespVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 退款订单详情 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayRefundDetailsRespVO extends PayRefundBaseVO { - - @Schema(description = "支付退款编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是芋艿") - private String appName; - - @Schema(description = "支付订单", requiredMode = Schema.RequiredMode.REQUIRED) - private Order order; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - - @Schema(description = "更新时间") - private LocalDateTime updateTime; - - @Schema(description = "管理后台 - 支付订单") - @Data - public static class Order { - - @Schema(description = "商品标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆") - private String subject; - - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExcelVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExcelVO.java deleted file mode 100755 index 758b6b6b0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExcelVO.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.framework.excel.core.convert.MoneyConvert; -import cn.iocoder.yudao.module.pay.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 退款订单 Excel VO - * - * @author aquan - */ -@Data -public class PayRefundExcelVO { - - @ExcelProperty("支付退款编号") - private Long id; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - - @ExcelProperty(value = "支付金额", converter = MoneyConvert.class) - private Integer payPrice; - - @ExcelProperty(value = "退款金额", converter = MoneyConvert.class) - private Integer refundPrice; - - @ExcelProperty("商户退款单号") - private String merchantRefundId; - @ExcelProperty("退款单号") - private String no; - @ExcelProperty("渠道退款单号") - private String channelRefundNo; - - @ExcelProperty("商户支付单号") - private String merchantOrderId; - @ExcelProperty("渠道支付单号") - private String channelOrderNo; - - @ExcelProperty(value = "退款状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.REFUND_STATUS) - private Integer status; - - @ExcelProperty(value = "退款渠道", converter = DictConvert.class) - @DictFormat(DictTypeConstants.CHANNEL_CODE) - private String channelCode; - - @ExcelProperty("成功时间") - private LocalDateTime successTime; - - @ExcelProperty(value = "支付应用") - private String appName; - - @ExcelProperty("退款原因") - private String reason; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExportReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExportReqVO.java deleted file mode 100755 index 645816ee2..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExportReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 退款订单 Excel 导出 Request VO,参数和 PayRefundPageReqVO 是一致的") -@Data -public class PayRefundExportReqVO { - - @Schema(description = "应用编号", example = "1024") - private Long appId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户支付单号", example = "10") - private String merchantOrderId; - - @Schema(description = "商户退款单号", example = "20") - private String merchantRefundId; - - @Schema(description = "渠道支付单号", example = "30") - private String channelOrderNo; - - @Schema(description = "渠道退款单号", example = "40") - private String channelRefundNo; - - @Schema(description = "退款状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageItemRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageItemRespVO.java deleted file mode 100755 index 27c1285cc..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageItemRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 退款订单分页查询 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayRefundPageItemRespVO extends PayRefundBaseVO { - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是芋艿") - private String appName; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageReqVO.java deleted file mode 100755 index 7ff1530f0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageReqVO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.refund.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 退款订单分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayRefundPageReqVO extends PageParam { - - @Schema(description = "应用编号", example = "1024") - private Long appId; - - @Schema(description = "渠道编码", example = "wx_app") - private String channelCode; - - @Schema(description = "商户支付单号", example = "10") - private String merchantOrderId; - - @Schema(description = "商户退款单号", example = "20") - private String merchantRefundId; - - @Schema(description = "渠道支付单号", example = "30") - private String channelOrderNo; - - @Schema(description = "渠道退款单号", example = "40") - private String channelRefundNo; - - @Schema(description = "退款状态", example = "0") - private Integer status; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java deleted file mode 100644 index 6d8592058..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/PayTransferController.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.transfer; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferSubmitRespVO; -import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; - -@Tag(name = "管理后台 - 转账单") -@RestController -@RequestMapping("/pay/transfer") -@Validated -public class PayTransferController { - - @Resource - private PayTransferService payTransferService; - - @PostMapping("/submit") - @Operation(summary = "提交转账订单") - // TODO @jason:权限的设置, 管理后台页面加的时候加一下 - public CommonResult submitPayTransfer(@Valid @RequestBody PayTransferSubmitReqVO reqVO) { - PayTransferSubmitRespVO respVO = payTransferService.submitTransfer(reqVO, getClientIP()); - return success(respVO); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferSubmitReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferSubmitReqVO.java deleted file mode 100644 index 36e67ce01..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferSubmitReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.transfer.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@Schema(description = "管理后台 - 转账单提交 Request VO") -@Data -public class PayTransferSubmitReqVO { - - @Schema(description = "转账单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "转账单编号不能为空") - private Long id; - - @Schema(description = "转账渠道", requiredMode = Schema.RequiredMode.REQUIRED, example = "alipay_transfer") - @NotEmpty(message = "转账渠道不能为空") - private String channelCode; - - @Schema(description = "转账渠道的额外参数") - private Map channelExtras; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferSubmitRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferSubmitRespVO.java deleted file mode 100644 index fef296f09..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/transfer/vo/PayTransferSubmitRespVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.transfer.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 转账单提交 Response VO") -@Data -public class PayTransferSubmitRespVO { - - @Schema(description = "转账状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 参见 PayTransferStatusEnum 枚举 - private Integer status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java deleted file mode 100644 index 8fcb668ac..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet; - -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletUserReqVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.enums.UserTypeEnum.MEMBER; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; - -@Tag(name = "管理后台 - 用户钱包") -@RestController -@RequestMapping("/pay/wallet") -@Validated -@Slf4j -public class PayWalletController { - - @Resource - private PayWalletService payWalletService; - @Resource - private MemberUserApi memberUserApi; - - @GetMapping("/get") - @PreAuthorize("@ss.hasPermission('pay:wallet:query')") - @Operation(summary = "获得用户钱包明细") - public CommonResult getWallet(PayWalletUserReqVO reqVO) { - PayWalletDO wallet = payWalletService.getOrCreateWallet(reqVO.getUserId(), MEMBER.getValue()); - // TODO jason:如果为空,返回给前端只要 null 就可以了 - MemberUserRespDTO memberUser = memberUserApi.getUser(reqVO.getUserId()).getCheckedData(); - String nickname = memberUser == null ? "" : memberUser.getNickname(); - String avatar = memberUser == null ? "" : memberUser.getAvatar(); - return success(PayWalletConvert.INSTANCE.convert02(nickname, avatar, wallet)); - } - - @GetMapping("/page") - @Operation(summary = "获得会员钱包分页") - @PreAuthorize("@ss.hasPermission('pay:wallet:query')") - public CommonResult> getWalletPage(@Valid PayWalletPageReqVO pageVO) { - if (StrUtil.isNotEmpty(pageVO.getNickname())) { - List users = memberUserApi.getUserListByNickname(pageVO.getNickname()).getCheckedData(); - pageVO.setUserIds(convertSet(users, MemberUserRespDTO::getId)); - } - // TODO @jason:管理员也可以先查询下。。 - // 暂时支持查询 userType 会员类型。管理员类型还不知道使用场景 - PageResult pageResult = payWalletService.getWalletPage(MEMBER.getValue(),pageVO); - if (CollectionUtil.isEmpty(pageResult.getList())) { - return success(new PageResult<>(pageResult.getTotal())); - } - List users = memberUserApi.getUserList(convertList(pageResult.getList(), PayWalletDO::getUserId)).getCheckedData(); - Map userMap = convertMap(users, MemberUserRespDTO::getId); - return success(PayWalletConvert.INSTANCE.convertPage(pageResult, userMap)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargeController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargeController.java deleted file mode 100644 index 97942c319..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargeController.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.annotation.security.PermitAll; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; - -@Tag(name = "管理后台 - 钱包充值") -@RestController -@RequestMapping("/pay/wallet-recharge") -@Validated -@Slf4j -public class PayWalletRechargeController { - - @Resource - private PayWalletRechargeService walletRechargeService; - - @PostMapping("/update-paid") - @Operation(summary = "更新钱包充值为已充值") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录, 内部校验实现 - public CommonResult updateWalletRechargerPaid(@Valid @RequestBody PayOrderNotifyReqDTO notifyReqDTO) { - walletRechargeService.updateWalletRechargerPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), - notifyReqDTO.getPayOrderId()); - return success(true); - } - - // TODO @jason:发起退款,要 post 操作哈; - @GetMapping("/refund") - @Operation(summary = "发起钱包充值退款") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult refundWalletRecharge(@RequestParam("id") Long id) { - walletRechargeService.refundWalletRecharge(id, getClientIP()); - return success(true); - } - - @PostMapping("/update-refunded") - @Operation(summary = "更新钱包充值为已退款") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob - @PermitAll // 无需登录, 内部校验实现 - public CommonResult updateWalletRechargeRefunded(@RequestBody PayRefundNotifyReqDTO notifyReqDTO) { - walletRechargeService.updateWalletRechargeRefunded( - Long.valueOf(notifyReqDTO.getMerchantOrderId()), notifyReqDTO.getPayRefundId()); - return success(true); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargePackageController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargePackageController.java deleted file mode 100644 index c60127fe7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargePackageController.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.wallet.WalletRechargePackageConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargePackageService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - - -@Tag(name = "管理后台 - 钱包充值套餐") -@RestController -@RequestMapping("/pay/wallet-recharge-package") -@Validated -public class PayWalletRechargePackageController { - - @Resource - private PayWalletRechargePackageService walletRechargePackageService; - - @PostMapping("/create") - @Operation(summary = "创建钱包充值套餐") - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:create')") - public CommonResult createWalletRechargePackage(@Valid @RequestBody WalletRechargePackageCreateReqVO createReqVO) { - return success(walletRechargePackageService.createWalletRechargePackage(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新钱包充值套餐") - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:update')") - public CommonResult updateWalletRechargePackage(@Valid @RequestBody WalletRechargePackageUpdateReqVO updateReqVO) { - walletRechargePackageService.updateWalletRechargePackage(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除钱包充值套餐") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:delete')") - public CommonResult deleteWalletRechargePackage(@RequestParam("id") Long id) { - walletRechargePackageService.deleteWalletRechargePackage(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得钱包充值套餐") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:query')") - public CommonResult getWalletRechargePackage(@RequestParam("id") Long id) { - PayWalletRechargePackageDO walletRechargePackage = walletRechargePackageService.getWalletRechargePackage(id); - return success(WalletRechargePackageConvert.INSTANCE.convert(walletRechargePackage)); - } - - @GetMapping("/page") - @Operation(summary = "获得钱包充值套餐分页") - @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:query')") - public CommonResult> getWalletRechargePackagePage(@Valid WalletRechargePackagePageReqVO pageVO) { - PageResult pageResult = walletRechargePackageService.getWalletRechargePackagePage(pageVO); - return success(WalletRechargePackageConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java deleted file mode 100644 index 37dd51642..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionRespVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - 钱包余额明细") -@RestController -@RequestMapping("/pay/wallet-transaction") -@Validated -@Slf4j -public class PayWalletTransactionController { - - @Resource - private PayWalletTransactionService payWalletTransactionService; - - @GetMapping("/page") - @Operation(summary = "获得钱包流水分页") - @PreAuthorize("@ss.hasPermission('pay:wallet:query')") - public CommonResult> getWalletTransactionPage( - @Valid PayWalletTransactionPageReqVO pageReqVO) { - PageResult result = payWalletTransactionService.getWalletTransactionPage(pageReqVO); - return success(PayWalletTransactionConvert.INSTANCE.convertPage2(result)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageBaseVO.java deleted file mode 100644 index c3f58e1da..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageBaseVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 充值套餐 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class WalletRechargePackageBaseVO { - - @Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") - @NotNull(message = "套餐名不能为空") - private String name; - - @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "16454") - @NotNull(message = "支付金额不能为空") - private Integer payPrice; - - @Schema(description = "赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20887") - @NotNull(message = "赠送金额不能为空") - private Integer bonusPrice; - - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "状态不能为空") - private Byte status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageCreateReqVO.java deleted file mode 100644 index 4232a9983..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageCreateReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -@Schema(description = "管理后台 - 充值套餐创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WalletRechargePackageCreateReqVO extends WalletRechargePackageBaseVO { - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackagePageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackagePageReqVO.java deleted file mode 100644 index 346e85902..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackagePageReqVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 充值套餐分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WalletRechargePackagePageReqVO extends PageParam { - - @Schema(description = "套餐名", example = "李四") - private String name; - - @Schema(description = "状态", example = "2") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageRespVO.java deleted file mode 100644 index e709cfdd3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageRespVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 充值套餐 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WalletRechargePackageRespVO extends WalletRechargePackageBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9032") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageUpdateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageUpdateReqVO.java deleted file mode 100644 index 37170cb8b..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/rechargepackage/WalletRechargePackageUpdateReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 充值套餐更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class WalletRechargePackageUpdateReqVO extends WalletRechargePackageBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9032") - @NotNull(message = "编号不能为空") - private Long id; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionPageReqVO.java deleted file mode 100644 index 678649ce0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionPageReqVO.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 钱包流水分页 Request VO") -@Data -public class PayWalletTransactionPageReqVO extends PageParam { - - @Schema(description = "钱包编号", example = "1") - private Long walletId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionRespVO.java deleted file mode 100644 index 6203b78d5..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionRespVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 APP - 钱包流水分页 Response VO") -@Data -public class PayWalletTransactionRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "钱包编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") - private Long walletId; - - @Schema(description = "业务分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer bizType; - - @Schema(description = "交易金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long price; - - @Schema(description = "流水标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆土豆") - private String title; - - @Schema(description = "交易后的余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long balance; - - @Schema(description = "交易时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - // TODO @jason:merchantOrderId 字段,需要在 PayWalletTransaction 存储下;然后,前端也返回下这个字段,界面也展示下商户名 - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletBaseVO.java deleted file mode 100644 index a45ea8b90..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletBaseVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * 用户钱包 Base VO,提供给添加、修改、详细的子 VO 使用 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 - */ -@Data -public class PayWalletBaseVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20020") - @NotNull(message = "用户编号不能为空") - private Long userId; - - @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "用户类型不能为空") - private Integer userType; - - @Schema(description = "余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "余额,单位分不能为空") - private Integer balance; - - @Schema(description = "累计支出,单位分", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "累计支出,单位分不能为空") - private Integer totalExpense; - - @Schema(description = "累计充值,单位分", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "累计充值,单位分不能为空") - private Integer totalRecharge; - - @Schema(description = "冻结金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "20737") - @NotNull(message = "冻结金额,单位分不能为空") - private Integer freezePrice; - -} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java deleted file mode 100644 index d74bd44b1..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; -import java.util.Collection; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 会员钱包分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayWalletPageReqVO extends PageParam { - - @Schema(description = "用户昵称", example = "李四") - private String nickname; - - @Schema(description = "用户编号", example = "[1,2]") - private Collection userIds; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java deleted file mode 100644 index a9eedbdfd..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 用户钱包 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayWalletRespVO extends PayWalletBaseVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29528") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王**") - private String nickname; - @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") - private String avatar; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java deleted file mode 100644 index dfa335166..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 用户钱包明细 Request VO") -@Data -public class PayWalletUserReqVO { - - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "用户编号不能为空") - private Long userId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/channel/AppPayChannelController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/channel/AppPayChannelController.java deleted file mode 100644 index 12323a7d5..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/channel/AppPayChannelController.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.channel; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "用户 App - 支付渠道") -@RestController -@RequestMapping("/pay/channel") -@Validated -public class AppPayChannelController { - - @Resource - private PayChannelService channelService; - - @GetMapping("/get-enable-code-list") - @Operation(summary = "获得指定应用的开启的支付渠道编码列表") - @Parameter(name = "appId", description = "应用编号", required = true, example = "1") - public CommonResult> getEnableChannelCodeList(@RequestParam("appId") Long appId) { - List channels = channelService.getEnableChannelList(appId); - return success(convertSet(channels, PayChannelDO::getCode)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.http b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.http deleted file mode 100644 index 14ce54ef9..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.http +++ /dev/null @@ -1,63 +0,0 @@ -### /pay/create 提交支付订单【alipay_pc】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 174, - "channelCode": "alipay_pc" -} - -### /pay/create 提交支付订单【wx_bar】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 202, - "channelCode": "wx_bar", - "channelExtras": { - "authCode": "134042110834344848" - } -} - -### /pay/create 提交支付订单【wx_pub】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 202, - "channelCode": "wx_pub", - "channelExtras": { - "openid": "ockUAwIZ-0OeMZl9ogcZ4ILrGba0" - } -} - -### /pay/create 提交支付订单【wx_lite】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 202, - "channelCode": "wx_lite", - "channelExtras": { - "openid": "oLefc4g5GjKWHJjLjMSXB3wX0fD0" - } -} - -### /pay/create 提交支付订单【wx_native】 -POST {{appApi}}/pay/order/submit -Content-Type: application/json -Authorization: Bearer {{appToken}} -tenant-id: {{appTenentId}} - -{ - "id": 202, - "channelCode": "wx_native" -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.java deleted file mode 100644 index 8033b26b0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.order; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import com.google.common.collect.Maps; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; - -import java.util.Map; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType; - -@Tag(name = "用户 APP - 支付订单") -@RestController -@RequestMapping("/pay/order") -@Validated -@Slf4j -public class AppPayOrderController { - - @Resource - private PayOrderService payOrderService; - - // TODO 芋艿:临时 demo,技术打样。 - @GetMapping("/get") - @Operation(summary = "获得支付订单") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - public CommonResult getOrder(@RequestParam("id") Long id) { - return success(PayOrderConvert.INSTANCE.convert(payOrderService.getOrder(id))); - } - - @PostMapping("/submit") - @Operation(summary = "提交支付订单") - public CommonResult submitPayOrder(@RequestBody AppPayOrderSubmitReqVO reqVO) { - // 1. 钱包支付事,需要额外传 user_id 和 user_type - if (Objects.equals(reqVO.getChannelCode(), PayChannelEnum.WALLET.getCode())) { - Map channelExtras = reqVO.getChannelExtras() == null ? - Maps.newHashMapWithExpectedSize(2) : reqVO.getChannelExtras(); - channelExtras.put(WalletPayClient.USER_ID_KEY, String.valueOf(getLoginUserId())); - channelExtras.put(WalletPayClient.USER_TYPE_KEY, String.valueOf(getLoginUserType())); - reqVO.setChannelExtras(channelExtras); - } - - // 2. 提交支付 - PayOrderSubmitRespVO respVO = payOrderService.submitOrder(reqVO, getClientIP()); - return success(PayOrderConvert.INSTANCE.convert3(respVO)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitReqVO.java deleted file mode 100644 index 8f18c6cec..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitReqVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.order.vo; - -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@Schema(description = "用户 APP - 支付订单提交 Request VO") -@Data -public class AppPayOrderSubmitReqVO extends PayOrderSubmitReqVO { -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitRespVO.java deleted file mode 100644 index 106535efd..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/vo/AppPayOrderSubmitRespVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.order.vo; - -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -@Schema(description = "用户 APP - 支付订单提交 Response VO") -@Data -public class AppPayOrderSubmitRespVO extends PayOrderSubmitRespVO { - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/refund/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/refund/package-info.java deleted file mode 100644 index ee2004e1a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/refund/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占个位置,没啥用 - */ -package cn.iocoder.yudao.module.pay.controller.app.refund; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletController.java deleted file mode 100644 index 95c085cbc..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletController.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet.AppPayWalletRespVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -/** - * @author jason - */ -@Tag(name = "用户 APP - 钱包") -@RestController -@RequestMapping("/pay/wallet") -@Validated -@Slf4j -public class AppPayWalletController { - - @Resource - private PayWalletService payWalletService; - - @GetMapping("/get") - @Operation(summary = "获取钱包") - @PreAuthenticated - public CommonResult getPayWallet() { - PayWalletDO wallet = payWalletService.getOrCreateWallet(getLoginUserId(), UserTypeEnum.MEMBER.getValue()); - return success(PayWalletConvert.INSTANCE.convert(wallet)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java deleted file mode 100644 index 5f0a64286..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType; - -@Tag(name = "用户 APP - 钱包充值") -@RestController -@RequestMapping("/pay/wallet-recharge") -@Validated -@Slf4j -public class AppPayWalletRechargeController { - - @Resource - private PayWalletRechargeService walletRechargeService; - - @PostMapping("/create") - @Operation(summary = "创建钱包充值记录(发起充值)") - public CommonResult createWalletRecharge( - @Valid @RequestBody AppPayWalletRechargeCreateReqVO reqVO) { - PayWalletRechargeDO walletRecharge = walletRechargeService.createWalletRecharge( - getLoginUserId(), getLoginUserType(), getClientIP(), reqVO); - return success(PayWalletRechargeConvert.INSTANCE.convert(walletRecharge)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargePackageController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargePackageController.java deleted file mode 100644 index 9b2aac188..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargePackageController.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletPackageRespVO; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.ArrayList; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "用户 APP - 钱包充值套餐") -@RestController -@RequestMapping("/pay/wallet-recharge-package") -@Validated -@Slf4j -public class AppPayWalletRechargePackageController { - - @GetMapping("/list") - @Operation(summary = "获得钱包充值套餐列表") - public CommonResult> getWalletRechargePackageList() { - // 只查询开启;需要按照 payPrice 排序; - List list = new ArrayList<>(); - list.add(new AppPayWalletPackageRespVO().setId(1L).setName("土豆").setPayPrice(10).setBonusPrice(2)); - list.add(new AppPayWalletPackageRespVO().setId(2L).setName("番茄").setPayPrice(20).setBonusPrice(5)); - return success(list); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletTransactionController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletTransactionController.java deleted file mode 100644 index db0c7844d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletTransactionController.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "用户 APP - 钱包余额明细") -@RestController -@RequestMapping("/pay/wallet-transaction") -@Validated -@Slf4j -public class AppPayWalletTransactionController { - - @Resource - private PayWalletTransactionService payWalletTransactionService; - - @GetMapping("/page") - @Operation(summary = "获得钱包流水分页") - public CommonResult> getWalletTransactionPage( - @Valid AppPayWalletTransactionPageReqVO pageReqVO) { - if (true) { - PageResult result = new PageResult<>(10L); - result.getList().add(new AppPayWalletTransactionRespVO().setPrice(1L) - .setTitle("测试").setCreateTime(LocalDateTime.now())); - result.getList().add(new AppPayWalletTransactionRespVO().setPrice(-1L) - .setTitle("测试2").setCreateTime(LocalDateTime.now())); - return success(result); - } - PageResult result = payWalletTransactionService.getWalletTransactionPage(getLoginUserId(), - UserTypeEnum.MEMBER.getValue(), pageReqVO); - return success(PayWalletTransactionConvert.INSTANCE.convertPage(result)); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletPackageRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletPackageRespVO.java deleted file mode 100644 index c12db9889..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletPackageRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 APP - 用户充值套餐 Response VO") -@Data -public class AppPayWalletPackageRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - @Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "小套餐") - private String name; - - @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - private Integer payPrice; - @Schema(description = "赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") - private Integer bonusPrice; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java deleted file mode 100644 index 1421fb0b5..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Min; -import java.util.Objects; - -@Schema(description = "用户 APP - 创建钱包充值 Request VO") -@Data -public class AppPayWalletRechargeCreateReqVO { - - @Schema(description = "支付金额", example = "1000") - @Min(value = 1, message = "支付金额必须大于零") - private Integer payPrice; - - @Schema(description = "充值套餐编号", example = "1024") - private Long packageId; - - @AssertTrue(message = "充值金额和充钱套餐不能同时为空") - public boolean validatePayPriceAndPackageId() { - return Objects.nonNull(payPrice) || Objects.nonNull(packageId); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateRespVO.java deleted file mode 100644 index 2c4a96f62..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateRespVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 APP - 创建钱包充值 Resp VO") -@Data -public class AppPayWalletRechargeCreateRespVO { - - @Schema(description = "钱包充值编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long payOrderId; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionPageReqVO.java deleted file mode 100644 index 942ab5b6d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionPageReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 APP - 钱包流水分页 Request VO") -@Data -public class AppPayWalletTransactionPageReqVO extends PageParam { - - /** - * 类型 - 收入 - */ - public static final Integer TYPE_INCOME = 1; - /** - * 类型 - 支出 - */ - public static final Integer TYPE_EXPENSE = 2; - - @Schema(description = "类型", example = "1") - private Integer type; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionRespVO.java deleted file mode 100644 index 5c20188eb..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.time.LocalDateTime; - -@Schema(description = "用户 APP - 钱包流水分页 Response VO") -@Data -public class AppPayWalletTransactionRespVO { - - @Schema(description = "业务分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer bizType; - - @Schema(description = "交易金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Long price; - - @Schema(description = "流水标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆土豆") - private String title; - - @Schema(description = "交易时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/wallet/AppPayWalletRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/wallet/AppPayWalletRespVO.java deleted file mode 100644 index f0c78e405..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/wallet/AppPayWalletRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "用户 APP - 用户钱包 Response VO") -@Data -public class AppPayWalletRespVO { - - @Schema(description = "钱包余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer balance; - - @Schema(description = "累计支出, 单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") - private Integer totalExpense; - - @Schema(description = "累计充值, 单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") - private Integer totalRecharge; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/package-info.java deleted file mode 100644 index 652122752..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.pay.controller; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/app/PayAppConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/app/PayAppConvert.java deleted file mode 100644 index 4853d07f7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/app/PayAppConvert.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.app; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageItemRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; - -/** - * 支付应用信息 Convert - * - * @author 芋艿 - */ -@Mapper -public interface PayAppConvert { - - PayAppConvert INSTANCE = Mappers.getMapper(PayAppConvert.class); - - PayAppPageItemRespVO pageConvert (PayAppDO bean); - - PayAppDO convert(PayAppCreateReqVO bean); - - PayAppDO convert(PayAppUpdateReqVO bean); - - PayAppRespVO convert(PayAppDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult pageResult, List channels) { - PageResult voPageResult = convertPage(pageResult); - // 处理 channel 关系 - Map> appIdChannelMap = CollectionUtils.convertMultiMap2(channels, PayChannelDO::getAppId, PayChannelDO::getCode); - voPageResult.getList().forEach(app -> app.setChannelCodes(appIdChannelMap.get(app.getId()))); - return voPageResult; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java deleted file mode 100644 index 5baf598fd..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.channel; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface PayChannelConvert { - - PayChannelConvert INSTANCE = Mappers.getMapper(PayChannelConvert.class); - - @Mapping(target = "config",ignore = true) - PayChannelDO convert(PayChannelCreateReqVO bean); - - @Mapping(target = "config",ignore = true) - PayChannelDO convert(PayChannelUpdateReqVO bean); - - @Mapping(target = "config",expression = "java(cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString(bean.getConfig()))") - PayChannelRespVO convert(PayChannelDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/demo/PayDemoOrderConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/demo/PayDemoOrderConvert.java deleted file mode 100644 index 313e5d266..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/demo/PayDemoOrderConvert.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.demo; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.PayDemoOrderCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.PayDemoOrderRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * 示例订单 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface PayDemoOrderConvert { - - PayDemoOrderConvert INSTANCE = Mappers.getMapper(PayDemoOrderConvert.class); - - PayDemoOrderDO convert(PayDemoOrderCreateReqVO bean); - - PayDemoOrderRespVO convert(PayDemoOrderDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/notify/PayNotifyTaskConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/notify/PayNotifyTaskConvert.java deleted file mode 100644 index d0b8e36ff..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/notify/PayNotifyTaskConvert.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.notify; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskDetailRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 支付通知 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface PayNotifyTaskConvert { - - PayNotifyTaskConvert INSTANCE = Mappers.getMapper(PayNotifyTaskConvert.class); - - PayNotifyTaskRespVO convert(PayNotifyTaskDO bean); - - default PageResult convertPage(PageResult page, Map appMap){ - PageResult result = convertPage(page); - result.getList().forEach(order -> MapUtils.findAndThen(appMap, order.getAppId(), app -> order.setAppName(app.getName()))); - return result; - } - PageResult convertPage(PageResult page); - - default PayNotifyTaskDetailRespVO convert(PayNotifyTaskDO task, PayAppDO app, List logs) { - PayNotifyTaskDetailRespVO respVO = convert(task, logs); - if (app != null) { - respVO.setAppName(app.getName()); - } - return respVO; - } - PayNotifyTaskDetailRespVO convert(PayNotifyTaskDO task, List logs); -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java deleted file mode 100755 index 682006041..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.*; -import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * 支付订单 Convert - * - * @author aquan - */ -@Mapper -public interface PayOrderConvert { - - PayOrderConvert INSTANCE = Mappers.getMapper(PayOrderConvert.class); - - PayOrderRespVO convert(PayOrderDO bean); - - PayOrderRespDTO convert2(PayOrderDO order); - - default PayOrderDetailsRespVO convert(PayOrderDO order, PayOrderExtensionDO orderExtension, PayAppDO app) { - PayOrderDetailsRespVO respVO = convertDetail(order); - respVO.setExtension(convert(orderExtension)); - if (app != null) { - respVO.setAppName(app.getName()); - } - return respVO; - } - PayOrderDetailsRespVO convertDetail(PayOrderDO bean); - PayOrderDetailsRespVO.PayOrderExtension convert(PayOrderExtensionDO bean); - - default PageResult convertPage(PageResult page, Map appMap) { - PageResult result = convertPage(page); - result.getList().forEach(order -> MapUtils.findAndThen(appMap, order.getAppId(), app -> order.setAppName(app.getName()))); - return result; - } - PageResult convertPage(PageResult page); - - default List convertList(List list, Map appMap) { - return CollectionUtils.convertList(list, order -> { - PayOrderExcelVO excelVO = convertExcel(order); - MapUtils.findAndThen(appMap, order.getAppId(), app -> excelVO.setAppName(app.getName())); - return excelVO; - }); - } - PayOrderExcelVO convertExcel(PayOrderDO bean); - - PayOrderDO convert(PayOrderCreateReqDTO bean); - - @Mapping(target = "id", ignore = true) - PayOrderExtensionDO convert(PayOrderSubmitReqVO bean, String userIp); - - PayOrderUnifiedReqDTO convert2(PayOrderSubmitReqVO reqVO, String userIp); - - @Mapping(source = "order.status", target = "status") - PayOrderSubmitRespVO convert(PayOrderDO order, cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO respDTO); - - AppPayOrderSubmitRespVO convert3(PayOrderSubmitRespVO bean); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/package-info.java deleted file mode 100644 index df43d5ac3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 POJO 类的实体转换 - * - * 目前使用 MapStruct 框架 - */ -package cn.iocoder.yudao.module.pay.convert; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/refund/PayRefundConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/refund/PayRefundConvert.java deleted file mode 100755 index 9f087f702..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/refund/PayRefundConvert.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.refund; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundDetailsRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExcelVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageItemRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -@Mapper -public interface PayRefundConvert { - - PayRefundConvert INSTANCE = Mappers.getMapper(PayRefundConvert.class); - - - default PayRefundDetailsRespVO convert(PayRefundDO refund, PayAppDO app) { - PayRefundDetailsRespVO respVO = convert(refund); - if (app != null) { - respVO.setAppName(app.getName()); - } - return respVO; - } - PayRefundDetailsRespVO convert(PayRefundDO bean); - PayRefundDetailsRespVO.Order convert(PayOrderDO bean); - - default PageResult convertPage(PageResult page, Map appMap) { - PageResult result = convertPage(page); - result.getList().forEach(order -> MapUtils.findAndThen(appMap, order.getAppId(), app -> order.setAppName(app.getName()))); - return result; - } - PageResult convertPage(PageResult page); - - PayRefundDO convert(PayRefundCreateReqDTO bean); - - PayRefundRespDTO convert02(PayRefundDO bean); - - default List convertList(List list, Map appMap) { - return CollectionUtils.convertList(list, order -> { - PayRefundExcelVO excelVO = convertExcel(order); - MapUtils.findAndThen(appMap, order.getAppId(), app -> excelVO.setAppName(app.getName())); - return excelVO; - }); - } - PayRefundExcelVO convertExcel(PayRefundDO bean); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java deleted file mode 100644 index 440f0103b..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/transfer/PayTransferConvert.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.transfer; - -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface PayTransferConvert { - - PayTransferConvert INSTANCE = Mappers.getMapper(PayTransferConvert.class); - - @Mapping(source = "title", target = "subject") // TODO @jason:是不是都改成 subject 完事呀? - PayTransferDO convert(PayTransferCreateReqDTO dto); - - PayTransferCreateReqDTO convert(PayDemoTransferCreateReqVO vo); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java deleted file mode 100644 index e162b88bc..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet.AppPayWalletRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.Map; - -@Mapper -public interface PayWalletConvert { - - PayWalletConvert INSTANCE = Mappers.getMapper(PayWalletConvert.class); - - AppPayWalletRespVO convert(PayWalletDO bean); - - PayWalletRespVO convert02(String nickname,String avatar, PayWalletDO bean); - - PageResult convertPage(PageResult page); - - default PageResult convertPage(PageResult page, Map userMap){ - PageResult pageResult = convertPage(page); - pageResult.getList().forEach( wallet -> MapUtils.findAndThen(userMap, wallet.getUserId(), - user -> { - // TODO @jason:可以链式调用哈; - wallet.setNickname(user.getNickname()); - wallet.setAvatar(user.getAvatar()); - })); - return pageResult; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletRechargeConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletRechargeConvert.java deleted file mode 100644 index eda8bcf95..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletRechargeConvert.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.wallet; - -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface PayWalletRechargeConvert { - - PayWalletRechargeConvert INSTANCE = Mappers.getMapper(PayWalletRechargeConvert.class); - - @Mapping(target = "totalPrice", expression = "java( payPrice + bonusPrice)") - PayWalletRechargeDO convert(Long walletId, Integer payPrice, Integer bonusPrice, Long packageId); - - AppPayWalletRechargeCreateRespVO convert(PayWalletRechargeDO bean); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletTransactionConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletTransactionConvert.java deleted file mode 100644 index f956f8d56..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletTransactionConvert.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionRespVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface PayWalletTransactionConvert { - - PayWalletTransactionConvert INSTANCE = Mappers.getMapper(PayWalletTransactionConvert.class); - - PageResult convertPage(PageResult page); - - PageResult convertPage2(PageResult page); - - PayWalletTransactionDO convert(WalletTransactionCreateReqBO bean); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/WalletRechargePackageConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/WalletRechargePackageConvert.java deleted file mode 100644 index 8784adda7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/WalletRechargePackageConvert.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface WalletRechargePackageConvert { - - WalletRechargePackageConvert INSTANCE = Mappers.getMapper(WalletRechargePackageConvert.class); - - PayWalletRechargePackageDO convert(WalletRechargePackageCreateReqVO bean); - - PayWalletRechargePackageDO convert(WalletRechargePackageUpdateReqVO bean); - - WalletRechargePackageRespVO convert(PayWalletRechargePackageDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md deleted file mode 100644 index 8153487b7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/app/PayAppDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/app/PayAppDO.java deleted file mode 100644 index 977eff93a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/app/PayAppDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.app; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 支付应用 DO - * 一个商户下,可能会有多个支付应用。例如说,京东有京东商城、京东到家等等 - * 不过一般来说,一个商户,只有一个应用哈~ - * - * 即 PayMerchantDO : PayAppDO = 1 : n - * - * @author 芋道源码 - */ -@TableName("pay_app") -@KeySequence("pay_app_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayAppDO extends BaseDO { - - /** - * 应用编号,数据库自增 - */ - @TableId - private Long id; - /** - * 应用名 - */ - private String name; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - /** - * 支付结果的回调地址 - */ - private String orderNotifyUrl; - /** - * 退款结果的回调地址 - */ - private String refundNotifyUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/channel/PayChannelDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/channel/PayChannelDO.java deleted file mode 100644 index 72387eb1c..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/channel/PayChannelDO.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.channel; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -/** - * 支付渠道 DO - * 一个应用下,会有多种支付渠道,例如说微信支付、支付宝支付等等 - * - * 即 PayAppDO : PayChannelDO = 1 : n - * - * @author 芋道源码 - */ -@TableName(value = "pay_channel", autoResultMap = true) -@KeySequence("pay_channel_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayChannelDO extends TenantBaseDO { - - /** - * 渠道编号,数据库自增 - */ - private Long id; - /** - * 渠道编码 - * - * 枚举 {@link PayChannelEnum} - */ - private String code; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 渠道费率,单位:百分比 - */ - private Double feeRate; - /** - * 备注 - */ - private String remark; - - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 支付渠道配置 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private PayClientConfig config; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoOrderDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoOrderDO.java deleted file mode 100644 index a22f7c1b8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoOrderDO.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.demo; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 示例订单 - * - * 演示业务系统的订单,如何接入 pay 系统的支付与退款 - * - * @author 芋道源码 - */ -@TableName("pay_demo_order") -@KeySequence("pay_demo_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayDemoOrderDO extends BaseDO { - - /** - * 订单编号,自增 - */ - @TableId - private Long id; - /** - * 用户编号 - */ - private Long userId; - /** - * 商品编号 - */ - private Long spuId; - /** - * 商品名称 - */ - private String spuName; - /** - * 价格,单位:分 - */ - private Integer price; - - // ========== 支付相关字段 ========== - - /** - * 是否支付 - */ - private Boolean payStatus; - /** - * 支付订单编号 - * - * 对接 pay-module-biz 支付服务的支付订单编号,即 PayOrderDO 的 id 编号 - */ - private Long payOrderId; - /** - * 付款时间 - */ - private LocalDateTime payTime; - /** - * 支付渠道 - * - * 对应 PayChannelEnum 枚举 - */ - private String payChannelCode; - - // ========== 退款相关字段 ========== - /** - * 支付退款单号 - */ - private Long payRefundId; - /** - * 退款金额,单位:分 - */ - private Integer refundPrice; - /** - * 退款完成时间 - */ - private LocalDateTime refundTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoTransferDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoTransferDO.java deleted file mode 100644 index b036c30a2..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/demo/PayDemoTransferDO.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.demo; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Map; - -/** - * 示例转账订单 - * - * 演示业务系统的转账业务 - */ -@TableName(value ="pay_demo_transfer", autoResultMap = true) -@KeySequence("pay_demo_transfer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayDemoTransferDO extends BaseDO { - - /** - * 订单编号 - */ - @TableId - private Long id; - - /** - * 用户编号 - */ - private Long userId; - - /** - * 转账金额,单位:分 - */ - private Integer price; - - /** - * 转账类型 - */ - private Integer type; - - // TODO @jason:要不字段还是弄成正确的平铺开? - /** - * 收款人信息,不同类型和渠道不同 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private Map payeeInfo; - - /** - * 转账状态 - */ - private Integer transferStatus; - - /** - * 转账订单编号 - */ - private Long payTransferId; - - /** - * 转账支付成功渠道 - */ - private String payChannelCode; - - /** - * 转账支付时间 - */ - private LocalDateTime transferTime; - -} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyLogDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyLogDO.java deleted file mode 100644 index a482605d5..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyLogDO.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.notify; - -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * 商户支付、退款等的通知 Log - * 每次通知时,都会在该表中,记录一次 Log,方便排查问题 - * - * @author 芋道源码 - */ -@TableName("pay_notify_log") -@KeySequence("pay_notify_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayNotifyLogDO extends BaseDO { - - /** - * 日志编号,自增 - */ - private Long id; - /** - * 通知任务编号 - * - * 关联 {@link PayNotifyTaskDO#getId()} - */ - private Long taskId; - /** - * 第几次被通知 - * - * 对应到 {@link PayNotifyTaskDO#getNotifyTimes()} - */ - private Integer notifyTimes; - /** - * HTTP 响应结果 - */ - private String response; - /** - * 支付通知状态 - * - * 外键 {@link PayNotifyStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyTaskDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyTaskDO.java deleted file mode 100644 index 181a32802..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyTaskDO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.notify; - -import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.time.LocalDateTime; - -/** - * 支付通知 - * 在支付系统收到支付渠道的支付、退款的结果后,需要不断的通知到业务系统,直到成功。 - * - * @author 芋道源码 - */ -@TableName("pay_notify_task") -@KeySequence("pay_notify_task_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class PayNotifyTaskDO extends TenantBaseDO { - - /** - * 通知频率,单位为秒。 - * - * 算上首次的通知,实际是一共 1 + 8 = 9 次。 - */ - public static final Integer[] NOTIFY_FREQUENCY = new Integer[]{ - 15, 15, 30, 180, - 1800, 1800, 1800, 3600 - }; - - /** - * 编号,自增 - */ - @TableId - private Long id; - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 通知类型 - * - * 外键 {@link PayNotifyTypeEnum} - */ - private Integer type; - /** - * 数据编号,根据不同 type 进行关联: - * - * 1. {@link PayNotifyTypeEnum#ORDER} 时,关联 {@link PayOrderDO#getId()} - * 2. {@link PayNotifyTypeEnum#REFUND} 时,关联 {@link PayRefundDO#getId()} - */ - private Long dataId; - /** - * 商户订单编号 - */ - private String merchantOrderId; - /** - * 通知状态 - * - * 外键 {@link PayNotifyStatusEnum} - */ - private Integer status; - /** - * 下一次通知时间 - */ - private LocalDateTime nextNotifyTime; - /** - * 最后一次执行时间 - */ - private LocalDateTime lastExecuteTime; - /** - * 当前通知次数 - */ - private Integer notifyTimes; - /** - * 最大可通知次数 - */ - private Integer maxNotifyTimes; - /** - * 通知地址 - */ - private String notifyUrl; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderDO.java deleted file mode 100644 index a51b875fd..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderDO.java +++ /dev/null @@ -1,138 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.order; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 支付订单 DO - * - * @author 芋道源码 - */ -@TableName("pay_order") -@KeySequence("pay_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayOrderDO extends BaseDO { - - /** - * 订单编号,数据库自增 - */ - private Long id; - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 渠道编号 - * - * 关联 {@link PayChannelDO#getId()} - */ - private Long channelId; - /** - * 渠道编码 - * - * 枚举 {@link PayChannelEnum} - */ - private String channelCode; - - // ========== 商户相关字段 ========== - - /** - * 商户订单编号 - * - * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一 - */ - private String merchantOrderId; - /** - * 商品标题 - */ - private String subject; - /** - * 商品描述信息 - */ - private String body; - /** - * 异步通知地址 - */ - private String notifyUrl; - - // ========== 订单相关字段 ========== - - /** - * 支付金额,单位:分 - */ - private Integer price; - /** - * 渠道手续费,单位:百分比 - * - * 冗余 {@link PayChannelDO#getFeeRate()} - */ - private Double channelFeeRate; - /** - * 渠道手续金额,单位:分 - */ - private Integer channelFeePrice; - /** - * 支付状态 - * - * 枚举 {@link PayOrderStatusEnum} - */ - private Integer status; - /** - * 用户 IP - */ - private String userIp; - /** - * 订单失效时间 - */ - private LocalDateTime expireTime; - /** - * 订单支付成功时间 - */ - private LocalDateTime successTime; - /** - * 支付成功的订单拓展单编号 - * - * 关联 {@link PayOrderExtensionDO#getId()} - */ - private Long extensionId; - /** - * 支付成功的外部订单号 - * - * 关联 {@link PayOrderExtensionDO#getNo()} - */ - private String no; - - // ========== 退款相关字段 ========== - /** - * 退款总金额,单位:分 - */ - private Integer refundPrice; - - // ========== 渠道相关字段 ========== - /** - * 渠道用户编号 - * - * 例如说,微信 openid、支付宝账号 - */ - private String channelUserId; - /** - * 渠道订单号 - */ - private String channelOrderNo; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderExtensionDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderExtensionDO.java deleted file mode 100644 index 9466243e1..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderExtensionDO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.order; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.*; - -import java.util.Map; - -/** - * 支付订单拓展 DO - * - * 每次调用支付渠道,都会生成一条对应记录 - * - * @author 芋道源码 - */ -@TableName(value = "pay_order_extension",autoResultMap = true) -@KeySequence("pay_order_extension_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayOrderExtensionDO extends BaseDO { - - /** - * 订单拓展编号,数据库自增 - */ - private Long id; - /** - * 外部订单号,根据规则生成 - * - * 调用支付渠道时,使用该字段作为对接的订单号: - * 1. 微信支付:对应 JSAPI 支付 的 out_trade_no 字段 - * 2. 支付宝支付:对应 电脑网站支付 的 out_trade_no 字段 - * - * 例如说,P202110132239124200055 - */ - private String no; - /** - * 订单号 - * - * 关联 {@link PayOrderDO#getId()} - */ - private Long orderId; - /** - * 渠道编号 - * - * 关联 {@link PayChannelDO#getId()} - */ - private Long channelId; - /** - * 渠道编码 - */ - private String channelCode; - /** - * 用户 IP - */ - private String userIp; - /** - * 支付状态 - * - * 枚举 {@link PayOrderStatusEnum} - */ - private Integer status; - /** - * 支付渠道的额外参数 - * - * 参见 参数说明 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private Map channelExtras; - - /** - * 调用渠道的错误码 - */ - private String channelErrorCode; - /** - * 调用渠道报错时,错误信息 - */ - private String channelErrorMsg; - - /** - * 支付渠道的同步/异步通知的内容 - * - * 对应 {@link PayOrderRespDTO#getRawData()} - */ - private String channelNotifyData; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/refund/PayRefundDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/refund/PayRefundDO.java deleted file mode 100644 index 5d9c612a3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/refund/PayRefundDO.java +++ /dev/null @@ -1,160 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.refund; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.time.LocalDateTime; - -/** - * 支付退款单 DO - * 一个支付订单,可以拥有多个支付退款单 - * - * 即 PayOrderDO : PayRefundDO = 1 : n - * - * @author 芋道源码 - */ -@TableName("pay_refund") -@KeySequence("pay_refund_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayRefundDO extends BaseDO { - - /** - * 退款单编号,数据库自增 - */ - @TableId - private Long id; - /** - * 外部退款号,根据规则生成 - * - * 调用支付渠道时,使用该字段作为对接的退款号: - * 1. 微信退款:对应 申请退款 的 out_refund_no 字段 - * 2. 支付宝退款:对应 的 out_request_no 字段 - */ - private String no; - - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 渠道编号 - * - * 关联 {@link PayChannelDO#getId()} - */ - private Long channelId; - /** - * 商户编码 - * - * 枚举 {@link PayChannelEnum} - */ - private String channelCode; - /** - * 订单编号 - * - * 关联 {@link PayOrderDO#getId()} - */ - private Long orderId; - /** - * 支付订单编号 - * - * 冗余 {@link PayOrderDO#getNo()} - */ - private String orderNo; - - // ========== 商户相关字段 ========== - /** - * 商户订单编号 - * - * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一 - */ - private String merchantOrderId; - /** - * 商户退款订单号 - * - * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一 - */ - private String merchantRefundId; - /** - * 异步通知地址 - */ - private String notifyUrl; - - // ========== 退款相关字段 ========== - /** - * 退款状态 - * - * 枚举 {@link PayRefundStatusEnum} - */ - private Integer status; - - /** - * 支付金额,单位:分 - */ - private Integer payPrice; - /** - * 退款金额,单位:分 - */ - private Integer refundPrice; - - /** - * 退款原因 - */ - private String reason; - - /** - * 用户 IP - */ - private String userIp; - - // ========== 渠道相关字段 ========== - /** - * 渠道订单号 - * - * 冗余 {@link PayOrderDO#getChannelOrderNo()} - */ - private String channelOrderNo; - /** - * 渠道退款单号 - * - * 1. 微信退款:对应 申请退款 的 refund_id 字段 - * 2. 支付宝退款:没有字段 - */ - private String channelRefundNo; - /** - * 退款成功时间 - */ - private LocalDateTime successTime; - - /** - * 调用渠道的错误码 - */ - private String channelErrorCode; - /** - * 调用渠道的错误提示 - */ - private String channelErrorMsg; - - /** - * 支付渠道的同步/异步通知的内容 - * - * 对应 {@link PayRefundRespDTO#getRawData()} - */ - private String channelNotifyData; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java deleted file mode 100644 index 507157a7a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferDO.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.transfer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.Map; - -/** - * 转账单 DO - * - * @author jason - */ -@TableName(value ="pay_transfer", autoResultMap = true) -@KeySequence("pay_transfer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayTransferDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 应用编号 - * - * 关联 {@link PayAppDO#getId()} - */ - private Long appId; - /** - * 转账渠道编号 - * - * 关联 {@link PayChannelDO#getId()} - */ - private Long channelId; - /** - * 转账渠道编码 - * - * 枚举 {@link PayChannelEnum} - */ - private String channelCode; - /** - * 类型 - * - * 枚举 {@link PayTransferTypeEnum} - */ - private Integer type; - - // ========== 商户相关字段 ========== - - /** - * 商户订单编号 - * - * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一 - */ - private String merchantOrderId; - - /** - * 转账标题 - */ - private String subject; - - // ========== 转账相关字段 ========== - /** - * 转账金额,单位:分 - */ - private Integer price; - /** - * 转账状态 - * - * 枚举 {@link PayTransferStatusRespEnum} - */ - private Integer status; - /** - * 订单转账成功时间 - */ - private LocalDateTime successTime; - /** - * 转账成功的转账拓展单编号 - * - * 关联 {@link PayTransferExtensionDO#getId()} - */ - private Long extensionId; - /** - * 转账成功的转账拓展单号 - * - * 关联 {@link PayTransferExtensionDO#getNo()} - */ - private String no; - /** - * 收款人信息,不同类型和渠道不同 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private Map payeeInfo; - -} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferExtensionDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferExtensionDO.java deleted file mode 100644 index c3d4253e8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/transfer/PayTransferExtensionDO.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.transfer; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; -import lombok.Data; - -import java.util.Map; - -// TODO @jason:转账是不是类似 refund,不用拓展单呀?支付做拓展单的原因,是因为它存在不确定性,可以切换多种;转账和退款,都是明确方式的; -// @芋艿 转账是不是也存在多种方式。 例如转账到银行卡。 可以使用微信,也可以使用支付宝。 支付宝账号余额不够,可以切换到微信; -// TODO @jason:发起了,就不允许调整了,类似退款哈; -/** - * 转账拓展单 DO - * - * @author jason - */ -@TableName(value ="pay_transfer_extension",autoResultMap = true) -@KeySequence("pay_transfer_extension_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayTransferExtensionDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 转账单号 - */ - private String no; - - /** - * 转账单编号 - */ - private Long transferId; - - /** - * 转账渠道编号 - */ - private Long channelId; - - /** - * 转账渠道编码 - */ - private String channelCode; - - /** - * 支付渠道的额外参数 - */ - @TableField(typeHandler = JacksonTypeHandler.class) - private Map channelExtras; - - /** - * 转账状态 - */ - private Integer status; - - /** - * 支付渠道异步通知的内容 - */ - private String channelNotifyData; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletDO.java deleted file mode 100644 index a3c54c969..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletDO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -/** - * 会员钱包 DO - * - * @author jason - */ -@TableName(value ="pay_wallet") -@KeySequence("pay_wallet_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayWalletDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 用户 id - * - * 关联 MemberUserDO 的 id 编号 - * 关联 AdminUserDO 的 id 编号 - */ - private Long userId; - /** - * 用户类型, 预留 多商户转帐可能需要用到 - * - * 关联 {@link UserTypeEnum} - */ - private Integer userType; - - /** - * 余额,单位分 - */ - private Integer balance; - - /** - * 冻结金额,单位分 - */ - private Integer freezePrice; - - /** - * 累计支出,单位分 - */ - private Integer totalExpense; - /** - * 累计充值,单位分 - */ - private Integer totalRecharge; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargeDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargeDO.java deleted file mode 100644 index a842c95e6..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargeDO.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 会员钱包充值 - */ -@TableName(value ="pay_wallet_recharge") -@KeySequence("pay_wallet_recharge_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayWalletRechargeDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 钱包编号 - * - * 关联 {@link PayWalletDO#getId()} - */ - private Long walletId; - - /** - * 用户实际到账余额 - * - * 例如充 100 送 20,则该值是 120 - */ - private Integer totalPrice; - /** - * 实际支付金额 - */ - private Integer payPrice; - /** - * 钱包赠送金额 - */ - private Integer bonusPrice; - - /** - * 充值套餐编号 - * - * 关联 {@link PayWalletRechargeDO#getPackageId()} 字段 - */ - private Long packageId; - - /** - * 是否已支付 - * - * true - 已支付 - * false - 未支付 - */ - private Boolean payStatus; - - /** - * 支付订单编号 - * - * 关联 {@link PayOrderDO#getId()} - */ - private Long payOrderId; - - /** - * 支付成功的支付渠道 - * - * 冗余 {@link PayOrderDO#getChannelCode()} - */ - private String payChannelCode; - /** - * 订单支付时间 - */ - private LocalDateTime payTime; - - /** - * 支付退款单编号 - * - * 关联 {@link PayRefundDO#getId()} - */ - private Long payRefundId; - - /** - * 退款金额,包含赠送金额 - */ - private Integer refundTotalPrice; - /** - * 退款支付金额 - */ - private Integer refundPayPrice; - - /** - * 退款钱包赠送金额 - */ - private Integer refundBonusPrice; - - /** - * 退款时间 - */ - private LocalDateTime refundTime; - - /** - * 退款状态 - * - * 枚举 {@link PayRefundStatusEnum} - */ - private Integer refundStatus; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargePackageDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargePackageDO.java deleted file mode 100644 index 72fc43d96..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargePackageDO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -/** - * 会员钱包充值套餐 DO - * - * 通过充值套餐时,可以赠送一定金额; - * - * @author 芋道源码 - */ -@TableName(value ="pay_wallet_recharge_package") -@KeySequence("pay_wallet_recharge_package_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayWalletRechargePackageDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - /** - * 套餐名 - */ - private String name; - - /** - * 支付金额 - */ - private Integer payPrice; - /** - * 赠送金额 - */ - private Integer bonusPrice; - - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletTransactionDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletTransactionDO.java deleted file mode 100644 index 654e51157..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletTransactionDO.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; - -/** - * 会员钱包流水 DO - * - * @author jason - */ -@TableName(value ="pay_wallet_transaction") -@KeySequence("pay_wallet_transaction_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -public class PayWalletTransactionDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Long id; - - /** - * 流水号 - */ - private String no; - - /** - * 钱包编号 - * - * 关联 {@link PayWalletDO#getId()} - */ - private Long walletId; - - /** - * 关联业务分类 - * - * 枚举 {@link PayWalletBizTypeEnum#getType()} - */ - private Integer bizType; - - /** - * 关联业务编号 - */ - private String bizId; - - /** - * 流水说明 - */ - private String title; - - /** - * 交易金额,单位分 - * - * 正值表示余额增加,负值表示余额减少 - */ - private Integer price; - - /** - * 交易后余额,单位分 - */ - private Integer balance; -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/app/PayAppMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/app/PayAppMapper.java deleted file mode 100644 index c31dba551..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/app/PayAppMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.app; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayAppMapper extends BaseMapperX { - - default PageResult selectPage(PayAppPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(PayAppDO::getName, reqVO.getName()) - .eqIfPresent(PayAppDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayAppDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayAppDO::getId)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/channel/PayChannelMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/channel/PayChannelMapper.java deleted file mode 100644 index c7e6ad0f8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/channel/PayChannelMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.channel; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface PayChannelMapper extends BaseMapperX { - - default PayChannelDO selectByAppIdAndCode(Long appId, String code) { - return selectOne(PayChannelDO::getAppId, appId, PayChannelDO::getCode, code); - } - - default List selectListByAppIds(Collection appIds){ - return selectList(PayChannelDO::getAppId, appIds); - } - - default List selectListByAppId(Long appId, Integer status) { - return selectList(new LambdaQueryWrapperX() - .eq(PayChannelDO::getAppId, appId) - .eq(PayChannelDO::getStatus, status)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoOrderMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoOrderMapper.java deleted file mode 100644 index 0a92c6b76..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoOrderMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.demo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * 示例订单 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface PayDemoOrderMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .orderByDesc(PayDemoOrderDO::getId)); - } - - default int updateByIdAndPayed(Long id, boolean wherePayed, PayDemoOrderDO updateObj) { - return update(updateObj, new LambdaQueryWrapperX() - .eq(PayDemoOrderDO::getId, id).eq(PayDemoOrderDO::getPayStatus, wherePayed)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoTransferMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoTransferMapper.java deleted file mode 100644 index a2a600660..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/demo/PayDemoTransferMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.demo; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoTransferDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayDemoTransferMapper extends BaseMapperX { - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyLogMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyLogMapper.java deleted file mode 100644 index 8b586dff2..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyLogMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.notify; - -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface PayNotifyLogMapper extends BaseMapperX { - - default List selectListByTaskId(Long taskId) { - return selectList(PayNotifyLogDO::getTaskId, taskId); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyTaskMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyTaskMapper.java deleted file mode 100644 index cc7701271..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/notify/PayNotifyTaskMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.notify; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; - -@Mapper -public interface PayNotifyTaskMapper extends BaseMapperX { - - /** - * 获得需要通知的 PayNotifyTaskDO 记录。需要满足如下条件: - * - * 1. status 非成功 - * 2. nextNotifyTime 小于当前时间 - * - * @return PayTransactionNotifyTaskDO 数组 - */ - default List selectListByNotify() { - return selectList(new LambdaQueryWrapper() - .in(PayNotifyTaskDO::getStatus, PayNotifyStatusEnum.WAITING.getStatus(), - PayNotifyStatusEnum.REQUEST_SUCCESS.getStatus(), PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()) - .le(PayNotifyTaskDO::getNextNotifyTime, LocalDateTime.now())); - } - - default PageResult selectPage(PayNotifyTaskPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(PayNotifyTaskDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayNotifyTaskDO::getType, reqVO.getType()) - .eqIfPresent(PayNotifyTaskDO::getDataId, reqVO.getDataId()) - .eqIfPresent(PayNotifyTaskDO::getStatus, reqVO.getStatus()) - .eqIfPresent(PayNotifyTaskDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .betweenIfPresent(PayNotifyTaskDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayNotifyTaskDO::getId)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderExtensionMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderExtensionMapper.java deleted file mode 100755 index 8513c4b31..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderExtensionMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.order; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; - -@Mapper -public interface PayOrderExtensionMapper extends BaseMapperX { - - default PayOrderExtensionDO selectByNo(String no) { - return selectOne(PayOrderExtensionDO::getNo, no); - } - - default int updateByIdAndStatus(Long id, Integer status, PayOrderExtensionDO update) { - return update(update, new LambdaQueryWrapper() - .eq(PayOrderExtensionDO::getId, id).eq(PayOrderExtensionDO::getStatus, status)); - } - - default List selectListByOrderId(Long orderId) { - return selectList(PayOrderExtensionDO::getOrderId, orderId); - } - - default List selectListByStatusAndCreateTimeGe(Integer status, LocalDateTime minCreateTime) { - return selectList(new LambdaQueryWrapper() - .eq(PayOrderExtensionDO::getStatus, status) - .ge(PayOrderExtensionDO::getCreateTime, minCreateTime)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java deleted file mode 100755 index 95510d5f7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.time.LocalDateTime; -import java.util.List; - -@Mapper -public interface PayOrderMapper extends BaseMapperX { - - default PageResult selectPage(PayOrderPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(PayOrderDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayOrderDO::getChannelCode, reqVO.getChannelCode()) - .likeIfPresent(PayOrderDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .likeIfPresent(PayOrderDO::getChannelOrderNo, reqVO.getChannelOrderNo()) - .likeIfPresent(PayOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(PayOrderDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayOrderDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayOrderDO::getId)); - } - - default List selectList(PayOrderExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(PayOrderDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayOrderDO::getChannelCode, reqVO.getChannelCode()) - .likeIfPresent(PayOrderDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .likeIfPresent(PayOrderDO::getChannelOrderNo, reqVO.getChannelOrderNo()) - .likeIfPresent(PayOrderDO::getNo, reqVO.getNo()) - .eqIfPresent(PayOrderDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayOrderDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayOrderDO::getId)); - } - - default Long selectCountByAppId(Long appId) { - return selectCount(PayOrderDO::getAppId, appId); - } - - default PayOrderDO selectByAppIdAndMerchantOrderId(Long appId, String merchantOrderId) { - return selectOne(PayOrderDO::getAppId, appId, - PayOrderDO::getMerchantOrderId, merchantOrderId); - } - - default int updateByIdAndStatus(Long id, Integer status, PayOrderDO update) { - return update(update, new LambdaQueryWrapper() - .eq(PayOrderDO::getId, id).eq(PayOrderDO::getStatus, status)); - } - - default List selectListByStatusAndExpireTimeLt(Integer status, LocalDateTime expireTime) { - return selectList(new LambdaQueryWrapper() - .eq(PayOrderDO::getStatus, status) - .lt(PayOrderDO::getExpireTime, expireTime)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/refund/PayRefundMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/refund/PayRefundMapper.java deleted file mode 100755 index 0b620eaed..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/refund/PayRefundMapper.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.refund; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface PayRefundMapper extends BaseMapperX { - - default Long selectCountByAppId(Long appId) { - return selectCount(PayRefundDO::getAppId, appId); - } - - default PayRefundDO selectByAppIdAndMerchantRefundId(Long appId, String merchantRefundId) { - return selectOne(new LambdaQueryWrapperX() - .eq(PayRefundDO::getAppId, appId) - .eq(PayRefundDO::getMerchantRefundId, merchantRefundId)); - } - - default Long selectCountByAppIdAndOrderId(Long appId, Long orderId, Integer status) { - return selectCount(new LambdaQueryWrapperX() - .eq(PayRefundDO::getAppId, appId) - .eq(PayRefundDO::getOrderId, orderId) - .eq(PayRefundDO::getStatus, status)); - } - - default PayRefundDO selectByAppIdAndNo(Long appId, String no) { - return selectOne(new LambdaQueryWrapperX() - .eq(PayRefundDO::getAppId, appId) - .eq(PayRefundDO::getNo, no)); - } - - default PayRefundDO selectByNo(String no) { - return selectOne(PayRefundDO::getNo, no); - } - - default int updateByIdAndStatus(Long id, Integer status, PayRefundDO update) { - return update(update, new LambdaQueryWrapper() - .eq(PayRefundDO::getId, id).eq(PayRefundDO::getStatus, status)); - } - - default PageResult selectPage(PayRefundPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(PayRefundDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayRefundDO::getChannelCode, reqVO.getChannelCode()) - .likeIfPresent(PayRefundDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .likeIfPresent(PayRefundDO::getMerchantRefundId, reqVO.getMerchantRefundId()) - .likeIfPresent(PayRefundDO::getChannelOrderNo, reqVO.getChannelOrderNo()) - .likeIfPresent(PayRefundDO::getChannelRefundNo, reqVO.getChannelRefundNo()) - .eqIfPresent(PayRefundDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayRefundDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayRefundDO::getId)); - } - - default List selectList(PayRefundExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(PayRefundDO::getAppId, reqVO.getAppId()) - .eqIfPresent(PayRefundDO::getChannelCode, reqVO.getChannelCode()) - .likeIfPresent(PayRefundDO::getMerchantOrderId, reqVO.getMerchantOrderId()) - .likeIfPresent(PayRefundDO::getMerchantRefundId, reqVO.getMerchantRefundId()) - .likeIfPresent(PayRefundDO::getChannelOrderNo, reqVO.getChannelOrderNo()) - .likeIfPresent(PayRefundDO::getChannelRefundNo, reqVO.getChannelRefundNo()) - .eqIfPresent(PayRefundDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayRefundDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayRefundDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(PayRefundDO::getStatus, status); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferExtensionMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferExtensionMapper.java deleted file mode 100644 index 8e808f24d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferExtensionMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.transfer; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferExtensionDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface PayTransferExtensionMapper extends BaseMapperX { - - default PayTransferExtensionDO selectByNo(String no){ - return selectOne(PayTransferExtensionDO::getNo, no); - } - - default int updateByIdAndStatus(Long id, List whereStatuses, PayTransferExtensionDO updateObj) { - return update(updateObj, new LambdaQueryWrapper() - .eq(PayTransferExtensionDO::getId, id).in(PayTransferExtensionDO::getStatus, whereStatuses)); - } - -} - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java deleted file mode 100644 index 3bd25d4b5..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/transfer/PayTransferMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.transfer; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface PayTransferMapper extends BaseMapperX { - - default int updateByIdAndStatus(Long id, List status, PayTransferDO updateObj) { - return update(updateObj, new LambdaQueryWrapper() - .eq(PayTransferDO::getId, id).in(PayTransferDO::getStatus, status)); - } - -} - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java deleted file mode 100644 index ce672255a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.wallet; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayWalletMapper extends BaseMapperX { - - default PayWalletDO selectByUserIdAndType(Long userId, Integer userType) { - return selectOne(PayWalletDO::getUserId, userId, - PayWalletDO::getUserType, userType); - } - - default PageResult selectPage(Integer userType, PayWalletPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .inIfPresent(PayWalletDO::getUserId, reqVO.getUserIds()) - .eqIfPresent(PayWalletDO::getUserType, userType) - .betweenIfPresent(PayWalletDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayWalletDO::getId)); - } - - /** - * 当消费退款时候, 更新钱包 - * - * @param id 钱包 id - * @param price 消费金额 - */ - default int updateWhenConsumptionRefund(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance + " + price - + ", total_expense = total_expense - " + price) - .eq(PayWalletDO::getId, id); - return update(null, lambdaUpdateWrapper); - } - - /** - * 当消费时候, 更新钱包 - * - * @param price 消费金额 - * @param id 钱包 id - */ - default int updateWhenConsumption(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance - " + price - + ", total_expense = total_expense + " + price) - .eq(PayWalletDO::getId, id) - .ge(PayWalletDO::getBalance, price); // cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - /** - * 当充值的时候,更新钱包 - * - * @param id 钱包 id - * @param price 钱包金额 - */ - default int updateWhenRecharge(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance + " + price - + ", total_recharge = total_recharge + " + price) - .eq(PayWalletDO::getId, id); - return update(null, lambdaUpdateWrapper); - } - - /** - * 冻结钱包部分余额 - * - * @param id 钱包 id - * @param price 冻结金额 - */ - default int freezePrice(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance - " + price - + ", freeze_price = freeze_price + " + price) - .eq(PayWalletDO::getId, id) - .ge(PayWalletDO::getBalance, price); // cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - /** - * 解冻钱包余额 - * - * @param id 钱包 id - * @param price 解冻金额 - */ - default int unFreezePrice(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" balance = balance + " + price - + ", freeze_price = freeze_price - " + price) - .eq(PayWalletDO::getId, id) - .ge(PayWalletDO::getFreezePrice, price); // cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - /** - * 当充值退款时, 更新钱包 - * - * @param id 钱包 id - * @param price 退款金额 - */ - default int updateWhenRechargeRefund(Long id, Integer price){ - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper() - .setSql(" freeze_price = freeze_price - " + price - + ", total_recharge = total_recharge - " + price) - .eq(PayWalletDO::getId, id) - .ge(PayWalletDO::getFreezePrice, price) - .ge(PayWalletDO::getTotalRecharge, price);// cas 逻辑 - return update(null, lambdaUpdateWrapper); - } - - -} - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java deleted file mode 100644 index 4cb77f020..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.wallet; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayWalletRechargeMapper extends BaseMapperX { - - default int updateByIdAndPaid(Long id, boolean wherePayStatus, PayWalletRechargeDO updateObj) { - return update(updateObj, new LambdaQueryWrapperX() - .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getPayStatus, wherePayStatus)); - } - - default int updateByIdAndRefunded(Long id, Integer whereRefundStatus, PayWalletRechargeDO updateObj) { - return update(updateObj, new LambdaQueryWrapperX() - .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getRefundStatus, whereRefundStatus)); - } - -} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargePackageMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargePackageMapper.java deleted file mode 100644 index b68b4c893..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargePackageMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.wallet; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface PayWalletRechargePackageMapper extends BaseMapperX { - - default PageResult selectPage(WalletRechargePackagePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(PayWalletRechargePackageDO::getName, reqVO.getName()) - .eqIfPresent(PayWalletRechargePackageDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PayWalletRechargePackageDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(PayWalletRechargePackageDO::getPayPrice)); - } - - // TODO @jason:这里要有空格哈;String name) { - default PayWalletRechargePackageDO selectByName(String name){ - return selectOne(PayWalletRechargePackageDO::getName, name); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java deleted file mode 100644 index 41d7dbeb4..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.wallet; - - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Objects; - -@Mapper -public interface PayWalletTransactionMapper extends BaseMapperX { - - default PageResult selectPage(Long walletId, Integer type, - PageParam pageParam) { - LambdaQueryWrapperX query = new LambdaQueryWrapperX() - .eqIfPresent(PayWalletTransactionDO::getWalletId, walletId); - if (Objects.equals(type, AppPayWalletTransactionPageReqVO.TYPE_INCOME)) { - query.gt(PayWalletTransactionDO::getPrice, 0); - } else if (Objects.equals(type, AppPayWalletTransactionPageReqVO.TYPE_EXPENSE)) { - query.lt(PayWalletTransactionDO::getPrice, 0); - } - query.orderByDesc(PayWalletTransactionDO::getId); - return selectPage(pageParam, query); - } - - default PayWalletTransactionDO selectByNo(String no) { - return selectOne(PayWalletTransactionDO::getNo, no); - } - - default PayWalletTransactionDO selectByBiz(String bizId, Integer bizType) { - return selectOne(PayWalletTransactionDO::getBizId, bizId, - PayWalletTransactionDO::getBizType, bizType); - } - -} - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/RedisKeyConstants.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/RedisKeyConstants.java deleted file mode 100644 index 30081c6e8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/RedisKeyConstants.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.redis; - -/** - * 支付 Redis Key 枚举类 - * - * @author 芋道源码 - */ -public interface RedisKeyConstants { - - /** - * 通知任务的分布式锁 - * - * KEY 格式:pay_notify:lock:%d // 参数来自 DefaultLockKeyBuilder 类 - * VALUE 数据格式:HASH // RLock.class:Redisson 的 Lock 锁,使用 Hash 数据结构 - * 过期时间:不固定 - */ - String PAY_NOTIFY_LOCK = "pay_notify:lock:%d"; - - /** - * 支付序号的缓存 - * - * KEY 格式:pay_no:{prefix} - * VALUE 数据格式:编号自增 - */ - String PAY_NO = "pay_no:"; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/no/PayNoRedisDAO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/no/PayNoRedisDAO.java deleted file mode 100644 index f6be6f92a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/no/PayNoRedisDAO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.redis.no; - -import cn.hutool.core.date.DatePattern;import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.module.pay.dal.redis.RedisKeyConstants; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Repository; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; - -/** - * 支付序号的 Redis DAO - * - * @author 芋道源码 - */ -@Repository -public class PayNoRedisDAO { - - @Resource - private StringRedisTemplate stringRedisTemplate; - - /** - * 生成序号 - * - * @param prefix 前缀 - * @return 序号 - */ - public String generate(String prefix) { - // 递增序号 - String noPrefix = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN); - String key = RedisKeyConstants.PAY_NO + noPrefix; - Long no = stringRedisTemplate.opsForValue().increment(key); - // 设置过期时间 - stringRedisTemplate.expire(key, Duration.ofMinutes(1L)); - return noPrefix + no; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/notify/PayNotifyLockRedisDAO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/notify/PayNotifyLockRedisDAO.java deleted file mode 100644 index 69fab20dc..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/notify/PayNotifyLockRedisDAO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.redis.notify; - -import org.redisson.api.RLock; -import org.redisson.api.RedissonClient; -import org.springframework.stereotype.Repository; - -import javax.annotation.Resource; -import java.util.concurrent.TimeUnit; - -import static cn.iocoder.yudao.module.pay.dal.redis.RedisKeyConstants.PAY_NOTIFY_LOCK; - -/** - * 支付通知的锁 Redis DAO - * - * @author 芋道源码 - */ -@Repository -public class PayNotifyLockRedisDAO { - - @Resource - private RedissonClient redissonClient; - - public void lock(Long id, Long timeoutMillis, Runnable runnable) { - String lockKey = formatKey(id); - RLock lock = redissonClient.getLock(lockKey); - try { - lock.lock(timeoutMillis, TimeUnit.MILLISECONDS); - // 执行逻辑 - runnable.run(); - } finally { - lock.unlock(); - } - } - - private static String formatKey(Long id) { - return String.format(PAY_NOTIFY_LOCK, id); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/config/PayJobConfiguration.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/config/PayJobConfiguration.java deleted file mode 100644 index cd6bd0bb7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/config/PayJobConfiguration.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.job.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -import java.util.concurrent.ThreadPoolExecutor; - -@Configuration(proxyBeanMethods = false) -public class PayJobConfiguration { - - public static final String NOTIFY_THREAD_POOL_TASK_EXECUTOR = "NOTIFY_THREAD_POOL_TASK_EXECUTOR"; - - @Bean(NOTIFY_THREAD_POOL_TASK_EXECUTOR) - public ThreadPoolTaskExecutor notifyThreadPoolTaskExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(8); // 设置核心线程数 - executor.setMaxPoolSize(16); // 设置最大线程数 - executor.setKeepAliveSeconds(60); // 设置空闲时间 - executor.setQueueCapacity(100); // 设置队列大小 - executor.setThreadNamePrefix("notify-task-"); // 配置线程池的前缀 - executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); - // 进行加载 - executor.initialize(); - return executor; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/core/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/core/package-info.java deleted file mode 100644 index 5a5a689f8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/job/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.pay.framework.job.core; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/package-info.java deleted file mode 100644 index a1286828e..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 pay 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.pay.framework; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayConfiguration.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayConfiguration.java deleted file mode 100644 index 376cd0acb..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayConfiguration.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.pay.config; - -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableConfigurationProperties(PayProperties.class) -public class PayConfiguration { -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java deleted file mode 100644 index d422b3528..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.pay.config; - -import lombok.Data; -import org.hibernate.validator.constraints.URL; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; - -import javax.validation.constraints.NotEmpty; - -@ConfigurationProperties(prefix = "yudao.pay") -@Validated -@Data -public class PayProperties { - - private static final String ORDER_NO_PREFIX = "P"; - private static final String REFUND_NO_PREFIX = "R"; - - /** - * 支付回调地址 - * - * 实际上,对应的 PayNotifyController 的 notifyOrder 方法的 URL - * - * 回调顺序:支付渠道(支付宝支付、微信支付) => yudao-module-pay 的 orderNotifyUrl 地址 => 业务的 PayAppDO.orderNotifyUrl 地址 - */ - @NotEmpty(message = "支付回调地址不能为空") - @URL(message = "支付回调地址的格式必须是 URL") - private String orderNotifyUrl; - - /** - * 退款回调地址 - * - * 实际上,对应的 PayNotifyController 的 notifyRefund 方法的 URL - * - * 回调顺序:支付渠道(支付宝支付、微信支付) => yudao-module-pay 的 refundNotifyUrl 地址 => 业务的 PayAppDO.notifyRefundUrl 地址 - */ - @NotEmpty(message = "支付回调地址不能为空") - @URL(message = "支付回调地址的格式必须是 URL") - private String refundNotifyUrl; - - /** - * 支付订单 no 的前缀 - */ - @NotEmpty(message = "支付订单 no 的前缀不能为空") - private String orderNoPrefix = ORDER_NO_PREFIX; - - /** - * 退款订单 no 的前缀 - */ - @NotEmpty(message = "退款订单 no 的前缀不能为空") - private String refundNoPrefix = REFUND_NO_PREFIX; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java deleted file mode 100644 index 212551f4d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java +++ /dev/null @@ -1,184 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.pay.core; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.map.MapUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; -import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; -import lombok.extern.slf4j.Slf4j; - -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_ORDER_EXTENSION_NOT_FOUND; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.REFUND_NOT_FOUND; - -/** - * 钱包支付的 PayClient 实现类 - * - * @author jason - */ -@Slf4j -public class WalletPayClient extends AbstractPayClient { - - public static final String USER_ID_KEY = "user_id"; - public static final String USER_TYPE_KEY = "user_type"; - - private PayWalletService wallService; - private PayWalletTransactionService walletTransactionService; - private PayOrderService orderService; - private PayRefundService refundService; - - public WalletPayClient(Long channelId, NonePayClientConfig config) { - super(channelId, PayChannelEnum.WALLET.getCode(), config); - } - - @Override - protected void doInit() { - if (wallService == null) { - wallService = SpringUtil.getBean(PayWalletService.class); - } - if (walletTransactionService == null) { - walletTransactionService = SpringUtil.getBean(PayWalletTransactionService.class); - } - } - - @Override - protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - try { - Long userId = MapUtil.getLong(reqDTO.getChannelExtras(), USER_ID_KEY); - Integer userType = MapUtil.getInt(reqDTO.getChannelExtras(), USER_TYPE_KEY); - Assert.notNull(userId, "用户 id 不能为空"); - Assert.notNull(userType, "用户类型不能为空"); - PayWalletTransactionDO transaction = wallService.orderPay(userId, userType, reqDTO.getOutTradeNo(), - reqDTO.getPrice()); - return PayOrderRespDTO.successOf(transaction.getNo(), transaction.getCreator(), - transaction.getCreateTime(), - reqDTO.getOutTradeNo(), transaction); - } catch (Throwable ex) { - log.error("[doUnifiedOrder] 失败", ex); - Integer errorCode = INTERNAL_SERVER_ERROR.getCode(); - String errorMsg = INTERNAL_SERVER_ERROR.getMsg(); - if (ex instanceof ServiceException) { - ServiceException serviceException = (ServiceException) ex; - errorCode = serviceException.getCode(); - errorMsg = serviceException.getMessage(); - } - return PayOrderRespDTO.closedOf(String.valueOf(errorCode), errorMsg, - reqDTO.getOutTradeNo(), ""); - } - } - - @Override - protected PayOrderRespDTO doParseOrderNotify(Map params, String body) { - throw new UnsupportedOperationException("钱包支付无支付回调"); - } - - @Override - protected PayOrderRespDTO doGetOrder(String outTradeNo) { - if (orderService == null) { - orderService = SpringUtil.getBean(PayOrderService.class); - } - PayOrderExtensionDO orderExtension = orderService.getOrderExtensionByNo(outTradeNo); - // 支付交易拓展单不存在, 返回关闭状态 - if (orderExtension == null) { - return PayOrderRespDTO.closedOf(String.valueOf(PAY_ORDER_EXTENSION_NOT_FOUND.getCode()), - PAY_ORDER_EXTENSION_NOT_FOUND.getMsg(), outTradeNo, ""); - } - // 关闭状态 - if (PayOrderStatusEnum.isClosed(orderExtension.getStatus())) { - return PayOrderRespDTO.closedOf(orderExtension.getChannelErrorCode(), - orderExtension.getChannelErrorMsg(), outTradeNo, ""); - } - // 成功状态 - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { - PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransaction( - String.valueOf(orderExtension.getOrderId()), PayWalletBizTypeEnum.PAYMENT); - Assert.notNull(walletTransaction, "支付单 {} 钱包流水不能为空", outTradeNo); - return PayOrderRespDTO.successOf(walletTransaction.getNo(), walletTransaction.getCreator(), - walletTransaction.getCreateTime(), outTradeNo, walletTransaction); - } - // 其它状态为无效状态 - log.error("[doGetOrder] 支付单 {} 的状态不正确", outTradeNo); - throw new IllegalStateException(String.format("支付单[%s] 状态不正确", outTradeNo)); - } - - @Override - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - try { - PayWalletTransactionDO payWalletTransaction = wallService.orderRefund(reqDTO.getOutRefundNo(), - reqDTO.getRefundPrice(), reqDTO.getReason()); - return PayRefundRespDTO.successOf(payWalletTransaction.getNo(), payWalletTransaction.getCreateTime(), - reqDTO.getOutRefundNo(), payWalletTransaction); - } catch (Throwable ex) { - log.error("[doUnifiedRefund] 失败", ex); - Integer errorCode = INTERNAL_SERVER_ERROR.getCode(); - String errorMsg = INTERNAL_SERVER_ERROR.getMsg(); - if (ex instanceof ServiceException) { - ServiceException serviceException = (ServiceException) ex; - errorCode = serviceException.getCode(); - errorMsg = serviceException.getMessage(); - } - return PayRefundRespDTO.failureOf(String.valueOf(errorCode), errorMsg, - reqDTO.getOutRefundNo(), ""); - } - } - - @Override - protected PayRefundRespDTO doParseRefundNotify(Map params, String body) { - throw new UnsupportedOperationException("钱包支付无退款回调"); - } - - @Override - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) { - if (refundService == null) { - refundService = SpringUtil.getBean(PayRefundService.class); - } - PayRefundDO payRefund = refundService.getRefundByNo(outRefundNo); - // 支付退款单不存在, 返回退款失败状态 - if (payRefund == null) { - return PayRefundRespDTO.failureOf(String.valueOf(REFUND_NOT_FOUND), REFUND_NOT_FOUND.getMsg(), - outRefundNo, ""); - } - // 退款失败 - if (PayRefundStatusRespEnum.isFailure(payRefund.getStatus())) { - return PayRefundRespDTO.failureOf(payRefund.getChannelErrorCode(), payRefund.getChannelErrorMsg(), - outRefundNo, ""); - } - // 退款成功 - if (PayRefundStatusRespEnum.isSuccess(payRefund.getStatus())) { - PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransaction( - String.valueOf(payRefund.getId()), PayWalletBizTypeEnum.PAYMENT_REFUND); - Assert.notNull(walletTransaction, "支付退款单 {} 钱包流水不能为空", outRefundNo); - return PayRefundRespDTO.successOf(walletTransaction.getNo(), walletTransaction.getCreateTime(), - outRefundNo, walletTransaction); - } - // 其它状态为无效状态 - log.error("[doGetRefund] 支付退款单 {} 的状态不正确", outRefundNo); - throw new IllegalStateException(String.format("支付退款单[%s] 状态不正确", outRefundNo)); - } - - @Override - public PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { - throw new UnsupportedOperationException("待实现"); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/rpc/config/RpcConfiguration.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index 92317f04b..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.rpc.config; - -import cn.iocoder.yudao.module.member.api.user.MemberUserApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = MemberUserApi.class) -public class RpcConfiguration { -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/rpc/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/rpc/package-info.java deleted file mode 100644 index 98523d98b..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/rpc/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.pay.framework.rpc; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/security/config/SecurityConfiguration.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 70a3a239f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.pay.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.pay.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Pay 模块的 Security 配置 - */ -@Configuration("paySecurityConfiguration") -public class SecurityConfiguration { - - @Bean("payAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/security/core/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/security/core/package-info.java deleted file mode 100644 index 12c1c533d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.pay.framework.security.core; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/notify/PayNotifyJob.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/notify/PayNotifyJob.java deleted file mode 100644 index b2c14a9bd..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/notify/PayNotifyJob.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.module.pay.job.notify; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 支付通知 Job - * 通过不断扫描待通知的 PayNotifyTaskDO 记录,回调业务线的回调接口 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class PayNotifyJob { - - @Resource - private PayNotifyService payNotifyService; - - @XxlJob("payNotifyJob") - @TenantJob // 多租户 - public void execute() throws Exception { - int notifyCount = payNotifyService.executeNotify(); - log.info("[execute][执行支付通知 ({}) 个]", notifyCount); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderExpireJob.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderExpireJob.java deleted file mode 100644 index 93dfe4548..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderExpireJob.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.job.order; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 支付订单的过期 Job - * - * 支付超过过期时间时,支付渠道是不会通知进行过期,所以需要定时进行过期关闭。 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class PayOrderExpireJob { - - @Resource - private PayOrderService orderService; - - @XxlJob("payOrderExpireJob") - @TenantJob // 多租户 - public void execute(String param) { - int count = orderService.expireOrder(); - log.info("[execute][支付过期 ({}) 个]", count); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderSyncJob.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderSyncJob.java deleted file mode 100644 index 15de61cdd..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/order/PayOrderSyncJob.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.yudao.module.pay.job.order; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; - -/** - * 支付订单的同步 Job - * - * 由于支付订单的状态,是由支付渠道异步通知进行同步,考虑到异步通知可能会失败(小概率),所以需要定时进行同步。 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class PayOrderSyncJob { - - /** - * 同步创建时间在 N 分钟之前的订单 - * - * 为什么同步 10 分钟之前的订单? - * 因为一个订单发起支付,到支付成功,大多数在 10 分钟内,需要保证轮询到。 - * 如果设置为 30、60 或者更大时间范围,会导致轮询的订单太多,影响性能。当然,你也可以根据自己的业务情况来处理。 - */ - private static final Duration CREATE_TIME_DURATION_BEFORE = Duration.ofMinutes(10); - - @Resource - private PayOrderService orderService; - - @XxlJob("payOrderSyncJob") - @TenantJob // 多租户 - public void execute() { - LocalDateTime minCreateTime = LocalDateTime.now().minus(CREATE_TIME_DURATION_BEFORE); - int count = orderService.syncOrder(minCreateTime); - log.info("[execute][同步支付订单 ({}) 个]", count); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/refund/PayRefundSyncJob.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/refund/PayRefundSyncJob.java deleted file mode 100644 index 25f239dc7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/job/refund/PayRefundSyncJob.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.job.refund; - -import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import com.xxl.job.core.handler.annotation.XxlJob; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 退款订单的同步 Job - * - * 由于退款订单的状态,是由支付渠道异步通知进行同步,考虑到异步通知可能会失败(小概率),所以需要定时进行同步。 - * - * @author 芋道源码 - */ -@Component -@Slf4j -public class PayRefundSyncJob { - - @Resource - private PayRefundService refundService; - - @XxlJob("payRefundSyncJob") - @TenantJob // 多租户 - public void execute() { - int count = refundService.syncRefund(); - log.info("[execute][同步退款订单 ({}) 个]", count); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/package-info.java deleted file mode 100644 index 40ab66da0..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * pay 模块,我们放支付业务,提供业务的支付能力。 - * 例如说:商户、应用、支付、退款等等 - * - * 1. Controller URL:以 /pay/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 pay_ 开头,方便在数据库中区分 - * - * 注意,由于 Pay 模块和 Trade 模块,容易重名,所以类名都加载 Pay 的前缀~ - */ -package cn.iocoder.yudao.module.pay; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppService.java deleted file mode 100644 index 4f9e289d6..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppService.java +++ /dev/null @@ -1,105 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.app; - -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 支付应用 Service 接口 - * - * @author 芋艿 - */ -public interface PayAppService { - - /** - * 创建支付应用 - * - * @param createReqVO 创建 - * @return 编号 - */ - Long createApp(@Valid PayAppCreateReqVO createReqVO); - - /** - * 更新支付应用 - * - * @param updateReqVO 更新 - */ - void updateApp(@Valid PayAppUpdateReqVO updateReqVO); - - /** - * 修改应用状态 - * - * @param id 应用编号 - * @param status 状态 - */ - void updateAppStatus(Long id, Integer status); - - /** - * 删除支付应用 - * - * @param id 编号 - */ - void deleteApp(Long id); - - /** - * 获得支付应用 - * - * @param id 编号 - * @return 支付应用 - */ - PayAppDO getApp(Long id); - - /** - * 获得支付应用列表 - * - * @param ids 编号 - * @return 支付应用列表 - */ - List getAppList(Collection ids); - - /** - * 获得支付应用列表 - * - * @return 支付应用列表 - */ - List getAppList(); - - /** - * 获得支付应用分页 - * - * @param pageReqVO 分页查询 - * @return 支付应用分页 - */ - PageResult getAppPage(PayAppPageReqVO pageReqVO); - - /** - * 获得指定编号的商户 Map - * - * @param ids 应用编号集合 - * @return 商户 Map - */ - default Map getAppMap(Collection ids) { - List list = getAppList(ids); - return CollectionUtils.convertMap(list, PayAppDO::getId); - } - - /** - * 支付应用的合法性 - * - * 如果不合法,抛出 {@link ServiceException} 业务异常 - * - * @param id 应用编号 - * @return 应用 - */ - PayAppDO validPayApp(Long id); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java deleted file mode 100644 index 56087ef13..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.app; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.app.PayAppConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.mysql.app.PayAppMapper; -import cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 支付应用 Service 实现类 - * - * @author aquan - */ -@Service -@Validated -public class PayAppServiceImpl implements PayAppService { - - @Resource - private PayAppMapper appMapper; - - @Resource - @Lazy // 延迟加载,避免循环依赖报错 - private PayOrderService orderService; - @Resource - @Lazy // 延迟加载,避免循环依赖报错 - private PayRefundService refundService; - - @Override - public Long createApp(PayAppCreateReqVO createReqVO) { - // 插入 - PayAppDO app = PayAppConvert.INSTANCE.convert(createReqVO); - appMapper.insert(app); - // 返回 - return app.getId(); - } - - @Override - public void updateApp(PayAppUpdateReqVO updateReqVO) { - // 校验存在 - validateAppExists(updateReqVO.getId()); - // 更新 - PayAppDO updateObj = PayAppConvert.INSTANCE.convert(updateReqVO); - appMapper.updateById(updateObj); - } - - @Override - public void updateAppStatus(Long id, Integer status) { - // 校验商户存在 - validateAppExists(id); - // 更新状态 - appMapper.updateById(new PayAppDO().setId(id).setStatus(status)); - } - - @Override - public void deleteApp(Long id) { - // 校验存在 - validateAppExists(id); - // 校验关联数据是否存在 - if (orderService.getOrderCountByAppId(id) > 0) { - throw exception(APP_EXIST_ORDER_CANT_DELETE); - } - if (refundService.getRefundCountByAppId(id) > 0) { - throw exception(APP_EXIST_REFUND_CANT_DELETE); - } - - // 删除 - appMapper.deleteById(id); - } - - private void validateAppExists(Long id) { - if (appMapper.selectById(id) == null) { - throw exception(APP_NOT_FOUND); - } - } - - @Override - public PayAppDO getApp(Long id) { - return appMapper.selectById(id); - } - - @Override - public List getAppList(Collection ids) { - return appMapper.selectBatchIds(ids); - } - - @Override - public List getAppList() { - return appMapper.selectList(); - } - - @Override - public PageResult getAppPage(PayAppPageReqVO pageReqVO) { - return appMapper.selectPage(pageReqVO); - } - - @Override - public PayAppDO validPayApp(Long id) { - PayAppDO app = appMapper.selectById(id); - // 校验是否存在 - if (app == null) { - throw exception(ErrorCodeConstants.APP_NOT_FOUND); - } - // 校验是否禁用 - if (CommonStatusEnum.DISABLE.getStatus().equals(app.getStatus())) { - throw exception(ErrorCodeConstants.APP_IS_DISABLE); - } - return app; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelService.java deleted file mode 100644 index 281496602..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelService.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.channel; - -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 支付渠道 Service 接口 - * - * @author aquan - */ -public interface PayChannelService { - - /** - * 创建支付渠道 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createChannel(@Valid PayChannelCreateReqVO createReqVO); - - /** - * 更新支付渠道 - * - * @param updateReqVO 更新信息 - */ - void updateChannel(@Valid PayChannelUpdateReqVO updateReqVO); - - /** - * 删除支付渠道 - * - * @param id 编号 - */ - void deleteChannel(Long id); - - /** - * 获得支付渠道 - * - * @param id 编号 - * @return 支付渠道 - */ - PayChannelDO getChannel(Long id); - - /** - * 根据支付应用 ID 集合,获得支付渠道列表 - * - * @param appIds 应用编号集合 - * @return 支付渠道列表 - */ - List getChannelListByAppIds(Collection appIds); - - /** - * 根据条件获取渠道 - * - * @param appId 应用编号 - * @param code 渠道编码 - * @return 数量 - */ - PayChannelDO getChannelByAppIdAndCode(Long appId, String code); - - /** - * 支付渠道的合法性 - * - * 如果不合法,抛出 {@link ServiceException} 业务异常 - * - * @param id 渠道编号 - * @return 渠道信息 - */ - PayChannelDO validPayChannel(Long id); - - /** - * 支付渠道的合法性 - * - * 如果不合法,抛出 {@link ServiceException} 业务异常 - * - * @param appId 应用编号 - * @param code 支付渠道 - * @return 渠道信息 - */ - PayChannelDO validPayChannel(Long appId, String code); - - /** - * 获得指定应用的开启的渠道列表 - * - * @param appId 应用编号 - * @return 渠道列表 - */ - List getEnableChannelList(Long appId); - - /** - * 获得指定编号的支付客户端 - * - * @param id 编号 - * @return 支付客户端 - */ - PayClient getPayClient(Long id); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java deleted file mode 100644 index 2fe495a5f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java +++ /dev/null @@ -1,208 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.channel; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.channel.PayChannelConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.mysql.channel.PayChannelMapper; -import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.PostConstruct; -import javax.annotation.Resource; -import javax.validation.Validator; -import java.time.Duration; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 支付渠道 Service 实现类 - * - * @author aquan - */ -@Service -@Slf4j -@Validated -public class PayChannelServiceImpl implements PayChannelService { - - /** - * {@link PayClient} 缓存,通过它异步清空 smsClientFactory - */ - @Getter - private final LoadingCache clientCache = buildAsyncReloadingCache(Duration.ofSeconds(10L), - new CacheLoader() { - - @Override - public PayClient load(Long id) { - // 查询,然后尝试清空 - PayChannelDO channel = payChannelMapper.selectById(id); - if (channel != null) { - payClientFactory.createOrUpdatePayClient(channel.getId(), channel.getCode(), channel.getConfig()); - } - return payClientFactory.getPayClient(id); - } - - }); - - @Resource - private PayClientFactory payClientFactory; - - @Resource - private PayChannelMapper payChannelMapper; - - @Resource - private Validator validator; - - /** - * 初始化,为了注册钱包 - */ - @PostConstruct - public void init() { - payClientFactory.registerPayClientClass(PayChannelEnum.WALLET, WalletPayClient.class); - } - - @Override - public Long createChannel(PayChannelCreateReqVO reqVO) { - // 断言是否有重复的 - PayChannelDO dbChannel = getChannelByAppIdAndCode(reqVO.getAppId(), reqVO.getCode()); - if (dbChannel != null) { - throw exception(CHANNEL_EXIST_SAME_CHANNEL_ERROR); - } - - // 新增渠道 - PayChannelDO channel = PayChannelConvert.INSTANCE.convert(reqVO) - .setConfig(parseConfig(reqVO.getCode(), reqVO.getConfig())); - payChannelMapper.insert(channel); - return channel.getId(); - } - - @Override - public void updateChannel(PayChannelUpdateReqVO updateReqVO) { - // 校验存在 - PayChannelDO dbChannel = validateChannelExists(updateReqVO.getId()); - - // 更新 - PayChannelDO channel = PayChannelConvert.INSTANCE.convert(updateReqVO) - .setConfig(parseConfig(dbChannel.getCode(), updateReqVO.getConfig())); - payChannelMapper.updateById(channel); - - // 清空缓存 - clearCache(channel.getId()); - } - - /** - * 解析并校验配置 - * - * @param code 渠道编码 - * @param configStr 配置 - * @return 支付配置 - */ - private PayClientConfig parseConfig(String code, String configStr) { - // 解析配置 - Class payClass = PayChannelEnum.getByCode(code).getConfigClass(); - if (ObjectUtil.isNull(payClass)) { - throw exception(CHANNEL_NOT_FOUND); - } - PayClientConfig config = JsonUtils.parseObject2(configStr, payClass); - Assert.notNull(config); - - // 验证参数 - config.validate(validator); - return config; - } - - @Override - public void deleteChannel(Long id) { - // 校验存在 - validateChannelExists(id); - - // 删除 - payChannelMapper.deleteById(id); - - // 清空缓存 - clearCache(id); - } - - /** - * 删除缓存 - * - * @param id 渠道编号 - */ - private void clearCache(Long id) { - clientCache.invalidate(id); - } - - private PayChannelDO validateChannelExists(Long id) { - PayChannelDO channel = payChannelMapper.selectById(id); - if (channel == null) { - throw exception(CHANNEL_NOT_FOUND); - } - return channel; - } - - @Override - public PayChannelDO getChannel(Long id) { - return payChannelMapper.selectById(id); - } - - @Override - public List getChannelListByAppIds(Collection appIds) { - return payChannelMapper.selectListByAppIds(appIds); - } - - @Override - public PayChannelDO getChannelByAppIdAndCode(Long appId, String code) { - return payChannelMapper.selectByAppIdAndCode(appId, code); - } - - @Override - public PayChannelDO validPayChannel(Long id) { - PayChannelDO channel = payChannelMapper.selectById(id); - validPayChannel(channel); - return channel; - } - - @Override - public PayChannelDO validPayChannel(Long appId, String code) { - PayChannelDO channel = payChannelMapper.selectByAppIdAndCode(appId, code); - validPayChannel(channel); - return channel; - } - - private void validPayChannel(PayChannelDO channel) { - if (channel == null) { - throw exception(CHANNEL_NOT_FOUND); - } - if (CommonStatusEnum.DISABLE.getStatus().equals(channel.getStatus())) { - throw exception(CHANNEL_IS_DISABLE); - } - } - - @Override - public List getEnableChannelList(Long appId) { - return payChannelMapper.selectListByAppId(appId, CommonStatusEnum.ENABLE.getStatus()); - } - - @Override - public PayClient getPayClient(Long id) { - return clientCache.getUnchecked(id); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderService.java deleted file mode 100644 index e6822e626..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderService.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.demo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.PayDemoOrderCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; - -import javax.validation.Valid; - -/** - * 示例订单 Service 接口 - * - * @author 芋道源码 - */ -public interface PayDemoOrderService { - - /** - * 创建示例订单 - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDemoOrder(Long userId, @Valid PayDemoOrderCreateReqVO createReqVO); - - /** - * 获得示例订单 - * - * @param id 编号 - * @return 示例订单 - */ - PayDemoOrderDO getDemoOrder(Long id); - - /** - * 获得示例订单分页 - * - * @param pageReqVO 分页查询 - * @return 示例订单分页 - */ - PageResult getDemoOrderPage(PageParam pageReqVO); - - /** - * 更新示例订单为已支付 - * - * @param id 编号 - * @param payOrderId 支付订单号 - */ - void updateDemoOrderPaid(Long id, Long payOrderId); - - /** - * 发起示例订单的退款 - * - * @param id 编号 - * @param userIp 用户编号 - */ - void refundDemoOrder(Long id, String userIp); - - /** - * 更新示例订单为已退款 - * - * @param id 编号 - * @param payRefundId 退款订单号 - */ - void updateDemoOrderRefunded(Long id, Long payRefundId); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderServiceImpl.java deleted file mode 100644 index c19b9dfd8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderServiceImpl.java +++ /dev/null @@ -1,265 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.demo; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.PayDemoOrderCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; -import cn.iocoder.yudao.module.pay.dal.mysql.demo.PayDemoOrderMapper; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import static cn.hutool.core.util.ObjectUtil.notEqual; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 示例订单 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class PayDemoOrderServiceImpl implements PayDemoOrderService { - - /** - * 接入的实力应用编号 - * - * 从 [支付管理 -> 应用信息] 里添加 - */ - private static final Long PAY_APP_ID = 7L; - - /** - * 商品信息 Map - * - * key:商品编号 - * value:[商品名、商品价格] - */ - private final Map spuNames = new HashMap<>(); - - @Resource - private PayOrderApi payOrderApi; - @Resource - private PayRefundApi payRefundApi; - - @Resource - private PayDemoOrderMapper payDemoOrderMapper; - - public PayDemoOrderServiceImpl() { - spuNames.put(1L, new Object[]{"华为手机", 1}); - spuNames.put(2L, new Object[]{"小米电视", 10}); - spuNames.put(3L, new Object[]{"苹果手表", 100}); - spuNames.put(4L, new Object[]{"华硕笔记本", 1000}); - spuNames.put(5L, new Object[]{"蔚来汽车", 200000}); - } - - @Override - public Long createDemoOrder(Long userId, PayDemoOrderCreateReqVO createReqVO) { - // 1.1 获得商品 - Object[] spu = spuNames.get(createReqVO.getSpuId()); - Assert.notNull(spu, "商品({}) 不存在", createReqVO.getSpuId()); - String spuName = (String) spu[0]; - Integer price = (Integer) spu[1]; - // 1.2 插入 demo 订单 - PayDemoOrderDO demoOrder = new PayDemoOrderDO().setUserId(userId) - .setSpuId(createReqVO.getSpuId()).setSpuName(spuName) - .setPrice(price).setPayStatus(false).setRefundPrice(0); - payDemoOrderMapper.insert(demoOrder); - - // 2.1 创建支付单 - Long payOrderId = payOrderApi.createOrder(new PayOrderCreateReqDTO() - .setAppId(PAY_APP_ID).setUserIp(getClientIP()) // 支付应用 - .setMerchantOrderId(demoOrder.getId().toString()) // 业务的订单编号 - .setSubject(spuName).setBody("").setPrice(price) // 价格信息 - .setExpireTime(addTime(Duration.ofHours(2L)))).getCheckedData(); // 支付的过期时间 - // 2.2 更新支付单到 demo 订单 - payDemoOrderMapper.updateById(new PayDemoOrderDO().setId(demoOrder.getId()) - .setPayOrderId(payOrderId)); - // 返回 - return demoOrder.getId(); - } - - @Override - public PayDemoOrderDO getDemoOrder(Long id) { - return payDemoOrderMapper.selectById(id); - } - - @Override - public PageResult getDemoOrderPage(PageParam pageReqVO) { - return payDemoOrderMapper.selectPage(pageReqVO); - } - - @Override - public void updateDemoOrderPaid(Long id, Long payOrderId) { - // 校验并获得支付订单(可支付) - PayOrderRespDTO payOrder = validateDemoOrderCanPaid(id, payOrderId); - - // 更新 PayDemoOrderDO 状态为已支付 - int updateCount = payDemoOrderMapper.updateByIdAndPayed(id, false, - new PayDemoOrderDO().setPayStatus(true).setPayTime(LocalDateTime.now()) - .setPayChannelCode(payOrder.getChannelCode())); - if (updateCount == 0) { - throw exception(DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - } - - /** - * 校验交易订单满足被支付的条件 - * - * 1. 交易订单未支付 - * 2. 支付单已支付 - * - * @param id 交易订单编号 - * @param payOrderId 支付订单编号 - * @return 交易订单 - */ - private PayOrderRespDTO validateDemoOrderCanPaid(Long id, Long payOrderId) { - // 1.1 校验订单是否存在 - PayDemoOrderDO order = payDemoOrderMapper.selectById(id); - if (order == null) { - throw exception(DEMO_ORDER_NOT_FOUND); - } - // 1.2 校验订单未支付 - if (order.getPayStatus()) { - log.error("[validateDemoOrderCanPaid][order({}) 不处于待支付状态,请进行处理!order 数据是:{}]", - id, toJsonString(order)); - throw exception(DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID); - } - // 1.3 校验支付订单匹配 - if (notEqual(order.getPayOrderId(), payOrderId)) { // 支付单号 - log.error("[validateDemoOrderCanPaid][order({}) 支付单不匹配({}),请进行处理!order 数据是:{}]", - id, payOrderId, toJsonString(order)); - throw exception(DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - - // 2.1 校验支付单是否存在 - PayOrderRespDTO payOrder = payOrderApi.getOrder(payOrderId).getCheckedData(); - if (payOrder == null) { - log.error("[validateDemoOrderCanPaid][order({}) payOrder({}) 不存在,请进行处理!]", id, payOrderId); - throw exception(PAY_ORDER_NOT_FOUND); - } - // 2.2 校验支付单已支付 - if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) { - log.error("[validateDemoOrderCanPaid][order({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]", - id, payOrderId, toJsonString(payOrder)); - throw exception(DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_STATUS_NOT_SUCCESS); - } - // 2.3 校验支付金额一致 - if (notEqual(payOrder.getPrice(), order.getPrice())) { - log.error("[validateDemoOrderCanPaid][order({}) payOrder({}) 支付金额不匹配,请进行处理!order 数据是:{},payOrder 数据是:{}]", - id, payOrderId, toJsonString(order), toJsonString(payOrder)); - throw exception(DEMO_ORDER_UPDATE_PAID_FAIL_PAY_PRICE_NOT_MATCH); - } - // 2.4 校验支付订单匹配(二次) - if (notEqual(payOrder.getMerchantOrderId(), id.toString())) { - log.error("[validateDemoOrderCanPaid][order({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]", - id, payOrderId, toJsonString(payOrder)); - throw exception(DEMO_ORDER_UPDATE_PAID_FAIL_PAY_ORDER_ID_ERROR); - } - return payOrder; - } - - @Override - public void refundDemoOrder(Long id, String userIp) { - // 1. 校验订单是否可以退款 - PayDemoOrderDO order = validateDemoOrderCanRefund(id); - - // 2.1 生成退款单号 - // 一般来说,用户发起退款的时候,都会单独插入一个售后维权表,然后使用该表的 id 作为 refundId - // 这里我们是个简单的 demo,所以没有售后维权表,直接使用订单 id + "-refund" 来演示 - String refundId = order.getId() + "-refund"; - // 2.2 创建退款单 - Long payRefundId = payRefundApi.createRefund(new PayRefundCreateReqDTO() - .setAppId(PAY_APP_ID).setUserIp(getClientIP()) // 支付应用 - .setMerchantOrderId(String.valueOf(order.getId())) // 支付单号 - .setMerchantRefundId(refundId) - .setReason("想退钱").setPrice(order.getPrice())).getCheckedData();// 价格信息 - // 2.3 更新退款单到 demo 订单 - payDemoOrderMapper.updateById(new PayDemoOrderDO().setId(id) - .setPayRefundId(payRefundId).setRefundPrice(order.getPrice())); - } - - private PayDemoOrderDO validateDemoOrderCanRefund(Long id) { - // 校验订单是否存在 - PayDemoOrderDO order = payDemoOrderMapper.selectById(id); - if (order == null) { - throw exception(DEMO_ORDER_NOT_FOUND); - } - // 校验订单是否支付 - if (!order.getPayStatus()) { - throw exception(DEMO_ORDER_REFUND_FAIL_NOT_PAID); - } - // 校验订单是否已退款 - if (order.getPayRefundId() != null) { - throw exception(DEMO_ORDER_REFUND_FAIL_REFUNDED); - } - return order; - } - - @Override - public void updateDemoOrderRefunded(Long id, Long payRefundId) { - // 1. 校验并获得退款订单(可退款) - PayRefundRespDTO payRefund = validateDemoOrderCanRefunded(id, payRefundId); - // 2.2 更新退款单到 demo 订单 - payDemoOrderMapper.updateById(new PayDemoOrderDO().setId(id) - .setRefundTime(payRefund.getSuccessTime())); - } - - private PayRefundRespDTO validateDemoOrderCanRefunded(Long id, Long payRefundId) { - // 1.1 校验示例订单 - PayDemoOrderDO order = payDemoOrderMapper.selectById(id); - if (order == null) { - throw exception(DEMO_ORDER_NOT_FOUND); - } - // 1.2 校验退款订单匹配 - if (Objects.equals(order.getPayOrderId(), payRefundId)) { - log.error("[validateDemoOrderCanRefunded][order({}) 退款单不匹配({}),请进行处理!order 数据是:{}]", - id, payRefundId, toJsonString(order)); - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_ORDER_ID_ERROR); - } - - // 2.1 校验退款订单 - PayRefundRespDTO payRefund = payRefundApi.getRefund(payRefundId).getCheckedData(); - if (payRefund == null) { - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_NOT_FOUND); - } - // 2.2 - if (!PayRefundStatusEnum.isSuccess(payRefund.getStatus())) { - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_NOT_SUCCESS); - } - // 2.3 校验退款金额一致 - if (notEqual(payRefund.getRefundPrice(), order.getPrice())) { - log.error("[validateDemoOrderCanRefunded][order({}) payRefund({}) 退款金额不匹配,请进行处理!order 数据是:{},payRefund 数据是:{}]", - id, payRefundId, toJsonString(order), toJsonString(payRefund)); - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_PRICE_NOT_MATCH); - } - // 2.4 校验退款订单匹配(二次) - if (notEqual(payRefund.getMerchantOrderId(), id.toString())) { - log.error("[validateDemoOrderCanRefunded][order({}) 退款单不匹配({}),请进行处理!payRefund 数据是:{}]", - id, payRefundId, toJsonString(payRefund)); - throw exception(DEMO_ORDER_REFUND_FAIL_REFUND_ORDER_ID_ERROR); - } - return payRefund; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferService.java deleted file mode 100644 index f775a838f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferService.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.demo; - -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; - -import javax.validation.Valid; - -/** - * 示例转账业务 Service 接口 - * - * @author jason - */ -public interface PayDemoTransferService { - - /** - * 创建转账单 - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createDemoTransfer(Long userId, @Valid PayDemoTransferCreateReqVO createReqVO); -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java deleted file mode 100644 index d4da016ac..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoTransferServiceImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.demo; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import cn.iocoder.yudao.module.pay.controller.admin.demo.vo.transfer.PayDemoTransferCreateReqVO; -import cn.iocoder.yudao.module.pay.convert.transfer.PayTransferConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoTransferDO; -import cn.iocoder.yudao.module.pay.dal.mysql.demo.PayDemoTransferMapper; -import cn.iocoder.yudao.module.pay.service.transfer.PayTransferService; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum.*; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_TRANSFER_ALIPAY_ACCOUNT_NAME_IS_EMPTY; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_TRANSFER_ALIPAY_LOGIN_ID_IS_EMPTY; -import static cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum.WAITING; - -/** - * 示例转账业务 Service 实现类 - * - * @author jason - */ -@Service -@Validated -public class PayDemoTransferServiceImpl implements PayDemoTransferService { - - /** - * 接入的实力应用编号 - - * 从 [支付管理 -> 应用信息] 里添加 - */ - private static final Long TRANSFER_APP_ID = 8L; - @Resource - private PayDemoTransferMapper demoTransferMapper; - @Resource - private PayTransferService transferService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createDemoTransfer(Long userId, @Valid PayDemoTransferCreateReqVO vo) { - // 1 校验收款账号 - validatePayeeInfo(vo.getType(), vo.getPayeeInfo()); - - // 2 保存示例转账业务表 - PayDemoTransferDO demoTransfer = new PayDemoTransferDO().setUserId(userId).setType(vo.getType()) - .setPrice(vo.getPrice()).setPayeeInfo(vo.getPayeeInfo()) - .setTransferStatus(WAITING.getStatus()); - demoTransferMapper.insert(demoTransfer); - - // 3.1 创建转账单 - Long transferId = transferService.createTransfer(PayTransferConvert.INSTANCE.convert(vo) - .setAppId(TRANSFER_APP_ID).setTitle("示例转账") - .setMerchantOrderId(String.valueOf(demoTransfer.getId()))); - // 3.2 更新转账单编号 - demoTransferMapper.updateById(new PayDemoTransferDO().setId(demoTransfer.getId()) - .setPayTransferId(transferId)); - return demoTransfer.getId(); - } - - // TODO @jason:可以参考 AppBrokerageWithdrawCreateReqVO 搞下字段哈,进行校验 - // @jason payeeinfo 字段确定改一下 - private void validatePayeeInfo(Integer transferType, Map payeeInfo) { - PayTransferTypeEnum transferTypeEnum = typeOf(transferType); - switch (transferTypeEnum) { - case ALIPAY_BALANCE: { - if (StrUtil.isEmpty(MapUtil.getStr(payeeInfo, ALIPAY_LOGON_ID))) { - throw exception(PAY_TRANSFER_ALIPAY_LOGIN_ID_IS_EMPTY); - } - if (StrUtil.isEmpty(MapUtil.getStr(payeeInfo, ALIPAY_ACCOUNT_NAME))) { - throw exception(PAY_TRANSFER_ALIPAY_ACCOUNT_NAME_IS_EMPTY); - } - break; - } - case WX_BALANCE: - case BANK_CARD: - case WALLET_BALANCE: { - throw new UnsupportedOperationException("待实现"); - } - } - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyService.java deleted file mode 100644 index ed9399772..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyService.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.notify; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; - -import java.util.List; - -/** - * 回调通知 Service 接口 - * - * @author 芋道源码 - */ -public interface PayNotifyService { - - /** - * 创建回调通知任务 - * - * @param type 类型 - * @param dataId 数据编号 - */ - void createPayNotifyTask(Integer type, Long dataId); - - /** - * 执行回调通知 - * - * 注意,该方法提供给定时任务调用。目前是 yudao-server 进行调用 - * @return 通知数量 - */ - int executeNotify() throws InterruptedException; - - /** - * 获得回调通知 - * - * @param id 编号 - * @return 回调通知 - */ - PayNotifyTaskDO getNotifyTask(Long id); - - /** - * 获得回调通知分页 - * - * @param pageReqVO 分页查询 - * @return 回调通知分页 - */ - PageResult getNotifyTaskPage(PayNotifyTaskPageReqVO pageReqVO); - - /** - * 获得回调日志列表 - * - * @param taskId 任务编号 - * @return 日志列表 - */ - List getNotifyLogList(Long taskId); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java deleted file mode 100644 index c85876ee7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java +++ /dev/null @@ -1,294 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.notify; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.exceptions.ExceptionUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.hutool.http.HttpResponse; -import cn.hutool.http.HttpUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; -import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyLogMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyTaskMapper; -import cn.iocoder.yudao.module.pay.dal.redis.notify.PayNotifyLockRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import com.google.common.annotations.VisibleForTesting; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.module.pay.framework.job.config.PayJobConfiguration.NOTIFY_THREAD_POOL_TASK_EXECUTOR; - -/** - * 支付通知 Core Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Valid -@Slf4j -public class PayNotifyServiceImpl implements PayNotifyService { - - /** - * 通知超时时间,单位:秒 - */ - public static final int NOTIFY_TIMEOUT = 120; - /** - * {@link #NOTIFY_TIMEOUT} 的毫秒 - */ - public static final long NOTIFY_TIMEOUT_MILLIS = 120 * DateUtils.SECOND_MILLIS; - - @Resource - @Lazy // 循环依赖,避免报错 - private PayOrderService orderService; - @Resource - @Lazy // 循环依赖,避免报错 - private PayRefundService refundService; - - @Resource - private PayNotifyTaskMapper notifyTaskMapper; - @Resource - private PayNotifyLogMapper notifyLogMapper; - - @Resource(name = NOTIFY_THREAD_POOL_TASK_EXECUTOR) - private ThreadPoolTaskExecutor threadPoolTaskExecutor; - - @Resource - private PayNotifyLockRedisDAO notifyLockCoreRedisDAO; - - @Override - @Transactional(rollbackFor = Exception.class) - public void createPayNotifyTask(Integer type, Long dataId) { - PayNotifyTaskDO task = new PayNotifyTaskDO().setType(type).setDataId(dataId); - task.setStatus(PayNotifyStatusEnum.WAITING.getStatus()).setNextNotifyTime(LocalDateTime.now()) - .setNotifyTimes(0).setMaxNotifyTimes(PayNotifyTaskDO.NOTIFY_FREQUENCY.length + 1); - // 补充 appId + notifyUrl 字段 - if (Objects.equals(task.getType(), PayNotifyTypeEnum.ORDER.getType())) { - PayOrderDO order = orderService.getOrder(task.getDataId()); // 不进行非空判断,有问题直接异常 - task.setAppId(order.getAppId()). - setMerchantOrderId(order.getMerchantOrderId()).setNotifyUrl(order.getNotifyUrl()); - } else if (Objects.equals(task.getType(), PayNotifyTypeEnum.REFUND.getType())) { - PayRefundDO refundDO = refundService.getRefund(task.getDataId()); - task.setAppId(refundDO.getAppId()) - .setMerchantOrderId(refundDO.getMerchantOrderId()).setNotifyUrl(refundDO.getNotifyUrl()); - } - - // 执行插入 - notifyTaskMapper.insert(task); - - // 必须在事务提交后,在发起任务,否则 PayNotifyTaskDO 还没入库,就提前回调接入的业务 - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - @Override - public void afterCommit() { - executeNotify(task); - } - }); - } - - @Override - public int executeNotify() throws InterruptedException { - // 获得需要通知的任务 - List tasks = notifyTaskMapper.selectListByNotify(); - if (CollUtil.isEmpty(tasks)) { - return 0; - } - - // 遍历,逐个通知 - CountDownLatch latch = new CountDownLatch(tasks.size()); - tasks.forEach(task -> threadPoolTaskExecutor.execute(() -> { - try { - executeNotify(task); - } finally { - latch.countDown(); - } - })); - // 等待完成 - awaitExecuteNotify(latch); - // 返回执行完成的任务数(成功 + 失败) - return tasks.size(); - } - - /** - * 等待全部支付通知的完成 - * 每 1 秒会打印一次剩余任务数量 - * - * @param latch Latch - * @throws InterruptedException 如果被打断 - */ - private void awaitExecuteNotify(CountDownLatch latch) throws InterruptedException { - long size = latch.getCount(); - for (int i = 0; i < NOTIFY_TIMEOUT; i++) { - if (latch.await(1L, TimeUnit.SECONDS)) { - return; - } - log.info("[awaitExecuteNotify][任务处理中, 总任务数({}) 剩余任务数({})]", size, latch.getCount()); - } - log.error("[awaitExecuteNotify][任务未处理完,总任务数({}) 剩余任务数({})]", size, latch.getCount()); - } - - /** - * 同步执行单个支付通知 - * - * @param task 通知任务 - */ - public void executeNotify(PayNotifyTaskDO task) { - // 分布式锁,避免并发问题 - notifyLockCoreRedisDAO.lock(task.getId(), NOTIFY_TIMEOUT_MILLIS, () -> { - // 校验,当前任务是否已经被通知过 - // 虽然已经通过分布式加锁,但是可能同时满足通知的条件,然后都去获得锁。此时,第一个执行完后,第二个还是能拿到锁,然后会再执行一次。 - // 因此,此处我们通过第 notifyTimes 通知次数是否匹配来判断 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - if (ObjectUtil.notEqual(task.getNotifyTimes(), dbTask.getNotifyTimes())) { - log.warn("[executeNotifySync][task({}) 任务被忽略,原因是它的通知不是第 ({}) 次,可能是因为并发执行了]", - JsonUtils.toJsonString(task), dbTask.getNotifyTimes()); - return; - } - - // 执行通知 - getSelf().executeNotify0(dbTask); - }); - } - - @Transactional(rollbackFor = Exception.class) - public void executeNotify0(PayNotifyTaskDO task) { - // 发起回调 - CommonResult invokeResult = null; - Throwable invokeException = null; - try { - invokeResult = executeNotifyInvoke(task); - } catch (Throwable e) { - invokeException = e; - } - - // 处理结果 - Integer newStatus = processNotifyResult(task, invokeResult, invokeException); - - // 记录 PayNotifyLog 日志 - String response = invokeException != null ? ExceptionUtil.getRootCauseMessage(invokeException) : - JsonUtils.toJsonString(invokeResult); - notifyLogMapper.insert(PayNotifyLogDO.builder().taskId(task.getId()) - .notifyTimes(task.getNotifyTimes() + 1).status(newStatus).response(response).build()); - } - - /** - * 执行单个支付任务的 HTTP 调用 - * - * @param task 通知任务 - * @return HTTP 响应 - */ - private CommonResult executeNotifyInvoke(PayNotifyTaskDO task) { - // 拼接 body 参数 - Object request; - if (Objects.equals(task.getType(), PayNotifyTypeEnum.ORDER.getType())) { - request = PayOrderNotifyReqDTO.builder().merchantOrderId(task.getMerchantOrderId()) - .payOrderId(task.getDataId()).build(); - } else if (Objects.equals(task.getType(), PayNotifyTypeEnum.REFUND.getType())) { - request = PayRefundNotifyReqDTO.builder().merchantOrderId(task.getMerchantOrderId()) - .payRefundId(task.getDataId()).build(); - } else { - throw new RuntimeException("未知的通知任务类型:" + JsonUtils.toJsonString(task)); - } - // 拼接 header 参数 - Map headers = new HashMap<>(); - TenantUtils.addTenantHeader(headers, task.getTenantId()); - - // 发起请求 - try (HttpResponse response = HttpUtil.createPost(task.getNotifyUrl()) - .body(JsonUtils.toJsonString(request)).addHeaders(headers) - .timeout((int) NOTIFY_TIMEOUT_MILLIS).execute()) { - // 解析结果 - return JsonUtils.parseObject(response.body(), CommonResult.class); - } - } - - /** - * 处理并更新通知结果 - * - * @param task 通知任务 - * @param invokeResult 通知结果 - * @param invokeException 通知异常 - * @return 最终任务的状态 - */ - @VisibleForTesting - Integer processNotifyResult(PayNotifyTaskDO task, CommonResult invokeResult, Throwable invokeException) { - // 设置通用的更新 PayNotifyTaskDO 的字段 - PayNotifyTaskDO updateTask = new PayNotifyTaskDO() - .setId(task.getId()) - .setLastExecuteTime(LocalDateTime.now()) - .setNotifyTimes(task.getNotifyTimes() + 1); - - // 情况一:调用成功 - if (invokeResult != null && invokeResult.isSuccess()) { - updateTask.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()); - notifyTaskMapper.updateById(updateTask); - return updateTask.getStatus(); - } - // 情况二:调用失败、调用异常 - // 2.1 超过最大回调次数 - if (updateTask.getNotifyTimes() >= PayNotifyTaskDO.NOTIFY_FREQUENCY.length) { - updateTask.setStatus(PayNotifyStatusEnum.FAILURE.getStatus()); - notifyTaskMapper.updateById(updateTask); - return updateTask.getStatus(); - } - // 2.2 未超过最大回调次数 - updateTask.setNextNotifyTime(addTime(Duration.ofSeconds(PayNotifyTaskDO.NOTIFY_FREQUENCY[updateTask.getNotifyTimes()]))); - updateTask.setStatus(invokeException != null ? PayNotifyStatusEnum.REQUEST_FAILURE.getStatus() - : PayNotifyStatusEnum.REQUEST_SUCCESS.getStatus()); - notifyTaskMapper.updateById(updateTask); - return updateTask.getStatus(); - } - - @Override - public PayNotifyTaskDO getNotifyTask(Long id) { - return notifyTaskMapper.selectById(id); - } - - @Override - public PageResult getNotifyTaskPage(PayNotifyTaskPageReqVO pageReqVO) { - return notifyTaskMapper.selectPage(pageReqVO); - } - - @Override - public List getNotifyLogList(Long taskId) { - return notifyLogMapper.selectListByTaskId(taskId); - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private PayNotifyServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderService.java deleted file mode 100755 index 978a7950c..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderService.java +++ /dev/null @@ -1,140 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.order; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; - -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; -import java.time.LocalDateTime; -import java.util.List; - -/** - * 支付订单 Service 接口 - * - * @author aquan - */ -public interface PayOrderService { - - /** - * 获得支付订单 - * - * @param id 编号 - * @return 支付订单 - */ - PayOrderDO getOrder(Long id); - - /** - * 获得支付订单 - * - * @param appId 应用编号 - * @param merchantOrderId 商户订单编号 - * @return 支付订单 - */ - PayOrderDO getOrder(Long appId, String merchantOrderId); - - /** - * 获得指定应用的订单数量 - * - * @param appId 应用编号 - * @return 订单数量 - */ - Long getOrderCountByAppId(Long appId); - - /** - * 获得支付订单分页 - * - * @param pageReqVO 分页查询 - * @return 支付订单分页 - */ - PageResult getOrderPage(PayOrderPageReqVO pageReqVO); - - /** - * 获得支付订单列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 支付订单列表 - */ - List getOrderList(PayOrderExportReqVO exportReqVO); - - /** - * 创建支付单 - * - * @param reqDTO 创建请求 - * @return 支付单编号 - */ - Long createOrder(@Valid PayOrderCreateReqDTO reqDTO); - - /** - * 提交支付 - * 此时,会发起支付渠道的调用 - * - * @param reqVO 提交请求 - * @param userIp 提交 IP - * @return 提交结果 - */ - PayOrderSubmitRespVO submitOrder(@Valid PayOrderSubmitReqVO reqVO, - @NotEmpty(message = "提交 IP 不能为空") String userIp); - - /** - * 通知支付单成功 - * - * @param channelId 渠道编号 - * @param notify 通知 - */ - void notifyOrder(Long channelId, PayOrderRespDTO notify); - - /** - * 更新支付订单的退款金额 - * - * @param id 编号 - * @param incrRefundPrice 增加的退款金额 - */ - void updateOrderRefundPrice(Long id, Integer incrRefundPrice); - - /** - * 更新支付订单价格 - * - * @param id 支付单编号 - * @param payPrice 支付单价格 - */ - void updatePayOrderPrice(Long id, Integer payPrice); - - /** - * 获得支付订单 - * - * @param id 编号 - * @return 支付订单 - */ - PayOrderExtensionDO getOrderExtension(Long id); - - /** - * 获得支付订单 - * - * @param no 支付订单 no - * @return 支付订单 - */ - PayOrderExtensionDO getOrderExtensionByNo(String no); - - /** - * 同步订单的支付状态 - * - * @param minCreateTime 最小创建时间 - * @return 同步到已支付的订单数量 - */ - int syncOrder(LocalDateTime minCreateTime); - - /** - * 将已过期的订单,状态修改为已关闭 - * - * @return 过期的订单数量 - */ - int expireOrder(); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java deleted file mode 100755 index 16977c630..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java +++ /dev/null @@ -1,570 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.order; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderExtensionMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import com.google.common.annotations.VisibleForTesting; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 支付订单 Service 实现类 - * - * @author aquan - */ -@Service -@Validated -@Slf4j -public class PayOrderServiceImpl implements PayOrderService { - - @Resource - private PayProperties payProperties; - - @Resource - private PayOrderMapper orderMapper; - @Resource - private PayOrderExtensionMapper orderExtensionMapper; - @Resource - private PayNoRedisDAO noRedisDAO; - - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - @Resource - private PayNotifyService notifyService; - - @Override - public PayOrderDO getOrder(Long id) { - return orderMapper.selectById(id); - } - - @Override - public PayOrderDO getOrder(Long appId, String merchantOrderId) { - return orderMapper.selectByAppIdAndMerchantOrderId(appId, merchantOrderId); - } - - @Override - public Long getOrderCountByAppId(Long appId) { - return orderMapper.selectCountByAppId(appId); - } - - @Override - public PageResult getOrderPage(PayOrderPageReqVO pageReqVO) { - return orderMapper.selectPage(pageReqVO); - } - - @Override - public List getOrderList(PayOrderExportReqVO exportReqVO) { - return orderMapper.selectList(exportReqVO); - } - - @Override - public Long createOrder(PayOrderCreateReqDTO reqDTO) { - // 校验 App - PayAppDO app = appService.validPayApp(reqDTO.getAppId()); - - // 查询对应的支付交易单是否已经存在。如果是,则直接返回 - PayOrderDO order = orderMapper.selectByAppIdAndMerchantOrderId( - reqDTO.getAppId(), reqDTO.getMerchantOrderId()); - if (order != null) { - log.warn("[createOrder][appId({}) merchantOrderId({}) 已经存在对应的支付单({})]", order.getAppId(), - order.getMerchantOrderId(), toJsonString(order)); // 理论来说,不会出现这个情况 - return order.getId(); - } - - // 创建支付交易单 - order = PayOrderConvert.INSTANCE.convert(reqDTO).setAppId(app.getId()) - // 商户相关字段 - .setNotifyUrl(app.getOrderNotifyUrl()) - // 订单相关字段 - .setStatus(PayOrderStatusEnum.WAITING.getStatus()) - // 退款相关字段 - .setRefundPrice(0); - orderMapper.insert(order); - return order.getId(); - } - - @Override // 注意,这里不能添加事务注解,避免调用支付渠道失败时,将 PayOrderExtensionDO 回滚了 - public PayOrderSubmitRespVO submitOrder(PayOrderSubmitReqVO reqVO, String userIp) { - // 1.1 获得 PayOrderDO ,并校验其是否存在 - PayOrderDO order = validateOrderCanSubmit(reqVO.getId()); - // 1.32 校验支付渠道是否有效 - PayChannelDO channel = validateChannelCanSubmit(order.getAppId(), reqVO.getChannelCode()); - PayClient client = channelService.getPayClient(channel.getId()); - - // 2. 插入 PayOrderExtensionDO - String no = noRedisDAO.generate(payProperties.getOrderNoPrefix()); - PayOrderExtensionDO orderExtension = PayOrderConvert.INSTANCE.convert(reqVO, userIp) - .setOrderId(order.getId()).setNo(no) - .setChannelId(channel.getId()).setChannelCode(channel.getCode()) - .setStatus(PayOrderStatusEnum.WAITING.getStatus()); - orderExtensionMapper.insert(orderExtension); - - // 3. 调用三方接口 - PayOrderUnifiedReqDTO unifiedOrderReqDTO = PayOrderConvert.INSTANCE.convert2(reqVO, userIp) - // 商户相关的字段 - .setOutTradeNo(orderExtension.getNo()) // 注意,此处使用的是 PayOrderExtensionDO.no 属性! - .setSubject(order.getSubject()).setBody(order.getBody()) - .setNotifyUrl(genChannelOrderNotifyUrl(channel)) - .setReturnUrl(reqVO.getReturnUrl()) - // 订单相关字段 - .setPrice(order.getPrice()).setExpireTime(order.getExpireTime()); - PayOrderRespDTO unifiedOrderResp = client.unifiedOrder(unifiedOrderReqDTO); - - // 4. 如果调用直接支付成功,则直接更新支付单状态为成功。例如说:付款码支付,免密支付时,就直接验证支付成功 - if (unifiedOrderResp != null) { - getSelf().notifyOrder(channel, unifiedOrderResp); - // 如有渠道错误码,则抛出业务异常,提示用户 - if (StrUtil.isNotEmpty(unifiedOrderResp.getChannelErrorCode())) { - throw exception(PAY_ORDER_SUBMIT_CHANNEL_ERROR, unifiedOrderResp.getChannelErrorCode(), - unifiedOrderResp.getChannelErrorMsg()); - } - // 此处需要读取最新的状态 - order = orderMapper.selectById(order.getId()); - } - return PayOrderConvert.INSTANCE.convert(order, unifiedOrderResp); - } - - private PayOrderDO validateOrderCanSubmit(Long id) { - PayOrderDO order = orderMapper.selectById(id); - if (order == null) { // 是否存在 - throw exception(PAY_ORDER_NOT_FOUND); - } - if (PayOrderStatusEnum.isSuccess(order.getStatus())) { // 校验状态,发现已支付 - throw exception(PAY_ORDER_STATUS_IS_SUCCESS); - } - if (!PayOrderStatusEnum.WAITING.getStatus().equals(order.getStatus())) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING); - } - if (LocalDateTimeUtils.beforeNow(order.getExpireTime())) { // 校验是否过期 - throw exception(PAY_ORDER_IS_EXPIRED); - } - - // 【重要】校验是否支付拓展单已支付,只是没有回调、或者数据不正常 - validateOrderActuallyPaid(id); - return order; - } - - /** - * 校验支付订单实际已支付 - * - * @param id 支付编号 - */ - @VisibleForTesting - void validateOrderActuallyPaid(Long id) { - List orderExtensions = orderExtensionMapper.selectListByOrderId(id); - orderExtensions.forEach(orderExtension -> { - // 情况一:校验数据库中的 orderExtension 是不是已支付 - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { - log.warn("[validateOrderCanSubmit][order({}) 的 extension({}) 已支付,可能是数据不一致]", - id, orderExtension.getId()); - throw exception(PAY_ORDER_EXTENSION_IS_PAID); - } - // 情况二:调用三方接口,查询支付单状态,是不是已支付 - PayClient payClient = channelService.getPayClient(orderExtension.getChannelId()); - if (payClient == null) { - log.error("[validateOrderCanSubmit][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId()); - return; - } - PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo()); - if (respDTO != null && PayOrderStatusRespEnum.isSuccess(respDTO.getStatus())) { - log.warn("[validateOrderCanSubmit][order({}) 的 PayOrderRespDTO({}) 已支付,可能是回调延迟]", - id, toJsonString(respDTO)); - throw exception(PAY_ORDER_EXTENSION_IS_PAID); - } - }); - } - - private PayChannelDO validateChannelCanSubmit(Long appId, String channelCode) { - // 校验 App - appService.validPayApp(appId); - // 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(appId, channelCode); - PayClient client = channelService.getPayClient(channel.getId()); - if (client == null) { - log.error("[validatePayChannelCanSubmit][渠道编号({}) 找不到对应的支付客户端]", channel.getId()); - throw exception(CHANNEL_NOT_FOUND); - } - return channel; - } - - /** - * 根据支付渠道的编码,生成支付渠道的回调地址 - * - * @param channel 支付渠道 - * @return 支付渠道的回调地址 配置地址 + "/" + channel id - */ - private String genChannelOrderNotifyUrl(PayChannelDO channel) { - return payProperties.getOrderNotifyUrl() + "/" + channel.getId(); - } - - @Override - public void notifyOrder(Long channelId, PayOrderRespDTO notify) { - // 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(channelId); - // 更新支付订单为已支付 - TenantUtils.execute(channel.getTenantId(), () -> getSelf().notifyOrder(channel, notify)); - } - - /** - * 通知并更新订单的支付结果 - * - * @param channel 支付渠道 - * @param notify 通知 - */ - @Transactional(rollbackFor = Exception.class) - // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyPayOrder(channel, notify) 调用,否则事务不生效 - public void notifyOrder(PayChannelDO channel, PayOrderRespDTO notify) { - // 情况一:支付成功的回调 - if (PayOrderStatusRespEnum.isSuccess(notify.getStatus())) { - notifyOrderSuccess(channel, notify); - return; - } - // 情况二:支付失败的回调 - if (PayOrderStatusRespEnum.isClosed(notify.getStatus())) { - notifyOrderClosed(channel, notify); - } - // 情况三:WAITING:无需处理 - // 情况四:REFUND:通过退款回调处理 - } - - private void notifyOrderSuccess(PayChannelDO channel, PayOrderRespDTO notify) { - // 1. 更新 PayOrderExtensionDO 支付成功 - PayOrderExtensionDO orderExtension = updateOrderSuccess(notify); - // 2. 更新 PayOrderDO 支付成功 - Boolean paid = updateOrderSuccess(channel, orderExtension, notify); - if (paid) { // 如果之前已经成功回调,则直接返回,不用重复记录支付通知记录;例如说:支付平台重复回调 - return; - } - - // 3. 插入支付通知记录 - notifyService.createPayNotifyTask(PayNotifyTypeEnum.ORDER.getType(), - orderExtension.getOrderId()); - } - - /** - * 更新 PayOrderExtensionDO 支付成功 - * - * @param notify 通知 - * @return PayOrderExtensionDO 对象 - */ - private PayOrderExtensionDO updateOrderSuccess(PayOrderRespDTO notify) { - // 1. 查询 PayOrderExtensionDO - PayOrderExtensionDO orderExtension = orderExtensionMapper.selectByNo(notify.getOutTradeNo()); - if (orderExtension == null) { - throw exception(PAY_ORDER_EXTENSION_NOT_FOUND); - } - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { // 如果已经是成功,直接返回,不用重复更新 - log.info("[updateOrderExtensionSuccess][orderExtension({}) 已经是已支付,无需更新]", orderExtension.getId()); - return orderExtension; - } - if (ObjectUtil.notEqual(orderExtension.getStatus(), PayOrderStatusEnum.WAITING.getStatus())) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - - // 2. 更新 PayOrderExtensionDO - int updateCounts = orderExtensionMapper.updateByIdAndStatus(orderExtension.getId(), orderExtension.getStatus(), - PayOrderExtensionDO.builder().status(PayOrderStatusEnum.SUCCESS.getStatus()).channelNotifyData(toJsonString(notify)).build()); - if (updateCounts == 0) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - log.info("[updateOrderExtensionSuccess][orderExtension({}) 更新为已支付]", orderExtension.getId()); - return orderExtension; - } - - /** - * 更新 PayOrderDO 支付成功 - * - * @param channel 支付渠道 - * @param orderExtension 支付拓展单 - * @param notify 通知回调 - * @return 是否之前已经成功回调 - */ - private Boolean updateOrderSuccess(PayChannelDO channel, PayOrderExtensionDO orderExtension, - PayOrderRespDTO notify) { - // 1. 判断 PayOrderDO 是否处于待支付 - PayOrderDO order = orderMapper.selectById(orderExtension.getOrderId()); - if (order == null) { - throw exception(PAY_ORDER_NOT_FOUND); - } - if (PayOrderStatusEnum.isSuccess(order.getStatus()) // 如果已经是成功,直接返回,不用重复更新 - && Objects.equals(order.getExtensionId(), orderExtension.getId())) { - log.info("[updateOrderExtensionSuccess][order({}) 已经是已支付,无需更新]", order.getId()); - return true; - } - if (!PayOrderStatusEnum.WAITING.getStatus().equals(order.getStatus())) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING); - } - - // 2. 更新 PayOrderDO - int updateCounts = orderMapper.updateByIdAndStatus(order.getId(), PayOrderStatusEnum.WAITING.getStatus(), - PayOrderDO.builder().status(PayOrderStatusEnum.SUCCESS.getStatus()) - .channelId(channel.getId()).channelCode(channel.getCode()) - .successTime(notify.getSuccessTime()).extensionId(orderExtension.getId()).no(orderExtension.getNo()) - .channelOrderNo(notify.getChannelOrderNo()).channelUserId(notify.getChannelUserId()) - .channelFeeRate(channel.getFeeRate()) - .channelFeePrice(MoneyUtils.calculateRatePrice(order.getPrice(), channel.getFeeRate())) - .build()); - if (updateCounts == 0) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING); - } - log.info("[updateOrderExtensionSuccess][order({}) 更新为已支付]", order.getId()); - return false; - } - - private void notifyOrderClosed(PayChannelDO channel, PayOrderRespDTO notify) { - updateOrderExtensionClosed(channel, notify); - } - - private void updateOrderExtensionClosed(PayChannelDO channel, PayOrderRespDTO notify) { - // 1. 查询 PayOrderExtensionDO - PayOrderExtensionDO orderExtension = orderExtensionMapper.selectByNo(notify.getOutTradeNo()); - if (orderExtension == null) { - throw exception(PAY_ORDER_EXTENSION_NOT_FOUND); - } - if (PayOrderStatusEnum.isClosed(orderExtension.getStatus())) { // 如果已经是关闭,直接返回,不用重复更新 - log.info("[updateOrderExtensionClosed][orderExtension({}) 已经是支付关闭,无需更新]", orderExtension.getId()); - return; - } - // 一般出现先是支付成功,然后支付关闭,都是全部退款导致关闭的场景。这个情况,我们不更新支付拓展单,只通过退款流程,更新支付单 - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { - log.info("[updateOrderExtensionClosed][orderExtension({}) 是已支付,无需更新为支付关闭]", orderExtension.getId()); - return; - } - if (ObjectUtil.notEqual(orderExtension.getStatus(), PayOrderStatusEnum.WAITING.getStatus())) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - - // 2. 更新 PayOrderExtensionDO - int updateCounts = orderExtensionMapper.updateByIdAndStatus(orderExtension.getId(), orderExtension.getStatus(), - PayOrderExtensionDO.builder().status(PayOrderStatusEnum.CLOSED.getStatus()).channelNotifyData(toJsonString(notify)) - .channelErrorCode(notify.getChannelErrorCode()).channelErrorMsg(notify.getChannelErrorMsg()).build()); - if (updateCounts == 0) { // 校验状态,必须是待支付 - throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - log.info("[updateOrderExtensionClosed][orderExtension({}) 更新为支付关闭]", orderExtension.getId()); - } - - @Override - public void updateOrderRefundPrice(Long id, Integer incrRefundPrice) { - PayOrderDO order = orderMapper.selectById(id); - if (order == null) { - throw exception(PAY_ORDER_NOT_FOUND); - } - if (!PayOrderStatusEnum.isSuccessOrRefund(order.getStatus())) { - throw exception(PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - if (order.getRefundPrice() + incrRefundPrice > order.getPrice()) { - throw exception(REFUND_PRICE_EXCEED); - } - - // 更新订单 - PayOrderDO updateObj = new PayOrderDO() - .setRefundPrice(order.getRefundPrice() + incrRefundPrice) - .setStatus(PayOrderStatusEnum.REFUND.getStatus()); - int updateCount = orderMapper.updateByIdAndStatus(id, order.getStatus(), updateObj); - if (updateCount == 0) { - throw exception(PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - } - - @Override - public void updatePayOrderPrice(Long id, Integer payPrice) { - PayOrderDO order = orderMapper.selectById(id); - if (order == null) { - throw exception(PAY_ORDER_NOT_FOUND); - } - if (ObjectUtil.notEqual(PayOrderStatusEnum.WAITING.getStatus(), order.getStatus())) { - throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING); - } - if (ObjectUtil.equal(order.getPrice(), payPrice)) { - return; - } - - // TODO 芋艿:应该 new 出来更新 - order.setPrice(payPrice); - orderMapper.updateById(order); - } - - @Override - public PayOrderExtensionDO getOrderExtension(Long id) { - return orderExtensionMapper.selectById(id); - } - - @Override - public PayOrderExtensionDO getOrderExtensionByNo(String no) { - return orderExtensionMapper.selectByNo(no); - } - - @Override - public int syncOrder(LocalDateTime minCreateTime) { - // 1. 查询指定创建时间内的待支付订单 - List orderExtensions = orderExtensionMapper.selectListByStatusAndCreateTimeGe( - PayOrderStatusEnum.WAITING.getStatus(), minCreateTime); - if (CollUtil.isEmpty(orderExtensions)) { - return 0; - } - // 2. 遍历执行 - int count = 0; - for (PayOrderExtensionDO orderExtension : orderExtensions) { - count += syncOrder(orderExtension) ? 1 : 0; - } - return count; - } - - /** - * 同步单个支付拓展单 - * - * @param orderExtension 支付拓展单 - * @return 是否已支付 - */ - private boolean syncOrder(PayOrderExtensionDO orderExtension) { - try { - // 1.1 查询支付订单信息 - PayClient payClient = channelService.getPayClient(orderExtension.getChannelId()); - if (payClient == null) { - log.error("[syncOrder][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId()); - return false; - } - PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo()); - // 1.2 回调支付结果 - notifyOrder(orderExtension.getChannelId(), respDTO); - - // 2. 如果是已支付,则返回 true - return PayOrderStatusRespEnum.isSuccess(respDTO.getStatus()); - } catch (Throwable e) { - log.error("[syncOrder][orderExtension({}) 同步支付状态异常]", orderExtension.getId(), e); - return false; - } - } - - @Override - public int expireOrder() { - // 1. 查询过期的待支付订单 - List orders = orderMapper.selectListByStatusAndExpireTimeLt( - PayOrderStatusEnum.WAITING.getStatus(), LocalDateTime.now()); - if (CollUtil.isEmpty(orders)) { - return 0; - } - - // 2. 遍历执行 - int count = 0; - for (PayOrderDO order : orders) { - count += expireOrder(order) ? 1 : 0; - } - return count; - } - - /** - * 同步单个支付单 - * - * @param order 支付单 - * @return 是否已过期 - */ - private boolean expireOrder(PayOrderDO order) { - try { - // 1. 需要先处理关联的支付拓展单,避免错误的过期已支付 or 已退款的订单 - List orderExtensions = orderExtensionMapper.selectListByOrderId(order.getId()); - for (PayOrderExtensionDO orderExtension : orderExtensions) { - if (PayOrderStatusEnum.isClosed(orderExtension.getStatus())) { - continue; - } - // 情况一:校验数据库中的 orderExtension 是不是已支付 - if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { - log.error("[expireOrder][order({}) 的 extension({}) 已支付,可能是数据不一致]", - order.getId(), orderExtension.getId()); - return false; - } - // 情况二:调用三方接口,查询支付单状态,是不是已支付/已退款 - PayClient payClient = channelService.getPayClient(orderExtension.getChannelId()); - if (payClient == null) { - log.error("[expireOrder][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId()); - return false; - } - PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo()); - if (PayOrderStatusRespEnum.isRefund(respDTO.getStatus())) { - // 补充说明:按道理,应该是 WAITING => SUCCESS => REFUND 状态,如果直接 WAITING => REFUND 状态,说明中间丢了过程 - // 此时,需要人工介入,手工补齐数据,保持 WAITING => SUCCESS => REFUND 的过程 - log.error("[expireOrder][extension({}) 的 PayOrderRespDTO({}) 已退款,可能是回调延迟]", - orderExtension.getId(), toJsonString(respDTO)); - return false; - } - if (PayOrderStatusRespEnum.isSuccess(respDTO.getStatus())) { - notifyOrder(orderExtension.getChannelId(), respDTO); - return false; - } - // 兜底逻辑:将支付拓展单更新为已关闭 - PayOrderExtensionDO updateObj = new PayOrderExtensionDO().setStatus(PayOrderStatusEnum.CLOSED.getStatus()) - .setChannelNotifyData(toJsonString(respDTO)); - if (orderExtensionMapper.updateByIdAndStatus(orderExtension.getId(), PayOrderStatusEnum.WAITING.getStatus(), - updateObj) == 0) { - log.error("[expireOrder][extension({}) 更新为支付关闭失败]", orderExtension.getId()); - return false; - } - log.info("[expireOrder][extension({}) 更新为支付关闭成功]", orderExtension.getId()); - } - - // 2. 都没有上述情况,可以安心更新为已关闭 - PayOrderDO updateObj = new PayOrderDO().setStatus(PayOrderStatusEnum.CLOSED.getStatus()); - if (orderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateObj) == 0) { - log.error("[expireOrder][order({}) 更新为支付关闭失败]", order.getId()); - return false; - } - log.info("[expireOrder][order({}) 更新为支付关闭失败]", order.getId()); - return true; - } catch (Throwable e) { - log.error("[expireOrder][order({}) 过期订单异常]", order.getId(), e); - return false; - } - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private PayOrderServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundService.java deleted file mode 100755 index 258cea964..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundService.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.refund; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; - -import java.util.List; - -/** - * 退款订单 Service 接口 - * - * @author aquan - */ -public interface PayRefundService { - - /** - * 获得退款订单 - * - * @param id 编号 - * @return 退款订单 - */ - PayRefundDO getRefund(Long id); - - /** - * 获得退款订单 - * - * @param no 外部退款单号 - * @return 退款订单 - */ - PayRefundDO getRefundByNo(String no); - - /** - * 获得指定应用的退款数量 - * - * @param appId 应用编号 - * @return 退款数量 - */ - Long getRefundCountByAppId(Long appId); - - /** - * 获得退款订单分页 - * - * @param pageReqVO 分页查询 - * @return 退款订单分页 - */ - PageResult getRefundPage(PayRefundPageReqVO pageReqVO); - - /** - * 获得退款订单列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 退款订单列表 - */ - List getRefundList(PayRefundExportReqVO exportReqVO); - - /** - * 创建退款申请 - * - * @param reqDTO 退款申请信息 - * @return 退款单号 - */ - Long createPayRefund(PayRefundCreateReqDTO reqDTO); - - /** - * 渠道的退款通知 - * - * @param channelId 渠道编号 - * @param notify 通知 - */ - void notifyRefund(Long channelId, PayRefundRespDTO notify); - - /** - * 同步渠道退款的退款状态 - * - * @return 同步到状态的退款数量,包括退款成功、退款失败 - */ - int syncRefund(); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java deleted file mode 100755 index 20855826d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java +++ /dev/null @@ -1,331 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.refund; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; -import cn.iocoder.yudao.module.pay.convert.refund.PayRefundConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.mysql.refund.PayRefundMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 退款订单 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -@Validated -public class PayRefundServiceImpl implements PayRefundService { - - @Resource - private PayProperties payProperties; - - @Resource - private PayRefundMapper refundMapper; - @Resource - private PayNoRedisDAO noRedisDAO; - - @Resource - private PayOrderService orderService; - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - @Resource - private PayNotifyService notifyService; - - @Override - public PayRefundDO getRefund(Long id) { - return refundMapper.selectById(id); - } - - @Override - public PayRefundDO getRefundByNo(String no) { - return refundMapper.selectByNo(no); - } - - @Override - public Long getRefundCountByAppId(Long appId) { - return refundMapper.selectCountByAppId(appId); - } - - @Override - public PageResult getRefundPage(PayRefundPageReqVO pageReqVO) { - return refundMapper.selectPage(pageReqVO); - } - - @Override - public List getRefundList(PayRefundExportReqVO exportReqVO) { - return refundMapper.selectList(exportReqVO); - } - - @Override - public Long createPayRefund(PayRefundCreateReqDTO reqDTO) { - // 1.1 校验 App - PayAppDO app = appService.validPayApp(reqDTO.getAppId()); - // 1.2 校验支付订单 - PayOrderDO order = validatePayOrderCanRefund(reqDTO); - // 1.3 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(order.getChannelId()); - PayClient client = channelService.getPayClient(channel.getId()); - if (client == null) { - log.error("[refund][渠道编号({}) 找不到对应的支付客户端]", channel.getId()); - throw exception(CHANNEL_NOT_FOUND); - } - // 1.4 校验退款订单是否已经存在 - PayRefundDO refund = refundMapper.selectByAppIdAndMerchantRefundId( - app.getId(), reqDTO.getMerchantRefundId()); - if (refund != null) { - throw exception(REFUND_EXISTS); - } - - // 2.1 插入退款单 - String no = noRedisDAO.generate(payProperties.getRefundNoPrefix()); - refund = PayRefundConvert.INSTANCE.convert(reqDTO) - .setNo(no).setOrderId(order.getId()).setOrderNo(order.getNo()) - .setChannelId(order.getChannelId()).setChannelCode(order.getChannelCode()) - // 商户相关的字段 - .setNotifyUrl(app.getRefundNotifyUrl()) - // 渠道相关字段 - .setChannelOrderNo(order.getChannelOrderNo()) - // 退款相关字段 - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setPayPrice(order.getPrice()).setRefundPrice(reqDTO.getPrice()); - refundMapper.insert(refund); - try { - // 2.2 向渠道发起退款申请 - PayRefundUnifiedReqDTO unifiedReqDTO = new PayRefundUnifiedReqDTO() - .setPayPrice(order.getPrice()) - .setRefundPrice(reqDTO.getPrice()) - .setOutTradeNo(order.getNo()) - .setOutRefundNo(refund.getNo()) - .setNotifyUrl(genChannelRefundNotifyUrl(channel)) - .setReason(reqDTO.getReason()); - PayRefundRespDTO refundRespDTO = client.unifiedRefund(unifiedReqDTO); - // 2.3 处理退款返回 - getSelf().notifyRefund(channel, refundRespDTO); - } catch (Throwable e) { - // 注意:这里仅打印异常,不进行抛出。 - // 原因是:虽然调用支付渠道进行退款发生异常(网络请求超时),实际退款成功。这个结果,后续通过退款回调、或者退款轮询补偿可以拿到。 - // 最终,在异常的情况下,支付中心会异步回调业务的退款回调接口,提供退款结果 - log.error("[createPayRefund][退款 id({}) requestDTO({}) 发生异常]", - refund.getId(), reqDTO, e); - } - - // 返回退款编号 - return refund.getId(); - } - - /** - * 校验支付订单是否可以退款 - * - * @param reqDTO 退款申请信息 - * @return 支付订单 - */ - private PayOrderDO validatePayOrderCanRefund(PayRefundCreateReqDTO reqDTO) { - PayOrderDO order = orderService.getOrder(reqDTO.getAppId(), reqDTO.getMerchantOrderId()); - if (order == null) { - throw exception(PAY_ORDER_NOT_FOUND); - } - // 校验状态,必须是已支付、或者已退款 - if (!PayOrderStatusEnum.isSuccessOrRefund(order.getStatus())) { - throw exception(PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - - // 校验金额,退款金额不能大于原定的金额 - if (reqDTO.getPrice() + order.getRefundPrice() > order.getPrice()){ - throw exception(REFUND_PRICE_EXCEED); - } - // 是否有退款中的订单 - if (refundMapper.selectCountByAppIdAndOrderId(reqDTO.getAppId(), order.getId(), - PayRefundStatusEnum.WAITING.getStatus()) > 0) { - throw exception(REFUND_HAS_REFUNDING); - } - return order; - } - - /** - * 根据支付渠道的编码,生成支付渠道的回调地址 - * - * @param channel 支付渠道 - * @return 支付渠道的回调地址 配置地址 + "/" + channel id - */ - private String genChannelRefundNotifyUrl(PayChannelDO channel) { - return payProperties.getRefundNotifyUrl() + "/" + channel.getId(); - } - - @Override - public void notifyRefund(Long channelId, PayRefundRespDTO notify) { - // 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(channelId); - // 更新退款订单 - TenantUtils.execute(channel.getTenantId(), () -> getSelf().notifyRefund(channel, notify)); - } - - /** - * 通知并更新订单的退款结果 - * - * @param channel 支付渠道 - * @param notify 通知 - */ - @Transactional(rollbackFor = Exception.class) // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyRefund(channel, notify) 调用,否则事务不生效 - public void notifyRefund(PayChannelDO channel, PayRefundRespDTO notify) { - // 情况一:退款成功 - if (PayRefundStatusRespEnum.isSuccess(notify.getStatus())) { - notifyRefundSuccess(channel, notify); - return; - } - // 情况二:退款失败 - if (PayRefundStatusRespEnum.isFailure(notify.getStatus())) { - notifyRefundFailure(channel, notify); - } - } - - private void notifyRefundSuccess(PayChannelDO channel, PayRefundRespDTO notify) { - // 1.1 查询 PayRefundDO - PayRefundDO refund = refundMapper.selectByAppIdAndNo( - channel.getAppId(), notify.getOutRefundNo()); - if (refund == null) { - throw exception(REFUND_NOT_FOUND); - } - if (PayRefundStatusEnum.isSuccess(refund.getStatus())) { // 如果已经是成功,直接返回,不用重复更新 - log.info("[notifyRefundSuccess][退款订单({}) 已经是退款成功,无需更新]", refund.getId()); - return; - } - if (!PayRefundStatusEnum.WAITING.getStatus().equals(refund.getStatus())) { - throw exception(REFUND_STATUS_IS_NOT_WAITING); - } - // 1.2 更新 PayRefundDO - PayRefundDO updateRefundObj = new PayRefundDO() - .setSuccessTime(notify.getSuccessTime()) - .setChannelRefundNo(notify.getChannelRefundNo()) - .setStatus(PayRefundStatusEnum.SUCCESS.getStatus()) - .setChannelNotifyData(toJsonString(notify)); - int updateCounts = refundMapper.updateByIdAndStatus(refund.getId(), refund.getStatus(), updateRefundObj); - if (updateCounts == 0) { // 校验状态,必须是等待状态 - throw exception(REFUND_STATUS_IS_NOT_WAITING); - } - log.info("[notifyRefundSuccess][退款订单({}) 更新为退款成功]", refund.getId()); - - // 2. 更新订单 - orderService.updateOrderRefundPrice(refund.getOrderId(), refund.getRefundPrice()); - - // 3. 插入退款通知记录 - notifyService.createPayNotifyTask(PayNotifyTypeEnum.REFUND.getType(), - refund.getId()); - } - - private void notifyRefundFailure(PayChannelDO channel, PayRefundRespDTO notify) { - // 1.1 查询 PayRefundDO - PayRefundDO refund = refundMapper.selectByAppIdAndNo( - channel.getAppId(), notify.getOutRefundNo()); - if (refund == null) { - throw exception(REFUND_NOT_FOUND); - } - if (PayRefundStatusEnum.isFailure(refund.getStatus())) { // 如果已经是成功,直接返回,不用重复更新 - log.info("[notifyRefundSuccess][退款订单({}) 已经是退款关闭,无需更新]", refund.getId()); - return; - } - if (!PayRefundStatusEnum.WAITING.getStatus().equals(refund.getStatus())) { - throw exception(REFUND_STATUS_IS_NOT_WAITING); - } - // 1.2 更新 PayRefundDO - PayRefundDO updateRefundObj = new PayRefundDO() - .setChannelRefundNo(notify.getChannelRefundNo()) - .setStatus(PayRefundStatusEnum.FAILURE.getStatus()) - .setChannelNotifyData(toJsonString(notify)) - .setChannelErrorCode(notify.getChannelErrorCode()).setChannelErrorMsg(notify.getChannelErrorMsg()); - int updateCounts = refundMapper.updateByIdAndStatus(refund.getId(), refund.getStatus(), updateRefundObj); - if (updateCounts == 0) { // 校验状态,必须是等待状态 - throw exception(REFUND_STATUS_IS_NOT_WAITING); - } - log.info("[notifyRefundFailure][退款订单({}) 更新为退款失败]", refund.getId()); - - // 2. 插入退款通知记录 - notifyService.createPayNotifyTask(PayNotifyTypeEnum.REFUND.getType(), - refund.getId()); - } - - @Override - public int syncRefund() { - // 1. 查询指定创建时间内的待退款订单 - List refunds = refundMapper.selectListByStatus(PayRefundStatusEnum.WAITING.getStatus()); - if (CollUtil.isEmpty(refunds)) { - return 0; - } - // 2. 遍历执行 - int count = 0; - for (PayRefundDO refund : refunds) { - count += syncRefund(refund) ? 1 : 0; - } - return count; - } - - /** - * 同步单个退款订单 - * - * @param refund 退款订单 - * @return 是否同步到 - */ - private boolean syncRefund(PayRefundDO refund) { - try { - // 1.1 查询退款订单信息 - PayClient payClient = channelService.getPayClient(refund.getChannelId()); - if (payClient == null) { - log.error("[syncRefund][渠道编号({}) 找不到对应的支付客户端]", refund.getChannelId()); - return false; - } - PayRefundRespDTO respDTO = payClient.getRefund(refund.getOrderNo(), refund.getNo()); - // 1.2 回调退款结果 - notifyRefund(refund.getChannelId(), respDTO); - - // 2. 如果同步到,则返回 true - return PayRefundStatusEnum.isSuccess(respDTO.getStatus()) - || PayRefundStatusEnum.isFailure(respDTO.getStatus()); - } catch (Throwable e) { - log.error("[syncRefund][refund({}) 同步退款状态异常]", refund.getId(), e); - return false; - } - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private PayRefundServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java deleted file mode 100644 index 0da38c640..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferService.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.transfer; - -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferSubmitRespVO; - -import javax.validation.Valid; - -/** - * 转账 Service 接口 - * - * @author jason - */ -public interface PayTransferService { - - /** - * 提交转账单 - * - * 此时,会发起支付渠道的调用 - * - * @param reqVO 请求 - * @param userIp 用户 ip - * @return 渠道的返回结果 - */ - PayTransferSubmitRespVO submitTransfer(@Valid PayTransferSubmitReqVO reqVO, String userIp); - - /** - * 创建转账单 - * - * @param reqDTO 创建请求 - * @return 转账单编号 - */ - Long createTransfer(@Valid PayTransferCreateReqDTO reqDTO); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java deleted file mode 100644 index cbe5b739c..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/transfer/PayTransferServiceImpl.java +++ /dev/null @@ -1,271 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.transfer; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferSubmitRespVO; -import cn.iocoder.yudao.module.pay.convert.transfer.PayTransferConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferExtensionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.transfer.PayTransferExtensionMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.transfer.PayTransferMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum.*; - -// TODO @jason:等彻底实现完,单测写写; -/** - * 转账 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -public class PayTransferServiceImpl implements PayTransferService { - - private static final String TRANSFER_NO_PREFIX = "T"; - - @Resource - private PayTransferMapper transferMapper; - @Resource - private PayTransferExtensionMapper transferExtensionMapper; - - @Resource - private PayAppService appService; - @Resource - private PayChannelService channelService; - - @Resource - private PayNoRedisDAO noRedisDAO; - - @Override - public PayTransferSubmitRespVO submitTransfer(PayTransferSubmitReqVO reqVO, String userIp) { - // 1.1 校验转账单是否可以提交 - PayTransferDO transfer = validateTransferCanSubmit(reqVO.getId()); - // 1.2 校验转账类型和渠道是否匹配 - validateChannelCodeAndTypeMatch(reqVO.getChannelCode(), transfer.getType()); - // 1.3 校验支付渠道是否有效 - PayChannelDO channel = validateChannelCanSubmit(transfer.getAppId(), reqVO.getChannelCode()); - PayClient client = channelService.getPayClient(channel.getId()); - - // 2. 新增转账拓展单 - String no = noRedisDAO.generate(TRANSFER_NO_PREFIX); - PayTransferExtensionDO transferExtension = new PayTransferExtensionDO().setNo(no) - .setTransferId(transfer.getId()).setChannelId(channel.getId()) - .setChannelCode(channel.getCode()).setStatus(WAITING.getStatus()); - transferExtensionMapper.insert(transferExtension); - - // 3. 调用三方渠道发起转账 - PayTransferUnifiedReqDTO transferUnifiedReq = new PayTransferUnifiedReqDTO() - .setOutTransferNo(transferExtension.getNo()).setPrice(transfer.getPrice()) - .setType(transfer.getType()).setTitle(transfer.getSubject()) - .setPayeeInfo(transfer.getPayeeInfo()).setUserIp(userIp) - .setChannelExtras(reqVO.getChannelExtras()); - PayTransferRespDTO unifiedTransferResp = client.unifiedTransfer(transferUnifiedReq); - - // 4. 通知转账结果 - getSelf().notifyTransfer(channel, unifiedTransferResp); - // 如有渠道错误码,则抛出业务异常,提示用户 - if (StrUtil.isNotEmpty(unifiedTransferResp.getChannelErrorCode())) { - throw exception(PAY_TRANSFER_SUBMIT_CHANNEL_ERROR, unifiedTransferResp.getChannelErrorCode(), - unifiedTransferResp.getChannelErrorMsg()); - } - return new PayTransferSubmitRespVO().setStatus(unifiedTransferResp.getStatus()); - } - - @Override - public Long createTransfer(PayTransferCreateReqDTO reqDTO) { - // 校验 App - appService.validPayApp(reqDTO.getAppId()); - // 创建转账单 - PayTransferDO transfer = PayTransferConvert.INSTANCE.convert(reqDTO) - .setStatus(WAITING.getStatus()); - transferMapper.insert(transfer); - return transfer.getId(); - } - - @Transactional(rollbackFor = Exception.class) - // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyTransfer(channel, notify) 调用,否则事务不生效 - public void notifyTransfer(PayChannelDO channel, PayTransferRespDTO notify) { - // 转账成功的回调 - if (PayTransferStatusRespEnum.isSuccess(notify.getStatus())) { - notifyTransferSuccess(channel, notify); - } - // 转账关闭的回调 - if (PayTransferStatusRespEnum.isClosed(notify.getStatus())) { - notifyTransferClosed(channel, notify); - } - // WAITING 状态无需处理 - // TODO IN_PROGRESS 待处理 - } - - private void notifyTransferSuccess(PayChannelDO channel, PayTransferRespDTO notify) { - // 1. 更新 PayTransferExtensionDO 转账成功 - PayTransferExtensionDO transferExtension = updateTransferExtensionSuccess(notify); - - // 2. 更新 PayTransferDO 转账成功 - Boolean transferred = updateTransferSuccess(channel,transferExtension, notify); - if (transferred) { - return; - } - // 3. TODO 插入转账通知记录 - } - - private Boolean updateTransferSuccess(PayChannelDO channel, PayTransferExtensionDO transferExtension, - PayTransferRespDTO notify) { - // 1.校验 - PayTransferDO transfer = transferMapper.selectById(transferExtension.getTransferId()); - if (transfer == null) { - throw exception(PAY_TRANSFER_NOT_FOUND); - } - if (isSuccess(transfer.getStatus()) && Objects.equals(transfer.getExtensionId(), transferExtension.getId())) { - log.info("[updateTransferSuccess][transfer({}) 已经是已转账,无需更新]", transfer.getId()); - return true; - } - if (!isPendingStatus(transfer.getStatus())) { - throw exception(PAY_TRANSFER_STATUS_IS_NOT_PENDING); - } - // 2.更新 - int updateCounts = transferMapper.updateByIdAndStatus(transfer.getId(), - CollUtil.newArrayList(WAITING.getStatus(), IN_PROGRESS.getStatus()), - new PayTransferDO().setStatus(SUCCESS.getStatus()).setSuccessTime(notify.getSuccessTime()) - .setChannelId(channel.getId()).setChannelCode(channel.getCode()) - .setExtensionId(transferExtension.getId()).setNo(transferExtension.getNo())); - if (updateCounts == 0) { - throw exception(PAY_TRANSFER_STATUS_IS_NOT_PENDING); - } - log.info("[updateTransferSuccess][transfer({}) 更新为已转账]", transfer.getId()); - return false; - } - - private PayTransferExtensionDO updateTransferExtensionSuccess(PayTransferRespDTO notify) { - // 1 校验 - PayTransferExtensionDO transferExtension = transferExtensionMapper.selectByNo(notify.getOutTransferNo()); - if (transferExtension == null) { - throw exception(PAY_TRANSFER_EXTENSION_NOT_FOUND); - } - if (isSuccess(transferExtension.getStatus())) { // 如果已成功,直接返回,不用重复更新 - log.info("[updateTransferExtensionSuccess][transferExtension({}) 已经是成功状态,无需更新]", transferExtension.getId()); - return transferExtension; - } - if (!isPendingStatus(transferExtension.getStatus())) { - throw exception(PAY_TRANSFER_EXTENSION_STATUS_IS_NOT_PENDING); - } - // 2. 更新 PayTransferExtensionDO - int updateCount = transferExtensionMapper.updateByIdAndStatus(transferExtension.getId(), - CollUtil.newArrayList(WAITING.getStatus(), IN_PROGRESS.getStatus()), - new PayTransferExtensionDO().setStatus(SUCCESS.getStatus()) - .setChannelNotifyData(JsonUtils.toJsonString(notify))); - if (updateCount == 0) { - throw exception(PAY_TRANSFER_EXTENSION_STATUS_IS_NOT_PENDING); - } - log.info("[updateTransferExtensionSuccess][transferExtension({}) 更新为已转账]", transferExtension.getId()); - return transferExtension; - } - - private void notifyTransferClosed(PayChannelDO channel, PayTransferRespDTO notify) { - // 更新 PayTransferExtensionDO 转账关闭 - updateTransferExtensionClosed(notify); - } - - private void updateTransferExtensionClosed(PayTransferRespDTO notify) { - // 1 校验 - PayTransferExtensionDO transferExtension = transferExtensionMapper.selectByNo(notify.getOutTransferNo()); - if (transferExtension == null) { - throw exception(PAY_TRANSFER_EXTENSION_NOT_FOUND); - } - if (isClosed(transferExtension.getStatus())) { // 如果已是关闭状态,直接返回,不用重复更新 - log.info("[updateTransferExtensionSuccess][transferExtension({}) 已经是关闭状态,无需更新]", transferExtension.getId()); - return; - } - if (!isPendingStatus(transferExtension.getStatus())) { - throw exception(PAY_TRANSFER_EXTENSION_STATUS_IS_NOT_PENDING); - } - // 2. 更新 PayTransferExtensionDO - int updateCount = transferExtensionMapper.updateByIdAndStatus(transferExtension.getId(), - CollUtil.newArrayList(WAITING.getStatus(), IN_PROGRESS.getStatus()), - new PayTransferExtensionDO().setStatus(CLOSED.getStatus()) - .setChannelNotifyData(JsonUtils.toJsonString(notify))); - if (updateCount == 0) { - throw exception(PAY_TRANSFER_EXTENSION_STATUS_IS_NOT_PENDING); - } - log.info("[updateTransferExtensionSuccess][transferExtension({}) 更新为关闭状态]", transferExtension.getId()); - } - - private void validateChannelCodeAndTypeMatch(String channelCode, Integer type) { - PayTransferTypeEnum transferType = PayTransferTypeEnum.typeOf(type); - PayChannelEnum payChannel = PayChannelEnum.getByCode(channelCode); - switch (transferType) { - case ALIPAY_BALANCE: { - // TODO @jason:可以抽到 PayChannelEnum 里,isAlipay? 类似这种哈 - if (!payChannel.getCode().startsWith("alipay")) { - throw exception(PAY_TRANSFER_TYPE_AND_CHANNEL_NOT_MATCH); - } - break; - } - case WX_BALANCE: - case BANK_CARD: - case WALLET_BALANCE: { - throw new UnsupportedOperationException("待实现"); - } - } - } - - private PayChannelDO validateChannelCanSubmit(Long appId, String channelCode) { - // 校验 App - appService.validPayApp(appId); - // 校验支付渠道是否有效 - PayChannelDO channel = channelService.validPayChannel(appId, channelCode); - PayClient client = channelService.getPayClient(channel.getId()); - if (client == null) { - log.error("[validateChannelCanSubmit][渠道编号({}) 找不到对应的支付客户端]", channel.getId()); - throw exception(CHANNEL_NOT_FOUND); - } - return channel; - } - - private PayTransferDO validateTransferCanSubmit(Long id) { - PayTransferDO transfer = transferMapper.selectById(id); - if (transfer == null) { // 是否存在 - throw exception(PAY_TRANSFER_NOT_FOUND); - } - if (PayTransferStatusEnum.isSuccess(transfer.getStatus())) { - throw exception(PAY_TRANSFER_STATUS_IS_SUCCESS); - } - if (!PayTransferStatusEnum.isWaiting(transfer.getStatus())) { - throw exception(PAY_TRANSFER_STATUS_IS_NOT_WAITING); - } - // TODO 查询拓展单是否未已转账和转账中 - return transfer; - } - - /** - * 获得自身的代理对象,解决 AOP 生效问题 - * - * @return 自己 - */ - private PayTransferServiceImpl getSelf() { - return SpringUtil.getBean(getClass()); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageService.java deleted file mode 100644 index 235d2a908..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageService.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; - -import javax.validation.Valid; - -/** - * 钱包充值套餐 Service 接口 - * - * @author jason - */ -public interface PayWalletRechargePackageService { - - /** - * 获取钱包充值套餐 - * @param packageId 充值套餐编号 - */ - PayWalletRechargePackageDO getWalletRechargePackage(Long packageId); - - /** - * 校验钱包充值套餐的有效性, 无效的话抛出 ServiceException 异常 - * - * @param packageId 充值套餐编号 - */ - PayWalletRechargePackageDO validWalletRechargePackage(Long packageId); - - /** - * 创建充值套餐 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createWalletRechargePackage(@Valid WalletRechargePackageCreateReqVO createReqVO); - - /** - * 更新充值套餐 - * - * @param updateReqVO 更新信息 - */ - void updateWalletRechargePackage(@Valid WalletRechargePackageUpdateReqVO updateReqVO); - - /** - * 删除充值套餐 - * - * @param id 编号 - */ - void deleteWalletRechargePackage(Long id); - - /** - * 获得充值套餐分页 - * - * @param pageReqVO 分页查询 - * @return 充值套餐分页 - */ - PageResult getWalletRechargePackagePage(WalletRechargePackagePageReqVO pageReqVO); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageServiceImpl.java deleted file mode 100644 index 12224ed4c..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargePackageServiceImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.wallet.WalletRechargePackageConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletRechargePackageMapper; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 钱包充值套餐 Service 实现类 - * - * @author jason - */ -@Service -public class PayWalletRechargePackageServiceImpl implements PayWalletRechargePackageService { - - @Resource - private PayWalletRechargePackageMapper walletRechargePackageMapper; - - @Override - public PayWalletRechargePackageDO getWalletRechargePackage(Long packageId) { - return walletRechargePackageMapper.selectById(packageId); - } - - @Override - public PayWalletRechargePackageDO validWalletRechargePackage(Long packageId) { - PayWalletRechargePackageDO rechargePackageDO = walletRechargePackageMapper.selectById(packageId); - if (rechargePackageDO == null) { - throw exception(WALLET_RECHARGE_PACKAGE_NOT_FOUND); - } - if (CommonStatusEnum.DISABLE.getStatus().equals(rechargePackageDO.getStatus())) { - throw exception(WALLET_RECHARGE_PACKAGE_IS_DISABLE); - } - return rechargePackageDO; - } - - @Override - public Long createWalletRechargePackage(WalletRechargePackageCreateReqVO createReqVO) { - // 校验套餐名是否唯一 - validateRechargePackageNameUnique(null, createReqVO.getName()); - - // 插入 - PayWalletRechargePackageDO walletRechargePackage = WalletRechargePackageConvert.INSTANCE.convert(createReqVO); - walletRechargePackageMapper.insert(walletRechargePackage); - // 返回 - return walletRechargePackage.getId(); - } - - @Override - public void updateWalletRechargePackage(WalletRechargePackageUpdateReqVO updateReqVO) { - // 校验存在 - validateWalletRechargePackageExists(updateReqVO.getId()); - // 校验套餐名是否唯一 - validateRechargePackageNameUnique(updateReqVO.getId(), updateReqVO.getName()); - - // 更新 - PayWalletRechargePackageDO updateObj = WalletRechargePackageConvert.INSTANCE.convert(updateReqVO); - walletRechargePackageMapper.updateById(updateObj); - } - - private void validateRechargePackageNameUnique(Long id, String name) { - if (StrUtil.isBlank(name)) { - return; - } - PayWalletRechargePackageDO rechargePackage = walletRechargePackageMapper.selectByName(name); - if (rechargePackage == null) { - return ; - } - if (id == null) { - throw exception(WALLET_RECHARGE_PACKAGE_NAME_EXISTS); - } - if (!id.equals(rechargePackage.getId())) { - throw exception(WALLET_RECHARGE_PACKAGE_NAME_EXISTS); - } - } - - @Override - public void deleteWalletRechargePackage(Long id) { - // 校验存在 - validateWalletRechargePackageExists(id); - // 删除 - walletRechargePackageMapper.deleteById(id); - } - - private void validateWalletRechargePackageExists(Long id) { - if (walletRechargePackageMapper.selectById(id) == null) { - throw exception(WALLET_RECHARGE_PACKAGE_NOT_FOUND); - } - } - - @Override - public PageResult getWalletRechargePackagePage(WalletRechargePackagePageReqVO pageReqVO) { - return walletRechargePackageMapper.selectPage(pageReqVO); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java deleted file mode 100644 index 752ce89af..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; - -/** - * 钱包充值 Service 接口 - * - * @author jason - */ -public interface PayWalletRechargeService { - - /** - * 创建钱包充值记录(发起充值) - * - * @param userId 用户 id - * @param userType 用户类型 - * @param createReqVO 钱包充值请求 VO - * @param userIp 用户Ip - * @return 钱包充值记录 - */ - PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp, - AppPayWalletRechargeCreateReqVO createReqVO); - - /** - * 更新钱包充值成功 - * - * @param id 钱包充值记录 id - * @param payOrderId 支付订单 id - */ - void updateWalletRechargerPaid(Long id, Long payOrderId); - - /** - * 发起钱包充值退款 - * - * @param id 钱包充值编号 - * @param userIp 用户 ip 地址 - */ - void refundWalletRecharge(Long id, String userIp); - - /** - * 更新钱包充值记录为已退款 - * - * @param id 钱包充值 id - * @param payRefundId 退款单id - */ - void updateWalletRechargeRefunded(Long id, Long payRefundId); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java deleted file mode 100644 index 1c6e10611..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java +++ /dev/null @@ -1,281 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; -import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletRechargeMapper; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.Objects; - -import static cn.hutool.core.util.ObjectUtil.notEqual; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert.INSTANCE; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*; - -/** - * 钱包充值 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { - - /** - * TODO 芋艿:放到 payconfig - */ - private static final Long WALLET_PAY_APP_ID = 8L; - - private static final String WALLET_RECHARGE_ORDER_SUBJECT = "钱包余额充值"; - - @Resource - private PayWalletRechargeMapper walletRechargeMapper; - @Resource - private PayWalletService payWalletService; - @Resource - private PayOrderService payOrderService; - @Resource - private PayRefundService payRefundService; - @Resource - private PayWalletRechargePackageService payWalletRechargePackageService; - - @Override - @Transactional(rollbackFor = Exception.class) - public PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp, - AppPayWalletRechargeCreateReqVO reqVO) { - - if (Objects.isNull(reqVO.getPayPrice()) && Objects.isNull(reqVO.getPackageId())) { - // TODO @jason @AssertTrue 貌似没有效果。需要查下原因 - throw exception(WALLET_RECHARGE_PACKAGE_AND_PRICE_IS_EMPTY); - } - // 1.1 计算充值金额 - int payPrice; - int bonusPrice = 0; - if (Objects.nonNull(reqVO.getPackageId())) { - PayWalletRechargePackageDO rechargePackage = payWalletRechargePackageService.validWalletRechargePackage(reqVO.getPackageId()); - payPrice = rechargePackage.getPayPrice(); - bonusPrice = rechargePackage.getBonusPrice(); - } else { - payPrice = reqVO.getPayPrice(); - } - // 1.2 插入充值记录 - PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType); - PayWalletRechargeDO recharge = INSTANCE.convert(wallet.getId(), payPrice, bonusPrice, reqVO.getPackageId()); - walletRechargeMapper.insert(recharge); - - // 2.1 创建支付单 - Long payOrderId = payOrderService.createOrder(new PayOrderCreateReqDTO() - .setAppId(WALLET_PAY_APP_ID).setUserIp(userIp) - .setMerchantOrderId(recharge.getId().toString()) // 业务的订单编号 - .setSubject(WALLET_RECHARGE_ORDER_SUBJECT).setBody("") - .setPrice(recharge.getPayPrice()) - .setExpireTime(addTime(Duration.ofHours(2L)))); // TODO @芋艿:支付超时时间 - // 2.2 更新钱包充值记录中支付订单 - walletRechargeMapper.updateById(new PayWalletRechargeDO().setId(recharge.getId()).setPayOrderId(payOrderId)); - recharge.setPayOrderId(payOrderId); - return recharge; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateWalletRechargerPaid(Long id, Long payOrderId) { - // 1.1 获取钱包充值记录 - PayWalletRechargeDO walletRecharge = walletRechargeMapper.selectById(id); - if (walletRecharge == null) { - log.error("[updateWalletRechargerPaid][钱包充值记录不存在,钱包充值记录 id({})]", id); - throw exception(WALLET_RECHARGE_NOT_FOUND); - } - // 1.2 校验钱包充值是否可以支付 - PayOrderDO payOrderDO = validateWalletRechargerCanPaid(walletRecharge, payOrderId); - - // 2. 更新钱包充值的支付状态 - int updateCount = walletRechargeMapper.updateByIdAndPaid(id, false, - new PayWalletRechargeDO().setId(id).setPayStatus(true).setPayTime(LocalDateTime.now()) - .setPayChannelCode(payOrderDO.getChannelCode())); - if (updateCount == 0) { - throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID); - } - - // 3. 更新钱包余额 - // TODO @jason:这样的话,未来提现会不会把充值的,也提现走哈。类似先充 100,送 110;然后提现 110; - // TODO 需要钱包中加个可提现余额 - payWalletService.addWalletBalance(walletRecharge.getWalletId(), String.valueOf(id), - PayWalletBizTypeEnum.RECHARGE, walletRecharge.getTotalPrice()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void refundWalletRecharge(Long id, String userIp) { - // 1.1 获取钱包充值记录 - PayWalletRechargeDO walletRecharge = walletRechargeMapper.selectById(id); - if (walletRecharge == null) { - log.error("[refundWalletRecharge][钱包充值记录不存在,钱包充值记录 id({})]", id); - throw exception(WALLET_RECHARGE_NOT_FOUND); - } - // 1.2 校验钱包充值是否可以发起退款 - PayWalletDO wallet = validateWalletRechargeCanRefund(walletRecharge); - - // 2. 冻结退款的余额,暂时只处理赠送的余额也全部退回 - payWalletService.freezePrice(wallet.getId(), walletRecharge.getTotalPrice()); - - // 3. 创建退款单 - String walletRechargeId = String.valueOf(id); - String refundId = walletRechargeId + "-refund"; - Long payRefundId = payRefundService.createPayRefund(new PayRefundCreateReqDTO() - .setAppId(WALLET_PAY_APP_ID).setUserIp(userIp) - .setMerchantOrderId(walletRechargeId) - .setMerchantRefundId(refundId) - .setReason("想退钱").setPrice(walletRecharge.getPayPrice())); - - // 4. 更新充值记录退款单号 - // TODO @jaosn:一般新建这种 update 对象,建议是,第一个 set id 属性,容易知道以它为更新 - walletRechargeMapper.updateById(new PayWalletRechargeDO().setPayRefundId(payRefundId) - .setRefundStatus(WAITING.getStatus()).setId(walletRecharge.getId())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void updateWalletRechargeRefunded(Long id, Long payRefundId) { - // 1.1 获取钱包充值记录 - PayWalletRechargeDO walletRecharge = walletRechargeMapper.selectById(id); - if (walletRecharge == null) { - log.error("[updateWalletRechargerPaid][钱包充值记录不存在,钱包充值记录 id({})]", id); - throw exception(WALLET_RECHARGE_NOT_FOUND); - } - // 1.2 校验钱包充值是否可以更新已退款 - PayRefundDO payRefund = validateWalletRechargeCanRefunded(walletRecharge, payRefundId); - - PayWalletRechargeDO updateObj = new PayWalletRechargeDO().setId(id); - // 退款成功 - if (PayRefundStatusEnum.isSuccess(payRefund.getStatus())) { - // 2.1 更新钱包余额 - payWalletService.reduceWalletBalance(walletRecharge.getWalletId(), id, - PayWalletBizTypeEnum.RECHARGE_REFUND, walletRecharge.getTotalPrice()); - - updateObj.setRefundStatus(SUCCESS.getStatus()).setRefundTime(payRefund.getSuccessTime()) - .setRefundTotalPrice(walletRecharge.getTotalPrice()).setRefundPayPrice(walletRecharge.getPayPrice()) - .setRefundBonusPrice(walletRecharge.getBonusPrice()); - } - // 退款失败 - if (PayRefundStatusRespEnum.isFailure(payRefund.getStatus())) { - // 2.2 解冻余额 - payWalletService.unfreezePrice(walletRecharge.getWalletId(), walletRecharge.getTotalPrice()); - - updateObj.setRefundStatus(FAILURE.getStatus()); - } - // 3. 更新钱包充值的退款字段 - walletRechargeMapper.updateByIdAndRefunded(id, WAITING.getStatus(), updateObj); - } - - private PayRefundDO validateWalletRechargeCanRefunded(PayWalletRechargeDO walletRecharge, Long payRefundId) { - // 1. 校验退款订单匹配 - if (notEqual(walletRecharge.getPayRefundId(), payRefundId)) { - log.error("[validateWalletRechargeCanRefunded][钱包充值({}) 退款单不匹配({}),请进行处理!钱包充值的数据是:{}]", - walletRecharge.getId(), payRefundId, toJsonString(walletRecharge)); - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR); - } - - // 2.1 校验退款订单 - PayRefundDO payRefund = payRefundService.getRefund(payRefundId); - if (payRefund == null) { - log.error("[validateWalletRechargeCanRefunded][payRefund({})不存在]", payRefundId); - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_NOT_FOUND); - } - // 2.2 校验退款金额一致 - if (notEqual(payRefund.getRefundPrice(), walletRecharge.getPayPrice())) { - log.error("[validateWalletRechargeCanRefunded][钱包({}) payRefund({}) 退款金额不匹配,请进行处理!钱包数据是:{},payRefund 数据是:{}]", - walletRecharge.getId(), payRefundId, toJsonString(walletRecharge), toJsonString(payRefund)); - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_PRICE_NOT_MATCH); - } - // 2.3 校验退款订单商户订单是否匹配 - if (notEqual(payRefund.getMerchantOrderId(), walletRecharge.getId().toString())) { - log.error("[validateWalletRechargeCanRefunded][钱包({}) 退款单不匹配({}),请进行处理!payRefund 数据是:{}]", - walletRecharge.getId(), payRefundId, toJsonString(payRefund)); - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR); - } - return payRefund; - } - - private PayWalletDO validateWalletRechargeCanRefund(PayWalletRechargeDO walletRecharge) { - // 校验充值订单是否支付 - if (!walletRecharge.getPayStatus()) { - throw exception(WALLET_RECHARGE_REFUND_FAIL_NOT_PAID); - } - // 校验充值订单是否已退款 - if (walletRecharge.getPayRefundId() != null) { - throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUNDED); - } - // 校验钱包余额是否足够 - PayWalletDO wallet = payWalletService.getWallet(walletRecharge.getWalletId()); - Assert.notNull(wallet, "用户钱包({}) 不存在", wallet.getId()); - if (wallet.getBalance() < walletRecharge.getTotalPrice()) { - throw exception(WALLET_RECHARGE_REFUND_BALANCE_NOT_ENOUGH); - } - // TODO @芋艿:需要考虑下,赠送的金额,会不会导致提现超过; - return wallet; - } - - private PayOrderDO validateWalletRechargerCanPaid(PayWalletRechargeDO walletRecharge, Long payOrderId) { - // 1.1 校验充值记录的支付状态 - if (walletRecharge.getPayStatus()) { - log.error("[validateWalletRechargerCanPaid][钱包({}) 不处于未支付状态! 钱包数据是:{}]", - walletRecharge.getId(), toJsonString(walletRecharge)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID); - } - // 1.2 校验支付订单匹配 - if (notEqual(walletRecharge.getPayOrderId(), payOrderId)) { // 支付单号 - log.error("[validateWalletRechargerCanPaid][钱包({}) 支付单不匹配({}),请进行处理! 钱包数据是:{}]", - walletRecharge.getId(), payOrderId, toJsonString(walletRecharge)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR); - } - - // 2.1 校验支付单是否存在 - PayOrderDO payOrder = payOrderService.getOrder(payOrderId); - if (payOrder == null) { - log.error("[validateWalletRechargerCanPaid][钱包({}) payOrder({}) 不存在,请进行处理!]", - walletRecharge.getId(), payOrderId); - throw exception(PAY_ORDER_NOT_FOUND); - } - // 2.2 校验支付单已支付 - if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) { - log.error("[validateWalletRechargerCanPaid][钱包({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]", - walletRecharge.getId(), payOrderId, toJsonString(payOrder)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS); - } - // 2.3 校验支付金额一致 - if (notEqual(payOrder.getPrice(), walletRecharge.getPayPrice())) { - log.error("[validateDemoOrderCanPaid][钱包({}) payOrder({}) 支付金额不匹配,请进行处理!钱包 数据是:{},payOrder 数据是:{}]", - walletRecharge.getId(), payOrderId, toJsonString(walletRecharge), toJsonString(payOrder)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH); - } - // 2.4 校验支付订单的商户订单匹配 - if (notEqual(payOrder.getMerchantOrderId(), walletRecharge.getId().toString())) { - log.error("[validateDemoOrderCanPaid][钱包({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]", - walletRecharge.getId(), payOrderId, toJsonString(payOrder)); - throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR); - } - return payOrder; - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java deleted file mode 100644 index d9abe958d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java +++ /dev/null @@ -1,101 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; - -/** - * 钱包 Service 接口 - * - * @author jason - */ -public interface PayWalletService { - - /** - * 获取钱包信息 - *

- * 如果不存在,则创建钱包。由于用户注册时候不会创建钱包 - * - * @param userId 用户编号 - * @param userType 用户类型 - */ - PayWalletDO getOrCreateWallet(Long userId, Integer userType); - - /** - * 获取钱包信息 - * - * @param walletId 钱包 id - */ - PayWalletDO getWallet(Long walletId); - - - /** - * 获得会员钱包分页 - * - * @param pageReqVO 分页查询 - * @return 会员钱包分页 - */ - PageResult getWalletPage(Integer userType, PayWalletPageReqVO pageReqVO); - - /** - * 钱包订单支付 - * - * @param userId 用户 id - * @param userType 用户类型 - * @param outTradeNo 外部订单号 - * @param price 金额 - */ - PayWalletTransactionDO orderPay(Long userId, Integer userType, String outTradeNo, Integer price); - - /** - * 钱包订单支付退款 - * - * @param outRefundNo 外部退款号 - * @param refundPrice 退款金额 - * @param reason 退款原因 - */ - PayWalletTransactionDO orderRefund(String outRefundNo, Integer refundPrice, String reason); - - /** - * 扣减钱包余额 - * - * @param walletId 钱包 id - * @param bizId 业务关联 id - * @param bizType 业务关联分类 - * @param price 扣减金额 - * @return 钱包流水 - */ - PayWalletTransactionDO reduceWalletBalance(Long walletId, Long bizId, - PayWalletBizTypeEnum bizType, Integer price); - - /** - * 增加钱包余额 - * - * @param walletId 钱包 id - * @param bizId 业务关联 id - * @param bizType 业务关联分类 - * @param price 增加金额 - * @return 钱包流水 - */ - PayWalletTransactionDO addWalletBalance(Long walletId, String bizId, - PayWalletBizTypeEnum bizType, Integer price); - - /** - * 冻结钱包部分余额 - * - * @param id 钱包编号 - * @param price 冻结金额 - */ - void freezePrice(Long id, Integer price); - - /** - * 解冻钱包余额 - * - * @param id 钱包编号 - * @param price 解冻金额 - */ - void unfreezePrice(Long id, Integer price); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java deleted file mode 100644 index db4ad647a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java +++ /dev/null @@ -1,206 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.hutool.core.lang.Assert; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletMapper; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYMENT; -import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYMENT_REFUND; - -/** - * 钱包 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -public class PayWalletServiceImpl implements PayWalletService { - - @Resource - private PayWalletMapper walletMapper; - @Resource - private PayWalletTransactionService walletTransactionService; - @Resource - @Lazy - private PayOrderService orderService; - @Resource - @Lazy - private PayRefundService refundService; - - @Override - public PayWalletDO getOrCreateWallet(Long userId, Integer userType) { - PayWalletDO wallet = walletMapper.selectByUserIdAndType(userId, userType); - if (wallet == null) { - wallet = new PayWalletDO().setUserId(userId).setUserType(userType) - .setBalance(0).setTotalExpense(0).setTotalRecharge(0); - wallet.setCreateTime(LocalDateTime.now()); - walletMapper.insert(wallet); - } - return wallet; - } - - @Override - public PayWalletDO getWallet(Long walletId) { - return walletMapper.selectById(walletId); - } - - @Override - public PageResult getWalletPage(Integer userType,PayWalletPageReqVO pageReqVO) { - return walletMapper.selectPage(userType, pageReqVO); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public PayWalletTransactionDO orderPay(Long userId, Integer userType, String outTradeNo, Integer price) { - // 1. 判断支付交易拓展单是否存 - PayOrderExtensionDO orderExtension = orderService.getOrderExtensionByNo(outTradeNo); - if (orderExtension == null) { - throw exception(PAY_ORDER_EXTENSION_NOT_FOUND); - } - PayWalletDO wallet = getOrCreateWallet(userId, userType); - // 2. 扣减余额 - return reduceWalletBalance(wallet.getId(), orderExtension.getOrderId(), PAYMENT, price); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public PayWalletTransactionDO orderRefund(String outRefundNo, Integer refundPrice, String reason) { - // 1.1 判断退款单是否存在 - PayRefundDO payRefund = refundService.getRefundByNo(outRefundNo); - if (payRefund == null) { - throw exception(REFUND_NOT_FOUND); - } - // 1.2 校验是否可以退款 - Long walletId = validateWalletCanRefund(payRefund.getId(), payRefund.getChannelOrderNo()); - PayWalletDO wallet = walletMapper.selectById(walletId); - Assert.notNull(wallet, "钱包 {} 不存在", walletId); - - // 2. 增加余额 - return addWalletBalance(walletId, String.valueOf(payRefund.getId()), PAYMENT_REFUND, refundPrice); - } - - /** - * 校验是否能退款 - * - * @param refundId 支付退款单 id - * @param walletPayNo 钱包支付 no - */ - private Long validateWalletCanRefund(Long refundId, String walletPayNo) { - // 1. 校验钱包支付交易存在 - PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransactionByNo(walletPayNo); - if (walletTransaction == null) { - throw exception(WALLET_TRANSACTION_NOT_FOUND); - } - // 2. 校验退款是否存在 - PayWalletTransactionDO refundTransaction = walletTransactionService.getWalletTransaction( - String.valueOf(refundId), PAYMENT_REFUND); - if (refundTransaction != null) { - throw exception(WALLET_REFUND_EXIST); - } - return walletTransaction.getWalletId(); - } - - @Override - public PayWalletTransactionDO reduceWalletBalance(Long walletId, Long bizId, - PayWalletBizTypeEnum bizType, Integer price) { - // 1. 获取钱包 - PayWalletDO payWallet = getWallet(walletId); - if (payWallet == null) { - log.error("[reduceWalletBalance],用户钱包({})不存在.", walletId); - throw exception(WALLET_NOT_FOUND); - } - - // 2.1 扣除余额 - int updateCounts; - switch (bizType) { - case PAYMENT: { - updateCounts = walletMapper.updateWhenConsumption(payWallet.getId(), price); - break; - } - case RECHARGE_REFUND: { - updateCounts = walletMapper.updateWhenRechargeRefund(payWallet.getId(), price); - break; - } - default: { - // TODO 其它类型待实现 - throw new UnsupportedOperationException("待实现"); - } - } - if (updateCounts == 0) { - throw exception(WALLET_BALANCE_NOT_ENOUGH); - } - // 2.2 生成钱包流水 - Integer afterBalance = payWallet.getBalance() - price; - WalletTransactionCreateReqBO bo = new WalletTransactionCreateReqBO().setWalletId(payWallet.getId()) - .setPrice(-price).setBalance(afterBalance).setBizId(String.valueOf(bizId)) - .setBizType(bizType.getType()).setTitle(bizType.getDescription()); - return walletTransactionService.createWalletTransaction(bo); - } - - @Override - public PayWalletTransactionDO addWalletBalance(Long walletId, String bizId, - PayWalletBizTypeEnum bizType, Integer price) { - // 1.1 获取钱包 - PayWalletDO payWallet = getWallet(walletId); - if (payWallet == null) { - log.error("[addWalletBalance],用户钱包({})不存在.", walletId); - throw exception(WALLET_NOT_FOUND); - } - // 1.2 更新钱包金额 - switch (bizType) { - case PAYMENT_REFUND: { // 退款更新 - walletMapper.updateWhenConsumptionRefund(payWallet.getId(), price); - break; - } - case RECHARGE: { // 充值更新 - walletMapper.updateWhenRecharge(payWallet.getId(), price); - break; - } - default: { - // TODO 其它类型待实现 - throw new UnsupportedOperationException("待实现"); - } - } - - // 2. 生成钱包流水 - WalletTransactionCreateReqBO transactionCreateReqBO = new WalletTransactionCreateReqBO() - .setWalletId(payWallet.getId()).setPrice(price).setBalance(payWallet.getBalance() + price) - .setBizId(bizId).setBizType(bizType.getType()).setTitle(bizType.getDescription()); - return walletTransactionService.createWalletTransaction(transactionCreateReqBO); - } - - @Override - public void freezePrice(Long id, Integer price) { - int updateCounts = walletMapper.freezePrice(id, price); - if (updateCounts == 0) { - throw exception(WALLET_BALANCE_NOT_ENOUGH); - } - } - - @Override - public void unfreezePrice(Long id, Integer price) { - int updateCounts = walletMapper.unFreezePrice(id, price); - if (updateCounts == 0) { - throw exception(WALLET_FREEZE_PRICE_NOT_ENOUGH); - } - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java deleted file mode 100644 index 21fc0dc18..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; - -import javax.validation.Valid; - -/** - * 钱包余额流水 Service 接口 - * - * @author jason - */ -public interface PayWalletTransactionService { - - /** - * 查询钱包余额流水分页 - * - * @param userId 用户编号 - * @param userType 用户类型 - * @param pageVO 分页查询参数 - */ - PageResult getWalletTransactionPage(Long userId, Integer userType, - AppPayWalletTransactionPageReqVO pageVO); - - /** - * 查询钱包余额流水分页 - * - * @param pageVO 分页查询参数 - */ - PageResult getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO); - - /** - * 新增钱包余额流水 - * - * @param bo 创建钱包流水 bo - * @return 新建的钱包 do - */ - PayWalletTransactionDO createWalletTransaction(@Valid WalletTransactionCreateReqBO bo); - - /** - * 根据 no,获取钱包余流水 - * - * @param no 流水号 - */ - PayWalletTransactionDO getWalletTransactionByNo(String no); - - /** - * 获取钱包流水 - * - * @param bizId 业务编号 - * @param type 业务类型 - * @return 钱包流水 - */ - PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java deleted file mode 100644 index 357ac6a4e..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; -import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletTransactionMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; - -/** - * 钱包流水 Service 实现类 - * - * @author jason - */ -@Service -@Slf4j -@Validated -public class PayWalletTransactionServiceImpl implements PayWalletTransactionService { - - /** - * 钱包流水的 no 前缀 - */ - private static final String WALLET_NO_PREFIX = "W"; - - @Resource - private PayWalletService payWalletService; - @Resource - private PayWalletTransactionMapper payWalletTransactionMapper; - @Resource - private PayNoRedisDAO noRedisDAO; - - @Override - public PageResult getWalletTransactionPage(Long userId, Integer userType, - AppPayWalletTransactionPageReqVO pageVO) { - PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType); - return payWalletTransactionMapper.selectPage(wallet.getId(), pageVO.getType(), pageVO); - } - - @Override - public PageResult getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO) { - return payWalletTransactionMapper.selectPage(pageVO.getWalletId(), null, pageVO); - } - - @Override - public PayWalletTransactionDO createWalletTransaction(WalletTransactionCreateReqBO bo) { - PayWalletTransactionDO transaction = PayWalletTransactionConvert.INSTANCE.convert(bo) - .setNo(noRedisDAO.generate(WALLET_NO_PREFIX)); - payWalletTransactionMapper.insert(transaction); - return transaction; - } - - @Override - public PayWalletTransactionDO getWalletTransactionByNo(String no) { - return payWalletTransactionMapper.selectByNo(no); - } - - @Override - public PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type) { - return payWalletTransactionMapper.selectByBiz(bizId, type.getType()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java deleted file mode 100644 index a305ceb0d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.wallet.bo; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 创建钱包流水 BO - * - * @author jason - */ -@Data -public class WalletTransactionCreateReqBO { - - /** - * 钱包编号 - * - */ - @NotNull(message = "钱包编号不能为空") - private Long walletId; - - /** - * 交易金额,单位分 - * - * 正值表示余额增加,负值表示余额减少 - */ - @NotNull(message = "交易金额不能为空") - private Integer price; - - /** - * 交易后余额,单位分 - */ - @NotNull(message = "交易后余额不能为空") - private Integer balance; - - /** - * 关联业务分类 - * - * 枚举 {@link PayWalletBizTypeEnum#getType()} - */ - @NotNull(message = "关联业务分类不能为空") - @InEnum(PayWalletBizTypeEnum.class) - private Integer bizType; - - /** - * 关联业务编号 - */ - @NotEmpty(message = "关联业务编号不能为空") - private String bizId; - - /** - * 流水说明 - */ - @NotEmpty(message = "流水说明不能为空") - private String title; -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/util/MoneyUtils.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/util/MoneyUtils.java deleted file mode 100644 index 15865f60a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/util/MoneyUtils.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.util; - -import cn.hutool.core.util.NumberUtil; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -/** - * 金额工具类 - * - * @author 芋道源码 - */ -public class MoneyUtils { - - /** - * 计算百分比金额,四舍五入 - * - * @param price 金额 - * @param rate 百分比,例如说 56.77% 则传入 56.77 - * @return 百分比金额 - */ - public static Integer calculateRatePrice(Integer price, Double rate) { - return calculateRatePrice(price, rate, 0, RoundingMode.HALF_UP).intValue(); - } - - /** - * 计算百分比金额 - * - * @param price 金额 - * @param rate 百分比,例如说 56.77% 则传入 56.77 - * @param scale 保留小数位数 - * @param roundingMode 舍入模式 - */ - public static BigDecimal calculateRatePrice(Number price, Number rate, int scale, RoundingMode roundingMode) { - return NumberUtil.toBigDecimal(price).multiply(NumberUtil.toBigDecimal(rate)) // 乘以 - .divide(BigDecimal.valueOf(100), scale, roundingMode); // 除以 100 - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/util/PaySeqUtils.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/util/PaySeqUtils.java deleted file mode 100644 index 3882a2fd3..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/util/PaySeqUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.pay.util; - -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.DateUtil; - -import java.time.LocalDateTime; -import java.util.concurrent.atomic.AtomicLong; - -/** - * 支付相关编号的生产 - */ -// TODO @jason:需要改造,基于 db; -public class PaySeqUtils { - - private static final AtomicLong REFUND_REQ_NO_SEQ = new AtomicLong(0L); - - private static final AtomicLong MER_REFUND_NO_SEQ = new AtomicLong(0L); - - private static final AtomicLong MER_ORDER_NO_SEQ = new AtomicLong(0L); - - // TODO 芋艿:需要看看 - /** - * 生成商户退款单号,用于测试,应该由商户系统生成 - * @return 商户退款单 - */ - public static String genMerchantRefundNo() { - return String.format("%s%s%04d", "MR", - DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_MS_PATTERN), - (int) MER_REFUND_NO_SEQ.getAndIncrement() % 10000); - } - - // TODO 芋艿:需要看看 - - /** - * 生成退款请求号 - * @return 退款请求号 - */ - public static String genRefundReqNo() { - return String.format("%s%s%04d", "RR", - DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_MS_PATTERN), - (int) REFUND_REQ_NO_SEQ.getAndIncrement() % 10000); - } - - /** - * 生成商户订单编号号 用于测试,应该由商户系统生成 - * @return 商户订单编号 - */ - public static String genMerchantOrderNo() { - return String.format("%s%s%04d", "MO", - DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_MS_PATTERN), - (int) MER_ORDER_NO_SEQ.getAndIncrement() % 10000); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-dev.yaml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index 30b8ecaf4..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,102 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - pay: - order-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/order # 支付渠道的【支付】回调地址 - refund-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址 - demo: false # 关闭演示模式 diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-local.yaml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-local.yaml deleted file mode 100644 index d250a3d51..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,128 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 - # password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:8000/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.pay.dal.mysql: debug - cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyTaskMapper: INFO # 配置 PayNotifyTaskMapper 的日志级别为 info - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - security: - mock-enable: true - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - pay: - order-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/order # 支付渠道的【支付】回调地址 - refund-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址 - demo: false # 关闭演示模式 diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application.yaml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application.yaml deleted file mode 100644 index 24eab6c32..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,108 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - executor: - appname: ${spring.application.name} # 执行器 AppName - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.pay - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - tenant: # 多租户相关配置项 - enable: true - ignore-urls: - - /admin-api/pay/notify/** # 支付回调通知,不携带租户编号 - -debug: false diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/bootstrap.yaml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 9f25acdb8..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: pay-server - - profiles: - active: local - -server: - port: 48085 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/logback-spring.xml b/yudao-module-pay/yudao-module-pay-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java deleted file mode 100644 index 73b4f6f82..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.merchant; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WXPayClientConfig; -import org.junit.jupiter.api.Test; - -public class PayChannelDOTest { - - @Test - public void testSerialization() { - PayChannelDO payChannelDO = new PayChannelDO(); - // 创建配置 - WXPayClientConfig config = new WXPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WXPayClientConfig.API_VERSION_V2); - config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p"); - payChannelDO.setConfig(config); - - // 序列化 - String text = JsonUtils.toJsonString(payChannelDO); - System.out.println(text); - - // 反序列化 - payChannelDO = JsonUtils.parseObject(text, PayChannelDO.class); - System.out.println(payChannelDO.getConfig().getClass()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java deleted file mode 100644 index 2150a8a15..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.merchant; - -import cn.hutool.core.io.IoUtil; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WXPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import cn.iocoder.yudao.module.pay.test.BaseDbIntegrationTest; -import org.junit.jupiter.api.Test; - -import javax.annotation.Resource; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.List; - -@Resource -public class PayChannelMapperIntegrationTest extends BaseDbIntegrationTest { - - @Resource - private PayChannelMapper payChannelMapper; - - /** - * 插入 {@link PayChannelEnum#WX_PUB} 初始配置 - */ - @Test - public void testInsertWxPub() throws FileNotFoundException { - PayChannelDO payChannelDO = new PayChannelDO(); - payChannelDO.setCode(PayChannelEnum.WX_PUB.getCode()); - payChannelDO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - payChannelDO.setFeeRate(1D); - payChannelDO.setAppId(6L); - // 配置 - WXPayClientConfig config = new WXPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WXPayClientConfig.API_VERSION_V2); - config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p"); - config.setPrivateKeyContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_key.pem"))); - config.setPrivateCertContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"))); - config.setApiV3Key("joerVi8y5DJ3o4ttA0o1uH47Xz1u2Ase"); - payChannelDO.setConfig(config); - // 执行插入 - payChannelMapper.insert(payChannelDO); - } - - // TODO @ouyang:Zfb 改成 AlipayQr - /** - * 插入 {@link PayChannelEnum#ALIPAY_QR} 初始配置 - */ - @Test - public void testInsertZfb() { - PayChannelDO payChannelDO = new PayChannelDO(); - payChannelDO.setCode(PayChannelEnum.ALIPAY_QR.getCode()); - payChannelDO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - payChannelDO.setFeeRate(1D); - payChannelDO.setAppId(6L); - // 配置 - AlipayPayClientConfig config = new AlipayPayClientConfig(); - config.setAppId("2021000118634035"); - config.setServerUrl(AlipayPayClientConfig.SERVER_URL_SANDBOX); - config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeYfX7YAXApzHqYNINzM79HemO3Yx1qLMW3okRFJ9pPRzbQ9qkTpsaegsmyX316zOBhzGRYjKbutTYwKBgQCm7phr9XdFW5Vh+XR90mVs483nrLmMiDKg7YKxSLJ8amiDjzPejCn7i95Hah08P+2MIZLIPbh2VLacczR6ltRRzN5bg5etFuqSgfkuHyxpoDmpjbe08+Q2h8JBYqcC5Nhv1AKU4iOUhVLHo/FBAQliMcGc/J3eiYTFC7EsNx382QKBgClb20doe7cttgFTXswBvaUmfFm45kmla924B7SpvrQpDD/f+VDtDZRp05fGmxuduSjYdtA3aVtpLiTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); - config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 - payChannelDO.setConfig(config); - // 执行插入 - payChannelMapper.insert(payChannelDO); - } - - /** - * 查询所有支付配置,看看是否都是 ok 的 - */ - @Test - public void testSelectList() { - List payChannels = payChannelMapper.selectList(); - System.out.println(payChannels.size()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java deleted file mode 100644 index 55a37ad1a..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.order; - -import cn.iocoder.yudao.module.pay.service.channel.PayAppServiceImpl; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelServiceImpl; -import cn.iocoder.yudao.module.pay.service.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.service.order.dto.PayOrderSubmitReqDTO; -import cn.iocoder.yudao.module.pay.test.BaseDbIntegrationTest; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.pay.config.YudaoPayAutoConfiguration; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.Duration; - -@Import({PayOrderServiceImpl.class, PayAppServiceImpl.class, - PayChannelServiceImpl.class, YudaoPayAutoConfiguration.class}) -public class PayOrderServiceIntegrationTest extends BaseDbIntegrationTest { - - @Resource - private PayOrderService payOrderService; - - @Test - public void testCreatePayOrder() { - // 构造请求 - PayOrderCreateReqDTO reqDTO = new PayOrderCreateReqDTO(); - reqDTO.setAppId(6L); - reqDTO.setUserIp("127.0.0.1"); - reqDTO.setMerchantOrderId(String.valueOf(System.currentTimeMillis())); - reqDTO.setSubject("标题"); - reqDTO.setBody("内容"); - reqDTO.setPrice(100); - reqDTO.setExpireTime(DateUtils.addTime(Duration.ofDays(1))); - // 发起请求 - payOrderService.createPayOrder(reqDTO); - } - - @Test - public void testSubmitPayOrder() { - // 构造请求 - PayOrderSubmitReqDTO reqDTO = new PayOrderSubmitReqDTO(); - reqDTO.setId(10L); - reqDTO.setAppId(6L); - reqDTO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqDTO.setUserIp("127.0.0.1"); - // 发起请求 - payOrderService.submitPayOrder(reqDTO); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/package-info.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/package-info.java deleted file mode 100644 index 2cad91eba..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.pay.service; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbAndRedisIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbAndRedisIntegrationTest.java deleted file mode 100644 index 2ee19ebf9..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbAndRedisIntegrationTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.module.pay.test; - -import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; -import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration; -import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; -import org.redisson.spring.starter.RedissonAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbAndRedisIntegrationTest.Application.class) -@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件 -public class BaseDbAndRedisIntegrationTest { - - @Import({ - // DB 配置类 - DynamicDataSourceAutoConfiguration.class, // Dynamic Datasource 配置类 - YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 - DataSourceAutoConfiguration.class, // Spring DB 自动配置类 - DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 - // MyBatis 配置类 - YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 - MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 - - // Redis 配置类 - RedisAutoConfiguration.class, // Spring Redis 自动配置类 - YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 - RedissonAutoConfiguration.class, // Redisson 自动高配置类 - }) - public static class Application { - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbIntegrationTest.java deleted file mode 100644 index 380efa3f4..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseDbIntegrationTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.pay.test; - -import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; -import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration; -import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbIntegrationTest.Application.class) -@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件 -public class BaseDbIntegrationTest { - - @Import({ - // DB 配置类 - DynamicDataSourceAutoConfiguration.class, // Dynamic Datasource 配置类 - YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 - DataSourceAutoConfiguration.class, // Spring DB 自动配置类 - DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 - // MyBatis 配置类 - YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 - MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 - }) - public static class Application { - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseRedisIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseRedisIntegrationTest.java deleted file mode 100644 index d01353d72..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/test/BaseRedisIntegrationTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.pay.test; - -import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; -import org.redisson.spring.starter.RedissonAutoConfiguration; -import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseRedisIntegrationTest.Application.class) -@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件 -public class BaseRedisIntegrationTest { - - @Import({ - // Redis 配置类 - RedisAutoConfiguration.class, // Spring Redis 自动配置类 - YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 - RedissonAutoConfiguration.class, // Redisson 自动高配置类 - }) - public static class Application { - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/resources/application-integration-test.yaml b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/resources/application-integration-test.yaml deleted file mode 100644 index 8d17aaa90..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/resources/application-integration-test.yaml +++ /dev/null @@ -1,83 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - name: ruoyi-vue-pro - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT - driver-class-name: com.mysql.jdbc.Driver - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 - name: ruoyi-vue-pro - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT - driver-class-name: com.mysql.jdbc.Driver - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印日志 - global-config: - db-config: - id-type: AUTO # 自增 ID - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - mapper-locations: classpath*:mapper/*.xml - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.pay - pay: - pay-notify-url: http://niubi.natapp1.cc/api/pay/order/notify - refund-notify-url: http://niubi.natapp1.cc/api/pay/refund/notify diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceTest.java deleted file mode 100644 index 1934cfe97..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceTest.java +++ /dev/null @@ -1,258 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.app; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.mysql.app.PayAppMapper; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static java.util.Collections.singleton; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link PayAppServiceImpl} 的单元测试 - * - * @author aquan - */ -@Import(PayAppServiceImpl.class) -public class PayAppServiceTest extends BaseDbUnitTest { - - @Resource - private PayAppServiceImpl appService; - - @Resource - private PayAppMapper appMapper; - - @MockBean - private PayOrderService orderService; - @MockBean - private PayRefundService refundService; - - @Test - public void testCreateApp_success() { - // 准备参数 - PayAppCreateReqVO reqVO = randomPojo(PayAppCreateReqVO.class, o -> - o.setStatus((RandomUtil.randomEle(CommonStatusEnum.values()).getStatus())) - .setOrderNotifyUrl(randomURL()) - .setRefundNotifyUrl(randomURL())); - - // 调用 - Long appId = appService.createApp(reqVO); - // 断言 - assertNotNull(appId); - PayAppDO app = appMapper.selectById(appId); - assertPojoEquals(reqVO, app); - } - - @Test - public void testUpdateApp_success() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - PayAppUpdateReqVO reqVO = randomPojo(PayAppUpdateReqVO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setOrderNotifyUrl(randomURL()).setRefundNotifyUrl(randomURL()); - o.setId(dbApp.getId()); // 设置更新的 ID - }); - - // 调用 - appService.updateApp(reqVO); - // 校验是否更新正确 - PayAppDO app = appMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, app); - } - - @Test - public void testUpdateApp_notExists() { - // 准备参数 - PayAppUpdateReqVO reqVO = randomPojo(PayAppUpdateReqVO.class, o -> - o.setStatus((RandomUtil.randomEle(CommonStatusEnum.values()).getStatus()))); - // 调用, 并断言异常 - assertServiceException(() -> appService.updateApp(reqVO), APP_NOT_FOUND); - } - - @Test - public void testUpdateAppStatus() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class, o -> - o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - - // 准备参数 - Long id = dbApp.getId(); - Integer status = CommonStatusEnum.ENABLE.getStatus(); - // 调用 - appService.updateAppStatus(id, status); - // 断言 - PayAppDO app = appMapper.selectById(id); // 获取最新的 - assertEquals(status, app.getStatus()); - } - - @Test - public void testDeleteApp_success() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - - // 调用 - appService.deleteApp(id); - // 校验数据不存在了 - assertNull(appMapper.selectById(id)); - } - - @Test - public void testDeleteApp_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> appService.deleteApp(id), APP_NOT_FOUND); - } - - @Test - public void testDeleteApp_existOrder() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - // mock 订单有订单 - when(orderService.getOrderCountByAppId(eq(id))).thenReturn(10L); - - // 调用, 并断言异常 - assertServiceException(() -> appService.deleteApp(id), APP_EXIST_ORDER_CANT_DELETE); - } - - @Test - public void testDeleteApp_existRefund() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - // mock 订单有订单 - when(refundService.getRefundCountByAppId(eq(id))).thenReturn(10L); - - // 调用, 并断言异常 - assertServiceException(() -> appService.deleteApp(id), APP_EXIST_REFUND_CANT_DELETE); - } - - @Test - public void testApp() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - - // 调用 - PayAppDO app = appService.getApp(id); - // 校验数据一致 - assertPojoEquals(app, dbApp); - } - - @Test - public void testAppMap() { - // mock 数据 - PayAppDO dbApp01 = randomPojo(PayAppDO.class); - appMapper.insert(dbApp01);// @Sql: 先插入出一条存在的数据 - PayAppDO dbApp02 = randomPojo(PayAppDO.class); - appMapper.insert(dbApp02);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp01.getId(); - - // 调用 - Map appMap = appService.getAppMap(singleton(id)); - // 校验数据一致 - assertEquals(1, appMap.size()); - assertPojoEquals(dbApp01, appMap.get(id)); - } - - @Test - public void testGetAppPage() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class, o -> { // 等会查询到 - o.setName("灿灿姐的杂货铺"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(buildTime(2021,11,20)); - }); - - appMapper.insert(dbApp); - // 测试 name 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setName("敏敏姐的杂货铺"))); - // 测试 status 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setCreateTime(buildTime(2021,12,21)))); - // 准备参数 - PayAppPageReqVO reqVO = new PayAppPageReqVO(); - reqVO.setName("灿灿姐的杂货铺"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2021, 11, 19, 2021, 11, 21)); - - // 调用 - PageResult pageResult = appService.getAppPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbApp, pageResult.getList().get(0)); - } - - @Test - public void testValidPayApp_success() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class, - o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - - // 调用 - PayAppDO app = appService.validPayApp(id); - // 校验数据一致 - assertPojoEquals(app, dbApp); - } - - @Test - public void testValidPayApp_notFound() { - assertServiceException(() -> appService.validPayApp(randomLongId()), APP_NOT_FOUND); - } - - @Test - public void testValidPayApp_disable() { - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class, - o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())); - appMapper.insert(dbApp);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbApp.getId(); - - // 调用,并断言异常 - assertServiceException(() -> appService.validPayApp(id), APP_IS_DISABLE); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java deleted file mode 100644 index 09631d3d2..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java +++ /dev/null @@ -1,343 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.channel; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.mysql.channel.PayChannelMapper; -import com.alibaba.fastjson.JSON; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import javax.validation.Validator; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -@Import({PayChannelServiceImpl.class}) -public class PayChannelServiceTest extends BaseDbUnitTest { - - @Resource - private PayChannelServiceImpl channelService; - - @Resource - private PayChannelMapper channelMapper; - - @MockBean - private PayClientFactory payClientFactory; - @MockBean - private Validator validator; - - @Test - public void testCreateChannel_success() { - // 准备参数 - WxPayClientConfig config = randomWxPayClientConfig(); - PayChannelCreateReqVO reqVO = randomPojo(PayChannelCreateReqVO.class, o -> { - o.setStatus(randomCommonStatus()); - o.setCode(PayChannelEnum.WX_PUB.getCode()); - o.setConfig(JsonUtils.toJsonString(config)); - }); - - // 调用 - Long channelId = channelService.createChannel(reqVO); - // 校验记录的属性是否正确 - PayChannelDO channel = channelMapper.selectById(channelId); - assertPojoEquals(reqVO, channel, "config"); - assertPojoEquals(config, channel.getConfig()); - // 校验缓存 - assertNull(channelService.getClientCache().getIfPresent(channelId)); - } - - @Test - public void testCreateChannel_exists() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, - o -> o.setConfig(randomWxPayClientConfig())); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - PayChannelCreateReqVO reqVO = randomPojo(PayChannelCreateReqVO.class, o -> { - o.setAppId(dbChannel.getAppId()); - o.setCode(dbChannel.getCode()); - }); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.createChannel(reqVO), CHANNEL_EXIST_SAME_CHANNEL_ERROR); - } - - @Test - public void testUpdateChannel_success() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - AlipayPayClientConfig config = randomAlipayPayClientConfig(); - PayChannelUpdateReqVO reqVO = randomPojo(PayChannelUpdateReqVO.class, o -> { - o.setId(dbChannel.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - o.setConfig(JsonUtils.toJsonString(config)); - }); - - // 调用 - channelService.updateChannel(reqVO); - // 校验是否更新正确 - PayChannelDO channel = channelMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, channel, "config"); - assertPojoEquals(config, channel.getConfig()); - // 校验缓存 - assertNull(channelService.getClientCache().getIfPresent(channel.getId())); - } - - @Test - public void testUpdateChannel_notExists() { - // 准备参数 - AlipayPayClientConfig payClientPublicKeyConfig = randomAlipayPayClientConfig(); - PayChannelUpdateReqVO reqVO = randomPojo(PayChannelUpdateReqVO.class, o -> { - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setConfig(JSON.toJSONString(payClientPublicKeyConfig)); - }); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.updateChannel(reqVO), CHANNEL_NOT_FOUND); - } - - @Test - public void testDeleteChannel_success() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbChannel.getId(); - - // 调用 - channelService.deleteChannel(id); - // 校验数据不存在了 - assertNull(channelMapper.selectById(id)); - // 校验缓存 - assertNull(channelService.getClientCache().getIfPresent(id)); - } - - @Test - public void testDeleteChannel_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.deleteChannel(id), CHANNEL_NOT_FOUND); - } - - @Test - public void testGetChannel() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbChannel.getId(); - - // 调用 - PayChannelDO channel = channelService.getChannel(id); - // 校验是否更新正确 - assertPojoEquals(dbChannel, channel); - } - - @Test - public void testGetChannelListByAppIds() { - // mock 数据 - PayChannelDO dbChannel01 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel01);// @Sql: 先插入出一条存在的数据 - PayChannelDO dbChannel02 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.WX_PUB.getCode()); - o.setConfig(randomWxPayClientConfig()); - }); - channelMapper.insert(dbChannel02);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long appId = dbChannel01.getAppId(); - - // 调用 - List channels = channelService.getChannelListByAppIds(Collections.singleton(appId)); - // 校验是否更新正确 - assertEquals(1, channels.size()); - assertPojoEquals(dbChannel01, channels.get(0)); - } - - @Test - public void testGetChannelByAppIdAndCode() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long appId = dbChannel.getAppId(); - String code = dbChannel.getCode(); - - // 调用 - PayChannelDO channel = channelService.getChannelByAppIdAndCode(appId, code); - // 断言 - assertPojoEquals(channel, dbChannel); - } - - @Test - public void testValidPayChannel_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.validPayChannel(id), CHANNEL_NOT_FOUND); - } - - @Test - public void testValidPayChannel_isDisable() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbChannel.getId(); - - // 调用, 并断言异常 - assertServiceException(() -> channelService.validPayChannel(id), CHANNEL_IS_DISABLE); - } - - @Test - public void testValidPayChannel_success() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbChannel.getId(); - - // 调用 - PayChannelDO channel = channelService.validPayChannel(id); - // 断言异常 - assertPojoEquals(channel, dbChannel); - } - - @Test - public void testValidPayChannel_appIdAndCode() { - // mock 数据 - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long appId = dbChannel.getAppId(); - String code = dbChannel.getCode(); - - // 调用 - PayChannelDO channel = channelService.validPayChannel(appId, code); - // 断言异常 - assertPojoEquals(channel, dbChannel); - } - - @Test - public void testGetEnableChannelList() { - // 准备参数 - Long appId = randomLongId(); - // mock 数据 01(enable 不匹配) - PayChannelDO dbChannel01 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - }); - channelMapper.insert(dbChannel01);// @Sql: 先插入出一条存在的数据 - // mock 数据 02(appId 不匹配) - PayChannelDO dbChannel02 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - channelMapper.insert(dbChannel02);// @Sql: 先插入出一条存在的数据 - // mock 数据 03 - PayChannelDO dbChannel03 = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - o.setAppId(appId); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - }); - channelMapper.insert(dbChannel03);// @Sql: 先插入出一条存在的数据 - - // 调用 - List channel = channelService.getEnableChannelList(appId); - // 断言异常 - assertPojoEquals(channel, dbChannel03); - } - - @Test - public void testGetPayClient() { - // mock 数据 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> { - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setConfig(randomAlipayPayClientConfig()); - }); - channelMapper.insert(channel); - // mock 参数 - Long id = channel.getId(); - // mock 方法 - PayClient mockClient = mock(PayClient.class); - when(payClientFactory.getPayClient(eq(id))).thenReturn(mockClient); - - // 调用 - PayClient client = channelService.getPayClient(id); - // 断言 - assertSame(client, mockClient); - verify(payClientFactory).createOrUpdatePayClient(eq(id), eq(channel.getCode()), - eq(channel.getConfig())); - } - - public WxPayClientConfig randomWxPayClientConfig() { - return new WxPayClientConfig() - .setAppId(randomString()) - .setMchId(randomString()) - .setApiVersion(WxPayClientConfig.API_VERSION_V2) - .setMchKey(randomString()); - } - - public AlipayPayClientConfig randomAlipayPayClientConfig() { - return new AlipayPayClientConfig() - .setServerUrl(randomURL()) - .setAppId(randomString()) - .setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT) - .setMode(AlipayPayClientConfig.MODE_PUBLIC_KEY) - .setPrivateKey(randomString()) - .setAlipayPublicKey(randomString()); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceTest.java deleted file mode 100644 index eb931f4fb..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceTest.java +++ /dev/null @@ -1,351 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.notify; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyLogDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.notify.PayNotifyTaskDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyLogMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.notify.PayNotifyTaskMapper; -import cn.iocoder.yudao.module.pay.dal.redis.notify.PayNotifyLockRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.framework.job.config.PayJobConfiguration; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; -import cn.iocoder.yudao.module.pay.service.refund.PayRefundServiceImpl; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.redisson.api.RLock; -import org.redisson.api.RedissonClient; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.Duration; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -/** - * {@link PayRefundServiceImpl} 的单元测试类 - * - * @author 芋艿 - */ -@Import({PayJobConfiguration.class, PayNotifyServiceImpl.class, PayNotifyLockRedisDAO.class}) -public class PayNotifyServiceTest extends BaseDbUnitTest { - - @Resource - private PayNotifyServiceImpl notifyService; - - @MockBean - private PayOrderService orderService; - @MockBean - private PayRefundService refundService; - - @Resource - private PayNotifyTaskMapper notifyTaskMapper; - @Resource - private PayNotifyLogMapper notifyLogMapper; - - @MockBean - private RedissonClient redissonClient; - - @Test - public void testCreatePayNotifyTask_order() { - PayNotifyServiceImpl payNotifyService = mock(PayNotifyServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayNotifyServiceImpl.class))) - .thenReturn(payNotifyService); - - // 准备参数 - Integer type = PayNotifyTypeEnum.ORDER.getType(); - Long dataId = 1L; - // mock 方法(order) - PayOrderDO order = randomPojo(PayOrderDO.class); - when(orderService.getOrder(eq(1L))).thenReturn(order); - // mock 方法(lock) - mockLock(null); // null 的原因,是咱没办法拿到 taskId 新增 - - // 调用 - notifyService.createPayNotifyTask(type, dataId); - // 断言,task - PayNotifyTaskDO dbTask = notifyTaskMapper.selectOne(null); - assertNotNull(dbTask.getNextNotifyTime()); - assertThat(dbTask) - .extracting("type", "dataId", "status", "notifyTimes", "maxNotifyTimes", - "appId", "merchantOrderId", "notifyUrl") - .containsExactly(type, dataId, PayNotifyStatusEnum.WAITING.getStatus(), 0, 9, - order.getAppId(), order.getMerchantOrderId(), order.getNotifyUrl()); - // 断言,调用 - verify(payNotifyService).executeNotify0(eq(dbTask)); - } - } - - @Test - public void testCreatePayNotifyTask_refund() { - PayNotifyServiceImpl payNotifyService = mock(PayNotifyServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayNotifyServiceImpl.class))) - .thenReturn(payNotifyService); - - // 准备参数 - Integer type = PayNotifyTypeEnum.REFUND.getType(); - Long dataId = 1L; - // mock 方法(refund) - PayRefundDO refund = randomPojo(PayRefundDO.class); - when(refundService.getRefund(eq(1L))).thenReturn(refund); - // mock 方法(lock) - mockLock(null); // null 的原因,是咱没办法拿到 taskId 新增 - - // 调用 - notifyService.createPayNotifyTask(type, dataId); - // 断言,task - PayNotifyTaskDO dbTask = notifyTaskMapper.selectOne(null); - assertNotNull(dbTask.getNextNotifyTime()); - assertThat(dbTask) - .extracting("type", "dataId", "status", "notifyTimes", "maxNotifyTimes", - "appId", "merchantOrderId", "notifyUrl") - .containsExactly(type, dataId, PayNotifyStatusEnum.WAITING.getStatus(), 0, 9, - refund.getAppId(), refund.getMerchantOrderId(), refund.getNotifyUrl()); - // 断言,调用 - verify(payNotifyService).executeNotify0(eq(dbTask)); - } - } - - @Test - public void testExecuteNotify() throws InterruptedException { - // mock 数据(notify) - PayNotifyTaskDO dbTask01 = randomPojo(PayNotifyTaskDO.class, - o -> o.setStatus(PayNotifyStatusEnum.WAITING.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask01); - PayNotifyTaskDO dbTask02 = randomPojo(PayNotifyTaskDO.class, - o -> o.setStatus(PayNotifyStatusEnum.REQUEST_SUCCESS.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask02); - PayNotifyTaskDO dbTask03 = randomPojo(PayNotifyTaskDO.class, - o -> o.setStatus(PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask03); - PayNotifyTaskDO dbTask04 = randomPojo(PayNotifyTaskDO.class, // 不满足状态 - o -> o.setStatus(PayNotifyStatusEnum.FAILURE.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask04); - PayNotifyTaskDO dbTask05 = randomPojo(PayNotifyTaskDO.class, // 不满足状态 - o -> o.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(-1)))); - notifyTaskMapper.insert(dbTask05); - PayNotifyTaskDO dbTask06 = randomPojo(PayNotifyTaskDO.class, // 不满足时间 - o -> o.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()) - .setNextNotifyTime(addTime(Duration.ofMinutes(1)))); - notifyTaskMapper.insert(dbTask06); - // mock 方法(lock) - mockLock(dbTask01.getId()); - mockLock(dbTask02.getId()); - mockLock(dbTask03.getId()); - - // 调用 - int count = notifyService.executeNotify(); - // 断言,数量 - assertEquals(count, 3); - } - - @Test // 由于 HttpUtil 不好 mock,所以只测试异常的情况 - public void testExecuteNotify0_exception() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, o -> o.setType(-1) - .setNotifyTimes(0).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - - // 调用 - notifyService.executeNotify0(task); - // 断言,task - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertNotEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 1); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()); - // 断言,log - PayNotifyLogDO dbLog = notifyLogMapper.selectOne(null); - assertEquals(dbLog.getTaskId(), task.getId()); - assertEquals(dbLog.getNotifyTimes(), 1); - assertTrue(dbLog.getResponse().contains("未知的通知任务类型:")); - assertEquals(dbLog.getStatus(), PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()); - } - - @Test - public void testProcessNotifyResult_success() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, - o -> o.setNotifyTimes(0).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - // 准备参数 - CommonResult invokeResult = CommonResult.success(randomString()); - - // 调用 - notifyService.processNotifyResult(task, invokeResult, null); - // 断言 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 1); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.SUCCESS.getStatus()); - } - - @Test - public void testProcessNotifyResult_failure() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, - o -> o.setNotifyTimes(8).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - // 准备参数 - CommonResult invokeResult = CommonResult.error(BAD_REQUEST); - - // 调用 - notifyService.processNotifyResult(task, invokeResult, null); - // 断言 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 9); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.FAILURE.getStatus()); - } - - @Test - public void testProcessNotifyResult_requestFailure() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, - o -> o.setNotifyTimes(0).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - // 准备参数 - CommonResult invokeResult = CommonResult.error(BAD_REQUEST); - - // 调用 - notifyService.processNotifyResult(task, invokeResult, null); - // 断言 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertNotEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 1); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.REQUEST_SUCCESS.getStatus()); - } - - @Test - public void testProcessNotifyResult_requestSuccess() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class, - o -> o.setNotifyTimes(0).setMaxNotifyTimes(9)); - notifyTaskMapper.insert(task); - // 准备参数 - CommonResult invokeResult = CommonResult.error(BAD_REQUEST); - RuntimeException invokeException = new RuntimeException(); - - // 调用 - notifyService.processNotifyResult(task, invokeResult, invokeException); - // 断言 - PayNotifyTaskDO dbTask = notifyTaskMapper.selectById(task.getId()); - assertNotEquals(task.getNextNotifyTime(), dbTask.getNextNotifyTime()); - assertNotEquals(task.getLastExecuteTime(), dbTask.getNextNotifyTime()); - assertEquals(dbTask.getNotifyTimes(), 1); - assertEquals(dbTask.getStatus(), PayNotifyStatusEnum.REQUEST_FAILURE.getStatus()); - } - - @Test - public void testGetNotifyTask() { - // mock 数据(task) - PayNotifyTaskDO task = randomPojo(PayNotifyTaskDO.class); - notifyTaskMapper.insert(task); - // 准备参数 - Long id = task.getId(); - - // 调用 - PayNotifyTaskDO dbTask = notifyService.getNotifyTask(id); - // 断言 - assertPojoEquals(dbTask, task); - } - - @Test - public void testGetNotifyTaskPage() { - // mock 数据 - PayNotifyTaskDO dbTask = randomPojo(PayNotifyTaskDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setType(PayNotifyTypeEnum.REFUND.getType()); - o.setDataId(100L); - o.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()); - o.setMerchantOrderId("P110"); - o.setCreateTime(buildTime(2023, 2, 3)); - }); - notifyTaskMapper.insert(dbTask); - // 测试 appId 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setAppId(2L))); - // 测试 type 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setType(PayNotifyTypeEnum.ORDER.getType()))); - // 测试 dataId 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setDataId(200L))); - // 测试 status 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setStatus(PayNotifyStatusEnum.FAILURE.getStatus()))); - // 测试 merchantOrderId 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setMerchantOrderId(randomString()))); - // 测试 createTime 不匹配 - notifyTaskMapper.insert(cloneIgnoreId(dbTask, o -> o.setCreateTime(buildTime(2023, 1, 1)))); - // 准备参数 - PayNotifyTaskPageReqVO reqVO = new PayNotifyTaskPageReqVO(); - reqVO.setAppId(1L); - reqVO.setType(PayNotifyTypeEnum.REFUND.getType()); - reqVO.setDataId(100L); - reqVO.setStatus(PayNotifyStatusEnum.SUCCESS.getStatus()); - reqVO.setMerchantOrderId("P110"); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - PageResult pageResult = notifyService.getNotifyTaskPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbTask, pageResult.getList().get(0)); - } - - @Test - public void testGetNotifyLogList() { - // mock 数据 - PayNotifyLogDO dbLog = randomPojo(PayNotifyLogDO.class); - notifyLogMapper.insert(dbLog); - PayNotifyLogDO dbLog02 = randomPojo(PayNotifyLogDO.class); - notifyLogMapper.insert(dbLog02); - // 准备参数 - Long taskId = dbLog.getTaskId(); - - // 调用 - List logList = notifyService.getNotifyLogList(taskId); - // 断言 - assertEquals(logList.size(), 1); - assertPojoEquals(dbLog, logList.get(0)); - } - - private void mockLock(Long id) { - RLock lock = mock(RLock.class); - if (id == null) { - when(redissonClient.getLock(anyString())) - .thenReturn(lock); - } else { - when(redissonClient.getLock(eq("pay_notify:lock:" + id))) - .thenReturn(lock); - } - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java deleted file mode 100755 index cf72aa819..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java +++ /dev/null @@ -1,1102 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.order; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest; -import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderExtensionMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; - -/** - * {@link PayOrderServiceImpl} 的单元测试类 - * - * @author 芋艿 - */ -@Import({PayOrderServiceImpl.class, PayNoRedisDAO.class}) -public class PayOrderServiceTest extends BaseDbAndRedisUnitTest { - - @Resource - private PayOrderServiceImpl orderService; - - @Resource - private PayOrderMapper orderMapper; - @Resource - private PayOrderExtensionMapper orderExtensionMapper; - - @MockBean - private PayProperties properties; - @MockBean - private PayAppService appService; - @MockBean - private PayChannelService channelService; - @MockBean - private PayNotifyService notifyService; - - @BeforeEach - public void setUp() { - when(properties.getOrderNotifyUrl()).thenReturn("http://127.0.0.1"); - } - - @Test - public void testGetOrder_id() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class); - orderMapper.insert(order); - // 准备参数 - Long id = order.getId(); - - // 调用 - PayOrderDO dbOrder = orderService.getOrder(id); - // 断言 - assertPojoEquals(dbOrder, order); - } - - @Test - public void testGetOrder_appIdAndMerchantOrderId() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class); - orderMapper.insert(order); - // 准备参数 - Long appId = order.getAppId(); - String merchantOrderId = order.getMerchantOrderId(); - - // 调用 - PayOrderDO dbOrder = orderService.getOrder(appId, merchantOrderId); - // 断言 - assertPojoEquals(dbOrder, order); - } - - @Test - public void testGetOrderCountByAppId() { - // mock 数据(PayOrderDO) - PayOrderDO order01 = randomPojo(PayOrderDO.class); - orderMapper.insert(order01); - PayOrderDO order02 = randomPojo(PayOrderDO.class); - orderMapper.insert(order02); - // 准备参数 - Long appId = order01.getAppId(); - - // 调用 - Long count = orderService.getOrderCountByAppId(appId); - // 断言 - assertEquals(count, 1L); - } - - @Test - public void testGetOrderPage() { - // mock 数据 - PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - o.setMerchantOrderId("110"); - o.setChannelOrderNo("220"); - o.setNo("330"); - o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - o.setCreateTime(buildTime(2018, 1, 15)); - }); - orderMapper.insert(dbOrder); - // 测试 appId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setAppId(2L))); - // 测试 channelCode 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); - // 测试 merchantOrderId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setMerchantOrderId(randomString()))); - // 测试 channelOrderNo 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelOrderNo(randomString()))); - // 测试 no 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setNo(randomString()))); - // 测试 status 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus()))); - // 测试 createTime 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setCreateTime(buildTime(2019, 1, 1)))); - // 准备参数 - PayOrderPageReqVO reqVO = new PayOrderPageReqVO(); - reqVO.setAppId(1L); - reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqVO.setMerchantOrderId("11"); - reqVO.setChannelOrderNo("22"); - reqVO.setNo("33"); - reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2018, 1, 10, 2018, 1, 30)); - - // 调用 - PageResult pageResult = orderService.getOrderPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbOrder, pageResult.getList().get(0)); - } - - @Test - public void testGetOrderList() { - // mock 数据 - PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - o.setMerchantOrderId("110"); - o.setChannelOrderNo("220"); - o.setNo("330"); - o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - o.setCreateTime(buildTime(2018, 1, 15)); - }); - orderMapper.insert(dbOrder); - // 测试 appId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setAppId(2L))); - // 测试 channelCode 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); - // 测试 merchantOrderId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setMerchantOrderId(randomString()))); - // 测试 channelOrderNo 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setChannelOrderNo(randomString()))); - // 测试 no 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setNo(randomString()))); - // 测试 status 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus()))); - // 测试 createTime 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setCreateTime(buildTime(2019, 1, 1)))); - // 准备参数 - PayOrderExportReqVO reqVO = new PayOrderExportReqVO(); - reqVO.setAppId(1L); - reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqVO.setMerchantOrderId("11"); - reqVO.setChannelOrderNo("22"); - reqVO.setNo("33"); - reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - reqVO.setCreateTime(buildBetweenTime(2018, 1, 10, 2018, 1, 30)); - - // 调用 - List list = orderService.getOrderList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbOrder, list.get(0)); - } - - @Test - public void testCreateOrder_success() { - // mock 参数 - PayOrderCreateReqDTO reqDTO = randomPojo(PayOrderCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("10") - .setSubject(randomString()).setBody(randomString())); - // mock 方法 - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L).setOrderNotifyUrl("http://127.0.0.1")); - when(appService.validPayApp(eq(reqDTO.getAppId()))).thenReturn(app); - - // 调用 - Long orderId = orderService.createOrder(reqDTO); - // 断言 - PayOrderDO order = orderMapper.selectById(orderId); - assertPojoEquals(order, reqDTO); - assertEquals(order.getAppId(), 1L); - assertEquals(order.getNotifyUrl(), "http://127.0.0.1"); - assertEquals(order.getStatus(), PayOrderStatusEnum.WAITING.getStatus()); - assertEquals(order.getRefundPrice(), 0); - } - - @Test - public void testCreateOrder_exists() { - // mock 参数 - PayOrderCreateReqDTO reqDTO = randomPojo(PayOrderCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("10")); - // mock 数据 - PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> o.setAppId(1L).setMerchantOrderId("10")); - orderMapper.insert(dbOrder); - - // 调用 - Long orderId = orderService.createOrder(reqDTO); - // 断言 - PayOrderDO order = orderMapper.selectById(orderId); - assertPojoEquals(dbOrder, order); - } - - @Test - public void testSubmitOrder_notFound() { - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class); - String userIp = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_NOT_FOUND); - } - - @Test - public void testSubmitOrder_notWaiting() { - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.REFUND.getStatus())); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId())); - String userIp = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_STATUS_IS_NOT_WAITING); - } - - @Test - public void testSubmitOrder_isSuccess() { - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId())); - String userIp = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_STATUS_IS_SUCCESS); - } - - @Test - public void testSubmitOrder_expired() { - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofDays(-1)))); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId())); - String userIp = randomString(); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_IS_EXPIRED); - } - - @Test - public void testSubmitOrder_channelNotFound() { - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setAppId(1L).setExpireTime(addTime(Duration.ofDays(1)))); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId()) - .setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - String userIp = randomString(); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L), eq(PayChannelEnum.ALIPAY_APP.getCode()))) - .thenReturn(channel); - - // 调用, 并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), CHANNEL_NOT_FOUND); - } - - @Test // 调用 unifiedOrder 接口,返回存在渠道错误 - public void testSubmitOrder_channelError() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setAppId(1L).setExpireTime(addTime(Duration.ofDays(1)))); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId()) - .setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - String userIp = randomString(); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L), eq(PayChannelEnum.ALIPAY_APP.getCode()))) - .thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法() - PayOrderRespDTO unifiedOrderResp = randomPojo(PayOrderRespDTO.class, o -> - o.setChannelErrorCode("001").setChannelErrorMsg("模拟异常")); - when(client.unifiedOrder(argThat(payOrderUnifiedReqDTO -> { - assertNotNull(payOrderUnifiedReqDTO.getOutTradeNo()); - assertThat(payOrderUnifiedReqDTO) - .extracting("subject", "body", "notifyUrl", "returnUrl", "price", "expireTime") - .containsExactly(order.getSubject(), order.getBody(), "http://127.0.0.1/10", - reqVO.getReturnUrl(), order.getPrice(), order.getExpireTime()); - return true; - }))).thenReturn(unifiedOrderResp); - - // 调用,并断言异常 - assertServiceException(() -> orderService.submitOrder(reqVO, userIp), - PAY_ORDER_SUBMIT_CHANNEL_ERROR, "001", "模拟异常"); - // 断言,数据记录(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = orderExtensionMapper.selectOne(null); - assertNotNull(orderExtension); - assertThat(orderExtension).extracting("no", "orderId").isNotNull(); - assertThat(orderExtension) - .extracting("channelId", "channelCode","userIp" ,"status", "channelExtras", - "channelErrorCode", "channelErrorMsg", "channelNotifyData") - .containsExactly(10L, PayChannelEnum.ALIPAY_APP.getCode(), userIp, - PayOrderStatusEnum.WAITING.getStatus(), reqVO.getChannelExtras(), - null, null, null); - } - } - - @Test - public void testSubmitOrder_success() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setAppId(1L).setExpireTime(addTime(Duration.ofDays(1)))); - orderMapper.insert(order); - // 准备参数 - PayOrderSubmitReqVO reqVO = randomPojo(PayOrderSubmitReqVO.class, o -> o.setId(order.getId()) - .setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - String userIp = randomString(); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L), eq(PayChannelEnum.ALIPAY_APP.getCode()))) - .thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(支付渠道的调用) - PayOrderRespDTO unifiedOrderResp = randomPojo(PayOrderRespDTO.class, o -> o.setChannelErrorCode(null).setChannelErrorMsg(null) - .setDisplayMode(PayOrderDisplayModeEnum.URL.getMode()).setDisplayContent("tudou")); - when(client.unifiedOrder(argThat(payOrderUnifiedReqDTO -> { - assertNotNull(payOrderUnifiedReqDTO.getOutTradeNo()); - assertThat(payOrderUnifiedReqDTO) - .extracting("subject", "body", "notifyUrl", "returnUrl", "price", "expireTime") - .containsExactly(order.getSubject(), order.getBody(), "http://127.0.0.1/10", - reqVO.getReturnUrl(), order.getPrice(), order.getExpireTime()); - return true; - }))).thenReturn(unifiedOrderResp); - - // 调用 - PayOrderSubmitRespVO result = orderService.submitOrder(reqVO, userIp); - // 断言,数据记录(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = orderExtensionMapper.selectOne(null); - assertNotNull(orderExtension); - assertThat(orderExtension).extracting("no", "orderId").isNotNull(); - assertThat(orderExtension) - .extracting("channelId", "channelCode","userIp" ,"status", "channelExtras", - "channelErrorCode", "channelErrorMsg", "channelNotifyData") - .containsExactly(10L, PayChannelEnum.ALIPAY_APP.getCode(), userIp, - PayOrderStatusEnum.WAITING.getStatus(), reqVO.getChannelExtras(), - null, null, null); - // 断言,返回(PayOrderSubmitRespVO) - assertThat(result) - .extracting("status", "displayMode", "displayContent") - .containsExactly(PayOrderStatusEnum.WAITING.getStatus(), PayOrderDisplayModeEnum.URL.getMode(), "tudou"); - // 断言,调用 - verify(payOrderServiceImpl).notifyOrder(same(channel), same(unifiedOrderResp)); - } - } - - @Test - public void testValidateOrderActuallyPaid_dbPaid() { - // 准备参数 - Long id = randomLongId(); - // mock 方法(OrderExtension 已支付) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setOrderId(id).setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - orderExtensionMapper.insert(orderExtension); - - // 调用,并断言异常 - assertServiceException(() -> orderService.validateOrderActuallyPaid(id), - PAY_ORDER_EXTENSION_IS_PAID); - } - - @Test - public void testValidateOrderActuallyPaid_remotePaid() { - // 准备参数 - Long id = randomLongId(); - // mock 方法(OrderExtension 已支付) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setOrderId(id).setStatus(PayOrderStatusEnum.WAITING.getStatus())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient 已支付) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(orderExtension.getChannelId()))).thenReturn(client); - when(client.getOrder(eq(orderExtension.getNo()))).thenReturn(randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()))); - - // 调用,并断言异常 - assertServiceException(() -> orderService.validateOrderActuallyPaid(id), - PAY_ORDER_EXTENSION_IS_PAID); - } - - @Test - public void testValidateOrderActuallyPaid_success() { - // 准备参数 - Long id = randomLongId(); - // mock 方法(OrderExtension 已支付) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setOrderId(id).setStatus(PayOrderStatusEnum.WAITING.getStatus())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient 已支付) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(orderExtension.getChannelId()))).thenReturn(client); - when(client.getOrder(eq(orderExtension.getNo()))).thenReturn(randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()))); - - // 调用,并断言异常 - orderService.validateOrderActuallyPaid(id); - } - - @Test - public void testNotifyOrder_channelId() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - // 准备参数 - Long channelId = 10L; - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - orderService.notifyOrder(channelId, notify); - // 断言 - verify(payOrderServiceImpl).notifyOrder(same(channel), same(notify)); - } - } - - @Test - public void testNotifyOrderSuccess_orderExtension_notFound() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus())); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_EXTENSION_NOT_FOUND); - } - - @Test - public void testNotifyOrderSuccess_orderExtension_closed() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - - @Test - public void testNotifyOrderSuccess_order_notFound() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_NOT_FOUND); - // 断言 PayOrderExtensionDO :数据更新被回滚 - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - } - - @Test - public void testNotifyOrderSuccess_order_closed() { - testNotifyOrderSuccess_order_closedOrRefund(PayOrderStatusEnum.CLOSED.getStatus()); - } - - @Test - public void testNotifyOrderSuccess_order_refund() { - testNotifyOrderSuccess_order_closedOrRefund(PayOrderStatusEnum.REFUND.getStatus()); - } - - private void testNotifyOrderSuccess_order_closedOrRefund(Integer status) { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(status)); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setNo("P110") - .setOrderId(order.getId())); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_STATUS_IS_NOT_WAITING); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 SUCCESS - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - } - - @Test - public void testNotifyOrderSuccess_order_paid() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setNo("P110") - .setOrderId(order.getId())); - orderExtensionMapper.insert(orderExtension); - // 重要:需要将 order 的 extensionId 更新下 - order.setExtensionId(orderExtension.getId()); - orderMapper.updateById(order); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 SUCCESS - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - // 断言 PayOrderDO :数据未更新,因为它是 SUCCESS - assertPojoEquals(order, orderMapper.selectOne(null)); - // 断言,调用 - verify(notifyService, never()).createPayNotifyTask(anyInt(), anyLong()); - } - - @Test - public void testNotifyOrderSuccess_order_waiting() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setPrice(10)); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setNo("P110") - .setOrderId(order.getId())); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setFeeRate(10D)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 SUCCESS - orderExtension.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setChannelNotifyData(toJsonString(notify)); - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null), - "updateTime", "updater"); - // 断言 PayOrderDO :数据未更新,因为它是 SUCCESS - order.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setChannelId(10L).setChannelCode(channel.getCode()) - .setSuccessTime(notify.getSuccessTime()).setExtensionId(orderExtension.getId()).setNo(orderExtension.getNo()) - .setChannelOrderNo(notify.getChannelOrderNo()).setChannelUserId(notify.getChannelUserId()) - .setChannelFeeRate(10D).setChannelFeePrice(1); - assertPojoEquals(order, orderMapper.selectOne(null), - "updateTime", "updater"); - // 断言,调用 - verify(notifyService).createPayNotifyTask(eq(PayNotifyTypeEnum.ORDER.getType()), - eq(orderExtension.getOrderId())); - } - - @Test - public void testNotifyOrderClosed_orderExtension_notFound() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus())); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_EXTENSION_NOT_FOUND); - } - - @Test - public void testNotifyOrderClosed_orderExtension_closed() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 CLOSED - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - } - - @Test - public void testNotifyOrderClosed_orderExtension_paid() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO :数据未更新,因为它是 SUCCESS - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null)); - } - - @Test - public void testNotifyOrderClosed_orderExtension_refund() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus()) - .setOutTradeNo("P110")); - - // 调用,并断言异常 - assertServiceException(() -> orderService.notifyOrder(channel, notify), - PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING); - } - - @Test - public void testNotifyOrderClosed_orderExtension_waiting() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setNo("P110")); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus()) - .setOutTradeNo("P110")); - - // 调用 - orderService.notifyOrder(channel, notify); - // 断言 PayOrderExtensionDO - orderExtension.setStatus(PayOrderStatusEnum.CLOSED.getStatus()).setChannelNotifyData(toJsonString(notify)) - .setChannelErrorCode(notify.getChannelErrorCode()).setChannelErrorMsg(notify.getChannelErrorMsg()); - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null), - "updateTime", "updater"); - } - - @Test - public void testUpdateOrderRefundPrice_notFound() { - // 准备参数 - Long id = randomLongId(); - Integer incrRefundPrice = randomInteger(); - - // 调用,并断言异常 - assertServiceException(() -> orderService.updateOrderRefundPrice(id, incrRefundPrice), - PAY_ORDER_NOT_FOUND); - } - - @Test - public void testUpdateOrderRefundPrice_waiting() { - testUpdateOrderRefundPrice_waitingOrClosed(PayOrderStatusEnum.WAITING.getStatus()); - } - - @Test - public void testUpdateOrderRefundPrice_closed() { - testUpdateOrderRefundPrice_waitingOrClosed(PayOrderStatusEnum.CLOSED.getStatus()); - } - - private void testUpdateOrderRefundPrice_waitingOrClosed(Integer status) { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(status)); - orderMapper.insert(order); - // 准备参数 - Long id = order.getId(); - Integer incrRefundPrice = randomInteger(); - - // 调用,并断言异常 - assertServiceException(() -> orderService.updateOrderRefundPrice(id, incrRefundPrice), - PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - - @Test - public void testUpdateOrderRefundPrice_priceExceed() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setRefundPrice(1).setPrice(10)); - orderMapper.insert(order); - // 准备参数 - Long id = order.getId(); - Integer incrRefundPrice = 10; - - // 调用,并断言异常 - assertServiceException(() -> orderService.updateOrderRefundPrice(id, incrRefundPrice), - REFUND_PRICE_EXCEED); - } - - @Test - public void testUpdateOrderRefundPrice_refund() { - testUpdateOrderRefundPrice_refundOrSuccess(PayOrderStatusEnum.REFUND.getStatus()); - } - - @Test - public void testUpdateOrderRefundPrice_success() { - testUpdateOrderRefundPrice_refundOrSuccess(PayOrderStatusEnum.SUCCESS.getStatus()); - } - - private void testUpdateOrderRefundPrice_refundOrSuccess(Integer status) { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(status).setRefundPrice(1).setPrice(10)); - orderMapper.insert(order); - // 准备参数 - Long id = order.getId(); - Integer incrRefundPrice = 8; - - // 调用 - orderService.updateOrderRefundPrice(id, incrRefundPrice); - // 断言 - order.setRefundPrice(9).setStatus(PayOrderStatusEnum.REFUND.getStatus()); - assertPojoEquals(order, orderMapper.selectOne(null), - "updateTime", "updater"); - } - - @Test - public void testGetOrderExtension() { - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class); - orderExtensionMapper.insert(orderExtension); - // 准备参数 - Long id = orderExtension.getId(); - - // 调用 - PayOrderExtensionDO dbOrderExtension = orderService.getOrderExtension(id); - // 断言 - assertPojoEquals(dbOrderExtension, orderExtension); - } - - @Test - public void testSyncOrder_payClientNotFound() { - // 准备参数 - LocalDateTime minCreateTime = LocalDateTime.now().minus(Duration.ofMinutes(10)); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setCreateTime(LocalDateTime.now())); - orderExtensionMapper.insert(orderExtension); - - // 调用 - int count = orderService.syncOrder(minCreateTime); - // 断言 - assertEquals(count, 0); - } - - @Test - public void testSyncOrder_exception() { - // 准备参数 - LocalDateTime minCreateTime = LocalDateTime.now().minus(Duration.ofMinutes(10)); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setChannelId(10L) - .setCreateTime(LocalDateTime.now())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 异常) - when(client.getOrder(any())).thenThrow(new RuntimeException()); - - // 调用 - int count = orderService.syncOrder(minCreateTime); - // 断言 - assertEquals(count, 0); - } - - @Test - public void testSyncOrder_orderSuccess() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // 准备参数 - LocalDateTime minCreateTime = LocalDateTime.now().minus(Duration.ofMinutes(10)); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setChannelId(10L).setNo("P110") - .setCreateTime(LocalDateTime.now())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 成功返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - // mock 方法(PayChannelDO) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - int count = orderService.syncOrder(minCreateTime); - // 断言 - assertEquals(count, 1); - verify(payOrderServiceImpl).notifyOrder(same(channel), same(respDTO)); - } - } - - @Test - public void testSyncOrder_orderClosed() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // 准备参数 - LocalDateTime minCreateTime = LocalDateTime.now().minus(Duration.ofMinutes(10)); - // mock 数据(PayOrderExtensionDO) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setChannelId(10L).setNo("P110") - .setCreateTime(LocalDateTime.now())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 成功返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - // mock 方法(PayChannelDO) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - int count = orderService.syncOrder(minCreateTime); - // 断言 - assertEquals(count, 0); - verify(payOrderServiceImpl).notifyOrder(same(channel), same(respDTO)); - } - } - - @Test - public void testExpireOrder_orderExtension_isSuccess() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 已支付) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()) - .setOrderId(order.getId())); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 0); - // 断言 order 没有变化,因为没更新 - assertPojoEquals(order, orderMapper.selectOne(null)); - } - - @Test - public void testExpireOrder_payClient_notFound() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 等待中) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setOrderId(order.getId()) - .setChannelId(10L)); - orderExtensionMapper.insert(orderExtension); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 0); - // 断言 order 没有变化,因为没更新 - assertPojoEquals(order, orderMapper.selectOne(null)); - } - - @Test - public void testExpireOrder_getOrder_isRefund() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 等待中) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setOrderId(order.getId()).setNo("P110") - .setChannelId(10L)); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 退款返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.REFUND.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 0); - // 断言 order 没有变化,因为没更新 - assertPojoEquals(order, orderMapper.selectOne(null)); - } - - @Test - public void testExpireOrder_getOrder_isSuccess() { - PayOrderServiceImpl payOrderServiceImpl = mock(PayOrderServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayOrderServiceImpl.class))) - .thenReturn(payOrderServiceImpl); - - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 等待中) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setOrderId(order.getId()).setNo("P110") - .setChannelId(10L)); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 成功返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - // mock 方法(PayChannelDO) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 0); - // 断言 order 没有变化,因为没更新 - assertPojoEquals(order, orderMapper.selectOne(null)); - verify(payOrderServiceImpl).notifyOrder(same(channel), same(respDTO)); - } - } - - @Test - public void testExpireOrder_success() { - // mock 数据(PayOrderDO) - PayOrderDO order = randomPojo(PayOrderDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setExpireTime(addTime(Duration.ofMinutes(-1)))); - orderMapper.insert(order); - // mock 数据(PayOrderExtensionDO 等待中) - PayOrderExtensionDO orderExtension = randomPojo(PayOrderExtensionDO.class, - o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()) - .setOrderId(order.getId()).setNo("P110") - .setChannelId(10L)); - orderExtensionMapper.insert(orderExtension); - // mock 方法(PayClient) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(PayClient 关闭返回) - PayOrderRespDTO respDTO = randomPojo(PayOrderRespDTO.class, - o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus())); - when(client.getOrder(eq("P110"))).thenReturn(respDTO); - - // 调用 - int count = orderService.expireOrder(); - // 断言 - assertEquals(count, 1); - // 断言 extension 变化 - orderExtension.setStatus(PayOrderStatusEnum.CLOSED.getStatus()) - .setChannelNotifyData(toJsonString(respDTO)); - assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null), - "updateTime", "updater"); - // 断言 order 变化 - order.setStatus(PayOrderStatusEnum.CLOSED.getStatus()); - assertPojoEquals(order, orderMapper.selectOne(null), - "updateTime", "updater"); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java deleted file mode 100755 index a9296f93f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java +++ /dev/null @@ -1,700 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.refund; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest; -import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.dal.mysql.refund.PayRefundMapper; -import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; -import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; -import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties; -import cn.iocoder.yudao.module.pay.service.app.PayAppService; -import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; -import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; -import cn.iocoder.yudao.module.pay.service.order.PayOrderService; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; - -/** - * {@link PayRefundServiceImpl} 的单元测试类 - * - * @author 芋艿 - */ -@Import({PayRefundServiceImpl.class, PayNoRedisDAO.class}) -public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { - - @Resource - private PayRefundServiceImpl refundService; - - @Resource - private PayRefundMapper refundMapper; - - @MockBean - private PayProperties payProperties; - @MockBean - private PayOrderService orderService; - @MockBean - private PayAppService appService; - @MockBean - private PayChannelService channelService; - @MockBean - private PayNotifyService notifyService; - - @BeforeEach - public void setUp() { - when(payProperties.getRefundNotifyUrl()).thenReturn("http://127.0.0.1"); - } - - @Test - public void testGetRefund() { - // mock 数据 - PayRefundDO refund = randomPojo(PayRefundDO.class); - refundMapper.insert(refund); - // 准备参数 - Long id = refund.getId(); - - // 调用 - PayRefundDO dbRefund = refundService.getRefund(id); - // 断言 - assertPojoEquals(dbRefund, refund); - } - - @Test - public void testGetRefundCountByAppId() { - // mock 数据 - PayRefundDO refund01 = randomPojo(PayRefundDO.class); - refundMapper.insert(refund01); - PayRefundDO refund02 = randomPojo(PayRefundDO.class); - refundMapper.insert(refund02); - // 准备参数 - Long appId = refund01.getAppId(); - - // 调用 - Long count = refundService.getRefundCountByAppId(appId); - // 断言 - assertEquals(count, 1); - } - - @Test - public void testGetRefundPage() { - // mock 数据 - PayRefundDO dbRefund = randomPojo(PayRefundDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - o.setMerchantOrderId("MOT0000001"); - o.setMerchantRefundId("MRF0000001"); - o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - o.setChannelOrderNo("CH0000001"); - o.setChannelRefundNo("CHR0000001"); - o.setCreateTime(buildTime(2021, 1, 10)); - }); - refundMapper.insert(dbRefund); - // 测试 appId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L))); - // 测试 channelCode 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); - // 测试 merchantOrderId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantOrderId(randomString()))); - // 测试 merchantRefundId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantRefundId(randomString()))); - // 测试 channelOrderNo 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelOrderNo(randomString()))); - // 测试 channelRefundNo 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelRefundNo(randomString()))); - // 测试 status 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()))); - // 测试 createTime 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setCreateTime(buildTime(2021, 1, 1)))); - // 准备参数 - PayRefundPageReqVO reqVO = new PayRefundPageReqVO(); - reqVO.setAppId(1L); - reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqVO.setMerchantOrderId("MOT0000001"); - reqVO.setMerchantRefundId("MRF0000001"); - reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - reqVO.setChannelOrderNo("CH0000001"); - reqVO.setChannelRefundNo("CHR0000001"); - reqVO.setCreateTime(buildBetweenTime(2021, 1, 9, 2021, 1, 11)); - - // 调用 - PageResult pageResult = refundService.getRefundPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbRefund, pageResult.getList().get(0)); - } - - @Test - public void testGetRefundList() { - // mock 数据 - PayRefundDO dbRefund = randomPojo(PayRefundDO.class, o -> { // 等会查询到 - o.setAppId(1L); - o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - o.setMerchantOrderId("MOT0000001"); - o.setMerchantRefundId("MRF0000001"); - o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - o.setChannelOrderNo("CH0000001"); - o.setChannelRefundNo("CHR0000001"); - o.setCreateTime(buildTime(2021, 1, 10)); - }); - refundMapper.insert(dbRefund); - // 测试 appId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L))); - // 测试 channelCode 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelCode(PayChannelEnum.ALIPAY_APP.getCode()))); - // 测试 merchantOrderId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantOrderId(randomString()))); - // 测试 merchantRefundId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantRefundId(randomString()))); - // 测试 channelOrderNo 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelOrderNo(randomString()))); - // 测试 channelRefundNo 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setChannelRefundNo(randomString()))); - // 测试 status 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setStatus(PayOrderStatusEnum.WAITING.getStatus()))); - // 测试 createTime 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setCreateTime(buildTime(2021, 1, 1)))); - // 准备参数 - PayRefundExportReqVO reqVO = new PayRefundExportReqVO(); - reqVO.setAppId(1L); - reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); - reqVO.setMerchantOrderId("MOT0000001"); - reqVO.setMerchantRefundId("MRF0000001"); - reqVO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()); - reqVO.setChannelOrderNo("CH0000001"); - reqVO.setChannelRefundNo("CHR0000001"); - reqVO.setCreateTime(buildBetweenTime(2021, 1, 9, 2021, 1, 11)); - - // 调用 - List list = refundService.getRefundList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbRefund, list.get(0)); - } - - @Test - public void testCreateRefund_orderNotFound() { - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L)); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - PAY_ORDER_NOT_FOUND); - } - - @Test - public void testCreateRefund_orderWaiting() { - testCreateRefund_orderWaitingOrClosed(PayOrderStatusEnum.WAITING.getStatus()); - } - - @Test - public void testCreateRefund_orderClosed() { - testCreateRefund_orderWaitingOrClosed(PayOrderStatusEnum.CLOSED.getStatus()); - } - - private void testCreateRefund_orderWaitingOrClosed(Integer status) { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100")); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> o.setStatus(status)); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - PAY_ORDER_REFUND_FAIL_STATUS_ERROR); - } - - @Test - public void testCreateRefund_refundPriceExceed() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(10)); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1)); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - REFUND_PRICE_EXCEED); - } - - @Test - public void testCreateRefund_orderHasRefunding() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(10)); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1)); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 数据(refund 在退款中) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> - o.setOrderId(order.getId()).setStatus(PayOrderStatusEnum.WAITING.getStatus())); - refundMapper.insert(refund); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - REFUND_PRICE_EXCEED); - } - - @Test - public void testCreateRefund_channelNotFound() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9)); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1) - .setChannelId(1L).setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L))).thenReturn(channel); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - CHANNEL_NOT_FOUND); - } - - @Test - public void testCreateRefund_refundExists() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9) - .setMerchantRefundId("200").setReason("测试退款")); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1) - .setChannelId(1L).setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(1L))).thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 数据(refund 已存在) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> - o.setAppId(1L).setMerchantRefundId("200")); - refundMapper.insert(refund); - - // 调用,并断言异常 - assertServiceException(() -> refundService.createPayRefund(reqDTO), - REFUND_EXISTS); - } - - @Test - public void testCreateRefund_invokeException() { - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9) - .setMerchantRefundId("200").setReason("测试退款")); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1) - .setChannelId(10L).setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(client 调用发生异常) - when(client.unifiedRefund(any(PayRefundUnifiedReqDTO.class))).thenThrow(new RuntimeException()); - - // 调用 - Long refundId = refundService.createPayRefund(reqDTO); - // 断言 - PayRefundDO refundDO = refundMapper.selectById(refundId); - assertPojoEquals(reqDTO, refundDO); - assertNotNull(refundDO.getNo()); - assertThat(refundDO) - .extracting("orderId", "orderNo", "channelId", "channelCode", - "notifyUrl", "channelOrderNo", "status", "payPrice", "refundPrice") - .containsExactly(order.getId(), order.getNo(), channel.getId(), channel.getCode(), - app.getRefundNotifyUrl(), order.getChannelOrderNo(), PayRefundStatusEnum.WAITING.getStatus(), - order.getPrice(), reqDTO.getPrice()); - } - - @Test - public void testCreateRefund_invokeSuccess() { - PayRefundServiceImpl payRefundServiceImpl = mock(PayRefundServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayRefundServiceImpl.class))) - .thenReturn(payRefundServiceImpl); - - // 准备参数 - PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9) - .setMerchantRefundId("200").setReason("测试退款")); - // mock 方法(app) - PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); - when(appService.validPayApp(eq(1L))).thenReturn(app); - // mock 数据(order) - PayOrderDO order = randomPojo(PayOrderDO.class, o -> - o.setStatus(PayOrderStatusEnum.REFUND.getStatus()) - .setPrice(10).setRefundPrice(1) - .setChannelId(10L).setChannelCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(orderService.getOrder(eq(1L), eq("100"))).thenReturn(order); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L) - .setCode(PayChannelEnum.ALIPAY_APP.getCode())); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(client 成功) - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class); - when(client.unifiedRefund(argThat(unifiedReqDTO -> { - assertNotNull(unifiedReqDTO.getOutRefundNo()); - assertThat(unifiedReqDTO) - .extracting("payPrice", "refundPrice", "outTradeNo", - "notifyUrl", "reason") - .containsExactly(order.getPrice(), reqDTO.getPrice(), order.getNo(), - "http://127.0.0.1/10", reqDTO.getReason()); - return true; - }))).thenReturn(refundRespDTO); - - // 调用 - Long refundId = refundService.createPayRefund(reqDTO); - // 断言 - PayRefundDO refundDO = refundMapper.selectById(refundId); - assertPojoEquals(reqDTO, refundDO); - assertNotNull(refundDO.getNo()); - assertThat(refundDO) - .extracting("orderId", "orderNo", "channelId", "channelCode", - "notifyUrl", "channelOrderNo", "status", "payPrice", "refundPrice") - .containsExactly(order.getId(), order.getNo(), channel.getId(), channel.getCode(), - app.getRefundNotifyUrl(), order.getChannelOrderNo(), PayRefundStatusEnum.WAITING.getStatus(), - order.getPrice(), reqDTO.getPrice()); - // 断言调用 - verify(payRefundServiceImpl).notifyRefund(same(channel), same(refundRespDTO)); - } - } - - @Test - public void testNotifyRefund() { - PayRefundServiceImpl payRefundServiceImpl = mock(PayRefundServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayRefundServiceImpl.class))) - .thenReturn(payRefundServiceImpl); - - // 准备参数 - Long channelId = 10L; - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - refundService.notifyRefund(channelId, refundRespDTO); - // 断言 - verify(payRefundServiceImpl).notifyRefund(same(channel), same(refundRespDTO)); - } - } - - @Test - public void testNotifyRefundSuccess_notFound() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - - // 调用,并断言异常 - assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO), - REFUND_NOT_FOUND); - } - - @Test - public void testNotifyRefundSuccess_isSuccess() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.SUCCESS.getStatus())); - refundMapper.insert(refund); - - // 调用 - refundService.notifyRefund(channel, refundRespDTO); - // 断言,refund 没有更新,因为已经退款成功 - assertPojoEquals(refund, refundMapper.selectById(refund.getId())); - } - - @Test - public void testNotifyRefundSuccess_failure() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.FAILURE.getStatus())); - refundMapper.insert(refund); - - // 调用,并断言异常 - assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO), - REFUND_STATUS_IS_NOT_WAITING); - } - - @Test - public void testNotifyRefundSuccess_updateOrderException() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderId(100L).setRefundPrice(23)); - refundMapper.insert(refund); - // mock 方法(order + 更新异常) - doThrow(new RuntimeException()).when(orderService) - .updateOrderRefundPrice(eq(100L), eq(23)); - - // 调用,并断言异常 - assertThrows(RuntimeException.class, () -> refundService.notifyRefund(channel, refundRespDTO)); - // 断言,refund 没有更新,因为事务回滚了 - assertPojoEquals(refund, refundMapper.selectById(refund.getId())); - } - - @Test - public void testNotifyRefundSuccess_success() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderId(100L).setRefundPrice(23)); - refundMapper.insert(refund); - - // 调用 - refundService.notifyRefund(channel, refundRespDTO); - // 断言,refund - refund.setSuccessTime(refundRespDTO.getSuccessTime()) - .setChannelRefundNo(refundRespDTO.getChannelRefundNo()) - .setStatus(PayRefundStatusEnum.SUCCESS.getStatus()) - .setChannelNotifyData(toJsonString(refundRespDTO)); - assertPojoEquals(refund, refundMapper.selectById(refund.getId()), - "updateTime", "updater"); - // 断言,调用 - verify(orderService).updateOrderRefundPrice(eq(100L), eq(23)); - verify(notifyService).createPayNotifyTask(eq(PayNotifyTypeEnum.REFUND.getType()), - eq(refund.getId())); - } - - @Test - public void testNotifyRefundFailure_notFound() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100")); - - // 调用,并断言异常 - assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO), - REFUND_NOT_FOUND); - } - - @Test - public void testNotifyRefundFailure_isFailure() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 退款失败) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.FAILURE.getStatus())); - refundMapper.insert(refund); - - // 调用 - refundService.notifyRefund(channel, refundRespDTO); - // 断言,refund 没有更新,因为已经退款失败 - assertPojoEquals(refund, refundMapper.selectById(refund.getId())); - } - - @Test - public void testNotifyRefundFailure_isSuccess() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.SUCCESS.getStatus())); - refundMapper.insert(refund); - - // 调用,并断言异常 - assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO), - REFUND_STATUS_IS_NOT_WAITING); - } - - @Test - public void testNotifyRefundFailure_success() { - // 准备参数 - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L)); - PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class, - o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100")); - // mock 数据(refund + 已支付) - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100") - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderId(100L).setRefundPrice(23)); - refundMapper.insert(refund); - - // 调用 - refundService.notifyRefund(channel, refundRespDTO); - // 断言,refund - refund.setChannelRefundNo(refundRespDTO.getChannelRefundNo()) - .setStatus(PayRefundStatusEnum.FAILURE.getStatus()) - .setChannelNotifyData(toJsonString(refundRespDTO)) - .setChannelErrorCode(refundRespDTO.getChannelErrorCode()) - .setChannelErrorMsg(refundRespDTO.getChannelErrorMsg()); - assertPojoEquals(refund, refundMapper.selectById(refund.getId()), - "updateTime", "updater"); - // 断言,调用 - verify(notifyService).createPayNotifyTask(eq(PayNotifyTypeEnum.REFUND.getType()), - eq(refund.getId())); - } - - @Test - public void testSyncRefund_notFound() { - // 准备参数 - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L) - .setStatus(PayRefundStatusEnum.WAITING.getStatus())); - refundMapper.insert(refund); - - // 调用 - int count = refundService.syncRefund(); - // 断言 - assertEquals(count, 0); - } - - @Test - public void testSyncRefund_waiting() { - assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusRespEnum.WAITING.getStatus()), 0); - } - - @Test - public void testSyncRefund_success() { - assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusRespEnum.SUCCESS.getStatus()), 1); - } - - @Test - public void testSyncRefund_failure() { - assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusRespEnum.FAILURE.getStatus()), 1); - } - - private int testSyncRefund_waitingOrSuccessOrFailure(Integer status) { - PayRefundServiceImpl payRefundServiceImpl = mock(PayRefundServiceImpl.class); - try (MockedStatic springUtilMockedStatic = mockStatic(SpringUtil.class)) { - springUtilMockedStatic.when(() -> SpringUtil.getBean(eq(PayRefundServiceImpl.class))) - .thenReturn(payRefundServiceImpl); - - // 准备参数 - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setChannelId(10L) - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderNo("P110").setNo("R220")); - refundMapper.insert(refund); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(client 返回指定状态) - PayRefundRespDTO respDTO = randomPojo(PayRefundRespDTO.class, o -> o.setStatus(status)); - when(client.getRefund(eq("P110"), eq("R220"))).thenReturn(respDTO); - // mock 方法(channel) - PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)); - when(channelService.validPayChannel(eq(10L))).thenReturn(channel); - - // 调用 - return refundService.syncRefund(); - } - } - - @Test - public void testSyncRefund_exception() { - // 准备参数 - PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setChannelId(10L) - .setStatus(PayRefundStatusEnum.WAITING.getStatus()) - .setOrderNo("P110").setNo("R220")); - refundMapper.insert(refund); - // mock 方法(client) - PayClient client = mock(PayClient.class); - when(channelService.getPayClient(eq(10L))).thenReturn(client); - // mock 方法(client 抛出异常) - when(client.getRefund(eq("P110"), eq("R220"))).thenThrow(new RuntimeException()); - - // 调用 - int count = refundService.syncRefund(); - // 断言 - assertEquals(count, 0); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/application-unit-test.yaml b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 93bccd939..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,52 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - -mybatis-plus: - global-config: - db-config: - id-type: AUTO # H2 主键递增 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/logback.xml b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/clean.sql b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index 91fff0cae..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,7 +0,0 @@ -DELETE FROM pay_app; -DELETE FROM pay_channel; -DELETE FROM pay_order; -DELETE FROM pay_order_extension; -DELETE FROM pay_refund; -DELETE FROM pay_notify_task; -DELETE FROM pay_notify_log; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/create_tables.sql b/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 6ae2ce2d4..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,146 +0,0 @@ -CREATE TABLE IF NOT EXISTS "pay_app" ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(64) NOT NULL, - "status" tinyint NOT NULL, - "remark" varchar(255) DEFAULT NULL, - `order_notify_url` varchar(1024) NOT NULL, - `refund_notify_url` varchar(1024) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '支付应用'; - -CREATE TABLE IF NOT EXISTS "pay_channel" ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "code" varchar(32) NOT NULL, - "status" tinyint(4) NOT NULL, - "remark" varchar(255) DEFAULT NULL, - "fee_rate" double NOT NULL DEFAULT 0, - "app_id" bigint(20) NOT NULL, - "config" varchar(10240) NOT NULL, - "creator" varchar(64) NULL DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) NULL DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit(1) NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT = '支付渠道'; - -CREATE TABLE IF NOT EXISTS `pay_order` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `app_id` bigint(20) NOT NULL, - `channel_id` bigint(20) DEFAULT NULL, - `channel_code` varchar(32) DEFAULT NULL, - `merchant_order_id` varchar(64) NOT NULL, - `subject` varchar(32) NOT NULL, - `body` varchar(128) NOT NULL, - `notify_url` varchar(1024) NOT NULL, - `price` bigint(20) NOT NULL, - `channel_fee_rate` double DEFAULT 0, - `channel_fee_price` bigint(20) DEFAULT 0, - `status` tinyint(4) NOT NULL, - `user_ip` varchar(50) NOT NULL, - `expire_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `success_time` datetime(0) DEFAULT CURRENT_TIMESTAMP, - `notify_time` datetime(0) DEFAULT CURRENT_TIMESTAMP, - `extension_id` bigint(20) DEFAULT NULL, - `no` varchar(64) NULL, - `refund_price` bigint(20) NOT NULL, - `channel_user_id` varchar(255) DEFAULT NULL, - `channel_order_no` varchar(64) DEFAULT NULL, - `creator` varchar(64) DEFAULT '', - `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) DEFAULT '', - `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '支付订单'; - -CREATE TABLE IF NOT EXISTS `pay_order_extension` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `no` varchar(64) NOT NULL, - `order_id` bigint(20) NOT NULL, - `channel_id` bigint(20) NOT NULL, - `channel_code` varchar(32) NOT NULL, - `user_ip` varchar(50) NULL DEFAULT NULL, - `status` tinyint(4) NOT NULL, - `channel_extras` varchar(1024) NULL DEFAULT NULL, - `channel_error_code` varchar(64) NULL, - `channel_error_msg` varchar(64) NULL, - `channel_notify_data` varchar(1024) NULL, - `creator` varchar(64) NULL DEFAULT '', - `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) NULL DEFAULT '', - `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '支付订单拓展'; - -CREATE TABLE IF NOT EXISTS `pay_refund` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `no` varchar(64) NOT NULL, - `app_id` bigint(20) NOT NULL, - `channel_id` bigint(20) NOT NULL, - `channel_code` varchar(32) NOT NULL, - `order_id` bigint(20) NOT NULL, - `order_no` varchar(64) NOT NULL, - `merchant_order_id` varchar(64) NOT NULL, - `merchant_refund_id` varchar(64) NOT NULL, - `notify_url` varchar(1024) NOT NULL, - `status` tinyint(4) NOT NULL, - `pay_price` bigint(20) NOT NULL, - `refund_price` bigint(20) NOT NULL, - `reason` varchar(256) NOT NULL, - `user_ip` varchar(50) NULL DEFAULT NULL, - `channel_order_no` varchar(64) NOT NULL, - `channel_refund_no` varchar(64) NULL DEFAULT NULL, - `success_time` datetime(0) NULL DEFAULT NULL, - `channel_error_code` varchar(128) NULL DEFAULT NULL, - `channel_error_msg` varchar(256) NULL DEFAULT NULL, - `channel_notify_data` varchar(1024) NULL, - `creator` varchar(64) NULL DEFAULT '', - `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) NULL DEFAULT '', - `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '退款订单'; - -CREATE TABLE IF NOT EXISTS `pay_notify_task` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `app_id` bigint(20) NOT NULL, - `type` tinyint(4) NOT NULL, - `data_id` bigint(20) NOT NULL, - `merchant_order_id` varchar(64) NOT NULL, - `status` tinyint(4) NOT NULL, - `next_notify_time` datetime(0) NULL DEFAULT NULL, - `last_execute_time` datetime(0) NULL DEFAULT NULL, - `notify_times` int NOT NULL, - `max_notify_times` int NOT NULL, - `notify_url` varchar(1024) NOT NULL, - `creator` varchar(64) NULL DEFAULT '', - `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) NULL DEFAULT '', - `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT FALSE, - `tenant_id` bigint(20) NOT NULL DEFAULT 0, - PRIMARY KEY ("id") -) COMMENT = '支付通知任务'; - -CREATE TABLE IF NOT EXISTS `pay_notify_log` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `task_id` bigint(20) NOT NULL, - `notify_times` int NOT NULL, - `response` varchar(1024) NOT NULL, - `status` tinyint(4) NOT NULL, - `creator` varchar(64) NULL DEFAULT '', - `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) NULL DEFAULT '', - `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '支付通知日志'; diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/pom.xml b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/pom.xml deleted file mode 100644 index 92ceed21c..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-pay - ${revision} - - 4.0.0 - - yudao-spring-boot-starter-biz-pay - ${project.artifactId} - 支付拓展,接入国内多个支付渠道 - 1. 支付宝,基于官方 SDK 接入 - 2. 微信支付,基于 weixin-java-pay 接入 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springframework.boot - spring-boot-starter - - - - - org.springframework.boot - spring-boot-starter-validation - - - - org.slf4j - slf4j-api - - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-core - - - - - com.alipay.sdk - alipay-sdk-java - 4.35.79.ALL - - - org.bouncycastle - bcprov-jdk15on - - - - - com.github.binarywang - weixin-java-pay - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - - - - diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/YudaoPayAutoConfiguration.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/YudaoPayAutoConfiguration.java deleted file mode 100644 index a9a98953c..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/YudaoPayAutoConfiguration.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.framework.pay.config; - -import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.client.impl.PayClientFactoryImpl; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.context.annotation.Bean; - -/** - * 支付配置类 - * - * @author 芋道源码 - */ -@AutoConfiguration -public class YudaoPayAutoConfiguration { - - @Bean - public PayClientFactory payClientFactory() { - return new PayClientFactoryImpl(); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java deleted file mode 100644 index 18ae017d1..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClient.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; - -import java.util.Map; - -/** - * 支付客户端,用于对接各支付渠道的 SDK,实现发起支付、退款等功能 - * - * @author 芋道源码 - */ -public interface PayClient { - - /** - * 获得渠道编号 - * - * @return 渠道编号 - */ - Long getId(); - - // ============ 支付相关 ========== - - /** - * 调用支付渠道,统一下单 - * - * @param reqDTO 下单信息 - * @return 支付订单信息 - */ - PayOrderRespDTO unifiedOrder(PayOrderUnifiedReqDTO reqDTO); - - /** - * 解析 order 回调数据 - * - * @param params HTTP 回调接口 content type 为 application/x-www-form-urlencoded 的所有参数 - * @param body HTTP 回调接口的 request body - * @return 支付订单信息 - */ - PayOrderRespDTO parseOrderNotify(Map params, String body); - - /** - * 获得支付订单信息 - * - * @param outTradeNo 外部订单号 - * @return 支付订单信息 - */ - PayOrderRespDTO getOrder(String outTradeNo); - - // ============ 退款相关 ========== - - /** - * 调用支付渠道,进行退款 - * - * @param reqDTO 统一退款请求信息 - * @return 退款信息 - */ - PayRefundRespDTO unifiedRefund(PayRefundUnifiedReqDTO reqDTO); - - /** - * 解析 refund 回调数据 - * - * @param params HTTP 回调接口 content type 为 application/x-www-form-urlencoded 的所有参数 - * @param body HTTP 回调接口的 request body - * @return 支付订单信息 - */ - PayRefundRespDTO parseRefundNotify(Map params, String body); - - /** - * 获得退款订单信息 - * - * @param outTradeNo 外部订单号 - * @param outRefundNo 外部退款号 - * @return 退款订单信息 - */ - PayRefundRespDTO getRefund(String outTradeNo, String outRefundNo); - - /** - * 调用渠道,进行转账 - * - * @param reqDTO 统一转账请求信息 - * @return 转账信息 - */ - PayTransferRespDTO unifiedTransfer(PayTransferUnifiedReqDTO reqDTO); - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientConfig.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientConfig.java deleted file mode 100644 index c3af46cd3..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientConfig.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client; - -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -import javax.validation.Validator; - -/** - * 支付客户端的配置,本质是支付渠道的配置 - * 每个不同的渠道,需要不同的配置,通过子类来定义 - * - * @author 芋道源码 - */ -@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS) -// @JsonTypeInfo 注解的作用,Jackson 多态 -// 1. 序列化到时数据库时,增加 @class 属性。 -// 2. 反序列化到内存对象时,通过 @class 属性,可以创建出正确的类型 -public interface PayClientConfig { - - /** - * 参数校验 - * - * @param validator 校验对象 - */ - void validate(Validator validator); - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java deleted file mode 100644 index 53f1a8c06..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/PayClientFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client; - -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; - -/** - * 支付客户端的工厂接口 - * - * @author 芋道源码 - */ -public interface PayClientFactory { - - /** - * 获得支付客户端 - * - * @param channelId 渠道编号 - * @return 支付客户端 - */ - PayClient getPayClient(Long channelId); - - /** - * 创建支付客户端 - * - * @param channelId 渠道编号 - * @param channelCode 渠道编码 - * @param config 支付配置 - */ - void createOrUpdatePayClient(Long channelId, String channelCode, - Config config); - - /** - * 注册支付客户端 Class,用于模块中实现的 PayClient - * - * @param channel 支付渠道的编码的枚举 - * @param payClientClass 支付客户端 class - */ - void registerPayClientClass(PayChannelEnum channel, Class payClientClass); - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderRespDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderRespDTO.java deleted file mode 100644 index 82050a6fc..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderRespDTO.java +++ /dev/null @@ -1,141 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.order; - -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 渠道支付订单 Response DTO - * - * @author 芋道源码 - */ -@Data -public class PayOrderRespDTO { - - /** - * 支付状态 - * - * 枚举:{@link PayOrderStatusRespEnum} - */ - private Integer status; - - /** - * 外部订单号 - * - * 对应 PayOrderExtensionDO 的 no 字段 - */ - private String outTradeNo; - - /** - * 支付渠道编号 - */ - private String channelOrderNo; - /** - * 支付渠道用户编号 - */ - private String channelUserId; - - /** - * 支付成功时间 - */ - private LocalDateTime successTime; - - /** - * 原始的同步/异步通知结果 - */ - private Object rawData; - - // ========== 主动发起支付时,会返回的字段 ========== - - /** - * 展示模式 - * - * 枚举 {@link PayOrderDisplayModeEnum} 类 - */ - private String displayMode; - /** - * 展示内容 - */ - private String displayContent; - - /** - * 调用渠道的错误码 - * - * 注意:这里返回的是业务异常,而是不系统异常。 - * 如果是系统异常,则会抛出 {@link PayException} - */ - private String channelErrorCode; - /** - * 调用渠道报错时,错误信息 - */ - private String channelErrorMsg; - - public PayOrderRespDTO() { - } - - /** - * 创建【WAITING】状态的订单返回 - */ - public static PayOrderRespDTO waitingOf(String displayMode, String displayContent, - String outTradeNo, Object rawData) { - PayOrderRespDTO respDTO = new PayOrderRespDTO(); - respDTO.status = PayOrderStatusRespEnum.WAITING.getStatus(); - respDTO.displayMode = displayMode; - respDTO.displayContent = displayContent; - // 相对通用的字段 - respDTO.outTradeNo = outTradeNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【SUCCESS】状态的订单返回 - */ - public static PayOrderRespDTO successOf(String channelOrderNo, String channelUserId, LocalDateTime successTime, - String outTradeNo, Object rawData) { - PayOrderRespDTO respDTO = new PayOrderRespDTO(); - respDTO.status = PayOrderStatusRespEnum.SUCCESS.getStatus(); - respDTO.channelOrderNo = channelOrderNo; - respDTO.channelUserId = channelUserId; - respDTO.successTime = successTime; - // 相对通用的字段 - respDTO.outTradeNo = outTradeNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建指定状态的订单返回,适合支付渠道回调时 - */ - public static PayOrderRespDTO of(Integer status, String channelOrderNo, String channelUserId, LocalDateTime successTime, - String outTradeNo, Object rawData) { - PayOrderRespDTO respDTO = new PayOrderRespDTO(); - respDTO.status = status; - respDTO.channelOrderNo = channelOrderNo; - respDTO.channelUserId = channelUserId; - respDTO.successTime = successTime; - // 相对通用的字段 - respDTO.outTradeNo = outTradeNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【CLOSED】状态的订单返回,适合调用支付渠道失败时 - */ - public static PayOrderRespDTO closedOf(String channelErrorCode, String channelErrorMsg, - String outTradeNo, Object rawData) { - PayOrderRespDTO respDTO = new PayOrderRespDTO(); - respDTO.status = PayOrderStatusRespEnum.CLOSED.getStatus(); - respDTO.channelErrorCode = channelErrorCode; - respDTO.channelErrorMsg = channelErrorMsg; - // 相对通用的字段 - respDTO.outTradeNo = outTradeNo; - respDTO.rawData = rawData; - return respDTO; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java deleted file mode 100644 index f269d2f8f..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java +++ /dev/null @@ -1,92 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.order; - -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import lombok.Data; -import org.hibernate.validator.constraints.Length; -import org.hibernate.validator.constraints.URL; - -import javax.validation.constraints.DecimalMin; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.Map; - -/** - * 统一下单 Request DTO - * - * @author 芋道源码 - */ -@Data -public class PayOrderUnifiedReqDTO { - - /** - * 用户 IP - */ - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - // ========== 商户相关字段 ========== - - /** - * 外部订单号 - * - * 对应 PayOrderExtensionDO 的 no 字段 - */ - @NotEmpty(message = "外部订单编号不能为空") - private String outTradeNo; - /** - * 商品标题 - */ - @NotEmpty(message = "商品标题不能为空") - @Length(max = 32, message = "商品标题不能超过 32") - private String subject; - /** - * 商品描述信息 - */ - @Length(max = 128, message = "商品描述信息长度不能超过128") - private String body; - /** - * 支付结果的 notify 回调地址 - */ - @NotEmpty(message = "支付结果的回调地址不能为空") - @URL(message = "支付结果的 notify 回调地址必须是 URL 格式") - private String notifyUrl; - /** - * 支付结果的 return 回调地址 - */ - @URL(message = "支付结果的 return 回调地址必须是 URL 格式") - private String returnUrl; - - // ========== 订单相关字段 ========== - - /** - * 支付金额,单位:分 - */ - @NotNull(message = "支付金额不能为空") - @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") - private Integer price; - - /** - * 支付过期时间 - */ - @NotNull(message = "支付过期时间不能为空") - private LocalDateTime expireTime; - - // ========== 拓展参数 ========== - /** - * 支付渠道的额外参数 - * - * 例如说,微信公众号需要传递 openid 参数 - */ - private Map channelExtras; - - /** - * 展示模式 - * - * 如果不传递,则每个支付渠道使用默认的方式 - * - * 枚举 {@link PayOrderDisplayModeEnum} - */ - private String displayMode; - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundRespDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundRespDTO.java deleted file mode 100644 index 3184f278d..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundRespDTO.java +++ /dev/null @@ -1,115 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.refund; - -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 渠道退款订单 Response DTO - * - * @author jason - */ -@Data -public class PayRefundRespDTO { - - /** - * 退款状态 - * - * 枚举 {@link PayRefundStatusRespEnum} - */ - private Integer status; - - /** - * 外部退款号 - * - * 对应 PayRefundDO 的 no 字段 - */ - private String outRefundNo; - - /** - * 渠道退款单号 - * - * 对应 PayRefundDO.channelRefundNo 字段 - */ - private String channelRefundNo; - - /** - * 退款成功时间 - */ - private LocalDateTime successTime; - - /** - * 原始的异步通知结果 - */ - private Object rawData; - - /** - * 调用渠道的错误码 - * - * 注意:这里返回的是业务异常,而是不系统异常。 - * 如果是系统异常,则会抛出 {@link PayException} - */ - private String channelErrorCode; - /** - * 调用渠道报错时,错误信息 - */ - private String channelErrorMsg; - - private PayRefundRespDTO() { - } - - /** - * 创建【WAITING】状态的退款返回 - */ - public static PayRefundRespDTO waitingOf(String channelRefundNo, - String outRefundNo, Object rawData) { - PayRefundRespDTO respDTO = new PayRefundRespDTO(); - respDTO.status = PayRefundStatusRespEnum.WAITING.getStatus(); - respDTO.channelRefundNo = channelRefundNo; - // 相对通用的字段 - respDTO.outRefundNo = outRefundNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【SUCCESS】状态的退款返回 - */ - public static PayRefundRespDTO successOf(String channelRefundNo, LocalDateTime successTime, - String outRefundNo, Object rawData) { - PayRefundRespDTO respDTO = new PayRefundRespDTO(); - respDTO.status = PayRefundStatusRespEnum.SUCCESS.getStatus(); - respDTO.channelRefundNo = channelRefundNo; - respDTO.successTime = successTime; - // 相对通用的字段 - respDTO.outRefundNo = outRefundNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【FAILURE】状态的退款返回 - */ - public static PayRefundRespDTO failureOf(String outRefundNo, Object rawData) { - return failureOf(null, null, - outRefundNo, rawData); - } - - /** - * 创建【FAILURE】状态的退款返回 - */ - public static PayRefundRespDTO failureOf(String channelErrorCode, String channelErrorMsg, - String outRefundNo, Object rawData) { - PayRefundRespDTO respDTO = new PayRefundRespDTO(); - respDTO.status = PayRefundStatusRespEnum.FAILURE.getStatus(); - respDTO.channelErrorCode = channelErrorCode; - respDTO.channelErrorMsg = channelErrorMsg; - // 相对通用的字段 - respDTO.outRefundNo = outRefundNo; - respDTO.rawData = rawData; - return respDTO; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedReqDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedReqDTO.java deleted file mode 100644 index 4f5e203d2..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedReqDTO.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.refund; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; -import org.hibernate.validator.constraints.URL; - -import javax.validation.constraints.DecimalMin; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 统一 退款 Request DTO - * - * @author jason - */ -@Accessors(chain = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -@Data -public class PayRefundUnifiedReqDTO { - - /** - * 外部订单号 - * - * 对应 PayOrderExtensionDO 的 no 字段 - */ - @NotEmpty(message = "外部订单编号不能为空") - private String outTradeNo; - - /** - * 外部退款号 - * - * 对应 PayRefundDO 的 no 字段 - */ - @NotEmpty(message = "退款请求单号不能为空") - private String outRefundNo; - - /** - * 退款原因 - */ - @NotEmpty(message = "退款原因不能为空") - private String reason; - - /** - * 支付金额,单位:分 - * - * 目前微信支付在退款的时候,必须传递该字段 - */ - @NotNull(message = "支付金额不能为空") - @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") - private Integer payPrice; - /** - * 退款金额,单位:分 - */ - @NotNull(message = "退款金额不能为空") - @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") - private Integer refundPrice; - - /** - * 退款结果的 notify 回调地址 - */ - @NotEmpty(message = "支付结果的回调地址不能为空") - @URL(message = "支付结果的 notify 回调地址必须是 URL 格式") - private String notifyUrl; - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferRespDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferRespDTO.java deleted file mode 100644 index 400abb510..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferRespDTO.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.transfer; - -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 统一转账 Response DTO - * - * @author jason - */ -@Data -public class PayTransferRespDTO { - - /** - * 转账状态 - * - * 关联 {@link PayTransferStatusRespEnum#getStatus()} - */ - private Integer status; - - /** - * 外部转账单号 - * - */ - private String outTransferNo; - - /** - * 支付渠道编号 - */ - private String channelOrderNo; - - /** - * 支付成功时间 - */ - private LocalDateTime successTime; - - /** - * 原始的返回结果 - */ - private Object rawData; - - /** - * 调用渠道的错误码 - */ - private String channelErrorCode; - /** - * 调用渠道报错时,错误信息 - */ - private String channelErrorMsg; - - /** - * 创建【WAITING】状态的转账返回 - */ - public static PayTransferRespDTO waitingOf(String channelOrderNo, - String outTransferNo, Object rawData) { - PayTransferRespDTO respDTO = new PayTransferRespDTO(); - respDTO.status = PayTransferStatusRespEnum.WAITING.getStatus(); - respDTO.channelOrderNo = channelOrderNo; - respDTO.outTransferNo = outTransferNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【CLOSED】状态的转账返回 - */ - public static PayTransferRespDTO closedOf(String channelErrorCode, String channelErrorMsg, - String outTransferNo, Object rawData) { - PayTransferRespDTO respDTO = new PayTransferRespDTO(); - respDTO.status = PayTransferStatusRespEnum.CLOSED.getStatus(); - respDTO.channelErrorCode = channelErrorCode; - respDTO.channelErrorMsg = channelErrorMsg; - // 相对通用的字段 - respDTO.outTransferNo = outTransferNo; - respDTO.rawData = rawData; - return respDTO; - } - - /** - * 创建【SUCCESS】状态的转账返回 - */ - public static PayTransferRespDTO successOf(String channelTransferNo, LocalDateTime successTime, - String outTransferNo, Object rawData) { - PayTransferRespDTO respDTO = new PayTransferRespDTO(); - respDTO.status = PayTransferStatusRespEnum.SUCCESS.getStatus(); - respDTO.channelOrderNo = channelTransferNo; - respDTO.successTime = successTime; - // 相对通用的字段 - respDTO.outTransferNo = outTransferNo; - respDTO.rawData = rawData; - return respDTO; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java deleted file mode 100644 index 17e47aa8b..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/transfer/PayTransferUnifiedReqDTO.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.dto.transfer; - -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import lombok.Data; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -/** - * 统一转账 Request DTO - * - * @author jason - */ -@Data -public class PayTransferUnifiedReqDTO { - - /** - * 转账类型 - * - * 关联 {@link PayTransferTypeEnum#getType()} - */ - @NotNull(message = "转账类型不能为空") - @InEnum(PayTransferTypeEnum.class) - private Integer type; - - /** - * 用户 IP - */ - @NotEmpty(message = "用户 IP 不能为空") - private String userIp; - - @NotEmpty(message = "外部转账单编号不能为空") - private String outTransferNo; - - /** - * 转账金额,单位:分 - */ - @NotNull(message = "转账金额不能为空") - @Min(value = 1, message = "转账金额必须大于零") - private Integer price; - - /** - * 转账标题 - */ - @NotEmpty(message = "转账标题不能为空") - @Length(max = 128, message = "转账标题不能超过 128") - private String title; - - /** - * 收款方信息。 - * - * 转账类型 {@link #type} 不同,收款方信息不同 - */ - @NotEmpty(message = "收款方信息 不能为空") - private Map payeeInfo; - - /** - * 支付渠道的额外参数 - */ - private Map channelExtras; - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/exception/PayException.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/exception/PayException.java deleted file mode 100644 index 75f4c3975..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/exception/PayException.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.exception; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * 支付系统异常 Exception - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class PayException extends RuntimeException { - - public PayException(Throwable cause) { - super(cause); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java deleted file mode 100644 index 49114fb5b..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java +++ /dev/null @@ -1,215 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl; - -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import lombok.extern.slf4j.Slf4j; - -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; - -/** - * 支付客户端的抽象类,提供模板方法,减少子类的冗余代码 - * - * @author 芋道源码 - */ -@Slf4j -public abstract class AbstractPayClient implements PayClient { - - /** - * 渠道编号 - */ - private final Long channelId; - /** - * 渠道编码 - */ - @SuppressWarnings("FieldCanBeLocal") - private final String channelCode; - /** - * 支付配置 - */ - protected Config config; - - public AbstractPayClient(Long channelId, String channelCode, Config config) { - this.channelId = channelId; - this.channelCode = channelCode; - this.config = config; - } - - /** - * 初始化 - */ - public final void init() { - doInit(); - log.debug("[init][客户端({}) 初始化完成]", getId()); - } - - /** - * 自定义初始化 - */ - protected abstract void doInit(); - - public final void refresh(Config config) { - // 判断是否更新 - if (config.equals(this.config)) { - return; - } - log.info("[refresh][客户端({})发生变化,重新初始化]", getId()); - this.config = config; - // 初始化 - this.init(); - } - - @Override - public Long getId() { - return channelId; - } - - // ============ 支付相关 ========== - - @Override - public final PayOrderRespDTO unifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - ValidationUtils.validate(reqDTO); - // 执行统一下单 - PayOrderRespDTO resp; - try { - resp = doUnifiedOrder(reqDTO); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - // 系统异常,则包装成 PayException 异常抛出 - log.error("[unifiedOrder][客户端({}) request({}) 发起支付异常]", - getId(), toJsonString(reqDTO), ex); - throw buildPayException(ex); - } - return resp; - } - - protected abstract PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) - throws Throwable; - - @Override - public final PayOrderRespDTO parseOrderNotify(Map params, String body) { - try { - return doParseOrderNotify(params, body); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - log.error("[parseOrderNotify][客户端({}) params({}) body({}) 解析失败]", - getId(), params, body, ex); - throw buildPayException(ex); - } - } - - protected abstract PayOrderRespDTO doParseOrderNotify(Map params, String body) - throws Throwable; - - @Override - public final PayOrderRespDTO getOrder(String outTradeNo) { - try { - return doGetOrder(outTradeNo); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - log.error("[getOrder][客户端({}) outTradeNo({}) 查询支付单异常]", - getId(), outTradeNo, ex); - throw buildPayException(ex); - } - } - - protected abstract PayOrderRespDTO doGetOrder(String outTradeNo) - throws Throwable; - - // ============ 退款相关 ========== - - @Override - public final PayRefundRespDTO unifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - ValidationUtils.validate(reqDTO); - // 执行统一退款 - PayRefundRespDTO resp; - try { - resp = doUnifiedRefund(reqDTO); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - // 系统异常,则包装成 PayException 异常抛出 - log.error("[unifiedRefund][客户端({}) request({}) 发起退款异常]", - getId(), toJsonString(reqDTO), ex); - throw buildPayException(ex); - } - return resp; - } - - protected abstract PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable; - - @Override - public final PayRefundRespDTO parseRefundNotify(Map params, String body) { - try { - return doParseRefundNotify(params, body); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - log.error("[parseRefundNotify][客户端({}) params({}) body({}) 解析失败]", - getId(), params, body, ex); - throw buildPayException(ex); - } - } - - protected abstract PayRefundRespDTO doParseRefundNotify(Map params, String body) - throws Throwable; - - @Override - public final PayRefundRespDTO getRefund(String outTradeNo, String outRefundNo) { - try { - return doGetRefund(outTradeNo, outRefundNo); - } catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - log.error("[getRefund][客户端({}) outTradeNo({}) outRefundNo({}) 查询退款单异常]", - getId(), outTradeNo, outRefundNo, ex); - throw buildPayException(ex); - } - } - - protected abstract PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) - throws Throwable; - - @Override - public final PayTransferRespDTO unifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { - ValidationUtils.validate(reqDTO); - PayTransferRespDTO resp; - try{ - resp = doUnifiedTransfer(reqDTO); - }catch (ServiceException ex) { // 业务异常,都是实现类已经翻译,所以直接抛出即可 - throw ex; - } catch (Throwable ex) { - // 系统异常,则包装成 PayException 异常抛出 - log.error("[unifiedTransfer][客户端({}) request({}) 发起转账异常]", - getId(), toJsonString(reqDTO), ex); - throw buildPayException(ex); - } - return resp; - } - - protected abstract PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) - throws Throwable; - - // ========== 各种工具方法 ========== - - private PayException buildPayException(Throwable ex) { - if (ex instanceof PayException) { - return (PayException) ex; - } - throw new PayException(ex); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/NonePayClientConfig.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/NonePayClientConfig.java deleted file mode 100644 index 48319036c..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/NonePayClientConfig.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl; - -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import lombok.Data; - -import javax.validation.Validator; - -/** - * 无需任何配置 PayClientConfig 实现类 - * - * @author jason - */ -@Data -public class NonePayClientConfig implements PayClientConfig { - - /** - * 配置名称 - *

- * 如果不加任何属性,JsonUtils.parseObject2 解析会报错,所以暂时加个名称 - */ - private String name; - - public NonePayClientConfig(){ - this.name = "none-config"; - } - - @Override - public void validate(Validator validator) { - // 无任何配置不需要校验 - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java deleted file mode 100644 index 0b39587ab..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl; - -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.ReflectUtil; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.*; -import cn.iocoder.yudao.framework.pay.core.client.impl.mock.MockPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.*; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import lombok.extern.slf4j.Slf4j; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import static cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum.*; - -/** - * 支付客户端的工厂实现类 - * - * @author 芋道源码 - */ -@Slf4j -public class PayClientFactoryImpl implements PayClientFactory { - - /** - * 支付客户端 Map - * - * key:渠道编号 - */ - private final ConcurrentMap> clients = new ConcurrentHashMap<>(); - - /** - * 支付客户端 Class Map - */ - private final Map> clientClass = new ConcurrentHashMap<>(); - - public PayClientFactoryImpl() { - // 微信支付客户端 - clientClass.put(WX_PUB, WxPubPayClient.class); - clientClass.put(WX_LITE, WxLitePayClient.class); - clientClass.put(WX_APP, WxAppPayClient.class); - clientClass.put(WX_BAR, WxBarPayClient.class); - clientClass.put(WX_NATIVE, WxNativePayClient.class); - // 支付包支付客户端 - clientClass.put(ALIPAY_WAP, AlipayWapPayClient.class); - clientClass.put(ALIPAY_QR, AlipayQrPayClient.class); - clientClass.put(ALIPAY_APP, AlipayAppPayClient.class); - clientClass.put(ALIPAY_PC, AlipayPcPayClient.class); - clientClass.put(ALIPAY_BAR, AlipayBarPayClient.class); - // Mock 支付客户端 - clientClass.put(MOCK, MockPayClient.class); - } - - @Override - public void registerPayClientClass(PayChannelEnum channel, Class payClientClass) { - clientClass.put(channel, payClientClass); - } - - @Override - public PayClient getPayClient(Long channelId) { - AbstractPayClient client = clients.get(channelId); - if (client == null) { - log.error("[getPayClient][渠道编号({}) 找不到客户端]", channelId); - } - return client; - } - - @Override - @SuppressWarnings("unchecked") - public void createOrUpdatePayClient(Long channelId, String channelCode, - Config config) { - AbstractPayClient client = (AbstractPayClient) clients.get(channelId); - if (client == null) { - client = this.createPayClient(channelId, channelCode, config); - client.init(); - clients.put(client.getId(), client); - } else { - client.refresh(config); - } - } - - @SuppressWarnings("unchecked") - private AbstractPayClient createPayClient(Long channelId, String channelCode, - Config config) { - PayChannelEnum channelEnum = PayChannelEnum.getByCode(channelCode); - Assert.notNull(channelEnum, String.format("支付渠道(%s) 为空", channelCode)); - Class payClientClass = clientClass.get(channelEnum); - Assert.notNull(payClientClass, String.format("支付渠道(%s) Class 为空", channelCode)); - return (AbstractPayClient) ReflectUtil.newInstance(payClientClass, channelId, config); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java deleted file mode 100644 index cb8a0df6e..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java +++ /dev/null @@ -1,304 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferTypeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.AlipayConfig; -import com.alipay.api.AlipayResponse; -import com.alipay.api.DefaultAlipayClient; -import com.alipay.api.domain.*; -import com.alipay.api.internal.util.AlipaySignature; -import com.alipay.api.request.AlipayFundTransUniTransferRequest; -import com.alipay.api.request.AlipayTradeFastpayRefundQueryRequest; -import com.alipay.api.request.AlipayTradeQueryRequest; -import com.alipay.api.request.AlipayTradeRefundRequest; -import com.alipay.api.response.AlipayFundTransUniTransferResponse; -import com.alipay.api.response.AlipayTradeFastpayRefundQueryResponse; -import com.alipay.api.response.AlipayTradeQueryResponse; -import com.alipay.api.response.AlipayTradeRefundResponse; -import lombok.Getter; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; - -import java.nio.charset.StandardCharsets; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.Map; -import java.util.Objects; -import java.util.function.Supplier; - -import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER; -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; -import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE; - -/** - * 支付宝抽象类,实现支付宝统一的接口、以及部分实现(退款) - * - * @author jason - */ -@Slf4j -public abstract class AbstractAlipayPayClient extends AbstractPayClient { - - @Getter // 仅用于单测场景 - protected DefaultAlipayClient client; - - public AbstractAlipayPayClient(Long channelId, String channelCode, AlipayPayClientConfig config) { - super(channelId, channelCode, config); - } - - @Override - @SneakyThrows - protected void doInit() { - AlipayConfig alipayConfig = new AlipayConfig(); - BeanUtil.copyProperties(config, alipayConfig, false); - this.client = new DefaultAlipayClient(alipayConfig); - } - - // ============ 支付相关 ========== - - /** - * 构造支付关闭的 {@link PayOrderRespDTO} 对象 - * - * @return 支付关闭的 {@link PayOrderRespDTO} 对象 - */ - protected PayOrderRespDTO buildClosedPayOrderRespDTO(PayOrderUnifiedReqDTO reqDTO, AlipayResponse response) { - Assert.isFalse(response.isSuccess()); - return PayOrderRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), - reqDTO.getOutTradeNo(), response); - } - - @Override - public PayOrderRespDTO doParseOrderNotify(Map params, String body) throws Throwable { - // 1. 校验回调数据 - Map bodyObj = HttpUtil.decodeParamMap(body, StandardCharsets.UTF_8); - AlipaySignature.rsaCheckV1(bodyObj, config.getAlipayPublicKey(), - StandardCharsets.UTF_8.name(), config.getSignType()); - - // 2. 解析订单的状态 - // 额外说明:支付宝不仅仅支付成功会回调,再各种触发支付单数据变化时,都会进行回调,所以这里 status 的解析会写的比较复杂 - Integer status = parseStatus(bodyObj.get("trade_status")); - // 特殊逻辑: 支付宝没有退款成功的状态,所以,如果有退款金额,我们认为是退款成功 - if (MapUtil.getDouble(bodyObj, "refund_fee", 0D) > 0) { - status = PayOrderStatusRespEnum.REFUND.getStatus(); - } - Assert.notNull(status, (Supplier) () -> { - throw new IllegalArgumentException(StrUtil.format("body({}) 的 trade_status 不正确", body)); - }); - return PayOrderRespDTO.of(status, bodyObj.get("trade_no"), bodyObj.get("seller_id"), parseTime(params.get("gmt_payment")), - bodyObj.get("out_trade_no"), body); - } - - @Override - protected PayOrderRespDTO doGetOrder(String outTradeNo) throws Throwable { - // 1.1 构建 AlipayTradeRefundModel 请求 - AlipayTradeQueryModel model = new AlipayTradeQueryModel(); - model.setOutTradeNo(outTradeNo); - // 1.2 构建 AlipayTradeQueryRequest 请求 - AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); - request.setBizModel(model); - AlipayTradeQueryResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { - // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - if (!response.isSuccess()) { // 不成功,例如说订单不存在 - return PayOrderRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), - outTradeNo, response); - } - // 2.2 解析订单的状态 - Integer status = parseStatus(response.getTradeStatus()); - Assert.notNull(status, () -> { - throw new IllegalArgumentException(StrUtil.format("body({}) 的 trade_status 不正确", response.getBody())); - }); - return PayOrderRespDTO.of(status, response.getTradeNo(), response.getBuyerUserId(), LocalDateTimeUtil.of(response.getSendPayDate()), - outTradeNo, response); - } - - private static Integer parseStatus(String tradeStatus) { - return Objects.equals("WAIT_BUYER_PAY", tradeStatus) ? PayOrderStatusRespEnum.WAITING.getStatus() - : ObjectUtils.equalsAny(tradeStatus, "TRADE_FINISHED", "TRADE_SUCCESS") ? PayOrderStatusRespEnum.SUCCESS.getStatus() - : Objects.equals("TRADE_CLOSED", tradeStatus) ? PayOrderStatusRespEnum.CLOSED.getStatus() : null; - } - - // ============ 退款相关 ========== - - /** - * 支付宝统一的退款接口 alipay.trade.refund - * - * @param reqDTO 退款请求 request DTO - * @return 退款请求 Response - */ - @Override - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradeRefundModel 请求 - AlipayTradeRefundModel model = new AlipayTradeRefundModel(); - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setOutRequestNo(reqDTO.getOutRefundNo()); - model.setRefundAmount(formatAmount(reqDTO.getRefundPrice())); - model.setRefundReason(reqDTO.getReason()); - // 1.2 构建 AlipayTradePayRequest 请求 - AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); - request.setBizModel(model); - - // 2.1 执行请求 - AlipayTradeRefundResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - if (!response.isSuccess()) { - // 当出现 ACQ.SYSTEM_ERROR, 退款可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询 - if (ObjectUtils.equalsAny(response.getSubCode(), "ACQ.SYSTEM_ERROR", "SYSTEM_ERROR")) { - return PayRefundRespDTO.waitingOf(null, reqDTO.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(response.getSubCode(), response.getSubMsg(), reqDTO.getOutRefundNo(), response); - } - // 2.2 创建返回结果 - // 支付宝只要退款调用返回 success,就认为退款成功,不需要回调。具体可见 parseNotify 方法的说明。 - // 另外,支付宝没有退款单号,所以不用设置 - return PayRefundRespDTO.successOf(null, LocalDateTimeUtil.of(response.getGmtRefundPay()), - reqDTO.getOutRefundNo(), response); - } - - @Override - public PayRefundRespDTO doParseRefundNotify(Map params, String body) { - // 补充说明:支付宝退款时,没有回调,这点和微信支付是不同的。并且,退款分成部分退款、和全部退款。 - // ① 部分退款:是会有回调,但是它回调的是订单状态的同步回调,不是退款订单的回调 - // ② 全部退款:Wap 支付有订单状态的同步回调,但是 PC/扫码又没有 - // 所以,这里在解析时,即使是退款导致的订单状态同步,我们也忽略不做为“退款同步”,而是订单的回调。 - // 实际上,支付宝退款只要发起成功,就可以认为退款成功,不需要等待回调。 - throw new UnsupportedOperationException("支付宝无退款回调"); - } - - @Override - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) throws AlipayApiException { - // 1.1 构建 AlipayTradeFastpayRefundQueryModel 请求 - AlipayTradeFastpayRefundQueryModel model = new AlipayTradeFastpayRefundQueryModel(); - model.setOutTradeNo(outTradeNo); - model.setOutRequestNo(outRefundNo); - model.setQueryOptions(Collections.singletonList("gmt_refund_pay")); - // 1.2 构建 AlipayTradeFastpayRefundQueryRequest 请求 - AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest(); - request.setBizModel(model); - - // 2.1 执行请求 - AlipayTradeFastpayRefundQueryResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - if (!response.isSuccess()) { - // 明确不存在的情况,应该就是失败,可进行关闭 - if (ObjectUtils.equalsAny(response.getSubCode(), "TRADE_NOT_EXIST", "ACQ.TRADE_NOT_EXIST")) { - return PayRefundRespDTO.failureOf(outRefundNo, response); - } - // 可能存在“ACQ.SYSTEM_ERROR”系统错误等情况,所以返回 WAIT 继续等待 - return PayRefundRespDTO.waitingOf(null, outRefundNo, response); - } - // 2.2 创建返回结果 - if (Objects.equals(response.getRefundStatus(), "REFUND_SUCCESS")) { - return PayRefundRespDTO.successOf(null, LocalDateTimeUtil.of(response.getGmtRefundPay()), - outRefundNo, response); - } - return PayRefundRespDTO.waitingOf(null, outRefundNo, response); - } - - @Override - protected PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 校验公钥类型 必须使用公钥证书模式 - if (!Objects.equals(config.getMode(), MODE_CERTIFICATE)) { - throw new IllegalStateException("支付宝单笔转账必须使用公钥证书模式"); - } - - // 1.2 构建 AlipayFundTransUniTransferModel - AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel(); - // ① 通用的参数 - model.setTransAmount(formatAmount(reqDTO.getPrice())); // 转账金额 - model.setOrderTitle(reqDTO.getTitle()); // 转账业务的标题,用于在支付宝用户的账单里显示。 - model.setOutBizNo(reqDTO.getOutTransferNo()); - model.setProductCode("TRANS_ACCOUNT_NO_PWD"); // 销售产品码。单笔无密转账固定为 TRANS_ACCOUNT_NO_PWD - model.setBizScene("DIRECT_TRANSFER"); // 业务场景 单笔无密转账固定为 DIRECT_TRANSFER - model.setBusinessParams(JsonUtils.toJsonString(reqDTO.getChannelExtras())); - PayTransferTypeEnum transferType = PayTransferTypeEnum.typeOf(reqDTO.getType()); - switch (transferType) { - // TODO @jason:是不是不用传递 transferType 参数哈?因为应该已经明确是支付宝啦? - // @芋艿。 是不是还要考虑转账到银行卡。所以传 transferType 但是转账到银行卡不知道要如何测试?? - case ALIPAY_BALANCE: { - // ② 个性化的参数 - Participant payeeInfo = new Participant(); - payeeInfo.setIdentityType("ALIPAY_LOGON_ID"); - String logonId = MapUtil.getStr(reqDTO.getPayeeInfo(), "ALIPAY_LOGON_ID"); - if (StrUtil.isEmpty(logonId)) { - throw exception0(BAD_REQUEST.getCode(), "支付包登录 ID 不能为空"); - } - String accountName = MapUtil.getStr(reqDTO.getPayeeInfo(), "ALIPAY_ACCOUNT_NAME"); - if (StrUtil.isEmpty(accountName)) { - throw exception0(BAD_REQUEST.getCode(), "支付包账户名称不能为空"); - } - payeeInfo.setIdentity(logonId); // 支付宝登录号 - payeeInfo.setName(accountName); // 支付宝账号姓名 - model.setPayeeInfo(payeeInfo); - // 1.3 构建 AlipayFundTransUniTransferRequest - AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest(); - request.setBizModel(model); - // 执行请求 - AlipayFundTransUniTransferResponse response = client.certificateExecute(request); - // 处理结果 - if (!response.isSuccess()) { - // 当出现 SYSTEM_ERROR, 转账可能成功也可能失败。 返回 WAIT 状态. 后续 job 会轮询 - if (ObjectUtils.equalsAny(response.getSubCode(), "SYSTEM_ERROR", "ACQ.SYSTEM_ERROR")) { - return PayTransferRespDTO.waitingOf(null, reqDTO.getOutTransferNo(), response); - } - return PayTransferRespDTO.closedOf(response.getSubCode(), response.getSubMsg(), - reqDTO.getOutTransferNo(), response); - } - return PayTransferRespDTO.successOf(response.getOrderId(), parseTime(response.getTransDate()), - response.getOutBizNo(), response); - } - case BANK_CARD: { - Participant payeeInfo = new Participant(); - payeeInfo.setIdentityType("BANKCARD_ACCOUNT"); - // TODO 待实现 - throw new UnsupportedOperationException("待实现"); - } - default: { - throw new IllegalStateException("不正确的转账类型: " + transferType); - } - } - } - - // ========== 各种工具方法 ========== - - protected String formatAmount(Integer amount) { - return String.valueOf(amount / 100.0); - } - - protected String formatTime(LocalDateTime time) { - return LocalDateTimeUtil.format(time, NORM_DATETIME_FORMATTER); - } - - protected LocalDateTime parseTime(String str) { - return LocalDateTimeUtil.parse(str, NORM_DATETIME_FORMATTER); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayAppPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayAppPayClient.java deleted file mode 100644 index 4e5a37e9d..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayAppPayClient.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradeAppPayModel; -import com.alipay.api.request.AlipayTradeAppPayRequest; -import com.alipay.api.response.AlipayTradeAppPayResponse; -import lombok.extern.slf4j.Slf4j; - -/** - * 支付宝【App 支付】的 PayClient 实现类 - * - * 文档:App 支付 - * - * // TODO 芋艿:未详细测试,因为手头没 App - * - * @author 芋道源码 - */ -@Slf4j -public class AlipayAppPayClient extends AbstractAlipayPayClient { - - public AlipayAppPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_APP.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradeAppPayModel 请求 - AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody() + "test"); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setTimeExpire(formatTime(reqDTO.getExpireTime())); - model.setProductCode("QUICK_MSECURITY_PAY"); // 销售产品码:无线快捷支付产品 - // ② 个性化的参数【无】 - // ③ 支付宝扫码支付只有一种展示 - String displayMode = PayOrderDisplayModeEnum.APP.getMode(); - - // 1.2 构建 AlipayTradePrecreateRequest 请求 - AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradeAppPayResponse response = client.sdkExecute(request); - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - return PayOrderRespDTO.waitingOf(displayMode, response.getBody(), - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java deleted file mode 100644 index 1f90d6b58..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClient.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradePayModel; -import com.alipay.api.request.AlipayTradePayRequest; -import com.alipay.api.response.AlipayTradePayResponse; -import lombok.extern.slf4j.Slf4j; - -import java.time.LocalDateTime; -import java.util.Objects; - -import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; -import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE; - -/** - * 支付宝【条码支付】的 PayClient 实现类 - * - * 文档:当面付 - * - * @author 芋道源码 - */ -@Slf4j -public class AlipayBarPayClient extends AbstractAlipayPayClient { - - public AlipayBarPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_BAR.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - String authCode = MapUtil.getStr(reqDTO.getChannelExtras(), "auth_code"); - if (StrUtil.isEmpty(authCode)) { - throw exception0(BAD_REQUEST.getCode(), "条形码不能为空"); - } - - // 1.1 构建 AlipayTradePayModel 请求 - AlipayTradePayModel model = new AlipayTradePayModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody()); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setScene("bar_code"); // 当面付条码支付场景 - // ② 个性化的参数 - model.setAuthCode(authCode); - // ③ 支付宝条码支付只有一种展示 - String displayMode = PayOrderDisplayModeEnum.BAR_CODE.getMode(); - - // 1.2 构建 AlipayTradePayRequest 请求 - AlipayTradePayRequest request = new AlipayTradePayRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradePayResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { - // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - if ("10000".equals(response.getCode())) { // 免密支付 - LocalDateTime successTime = LocalDateTimeUtil.of(response.getGmtPayment()); - return PayOrderRespDTO.successOf(response.getTradeNo(), response.getBuyerUserId(), successTime, - response.getOutTradeNo(), response) - .setDisplayMode(displayMode).setDisplayContent(""); - } - // 大额支付,需要用户输入密码,所以返回 waiting。此时,前端一般会进行轮询 - return PayOrderRespDTO.waitingOf(displayMode, "", - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayClientConfig.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayClientConfig.java deleted file mode 100644 index 4048e8177..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayClientConfig.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import lombok.Data; - -import javax.validation.Validator; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -/** - * 支付宝的 PayClientConfig 实现类 - * 属性主要来自 {@link com.alipay.api.AlipayConfig} 的必要属性 - * - * @author 芋道源码 - */ -@Data -public class AlipayPayClientConfig implements PayClientConfig { - - /** - * 公钥类型 - 公钥模式 - */ - public static final Integer MODE_PUBLIC_KEY = 1; - /** - * 公钥类型 - 证书模式 - */ - public static final Integer MODE_CERTIFICATE = 2; - - /** - * 签名算法类型 - RSA - */ - public static final String SIGN_TYPE_DEFAULT = "RSA2"; - - /** - * 网关地址 - * - * 1. 生产环境 - * 2. 沙箱环境 - */ - @NotBlank(message = "网关地址不能为空", groups = {ModePublicKey.class, ModeCertificate.class}) - private String serverUrl; - - /** - * 开放平台上创建的应用的 ID - */ - @NotBlank(message = "开放平台上创建的应用的 ID不能为空", groups = {ModePublicKey.class, ModeCertificate.class}) - private String appId; - - /** - * 签名算法类型,推荐:RSA2 - *

- * {@link #SIGN_TYPE_DEFAULT} - */ - @NotBlank(message = "签名算法类型不能为空", groups = {ModePublicKey.class, ModeCertificate.class}) - private String signType; - - /** - * 公钥类型 - * 1. {@link #MODE_PUBLIC_KEY} 情况,privateKey + alipayPublicKey - * 2. {@link #MODE_CERTIFICATE} 情况,appCertContent + alipayPublicCertContent + rootCertContent - */ - @NotNull(message = "公钥类型不能为空", groups = {ModePublicKey.class, ModeCertificate.class}) - private Integer mode; - - // ========== 公钥模式 ========== - /** - * 商户私钥 - */ - @NotBlank(message = "商户私钥不能为空", groups = {ModePublicKey.class}) - private String privateKey; - - /** - * 支付宝公钥字符串 - */ - @NotBlank(message = "支付宝公钥字符串不能为空", groups = {ModePublicKey.class}) - private String alipayPublicKey; - - // ========== 证书模式 ========== - /** - * 指定商户公钥应用证书内容字符串 - */ - @NotBlank(message = "指定商户公钥应用证书内容不能为空", groups = {ModeCertificate.class}) - private String appCertContent; - /** - * 指定支付宝公钥证书内容字符串 - */ - @NotBlank(message = "指定支付宝公钥证书内容不能为空", groups = {ModeCertificate.class}) - private String alipayPublicCertContent; - /** - * 指定根证书内容字符串 - */ - @NotBlank(message = "指定根证书内容字符串不能为空", groups = {ModeCertificate.class}) - private String rootCertContent; - - public interface ModePublicKey { - } - - public interface ModeCertificate { - } - - @Override - public void validate(Validator validator) { - ValidationUtils.validate(validator, this, - MODE_PUBLIC_KEY.equals(this.getMode()) ? ModePublicKey.class : ModeCertificate.class); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java deleted file mode 100644 index 6dbd19bef..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.http.Method; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradePagePayModel; -import com.alipay.api.request.AlipayTradePagePayRequest; -import com.alipay.api.response.AlipayTradePagePayResponse; -import lombok.extern.slf4j.Slf4j; - -import java.util.Objects; - -/** - * 支付宝【PC 网站】的 PayClient 实现类 - * - * 文档:电脑网站支付 - * - * @author XGD - */ -@Slf4j -public class AlipayPcPayClient extends AbstractAlipayPayClient { - - public AlipayPcPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_PC.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradePagePayModel 请求 - AlipayTradePagePayModel model = new AlipayTradePagePayModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody()); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setTimeExpire(formatTime(reqDTO.getExpireTime())); - model.setProductCode("FAST_INSTANT_TRADE_PAY"); // 销售产品码. 目前 PC 支付场景下仅支持 FAST_INSTANT_TRADE_PAY - // ② 个性化的参数 - // 如果想弄更多个性化的参数,可参考 https://www.pingxx.com/api/支付渠道 extra 参数说明.html 的 alipay_pc_direct 部分进行拓展 - model.setQrPayMode("2"); // 跳转模式 - 订单码,效果参见:https://help.pingxx.com/article/1137360/ - // ③ 支付宝 PC 支付有两种展示模式:FORM、URL - String displayMode = ObjectUtil.defaultIfNull(reqDTO.getDisplayMode(), - PayOrderDisplayModeEnum.URL.getMode()); - - // 1.2 构建 AlipayTradePagePayRequest 请求 - AlipayTradePagePayRequest request = new AlipayTradePagePayRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradePagePayResponse response; - if (Objects.equals(displayMode, PayOrderDisplayModeEnum.FORM.getMode())) { - response = client.pageExecute(request, Method.POST.name()); // 需要特殊使用 POST 请求 - } else { - response = client.pageExecute(request, Method.GET.name()); - } - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - return PayOrderRespDTO.waitingOf(displayMode, response.getBody(), - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java deleted file mode 100644 index bb3ad1771..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradePrecreateModel; -import com.alipay.api.request.AlipayTradePrecreateRequest; -import com.alipay.api.response.AlipayTradePrecreateResponse; -import lombok.extern.slf4j.Slf4j; - -import java.util.Objects; - -import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE; - -/** - * 支付宝【扫码支付】的 PayClient 实现类 - * - * 文档:扫码支付 - * - * @author 芋道源码 - */ -@Slf4j -public class AlipayQrPayClient extends AbstractAlipayPayClient { - - public AlipayQrPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_QR.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradePrecreateModel 请求 - AlipayTradePrecreateModel model = new AlipayTradePrecreateModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody()); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setProductCode("FACE_TO_FACE_PAYMENT"); // 销售产品码. 目前扫码支付场景下仅支持 FACE_TO_FACE_PAYMENT - // ② 个性化的参数【无】 - // ③ 支付宝扫码支付只有一种展示,考虑到前端可能希望二维码扫描后,手机打开 - String displayMode = PayOrderDisplayModeEnum.QR_CODE.getMode(); - - // 1.2 构建 AlipayTradePrecreateRequest 请求 - AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradePrecreateResponse response; - if (Objects.equals(config.getMode(), MODE_CERTIFICATE)) { - // 证书模式 - response = client.certificateExecute(request); - } else { - response = client.execute(request); - } - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - return PayOrderRespDTO.waitingOf(displayMode, response.getQrCode(), - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java deleted file mode 100644 index f9dccf5a7..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.http.Method; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradeWapPayModel; -import com.alipay.api.request.AlipayTradeWapPayRequest; -import com.alipay.api.response.AlipayTradeWapPayResponse; -import lombok.extern.slf4j.Slf4j; - -/** - * 支付宝【Wap 网站】的 PayClient 实现类 - * - * 文档:手机网站支付接口 - * - * @author 芋道源码 - */ -@Slf4j -public class AlipayWapPayClient extends AbstractAlipayPayClient { - - public AlipayWapPayClient(Long channelId, AlipayPayClientConfig config) { - super(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), config); - } - - @Override - public PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws AlipayApiException { - // 1.1 构建 AlipayTradeWapPayModel 请求 - AlipayTradeWapPayModel model = new AlipayTradeWapPayModel(); - // ① 通用的参数 - model.setOutTradeNo(reqDTO.getOutTradeNo()); - model.setSubject(reqDTO.getSubject()); - model.setBody(reqDTO.getBody()); - model.setTotalAmount(formatAmount(reqDTO.getPrice())); - model.setProductCode("QUICK_WAP_PAY"); // 销售产品码. 目前 Wap 支付场景下仅支持 QUICK_WAP_PAY - // ② 个性化的参数【无】 - // ③ 支付宝 Wap 支付只有一种展示:URL - String displayMode = PayOrderDisplayModeEnum.URL.getMode(); - - // 1.2 构建 AlipayTradeWapPayRequest 请求 - AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest(); - request.setBizModel(model); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - request.setReturnUrl(reqDTO.getReturnUrl()); - model.setQuitUrl(reqDTO.getReturnUrl()); - - // 2.1 执行请求 - AlipayTradeWapPayResponse response = client.pageExecute(request, Method.GET.name()); - // 2.2 处理结果 - if (!response.isSuccess()) { - return buildClosedPayOrderRespDTO(reqDTO, response); - } - return PayOrderRespDTO.waitingOf(displayMode, response.getBody(), - reqDTO.getOutTradeNo(), response); - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java deleted file mode 100644 index 309813697..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClient.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.mock; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; - -import java.time.LocalDateTime; -import java.util.Map; - -/** - * 模拟支付的 PayClient 实现类 - * - * 模拟支付返回结果都是成功,方便大家日常流畅 - * - * @author jason - */ -public class MockPayClient extends AbstractPayClient { - - private static final String MOCK_RESP_SUCCESS_DATA = "MOCK_SUCCESS"; - - public MockPayClient(Long channelId, NonePayClientConfig config) { - super(channelId, PayChannelEnum.MOCK.getCode(), config); - } - - @Override - protected void doInit() { - } - - @Override - protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - return PayOrderRespDTO.successOf("MOCK-P-" + reqDTO.getOutTradeNo(), "", LocalDateTime.now(), - reqDTO.getOutTradeNo(), MOCK_RESP_SUCCESS_DATA); - } - - @Override - protected PayOrderRespDTO doGetOrder(String outTradeNo) { - return PayOrderRespDTO.successOf("MOCK-P-" + outTradeNo, "", LocalDateTime.now(), - outTradeNo, MOCK_RESP_SUCCESS_DATA); - } - - @Override - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - return PayRefundRespDTO.successOf("MOCK-R-" + reqDTO.getOutRefundNo(), LocalDateTime.now(), - reqDTO.getOutRefundNo(), MOCK_RESP_SUCCESS_DATA); - } - - @Override - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) { - return PayRefundRespDTO.successOf("MOCK-R-" + outRefundNo, LocalDateTime.now(), - outRefundNo, MOCK_RESP_SUCCESS_DATA); - } - - @Override - protected PayRefundRespDTO doParseRefundNotify(Map params, String body) { - throw new UnsupportedOperationException("模拟支付无退款回调"); - } - - @Override - protected PayOrderRespDTO doParseOrderNotify(Map params, String body) { - throw new UnsupportedOperationException("模拟支付无支付回调"); - } - - @Override - protected PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { - throw new UnsupportedOperationException("待实现"); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java deleted file mode 100644 index 3e35c52dc..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/mock/MockPayClientConfig.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.mock; - -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import lombok.Data; - -import javax.validation.Validator; - -/** - * 模拟支付的 PayClientConfig 实现类 - * - * @author jason - */ -@Data -public class MockPayClientConfig implements PayClientConfig { - - /** - * 配置名称 - * - * 如果不加任何属性,JsonUtils.parseObject2 解析会报错,所以暂时加个名称 - */ - private String name; - - @Override - public void validate(Validator validator) { - // 模拟支付配置无需校验 - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java deleted file mode 100644 index bd361e9c0..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java +++ /dev/null @@ -1,476 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.codec.Base64; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.date.TemporalAccessorUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.io.FileUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import com.github.binarywang.wxpay.bean.notify.WxPayNotifyV3Result; -import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; -import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; -import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyV3Result; -import com.github.binarywang.wxpay.bean.request.*; -import com.github.binarywang.wxpay.bean.result.*; -import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.WxPayService; -import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; -import lombok.extern.slf4j.Slf4j; - -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.Map; -import java.util.Objects; - -import static cn.hutool.core.date.DatePattern.*; -import static cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig.API_VERSION_V2; - -/** - * 微信支付抽象类,实现微信统一的接口、以及部分实现(退款) - * - * @author 遇到源码 - */ -@Slf4j -public abstract class AbstractWxPayClient extends AbstractPayClient { - - protected WxPayService client; - - public AbstractWxPayClient(Long channelId, String channelCode, WxPayClientConfig config) { - super(channelId, channelCode, config); - } - - /** - * 初始化 client 客户端 - * - * @param tradeType 交易类型 - */ - protected void doInit(String tradeType) { - // 创建 config 配置 - WxPayConfig payConfig = new WxPayConfig(); - BeanUtil.copyProperties(config, payConfig, "keyContent", "privateKeyContent", "privateCertContent"); - payConfig.setTradeType(tradeType); - // weixin-pay-java 无法设置内容,只允许读取文件,所以这里要创建临时文件来解决 - if (Base64.isBase64(config.getKeyContent())) { - payConfig.setKeyPath(FileUtils.createTempFile(Base64.decode(config.getKeyContent())).getPath()); - } - if (StrUtil.isNotEmpty(config.getPrivateKeyContent())) { - payConfig.setPrivateKeyPath(FileUtils.createTempFile(config.getPrivateKeyContent()).getPath()); - } - if (StrUtil.isNotEmpty(config.getPrivateCertContent())) { - payConfig.setPrivateCertPath(FileUtils.createTempFile(config.getPrivateCertContent()).getPath()); - } - - // 创建 client 客户端 - client = new WxPayServiceImpl(); - client.setConfig(payConfig); - } - - // ============ 支付相关 ========== - - @Override - protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws Exception { - try { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doUnifiedOrderV2(reqDTO); - case WxPayClientConfig.API_VERSION_V3: - return doUnifiedOrderV3(reqDTO); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } catch (WxPayException e) { - String errorCode = getErrorCode(e); - String errorMessage = getErrorMessage(e); - return PayOrderRespDTO.closedOf(errorCode, errorMessage, - reqDTO.getOutTradeNo(), e.getXmlString()); - } - } - - /** - * 【V2】调用支付渠道,统一下单 - * - * @param reqDTO 下单信息 - * @return 各支付渠道的返回结果 - */ - protected abstract PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) - throws Exception; - - /** - * 【V3】调用支付渠道,统一下单 - * - * @param reqDTO 下单信息 - * @return 各支付渠道的返回结果 - */ - protected abstract PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) - throws WxPayException; - - /** - * 【V2】创建微信下单请求 - * - * @param reqDTO 下信息 - * @return 下单请求 - */ - protected WxPayUnifiedOrderRequest buildPayUnifiedOrderRequestV2(PayOrderUnifiedReqDTO reqDTO) { - return WxPayUnifiedOrderRequest.newBuilder() - .outTradeNo(reqDTO.getOutTradeNo()) - .body(reqDTO.getSubject()) - .detail(reqDTO.getBody()) - .totalFee(reqDTO.getPrice()) // 单位分 - .timeExpire(formatDateV2(reqDTO.getExpireTime())) - .spbillCreateIp(reqDTO.getUserIp()) - .notifyUrl(reqDTO.getNotifyUrl()) - .build(); - } - - /** - * 【V3】创建微信下单请求 - * - * @param reqDTO 下信息 - * @return 下单请求 - */ - protected WxPayUnifiedOrderV3Request buildPayUnifiedOrderRequestV3(PayOrderUnifiedReqDTO reqDTO) { - WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request(); - request.setOutTradeNo(reqDTO.getOutTradeNo()); - request.setDescription(reqDTO.getSubject()); - request.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(reqDTO.getPrice())); // 单位分 - request.setTimeExpire(formatDateV3(reqDTO.getExpireTime())); - request.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(reqDTO.getUserIp())); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - return request; - } - - @Override - public PayOrderRespDTO doParseOrderNotify(Map params, String body) throws WxPayException { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doParseOrderNotifyV2(body); - case WxPayClientConfig.API_VERSION_V3: - return doParseOrderNotifyV3(body); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } - - private PayOrderRespDTO doParseOrderNotifyV2(String body) throws WxPayException { - // 1. 解析回调 - WxPayOrderNotifyResult response = client.parseOrderNotifyResult(body); - // 2. 构建结果 - // V2 微信支付的回调,只有 SUCCESS 支付成功、CLOSED 支付失败两种情况,无需像支付宝一样解析的比较复杂 - Integer status = Objects.equals(response.getResultCode(), "SUCCESS") ? - PayOrderStatusRespEnum.SUCCESS.getStatus() : PayOrderStatusRespEnum.CLOSED.getStatus(); - return PayOrderRespDTO.of(status, response.getTransactionId(), response.getOpenid(), parseDateV2(response.getTimeEnd()), - response.getOutTradeNo(), body); - } - - private PayOrderRespDTO doParseOrderNotifyV3(String body) throws WxPayException { - // 1. 解析回调 - WxPayNotifyV3Result response = client.parseOrderNotifyV3Result(body, null); - WxPayNotifyV3Result.DecryptNotifyResult result = response.getResult(); - // 2. 构建结果 - Integer status = parseStatus(result.getTradeState()); - String openid = result.getPayer() != null ? result.getPayer().getOpenid() : null; - return PayOrderRespDTO.of(status, result.getTransactionId(), openid, parseDateV3(result.getSuccessTime()), - result.getOutTradeNo(), body); - } - - @Override - protected PayOrderRespDTO doGetOrder(String outTradeNo) throws Throwable { - try { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doGetOrderV2(outTradeNo); - case WxPayClientConfig.API_VERSION_V3: - return doGetOrderV3(outTradeNo); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } catch (WxPayException e) { - if (ObjectUtils.equalsAny(e.getErrCode(), "ORDERNOTEXIST", "ORDER_NOT_EXIST")) { - String errorCode = getErrorCode(e); - String errorMessage = getErrorMessage(e); - return PayOrderRespDTO.closedOf(errorCode, errorMessage, - outTradeNo, e.getXmlString()); - } - throw e; - } - } - - private PayOrderRespDTO doGetOrderV2(String outTradeNo) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayOrderQueryRequest request = WxPayOrderQueryRequest.newBuilder() - .outTradeNo(outTradeNo).build(); - // 执行请求 - WxPayOrderQueryResult response = client.queryOrder(request); - - // 转换结果 - Integer status = parseStatus(response.getTradeState()); - return PayOrderRespDTO.of(status, response.getTransactionId(), response.getOpenid(), parseDateV2(response.getTimeEnd()), - outTradeNo, response); - } - - private PayOrderRespDTO doGetOrderV3(String outTradeNo) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayOrderQueryV3Request request = new WxPayOrderQueryV3Request() - .setOutTradeNo(outTradeNo); - // 执行请求 - WxPayOrderQueryV3Result response = client.queryOrderV3(request); - - // 转换结果 - Integer status = parseStatus(response.getTradeState()); - String openid = response.getPayer() != null ? response.getPayer().getOpenid() : null; - return PayOrderRespDTO.of(status, response.getTransactionId(), openid, parseDateV3(response.getSuccessTime()), - outTradeNo, response); - } - - private static Integer parseStatus(String tradeState) { - switch (tradeState) { - case "NOTPAY": - case "USERPAYING": // 支付中,等待用户输入密码(条码支付独有) - return PayOrderStatusRespEnum.WAITING.getStatus(); - case "SUCCESS": - return PayOrderStatusRespEnum.SUCCESS.getStatus(); - case "REFUND": - return PayOrderStatusRespEnum.REFUND.getStatus(); - case "CLOSED": - case "REVOKED": // 已撤销(刷卡支付独有) - case "PAYERROR": // 支付失败(其它原因,如银行返回失败) - return PayOrderStatusRespEnum.CLOSED.getStatus(); - default: - throw new IllegalArgumentException(StrUtil.format("未知的支付状态({})", tradeState)); - } - } - - // ============ 退款相关 ========== - - @Override - protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable { - try { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doUnifiedRefundV2(reqDTO); - case WxPayClientConfig.API_VERSION_V3: - return doUnifiedRefundV3(reqDTO); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } catch (WxPayException e) { - String errorCode = getErrorCode(e); - String errorMessage = getErrorMessage(e); - return PayRefundRespDTO.failureOf(errorCode, errorMessage, - reqDTO.getOutTradeNo(), e.getXmlString()); - } - } - - private PayRefundRespDTO doUnifiedRefundV2(PayRefundUnifiedReqDTO reqDTO) throws Throwable { - // 1. 构建 WxPayRefundRequest 请求 - WxPayRefundRequest request = new WxPayRefundRequest() - .setOutTradeNo(reqDTO.getOutTradeNo()) - .setOutRefundNo(reqDTO.getOutRefundNo()) - .setRefundFee(reqDTO.getRefundPrice()) - .setRefundDesc(reqDTO.getReason()) - .setTotalFee(reqDTO.getPayPrice()) - .setNotifyUrl(reqDTO.getNotifyUrl()); - // 2.1 执行请求 - WxPayRefundResult response = client.refundV2(request); - // 2.2 创建返回结果 - if (Objects.equals("SUCCESS", response.getResultCode())) { // V2 情况下,不直接返回退款成功,而是等待异步通知 - return PayRefundRespDTO.waitingOf(response.getRefundId(), - reqDTO.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(reqDTO.getOutRefundNo(), response); - } - - private PayRefundRespDTO doUnifiedRefundV3(PayRefundUnifiedReqDTO reqDTO) throws Throwable { - // 1. 构建 WxPayRefundRequest 请求 - WxPayRefundV3Request request = new WxPayRefundV3Request() - .setOutTradeNo(reqDTO.getOutTradeNo()) - .setOutRefundNo(reqDTO.getOutRefundNo()) - .setAmount(new WxPayRefundV3Request.Amount().setRefund(reqDTO.getRefundPrice()) - .setTotal(reqDTO.getPayPrice()).setCurrency("CNY")) - .setReason(reqDTO.getReason()) - .setNotifyUrl(reqDTO.getNotifyUrl()); - // 2.1 执行请求 - WxPayRefundV3Result response = client.refundV3(request); - // 2.2 创建返回结果 - if (Objects.equals("SUCCESS", response.getStatus())) { - return PayRefundRespDTO.successOf(response.getRefundId(), parseDateV3(response.getSuccessTime()), - reqDTO.getOutRefundNo(), response); - } - if (Objects.equals("PROCESSING", response.getStatus())) { - return PayRefundRespDTO.waitingOf(response.getRefundId(), - reqDTO.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(reqDTO.getOutRefundNo(), response); - } - - @Override - public PayRefundRespDTO doParseRefundNotify(Map params, String body) throws WxPayException { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doParseRefundNotifyV2(body); - case WxPayClientConfig.API_VERSION_V3: - return parseRefundNotifyV3(body); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } - - private PayRefundRespDTO doParseRefundNotifyV2(String body) throws WxPayException { - // 1. 解析回调 - WxPayRefundNotifyResult response = client.parseRefundNotifyResult(body); - WxPayRefundNotifyResult.ReqInfo result = response.getReqInfo(); - // 2. 构建结果 - if (Objects.equals("SUCCESS", result.getRefundStatus())) { - return PayRefundRespDTO.successOf(result.getRefundId(), parseDateV2B(result.getSuccessTime()), - result.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(result.getOutRefundNo(), response); - } - - private PayRefundRespDTO parseRefundNotifyV3(String body) throws WxPayException { - // 1. 解析回调 - WxPayRefundNotifyV3Result response = client.parseRefundNotifyV3Result(body, null); - WxPayRefundNotifyV3Result.DecryptNotifyResult result = response.getResult(); - // 2. 构建结果 - if (Objects.equals("SUCCESS", result.getRefundStatus())) { - return PayRefundRespDTO.successOf(result.getRefundId(), parseDateV3(result.getSuccessTime()), - result.getOutRefundNo(), response); - } - return PayRefundRespDTO.failureOf(result.getOutRefundNo(), response); - } - - @Override - protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) throws WxPayException { - try { - switch (config.getApiVersion()) { - case API_VERSION_V2: - return doGetRefundV2(outTradeNo, outRefundNo); - case WxPayClientConfig.API_VERSION_V3: - return doGetRefundV3(outTradeNo, outRefundNo); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } catch (WxPayException e) { - if (ObjectUtils.equalsAny(e.getErrCode(), "REFUNDNOTEXIST", "RESOURCE_NOT_EXISTS")) { - String errorCode = getErrorCode(e); - String errorMessage = getErrorMessage(e); - return PayRefundRespDTO.failureOf(errorCode, errorMessage, - outRefundNo, e.getXmlString()); - } - throw e; - } - } - - private PayRefundRespDTO doGetRefundV2(String outTradeNo, String outRefundNo) throws WxPayException { - // 1. 构建 WxPayRefundRequest 请求 - WxPayRefundQueryRequest request = WxPayRefundQueryRequest.newBuilder() - .outTradeNo(outTradeNo) - .outRefundNo(outRefundNo) - .build(); - // 2.1 执行请求 - WxPayRefundQueryResult response = client.refundQuery(request); - // 2.2 创建返回结果 - if (!Objects.equals("SUCCESS", response.getResultCode())) { - return PayRefundRespDTO.waitingOf(null, - outRefundNo, response); - } - WxPayRefundQueryResult.RefundRecord refund = CollUtil.findOne(response.getRefundRecords(), - record -> record.getOutRefundNo().equals(outRefundNo)); - if (refund == null) { - return PayRefundRespDTO.failureOf(outRefundNo, response); - } - switch (refund.getRefundStatus()) { - case "SUCCESS": - return PayRefundRespDTO.successOf(refund.getRefundId(), parseDateV2B(refund.getRefundSuccessTime()), - outRefundNo, response); - case "PROCESSING": - return PayRefundRespDTO.waitingOf(refund.getRefundId(), - outRefundNo, response); - case "CHANGE": // 退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,资金回流到商户的现金帐号,需要商户人工干预,通过线下或者财付通转账的方式进行退款 - case "FAIL": - return PayRefundRespDTO.failureOf(outRefundNo, response); - default: - throw new IllegalArgumentException(String.format("未知的退款状态(%s)", refund.getRefundStatus())); - } - } - - private PayRefundRespDTO doGetRefundV3(String outTradeNo, String outRefundNo) throws WxPayException { - // 1. 构建 WxPayRefundRequest 请求 - WxPayRefundQueryV3Request request = new WxPayRefundQueryV3Request(); - request.setOutRefundNo(outRefundNo); - // 2.1 执行请求 - WxPayRefundQueryV3Result response = client.refundQueryV3(request); - // 2.2 创建返回结果 - switch (response.getStatus()) { - case "SUCCESS": - return PayRefundRespDTO.successOf(response.getRefundId(), parseDateV3(response.getSuccessTime()), - outRefundNo, response); - case "PROCESSING": - return PayRefundRespDTO.waitingOf(response.getRefundId(), - outRefundNo, response); - case "ABNORMAL": // 退款异常 - case "CLOSED": - return PayRefundRespDTO.failureOf(outRefundNo, response); - default: - throw new IllegalArgumentException(String.format("未知的退款状态(%s)", response.getStatus())); - } - } - - @Override - protected PayTransferRespDTO doUnifiedTransfer(PayTransferUnifiedReqDTO reqDTO) { - throw new UnsupportedOperationException("待实现"); - } - // ========== 各种工具方法 ========== - - static String formatDateV2(LocalDateTime time) { - return TemporalAccessorUtil.format(time.atZone(ZoneId.systemDefault()), PURE_DATETIME_PATTERN); - } - - static LocalDateTime parseDateV2(String time) { - return LocalDateTimeUtil.parse(time, PURE_DATETIME_PATTERN); - } - - static LocalDateTime parseDateV2B(String time) { - return LocalDateTimeUtil.parse(time, NORM_DATETIME_PATTERN); - } - - static String formatDateV3(LocalDateTime time) { - return TemporalAccessorUtil.format(time.atZone(ZoneId.systemDefault()), UTC_WITH_XXX_OFFSET_PATTERN); - } - - static LocalDateTime parseDateV3(String time) { - return LocalDateTimeUtil.parse(time, UTC_WITH_XXX_OFFSET_PATTERN); - } - - static String getErrorCode(WxPayException e) { - if (StrUtil.isNotEmpty(e.getErrCode())) { - return e.getErrCode(); - } - if (StrUtil.isNotEmpty(e.getCustomErrorMsg())) { - return "CUSTOM_ERROR"; - } - return e.getReturnCode(); - } - - static String getErrorMessage(WxPayException e) { - if (StrUtil.isNotEmpty(e.getErrCode())) { - return e.getErrCodeDes(); - } - if (StrUtil.isNotEmpty(e.getCustomErrorMsg())) { - return e.getCustomErrorMsg(); - } - return e.getReturnMsg(); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxAppPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxAppPayClient.java deleted file mode 100644 index 396694a75..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxAppPayClient.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import lombok.extern.slf4j.Slf4j; - -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; - -/** - * 微信支付【App 支付】的 PayClient 实现类 - * - * 文档:App 支付 - * - * // TODO 芋艿:未详细测试,因为手头没 App - * - * @author 芋道源码 - */ -@Slf4j -public class WxAppPayClient extends AbstractWxPayClient { - - public WxAppPayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_APP.getCode(), config); - } - - @Override - protected void doInit() { - super.doInit(WxPayConstants.TradeType.APP); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO); - // 执行请求 - WxPayMpOrderResult response = client.createOrder(request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response), - reqDTO.getOutTradeNo(), response); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderV3Request 对象 - WxPayUnifiedOrderV3Request request = buildPayUnifiedOrderRequestV3(reqDTO); - // 执行请求 - WxPayUnifiedOrderV3Result.AppResult response = client.createOrderV3(TradeTypeEnum.APP, request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response), - reqDTO.getOutTradeNo(), response); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClient.java deleted file mode 100644 index d01b50405..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClient.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.thread.ThreadUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest; -import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import lombok.extern.slf4j.Slf4j; - -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.concurrent.TimeUnit; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; - -/** - * 微信支付【付款码支付】的 PayClient 实现类 - * - * 文档:付款码支付 - * - * @author 芋道源码 - */ -@Slf4j -public class WxBarPayClient extends AbstractWxPayClient { - - /** - * 微信付款码的过期时间 - */ - private static final Duration AUTH_CODE_EXPIRE = Duration.ofMinutes(3); - - public WxBarPayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_BAR.getCode(), config); - } - - @Override - protected void doInit() { - super.doInit(WxPayConstants.TradeType.MICROPAY); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 由于付款码需要不断轮询,所以需要在较短的时间完成支付 - LocalDateTime expireTime = LocalDateTimeUtils.addTime(AUTH_CODE_EXPIRE); - if (expireTime.isAfter(reqDTO.getExpireTime())) { - expireTime = reqDTO.getExpireTime(); - } - // 构建 WxPayMicropayRequest 对象 - WxPayMicropayRequest request = WxPayMicropayRequest.newBuilder() - .outTradeNo(reqDTO.getOutTradeNo()) - .body(reqDTO.getSubject()) - .detail(reqDTO.getBody()) - .totalFee(reqDTO.getPrice()) // 单位分 - .timeExpire(formatDateV2(expireTime)) - .spbillCreateIp(reqDTO.getUserIp()) - .authCode(getAuthCode(reqDTO)) - .build(); - // 执行请求,重试直到失败(过期),或者成功 - WxPayException lastWxPayException = null; - for (int i = 1; i < Byte.MAX_VALUE; i++) { - try { - WxPayMicropayResult response = client.micropay(request); - // 支付成功,例如说:1)用户输入了密码;2)用户免密支付 - return PayOrderRespDTO.successOf(response.getTransactionId(), response.getOpenid(), parseDateV2(response.getTimeEnd()), - response.getOutTradeNo(), response) - .setDisplayMode(PayOrderDisplayModeEnum.BAR_CODE.getMode()); - } catch (WxPayException ex) { - lastWxPayException = ex; - // 如果不满足这 3 种任一的,则直接抛出 WxPayException 异常,不仅需处理 - // 1. SYSTEMERROR:接口返回错误:请立即调用被扫订单结果查询API,查询当前订单状态,并根据订单的状态决定下一步的操作。 - // 2. USERPAYING:用户支付中,需要输入密码:等待 5 秒,然后调用被扫订单结果查询 API,查询当前订单的不同状态,决定下一步的操作。 - // 3. BANKERROR:银行系统异常:请立即调用被扫订单结果查询 API,查询当前订单的不同状态,决定下一步的操作。 - if (!StrUtil.equalsAny(ex.getErrCode(), "SYSTEMERROR", "USERPAYING", "BANKERROR")) { - throw ex; - } - // 等待 5 秒,继续下一轮重新发起支付 - log.info("[doUnifiedOrderV2][发起微信 Bar 支付第({})失败,等待下一轮重试,请求({}),响应({})]", i, - toJsonString(request), ex.getMessage()); - ThreadUtil.sleep(5, TimeUnit.SECONDS); - } - } - throw lastWxPayException; - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - return doUnifiedOrderV2(reqDTO); - } - - // ========== 各种工具方法 ========== - - static String getAuthCode(PayOrderUnifiedReqDTO reqDTO) { - String authCode = MapUtil.getStr(reqDTO.getChannelExtras(), "authCode"); - if (StrUtil.isEmpty(authCode)) { - throw invalidParamException("支付请求的 authCode 不能为空!"); - } - return authCode; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxLitePayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxLitePayClient.java deleted file mode 100644 index 9929955ae..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxLitePayClient.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import lombok.extern.slf4j.Slf4j; - -/** - * 微信支付【小程序】的 PayClient 实现类 - * - * 由于公众号和小程序的微信支付逻辑一致,所以直接进行继承 - * - * 文档:JSAPI 下单 - * - * @author zwy - */ -@Slf4j -public class WxLitePayClient extends WxPubPayClient { - - public WxLitePayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_LITE.getCode(), config); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClient.java deleted file mode 100644 index 5a073501d..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClient.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import lombok.extern.slf4j.Slf4j; - -/** - * 微信支付【Native 二维码】的 PayClient 实现类 - * - * 文档:Native 下单 - * - * @author zwy - */ -@Slf4j -public class WxNativePayClient extends AbstractWxPayClient { - - public WxNativePayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_NATIVE.getCode(), config); - } - - @Override - protected void doInit() { - super.doInit(WxPayConstants.TradeType.NATIVE); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO); - // 执行请求 - WxPayNativeOrderResult response = client.createOrder(request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.QR_CODE.getMode(), response.getCodeUrl(), - reqDTO.getOutTradeNo(), response); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderV3Request 对象 - WxPayUnifiedOrderV3Request request = buildPayUnifiedOrderRequestV3(reqDTO); - // 执行请求 - String response = client.createOrderV3(TradeTypeEnum.NATIVE, request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.QR_CODE.getMode(), response, - reqDTO.getOutTradeNo(), response); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPayClientConfig.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPayClientConfig.java deleted file mode 100644 index 77027ae3a..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPayClientConfig.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.hutool.core.io.IoUtil; -import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import lombok.Data; - -import javax.validation.Validator; -import javax.validation.constraints.NotBlank; -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -/** - * 微信支付的 PayClientConfig 实现类 - * 属性主要来自 {@link com.github.binarywang.wxpay.config.WxPayConfig} 的必要属性 - * - * @author 芋道源码 - */ -@Data -public class WxPayClientConfig implements PayClientConfig { - - /** - * API 版本 - V2 - * - * V2 协议说明 - */ - public static final String API_VERSION_V2 = "v2"; - /** - * API 版本 - V3 - * - * V3 协议说明 - */ - public static final String API_VERSION_V3 = "v3"; - - /** - * 公众号或者小程序的 appid - * - * 只有公众号或小程序需要该字段 - */ - @NotBlank(message = "APPID 不能为空", groups = {V2.class, V3.class}) - private String appId; - /** - * 商户号 - */ - @NotBlank(message = "商户号不能为空", groups = {V2.class, V3.class}) - private String mchId; - /** - * API 版本 - */ - @NotBlank(message = "API 版本不能为空", groups = {V2.class, V3.class}) - private String apiVersion; - - // ========== V2 版本的参数 ========== - - /** - * 商户密钥 - */ - @NotBlank(message = "商户密钥不能为空", groups = V2.class) - private String mchKey; - /** - * apiclient_cert.p12 证书文件的对应字符串【base64 格式】 - * - * 为什么采用 base64 格式?因为 p12 读取后是二进制,需要转换成 base64 格式才好传输和存储 - */ - @NotBlank(message = "apiclient_cert.p12 不能为空", groups = V2.class) - private String keyContent; - - // ========== V3 版本的参数 ========== - /** - * apiclient_key.pem 证书文件的对应字符串 - */ - @NotBlank(message = "apiclient_key 不能为空", groups = V3.class) - private String privateKeyContent; - /** - * apiclient_cert.pem 证书文件的对应的字符串 - */ - @NotBlank(message = "apiclient_cert 不能为空", groups = V3.class) - private String privateCertContent; - /** - * apiV3 密钥值 - */ - @NotBlank(message = "apiV3 密钥值不能为空", groups = V3.class) - private String apiV3Key; - - /** - * 分组校验 v2版本 - */ - public interface V2 { - } - - /** - * 分组校验 v3版本 - */ - public interface V3 { - } - - @Override - public void validate(Validator validator) { - ValidationUtils.validate(validator, this, - API_VERSION_V2.equals(this.getApiVersion()) ? V2.class : V3.class); - } - - public static void main(String[] args) throws FileNotFoundException { - String path = "/Users/yunai/Downloads/wx_pay/apiclient_cert.p12"; - /// String path = "/Users/yunai/Downloads/wx_pay/apiclient_key.pem"; - /// String path = "/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"; - System.out.println(IoUtil.readUtf8(new FileInputStream(path))); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java deleted file mode 100644 index 390c51363..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import lombok.extern.slf4j.Slf4j; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException; -import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; - -/** - * 微信支付(公众号)的 PayClient 实现类 - * - * 文档:JSAPI 下单 - * - * @author 芋道源码 - */ -@Slf4j -public class WxPubPayClient extends AbstractWxPayClient { - - public WxPubPayClient(Long channelId, WxPayClientConfig config) { - super(channelId, PayChannelEnum.WX_PUB.getCode(), config); - } - - protected WxPubPayClient(Long channelId, String channelCode, WxPayClientConfig config) { - super(channelId, channelCode, config); - } - - @Override - protected void doInit() { - super.doInit(WxPayConstants.TradeType.JSAPI); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderRequest request = buildPayUnifiedOrderRequestV2(reqDTO) - .setOpenid(getOpenid(reqDTO)); - // 执行请求 - WxPayMpOrderResult response = client.createOrder(request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response), - reqDTO.getOutTradeNo(), response); - } - - @Override - protected PayOrderRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderV3Request request = buildPayUnifiedOrderRequestV3(reqDTO) - .setPayer(new WxPayUnifiedOrderV3Request.Payer().setOpenid(getOpenid(reqDTO))); - // 执行请求 - WxPayUnifiedOrderV3Result.JsapiResult response = client.createOrderV3(TradeTypeEnum.JSAPI, request); - - // 转换结果 - return PayOrderRespDTO.waitingOf(PayOrderDisplayModeEnum.APP.getMode(), toJsonString(response), - reqDTO.getOutTradeNo(), response); - } - - // ========== 各种工具方法 ========== - - static String getOpenid(PayOrderUnifiedReqDTO reqDTO) { - String openid = MapUtil.getStr(reqDTO.getChannelExtras(), "openid"); - if (StrUtil.isEmpty(openid)) { - throw invalidParamException("支付请求的 openid 不能为空!"); - } - return openid; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java deleted file mode 100644 index e049ad33e..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.channel; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 支付渠道的编码的枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayChannelEnum { - - WX_PUB("wx_pub", "微信 JSAPI 支付", WxPayClientConfig.class), // 公众号网页 - WX_LITE("wx_lite", "微信小程序支付", WxPayClientConfig.class), - WX_APP("wx_app", "微信 App 支付", WxPayClientConfig.class), - WX_NATIVE("wx_native", "微信 Native 支付", WxPayClientConfig.class), - WX_BAR("wx_bar", "微信付款码支付", WxPayClientConfig.class), - - ALIPAY_PC("alipay_pc", "支付宝 PC 网站支付", AlipayPayClientConfig.class), - ALIPAY_WAP("alipay_wap", "支付宝 Wap 网站支付", AlipayPayClientConfig.class), - ALIPAY_APP("alipay_app", "支付宝App 支付", AlipayPayClientConfig.class), - ALIPAY_QR("alipay_qr", "支付宝扫码支付", AlipayPayClientConfig.class), - ALIPAY_BAR("alipay_bar", "支付宝条码支付", AlipayPayClientConfig.class), - MOCK("mock", "模拟支付", NonePayClientConfig.class), - - WALLET("wallet", "钱包支付", NonePayClientConfig.class); - - /** - * 编码 - * - * 参考 支付渠道属性值 - */ - private final String code; - /** - * 名字 - */ - private final String name; - - /** - * 配置类 - */ - private final Class configClass; - - /** - * 微信支付 - */ - public static final String WECHAT = "WECHAT"; - - /** - * 支付宝支付 - */ - public static final String ALIPAY = "ALIPAY"; - - public static PayChannelEnum getByCode(String code) { - return ArrayUtil.firstMatch(o -> o.getCode().equals(code), values()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderDisplayModeEnum.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderDisplayModeEnum.java deleted file mode 100644 index 129c40602..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderDisplayModeEnum.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.order; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 支付 UI 展示模式 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayOrderDisplayModeEnum { - - URL("url"), // Redirect 跳转链接的方式 - IFRAME("iframe"), // IFrame 内嵌链接的方式【目前暂时用不到】 - FORM("form"), // HTML 表单提交 - QR_CODE("qr_code"), // 二维码的文字内容 - QR_CODE_URL("qr_code_url"), // 二维码的图片链接 - BAR_CODE("bar_code"), // 条形码 - APP("app"), // 应用:Android、iOS、微信小程序、微信公众号等,需要做自定义处理的 - ; - - /** - * 展示模式 - */ - private final String mode; - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderStatusRespEnum.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderStatusRespEnum.java deleted file mode 100644 index eac381c47..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderStatusRespEnum.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.order; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 渠道的支付状态枚举 - * - * @author 芋道源码 - */ -@Getter -@AllArgsConstructor -public enum PayOrderStatusRespEnum { - - WAITING(0, "未支付"), - SUCCESS(10, "支付成功"), - REFUND(20, "已退款"), - CLOSED(30, "支付关闭"), - ; - - private final Integer status; - private final String name; - - /** - * 判断是否支付成功 - * - * @param status 状态 - * @return 是否支付成功 - */ - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - /** - * 判断是否已退款 - * - * @param status 状态 - * @return 是否支付成功 - */ - public static boolean isRefund(Integer status) { - return Objects.equals(status, REFUND.getStatus()); - } - - /** - * 判断是否支付关闭 - * - * @param status 状态 - * @return 是否支付关闭 - */ - public static boolean isClosed(Integer status) { - return Objects.equals(status, CLOSED.getStatus()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayRefundStatusRespEnum.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayRefundStatusRespEnum.java deleted file mode 100644 index 8ad61a6cf..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayRefundStatusRespEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.refund; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 渠道的退款状态枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -public enum PayRefundStatusRespEnum { - - WAITING(0, "等待退款"), - SUCCESS(10, "退款成功"), - FAILURE(20, "退款失败"); - - private final Integer status; - private final String name; - - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - public static boolean isFailure(Integer status) { - return Objects.equals(status, FAILURE.getStatus()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferStatusRespEnum.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferStatusRespEnum.java deleted file mode 100644 index 145a470cc..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferStatusRespEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.transfer; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Objects; - -/** - * 渠道的转账状态枚举 - * - * @author jason - */ -@Getter -@AllArgsConstructor -public enum PayTransferStatusRespEnum { - - WAITING(0, "转账中"), - - /** - * TODO 转账到银行卡. 会有T+0 T+1 到账的请情况。 还未实现 - * TODO @jason:可以看看其它开源项目,针对这个场景,处理策略是怎么样的?例如说,每天主动轮询?这个状态的单子? - */ - IN_PROGRESS(10, "转账进行中"), - - SUCCESS(20, "转账成功"), - /** - * 转账关闭 (失败,或者其它情况) - */ - CLOSED(30, "转账关闭"); - - private final Integer status; - private final String name; - - public static boolean isSuccess(Integer status) { - return Objects.equals(status, SUCCESS.getStatus()); - } - - public static boolean isClosed(Integer status) { - return Objects.equals(status, CLOSED.getStatus()); - } -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferTypeEnum.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferTypeEnum.java deleted file mode 100644 index 2de6fd21f..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/transfer/PayTransferTypeEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.enums.transfer; - -import cn.hutool.core.util.ArrayUtil; -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.Arrays; - -/** - * 转账类型枚举 - * - * @author jason - */ -@AllArgsConstructor -@Getter -public enum PayTransferTypeEnum implements IntArrayValuable { - - ALIPAY_BALANCE(1, "支付宝余额"), - WX_BALANCE(2, "微信余额"), - BANK_CARD(3, "银行卡"), - WALLET_BALANCE(4, "钱包余额"); - - public static final String ALIPAY_LOGON_ID = "ALIPAY_LOGON_ID"; - public static final String ALIPAY_ACCOUNT_NAME = "ALIPAY_ACCOUNT_NAME"; - - private final Integer type; - private final String name; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PayTransferTypeEnum::getType).toArray(); - - @Override - public int[] array() { - return ARRAYS; - } - - public static PayTransferTypeEnum typeOf(Integer type) { - return ArrayUtil.firstMatch(item -> item.getType().equals(type), values()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 6fd198210..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1 +0,0 @@ -cn.iocoder.yudao.framework.pay.config.YudaoPayAutoConfiguration diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test-integration/java/cn/iocoder/yudao/framework/core/client/impl/PayClientFactoryImplTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test-integration/java/cn/iocoder/yudao/framework/core/client/impl/PayClientFactoryImplTest.java deleted file mode 100644 index 582840e4e..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test-integration/java/cn/iocoder/yudao/framework/core/client/impl/PayClientFactoryImplTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.framework.core.client.impl; - -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.PayClientFactoryImpl; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayQrPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayWapPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPubPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import com.alipay.api.response.AlipayTradePrecreateResponse; -import org.junit.jupiter.api.Test; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -/** - * {@link PayClientFactoryImpl} 的集成测试 - * - * @author 芋道源码 - */ -public class PayClientFactoryImplTest { - - private final PayClientFactoryImpl payClientFactory = new PayClientFactoryImpl(); - - /** - * {@link WXPubPayClient} 的 V2 版本 - */ - @Test - public void testCreatePayClient_WX_PUB_V2() { - // 创建配置 - WXPayClientConfig config = new WXPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WXPayClientConfig.API_VERSION_V2); - config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); - CommonResult result = client.unifiedOrder(reqDTO); - System.out.println(result); - } - - /** - * {@link WXPubPayClient} 的 V3 版本 - */ - @Test - public void testCreatePayClient_WX_PUB_V3() throws FileNotFoundException { - // 创建配置 - WXPayClientConfig config = new WXPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WXPayClientConfig.API_VERSION_V3); - config.setPrivateKeyContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_key.pem"))); - config.setPrivateCertContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"))); - config.setApiV3Key("joerVi8y5DJ3o4ttA0o1uH47Xz1u2Ase"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); - CommonResult result = client.unifiedOrder(reqDTO); - System.out.println(result); - } - - /** - * {@link AlipayQrPayClient} - */ - @Test - @SuppressWarnings("unchecked") - public void testCreatePayClient_ALIPAY_QR() { - // 创建配置 - AlipayPayClientConfig config = new AlipayPayClientConfig(); - config.setAppId("2021000118634035"); - config.setServerUrl(AlipayPayClientConfig.SERVER_URL_SANDBOX); - config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeYfX7YAXApzHqYNINzM79HemO3Yx1qLMW3okRFJ9pPRzbQ9qkTpsaegsmyX316zOBhzGRYjKbutTYwKBgQCm7phr9XdFW5Vh+XR90mVs483nrLmMiDKg7YKxSLJ8amiDjzPejCn7i95Hah08P+2MIZLIPbh2VLacczR6ltRRzN5bg5etFuqSgfkuHyxpoDmpjbe08+Q2h8JBYqcC5Nhv1AKU4iOUhVLHo/FBAQliMcGc/J3eiYTFC7EsNx382QKBgClb20doe7cttgFTXswBvaUmfFm45kmla924B7SpvrQpDD/f+VDtDZRp05fGmxuduSjYdtA3aVtpLiTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); - config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_QR.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); - reqDTO.setNotifyUrl("http://niubi.natapp1.cc/api/pay/order/notify/alipay-qr/1"); // TODO @tina: 这里改成你的 natapp 回调地址 - CommonResult result = (CommonResult) client.unifiedOrder(reqDTO); - System.out.println(JsonUtils.toJsonString(result)); - System.out.println(result.getData().getQrCode()); - } - - /** - * {@link AlipayWapPayClient} - */ - @Test - public void testCreatePayClient_ALIPAY_WAP() { - // 创建配置 - AlipayPayClientConfig config = new AlipayPayClientConfig(); - config.setAppId("2021000118634035"); - config.setServerUrl(AlipayPayClientConfig.SERVER_URL_SANDBOX); - config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeYfX7YAXApzHqYNINzM79HemO3Yx1qLMW3okRFJ9pPRzbQ9qkTpsaegsmyX316zOBhzGRYjKbutTYwKBgQCm7phr9XdFW5Vh+XR90mVs483nrLmMiDKg7YKxSLJ8amiDjzPejCn7i95Hah08P+2MIZLIPbh2VLacczR6ltRRzN5bg5etFuqSgfkuHyxpoDmpjbe08+Q2h8JBYqcC5Nhv1AKU4iOUhVLHo/FBAQliMcGc/J3eiYTFC7EsNx382QKBgClb20doe7cttgFTXswBvaUmfFm45kmla924B7SpvrQpDD/f+VDtDZRp05fGmxuduSjYdtA3aVtpLiTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); - config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); - CommonResult result = client.unifiedOrder(reqDTO); - System.out.println(JsonUtils.toJsonString(result)); - } - - private static PayOrderUnifiedReqDTO buildPayOrderUnifiedReqDTO() { - PayOrderUnifiedReqDTO reqDTO = new PayOrderUnifiedReqDTO(); - reqDTO.setAmount(123L); - reqDTO.setSubject("IPhone 13"); - reqDTO.setBody("biubiubiu"); - reqDTO.setMerchantOrderId(String.valueOf(System.currentTimeMillis())); - reqDTO.setUserIp("127.0.0.1"); - reqDTO.setNotifyUrl("http://127.0.0.1:8080"); - return reqDTO; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java deleted file mode 100644 index 984256063..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl; - -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.pay.core.client.PayClient; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayQrPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayWapPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPubPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -/** - * {@link PayClientFactoryImpl} 的集成测试 - * - * @author 芋道源码 - */ -@Disabled -public class PayClientFactoryImplIntegrationTest { - - private static final String SERVER_URL_SANDBOX = "https://openapi.alipaydev.com/gateway.do"; - - private final PayClientFactoryImpl payClientFactory = new PayClientFactoryImpl(); - - /** - * {@link WxPubPayClient} 的 V2 版本 - */ - @Test - public void testCreatePayClient_WX_PUB_V2() { - // 创建配置 - WxPayClientConfig config = new WxPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WxPayClientConfig.API_VERSION_V2); - config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); -// CommonResult result = client.unifiedOrder(reqDTO); -// System.out.println(result); - } - - /** - * {@link WxPubPayClient} 的 V3 版本 - */ - @Test - public void testCreatePayClient_WX_PUB_V3() throws FileNotFoundException { - // 创建配置 - WxPayClientConfig config = new WxPayClientConfig(); - config.setAppId("wx041349c6f39b268b"); - config.setMchId("1545083881"); - config.setApiVersion(WxPayClientConfig.API_VERSION_V3); - config.setPrivateKeyContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_key.pem"))); - config.setPrivateCertContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"))); - config.setApiV3Key("joerVi8y5DJ3o4ttA0o1uH47Xz1u2Ase"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.WX_PUB.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); -// CommonResult result = client.unifiedOrder(reqDTO); -// System.out.println(result); - } - - /** - * {@link AlipayQrPayClient} - */ - @Test - @SuppressWarnings("unchecked") - public void testCreatePayClient_ALIPAY_QR() { - // 创建配置 - AlipayPayClientConfig config = new AlipayPayClientConfig(); - config.setAppId("2021000118634035"); - config.setServerUrl(SERVER_URL_SANDBOX); - config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeYfX7YAXApzHqYNINzM79HemO3Yx1qLMW3okRFJ9pPRzbQ9qkTpsaegsmyX316zOBhzGRYjKbutTYwKBgQCm7phr9XdFW5Vh+XR90mVs483nrLmMiDKg7YKxSLJ8amiDjzPejCn7i95Hah08P+2MIZLIPbh2VLacczR6ltRRzN5bg5etFuqSgfkuHyxpoDmpjbe08+Q2h8JBYqcC5Nhv1AKU4iOUhVLHo/FBAQliMcGc/J3eiYTFC7EsNx382QKBgClb20doe7cttgFTXswBvaUmfFm45kmla924B7SpvrQpDD/f+VDtDZRp05fGmxuduSjYdtA3aVtpLiTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); - config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_QR.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); - reqDTO.setNotifyUrl("http://yunai.natapp1.cc/admin-api/pay/notify/callback/18"); // TODO @tina: 这里改成你的 natapp 回调地址 -// CommonResult result = (CommonResult) client.unifiedOrder(reqDTO); -// System.out.println(JsonUtils.toJsonString(result)); -// System.out.println(result.getData().getQrCode()); - } - - /** - * {@link AlipayWapPayClient} - */ - @Test - public void testCreatePayClient_ALIPAY_WAP() { - // 创建配置 - AlipayPayClientConfig config = new AlipayPayClientConfig(); - config.setAppId("2021000118634035"); - config.setServerUrl(SERVER_URL_SANDBOX); - config.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - config.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJv890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH6zyA2fPl7cYyQtbZoDJQFGqr4F+cGh2R6akzRKNoBkAeMYwoY6es2lX8sJxCVPWUmxNUoL3tScwlSpd7Bxw0q9c/X01jMwuQ0+Va358zgFiGERTE6yD01eu40OBDXOYO3z++y+TAYHlQQ2toMO63trepo88X3xV3R44/1DH+k2pAm2IF5ixiLrAgMBAAECggEAPx3SoXcseaD7rmcGcE0p4SMfbsUDdkUSmBBbtfF0GzwnqNLkWa+mgE0rWt9SmXngTQH97vByAYmLPl1s3G82ht1V7Sk7yQMe74lhFllr8eEyTjeVx3dTK1EEM4TwN+936DTXdFsr4TELJEcJJdD0KaxcCcfBLRDs2wnitEFZ9N+GoZybVmY8w0e0MI7PLObUZ2l0X4RurQnfG9ZxjXjC7PkeMVv7cGGylpNFi3BbvkRhdhLPDC2E6wqnr9e7zk+hiENivAezXrtxtwKovzCtnWJ1r0IO14Rh47H509Ic0wFnj+o5YyUL4LdmpL7yaaH6fM7zcSLFjNZPHvZCKPwYcQKBgQDQFho98QvnL8ex4v6cry4VitGpjSXm1qP3vmMQk4rTsn8iPWtcxPjqGEqOQJjdi4Mi0VZKQOLFwlH0kl95wNrD/isJ4O1yeYfX7YAXApzHqYNINzM79HemO3Yx1qLMW3okRFJ9pPRzbQ9qkTpsaegsmyX316zOBhzGRYjKbutTYwKBgQCm7phr9XdFW5Vh+XR90mVs483nrLmMiDKg7YKxSLJ8amiDjzPejCn7i95Hah08P+2MIZLIPbh2VLacczR6ltRRzN5bg5etFuqSgfkuHyxpoDmpjbe08+Q2h8JBYqcC5Nhv1AKU4iOUhVLHo/FBAQliMcGc/J3eiYTFC7EsNx382QKBgClb20doe7cttgFTXswBvaUmfFm45kmla924B7SpvrQpDD/f+VDtDZRp05fGmxuduSjYdtA3aVtpLiTwWu22OUUvZZqHDGruYOO4Hvdz23mL5b4ayqImCwoNU4bAZIc9v18p/UNf3/55NNE3oGcf/bev9rH2OjCQ4nM+Ktwhg8CFAoGACSgvbkShzUkv0ZcIf9ppu+ZnJh1AdGgINvGwaJ8vQ0nm/8h8NOoFZ4oNoGc+wU5Ubops7dUM6FjPR5e+OjdJ4E7Xp7d5O4J1TaIZlCEbo5OpdhaTDDcQvrkFu+Z4eN0qzj+YAKjDAOOrXc4tbr5q0FsgXscwtcNfaBuzFVTUrUkCgYEAwzPnMNhWG3zOWLUs2QFA2GP4Y+J8cpUYfj6pbKKzeLwyG9qBwF1NJpN8m+q9q7V9P2LY+9Lp9e1mGsGeqt5HMEA3P6vIpcqLJLqE/4PBLLRzfccTcmqb1m71+erxTRhHBRkGS+I7dZEb3olQfnS1Y1tpMBxiwYwR3LW4oXuJwj8="); - config.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnq90KnF4dTnlzzmxpujbI05OYqi5WxAS6cL0gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBNlrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 - Long channelId = RandomUtil.randomLong(); - payClientFactory.createOrUpdatePayClient(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), config); - PayClient client = payClientFactory.getPayClient(channelId); - // 发起支付 - PayOrderUnifiedReqDTO reqDTO = buildPayOrderUnifiedReqDTO(); -// CommonResult result = client.unifiedOrder(reqDTO); -// System.out.println(JsonUtils.toJsonString(result)); - } - - private static PayOrderUnifiedReqDTO buildPayOrderUnifiedReqDTO() { - PayOrderUnifiedReqDTO reqDTO = new PayOrderUnifiedReqDTO(); - reqDTO.setPrice(123); - reqDTO.setSubject("IPhone 13"); - reqDTO.setBody("biubiubiu"); - reqDTO.setOutTradeNo(String.valueOf(System.currentTimeMillis())); - reqDTO.setUserIp("127.0.0.1"); - reqDTO.setNotifyUrl("http://127.0.0.1:8080"); - return reqDTO; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClientTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClientTest.java deleted file mode 100644 index 2d220079e..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClientTest.java +++ /dev/null @@ -1,221 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -import com.alipay.api.AlipayApiException; -import com.alipay.api.DefaultAlipayClient; -import com.alipay.api.DefaultSigner; -import com.alipay.api.domain.AlipayTradeRefundModel; -import com.alipay.api.request.AlipayTradeRefundRequest; -import com.alipay.api.response.AlipayTradeRefundResponse; -import lombok.Setter; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.Mock; - -import javax.validation.ConstraintViolationException; -import java.util.Date; - -import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_PUBLIC_KEY; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.when; - -/** - * 支付宝 Client 的测试基类 - * - * @author jason - */ -public abstract class AbstractAlipayClientTest extends BaseMockitoUnitTest { - - protected AlipayPayClientConfig config = randomPojo(AlipayPayClientConfig.class, o -> { - o.setServerUrl(randomURL()); - o.setPrivateKey(randomString()); - o.setMode(MODE_PUBLIC_KEY); - o.setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT); - o.setAppCertContent(""); - o.setAlipayPublicCertContent(""); - o.setRootCertContent(""); - }); - - @Mock - protected DefaultAlipayClient defaultAlipayClient; - - @Setter - private AbstractAlipayPayClient client; - - /** - * 子类需要实现该方法. 设置 client 的具体实现 - */ - @BeforeEach - public abstract void setUp(); - - @Test - @DisplayName("支付宝 Client 初始化") - public void testDoInit() { - // 调用 - client.doInit(); - // 断言 - DefaultAlipayClient realClient = client.getClient(); - assertNotSame(defaultAlipayClient, realClient); - assertInstanceOf(DefaultSigner.class, realClient.getSigner()); - assertEquals(config.getPrivateKey(), ((DefaultSigner) realClient.getSigner()).getPrivateKey()); - } - - @Test - @DisplayName("支付宝 Client 统一退款:成功") - public void testUnifiedRefund_success() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - Date refundTime = randomDate(); - String outRefundNo = randomString(); - String outTradeNo = randomString(); - Integer refundAmount = randomInteger(); - AlipayTradeRefundResponse response = randomPojo(AlipayTradeRefundResponse.class, o -> { - o.setSubCode(""); - o.setGmtRefundPay(refundTime); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertInstanceOf(AlipayTradeRefundModel.class, request.getBizModel()); - AlipayTradeRefundModel bizModel = (AlipayTradeRefundModel) request.getBizModel(); - assertEquals(outRefundNo, bizModel.getOutRequestNo()); - assertEquals(outTradeNo, bizModel.getOutTradeNo()); - assertEquals(String.valueOf(refundAmount / 100.0), bizModel.getRefundAmount()); - return true; - }))).thenReturn(response); - // 准备请求参数 - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { - o.setOutRefundNo(outRefundNo); - o.setOutTradeNo(outTradeNo); - o.setNotifyUrl(notifyUrl); - o.setRefundPrice(refundAmount); - }); - - // 调用 - PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO); - // 断言 - assertEquals(PayRefundStatusRespEnum.SUCCESS.getStatus(), resp.getStatus()); - assertEquals(outRefundNo, resp.getOutRefundNo()); - assertNull(resp.getChannelRefundNo()); - assertEquals(LocalDateTimeUtil.of(refundTime), resp.getSuccessTime()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 Client 统一退款:渠道返回失败") - public void test_unified_refund_channel_failed() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - String subCode = randomString(); - String subMsg = randomString(); - AlipayTradeRefundResponse response = randomPojo(AlipayTradeRefundResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertInstanceOf(AlipayTradeRefundModel.class, request.getBizModel()); - return true; - }))).thenReturn(response); - // 准备请求参数 - String outRefundNo = randomString(); - String outTradeNo = randomString(); - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { - o.setOutRefundNo(outRefundNo); - o.setOutTradeNo(outTradeNo); - o.setNotifyUrl(notifyUrl); - }); - - // 调用 - PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO); - // 断言 - assertEquals(PayRefundStatusRespEnum.FAILURE.getStatus(), resp.getStatus()); - assertEquals(outRefundNo, resp.getOutRefundNo()); - assertNull(resp.getChannelRefundNo()); - assertNull(resp.getSuccessTime()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 Client 统一退款:参数校验不通过") - public void testUnifiedRefund_paramInvalidate() { - // 准备请求参数 - String notifyUrl = randomURL(); - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> { - o.setOutTradeNo(""); - o.setNotifyUrl(notifyUrl); - }); - - // 调用,并断言 - assertThrows(ConstraintViolationException.class, () -> client.unifiedRefund(refundReqDTO)); - } - - @Test - @DisplayName("支付宝 Client 统一退款:抛出业务异常") - public void testUnifiedRefund_throwServiceException() throws AlipayApiException { - // mock 方法 - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> true))) - .thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); - // 准备请求参数 - String notifyUrl = randomURL(); - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> o.setNotifyUrl(notifyUrl)); - - // 调用,并断言 - assertThrows(ServiceException.class, () -> client.unifiedRefund(refundReqDTO)); - } - - @Test - @DisplayName("支付宝 Client 统一退款:抛出系统异常") - public void testUnifiedRefund_throwPayException() throws AlipayApiException { - // mock 方法 - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> true))) - .thenThrow(new RuntimeException("系统异常")); - // 准备请求参数 - String notifyUrl = randomURL(); - PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> o.setNotifyUrl(notifyUrl)); - - // 调用,并断言 - assertThrows(PayException.class, () -> client.unifiedRefund(refundReqDTO)); - } - - @Test - @DisplayName("支付宝 Client 统一下单:参数校验不通过") - public void testUnifiedOrder_paramInvalidate() { - // 准备请求参数 - String outTradeNo = randomString(); - String notifyUrl = randomURL(); - PayOrderUnifiedReqDTO reqDTO = randomPojo(PayOrderUnifiedReqDTO.class, o -> { - o.setOutTradeNo(outTradeNo); - o.setNotifyUrl(notifyUrl); - }); - - // 调用,并断言 - assertThrows(ConstraintViolationException.class, () -> client.unifiedOrder(reqDTO)); - } - - protected PayOrderUnifiedReqDTO buildOrderUnifiedReqDTO(String notifyUrl, String outTradeNo, Integer price) { - return randomPojo(PayOrderUnifiedReqDTO.class, o -> { - o.setOutTradeNo(outTradeNo); - o.setNotifyUrl(notifyUrl); - o.setPrice(price); - o.setSubject(RandomUtil.randomString(32)); - o.setBody(RandomUtil.randomString(32)); - }); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClientTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClientTest.java deleted file mode 100644 index 47f10081c..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayBarPayClientTest.java +++ /dev/null @@ -1,170 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradePayModel; -import com.alipay.api.request.AlipayTradePayRequest; -import com.alipay.api.response.AlipayTradePayResponse; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.when; - -/** - * {@link AlipayBarPayClient} 单元测试 - * - * @author jason - */ -public class AlipayBarPayClientTest extends AbstractAlipayClientTest { - - @InjectMocks - private AlipayBarPayClient client = new AlipayBarPayClient(randomLongId(), config); - - @Override - @BeforeEach - public void setUp() { - setClient(client); - } - - @Test - @DisplayName("支付宝条码支付:非免密码支付下单成功") - public void testUnifiedOrder_success() throws AlipayApiException { - // mock 方法 - String outTradeNo = randomString(); - String notifyUrl = randomURL(); - Integer price = randomInteger(); - String authCode = randomString(); - AlipayTradePayResponse response = randomPojo(AlipayTradePayResponse.class, o -> o.setSubCode("")); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertInstanceOf(AlipayTradePayModel.class, request.getBizModel()); - assertEquals(notifyUrl, request.getNotifyUrl()); - AlipayTradePayModel model = (AlipayTradePayModel) request.getBizModel(); - assertEquals(outTradeNo, model.getOutTradeNo()); - assertEquals(String.valueOf(price / 100.0), model.getTotalAmount()); - assertEquals(authCode, model.getAuthCode()); - return true; - }))).thenReturn(response); - // 准备请求参数 - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - Map extraParam = new HashMap<>(); - extraParam.put("auth_code", authCode); - reqDTO.setChannelExtras(extraParam); - - // 调用方法 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.BAR_CODE.getMode(), resp.getDisplayMode()); - assertEquals("", resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝条码支付:免密码支付下单成功") - public void testUnifiedOrder_code10000Success() throws AlipayApiException { - // mock 方法 - String outTradeNo = randomString(); - String channelNo = randomString(); - String channelUserId = randomString(); - Date payTime = randomDate(); - AlipayTradePayResponse response = randomPojo(AlipayTradePayResponse.class, o -> { - o.setSubCode(""); - o.setCode("10000"); - o.setOutTradeNo(outTradeNo); - o.setTradeNo(channelNo); - o.setBuyerUserId(channelUserId); - o.setGmtPayment(payTime); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> true))) - .thenReturn(response); - // 准备请求参数 - String authCode = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); - Map extraParam = new HashMap<>(); - extraParam.put("auth_code", authCode); - reqDTO.setChannelExtras(extraParam); - - // 下单请求 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(PayOrderStatusRespEnum.SUCCESS.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertEquals(channelNo, resp.getChannelOrderNo()); - assertEquals(channelUserId, resp.getChannelUserId()); - assertEquals(LocalDateTimeUtil.of(payTime), resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.BAR_CODE.getMode(), resp.getDisplayMode()); - assertEquals("", resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝条码支付:没有传条码") - public void testUnifiedOrder_emptyAuthCode() { - // 准备参数 - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), randomString(), randomInteger()); - - // 调用,并断言 - assertThrows(ServiceException.class, () -> client.unifiedOrder(reqDTO)); - } - - @Test - @DisplayName("支付宝条码支付:渠道返回失败") - public void test_unified_order_channel_failed() throws AlipayApiException { - // mock 方法 - String subCode = randomString(); - String subMsg = randomString(); - AlipayTradePayResponse response = randomPojo(AlipayTradePayResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> true))) - .thenReturn(response); - // 准备请求参数 - String authCode = randomString(); - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); - Map extraParam = new HashMap<>(); - extraParam.put("auth_code", authCode); - reqDTO.setChannelExtras(extraParam); - - // 调用方法 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(CLOSED.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertNull(resp.getDisplayMode()); - assertNull(resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClientTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClientTest.java deleted file mode 100644 index a6b3d8743..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClientTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.http.Method; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.request.AlipayTradePagePayRequest; -import com.alipay.api.response.AlipayTradePagePayResponse; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; - -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link AlipayPcPayClient} 单元测试 - * - * @author jason - */ -public class AlipayPcPayClientTest extends AbstractAlipayClientTest { - - @InjectMocks - private AlipayPcPayClient client = new AlipayPcPayClient(randomLongId(), config); - - @Override - @BeforeEach - public void setUp() { - setClient(client); - } - - @Test - @DisplayName("支付宝 PC 网站支付:URL Display Mode 下单成功") - public void testUnifiedOrder_urlSuccess() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - AlipayTradePagePayResponse response = randomPojo(AlipayTradePagePayResponse.class, o -> o.setSubCode("")); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> true), - eq(Method.GET.name()))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - Integer price = randomInteger(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - reqDTO.setDisplayMode(null); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.URL.getMode(), resp.getDisplayMode()); - assertEquals(response.getBody(), resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 PC 网站支付:Form Display Mode 下单成功") - public void testUnifiedOrder_formSuccess() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - AlipayTradePagePayResponse response = randomPojo(AlipayTradePagePayResponse.class, o -> o.setSubCode("")); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> true), - eq(Method.POST.name()))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - Integer price = randomInteger(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - reqDTO.setDisplayMode(PayOrderDisplayModeEnum.FORM.getMode()); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.FORM.getMode(), resp.getDisplayMode()); - assertEquals(response.getBody(), resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 PC 网站支付:渠道返回失败") - public void testUnifiedOrder_channelFailed() throws AlipayApiException { - // mock 方法 - String subCode = randomString(); - String subMsg = randomString(); - AlipayTradePagePayResponse response = randomPojo(AlipayTradePagePayResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> true), - eq(Method.GET.name()))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); - reqDTO.setDisplayMode(PayOrderDisplayModeEnum.URL.getMode()); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(CLOSED.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertNull(resp.getDisplayMode()); - assertNull(resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClientTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClientTest.java deleted file mode 100644 index c7e1eb33f..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClientTest.java +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.request.AlipayTradePrecreateRequest; -import com.alipay.api.response.AlipayTradePrecreateResponse; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; - -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.Mockito.when; - -/** - * {@link AlipayQrPayClient} 单元测试 - * - * @author jason - */ -public class AlipayQrPayClientTest extends AbstractAlipayClientTest { - - @InjectMocks - private AlipayQrPayClient client = new AlipayQrPayClient(randomLongId(), config); - - @BeforeEach - public void setUp() { - setClient(client); - } - - @Test - @DisplayName("支付宝扫描支付:下单成功") - public void testUnifiedOrder_success() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - String qrCode = randomString(); - Integer price = randomInteger(); - AlipayTradePrecreateResponse response = randomPojo(AlipayTradePrecreateResponse.class, o -> { - o.setQrCode(qrCode); - o.setSubCode(""); - }); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.QR_CODE.getMode(), resp.getDisplayMode()); - assertEquals(response.getQrCode(), resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝扫描支付:渠道返回失败") - public void testUnifiedOrder_channelFailed() throws AlipayApiException { - // mock 方法 - String notifyUrl = randomURL(); - String subCode = randomString(); - String subMsg = randomString(); - Integer price = randomInteger(); - AlipayTradePrecreateResponse response = randomPojo(AlipayTradePrecreateResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - // mock - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(CLOSED.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertNull(resp.getDisplayMode()); - assertNull(resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝扫描支付, 抛出系统异常") - public void testUnifiedOrder_throwPayException() throws AlipayApiException { - // mock 方法 - String outTradeNo = randomString(); - String notifyUrl = randomURL(); - Integer price = randomInteger(); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }))).thenThrow(new RuntimeException("系统异常")); - // 准备请求参数 - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo,price); - - // 调用,并断言 - assertThrows(PayException.class, () -> client.unifiedOrder(reqDTO)); - } - - @Test - @DisplayName("支付宝 Client 统一下单:抛出业务异常") - public void testUnifiedOrder_throwServiceException() throws AlipayApiException { - // mock 方法 - String outTradeNo = randomString(); - String notifyUrl = randomURL(); - Integer price = randomInteger(); - when(defaultAlipayClient.execute(argThat((ArgumentMatcher) request -> { - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }))).thenThrow(ServiceExceptionUtil.exception(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR)); - // 准备请求参数 - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - - // 调用,并断言 - assertThrows(ServiceException.class, () -> client.unifiedOrder(reqDTO)); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClientTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClientTest.java deleted file mode 100644 index cfe3001a5..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClientTest.java +++ /dev/null @@ -1,110 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; - -import cn.hutool.http.Method; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.domain.AlipayTradeWapPayModel; -import com.alipay.api.request.AlipayTradeWapPayRequest; -import com.alipay.api.response.AlipayTradeWapPayResponse; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; - -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED; -import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -/** - * {@link AlipayWapPayClient} 单元测试 - * - * @author jason - */ -public class AlipayWapPayClientTest extends AbstractAlipayClientTest { - - /** - * 支付宝 H5 支付 Client - */ - @InjectMocks - private AlipayWapPayClient client = new AlipayWapPayClient(randomLongId(), config); - - @BeforeEach - public void setUp() { - setClient(client); - } - - @Test - @DisplayName("支付宝 H5 支付:下单成功") - public void testUnifiedOrder_success() throws AlipayApiException { - // mock 方法 - String h5Body = randomString(); - Integer price = randomInteger(); - AlipayTradeWapPayResponse response = randomPojo(AlipayTradeWapPayResponse.class, o -> { - o.setSubCode(""); - o.setBody(h5Body); - }); - String notifyUrl = randomURL(); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> { - assertInstanceOf(AlipayTradeWapPayModel.class, request.getBizModel()); - AlipayTradeWapPayModel bizModel = (AlipayTradeWapPayModel) request.getBizModel(); - assertEquals(String.valueOf(price / 100.0), bizModel.getTotalAmount()); - assertEquals(notifyUrl, request.getNotifyUrl()); - return true; - }), eq(Method.GET.name()))).thenReturn(response); - // 准备请求参数 - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo, price); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(WAITING.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertEquals(PayOrderDisplayModeEnum.URL.getMode(), resp.getDisplayMode()); - assertEquals(response.getBody(), resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertNull(resp.getChannelErrorCode()); - assertNull(resp.getChannelErrorMsg()); - } - - @Test - @DisplayName("支付宝 H5 支付:渠道返回失败") - public void test_unified_order_channel_failed() throws AlipayApiException { - // mock 方法 - String subCode = randomString(); - String subMsg = randomString(); - AlipayTradeWapPayResponse response = randomPojo(AlipayTradeWapPayResponse.class, o -> { - o.setSubCode(subCode); - o.setSubMsg(subMsg); - }); - when(defaultAlipayClient.pageExecute(argThat((ArgumentMatcher) request -> true), - eq(Method.GET.name()))).thenReturn(response); - String outTradeNo = randomString(); - PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(randomURL(), outTradeNo, randomInteger()); - - // 调用 - PayOrderRespDTO resp = client.unifiedOrder(reqDTO); - // 断言 - assertEquals(CLOSED.getStatus(), resp.getStatus()); - assertEquals(outTradeNo, resp.getOutTradeNo()); - assertNull(resp.getChannelOrderNo()); - assertNull(resp.getChannelUserId()); - assertNull(resp.getSuccessTime()); - assertNull(resp.getDisplayMode()); - assertNull(resp.getDisplayContent()); - assertSame(response, resp.getRawData()); - assertEquals(subCode, resp.getChannelErrorCode()); - assertEquals(subMsg, resp.getChannelErrorMsg()); - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClientIntegrationTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClientIntegrationTest.java deleted file mode 100644 index 9af11ac3f..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClientIntegrationTest.java +++ /dev/null @@ -1,123 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; -import com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest; -import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest; -import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult; -import com.github.binarywang.wxpay.bean.result.WxPayRefundResult; -import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result; -import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.WxPayService; -import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.time.Duration; - -import static cn.iocoder.yudao.framework.pay.core.client.impl.weixin.AbstractWxPayClient.formatDateV2; - -/** - * {@link WxBarPayClient} 的集成测试,用于快速调试微信条码支付 - * - * @author 芋道源码 - */ -@Disabled -public class WxBarPayClientIntegrationTest { - - @Test - public void testPayV2() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV2(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起支付 - WxPayMicropayRequest request = WxPayMicropayRequest.newBuilder() - .outTradeNo(String.valueOf(System.currentTimeMillis())) - .body("测试支付-body") - .detail("测试支付-detail") - .totalFee(1) // 单位分 - .timeExpire(formatDateV2(LocalDateTimeUtils.addTime(Duration.ofMinutes(2)))) - .spbillCreateIp("127.0.0.1") - .authCode("134298744426278497") - .build(); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - WxPayMicropayResult response = client.micropay(request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - @Test - public void testParseRefundNotifyV2() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV2(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行解析 - String xml = "SUCCESS"; - WxPayRefundNotifyResult response = client.parseRefundNotifyResult(xml); - System.out.println(response.getReqInfo()); - } - - @Test - public void testRefundV2() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV2(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起退款 - WxPayRefundRequest request = new WxPayRefundRequest() - .setOutTradeNo("1689545667276") - .setOutRefundNo(String.valueOf(System.currentTimeMillis())) - .setRefundFee(1) - .setRefundDesc("就是想退了") - .setTotalFee(1); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - WxPayRefundResult response = client.refund(request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - @Test - public void testRefundV3() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV2(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起退款 - WxPayRefundV3Request request = new WxPayRefundV3Request() - .setOutTradeNo("1689506325635") - .setOutRefundNo(String.valueOf(System.currentTimeMillis())) - .setAmount(new WxPayRefundV3Request.Amount().setTotal(1).setRefund(1).setCurrency("CNY")) - .setReason("就是想退了"); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - WxPayRefundV3Result response = client.refundV3(request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - private WxPayConfig buildWxPayConfigV2() { - WxPayConfig config = new WxPayConfig(); - config.setAppId("wx62056c0d5e8db250"); - config.setMchId("1545083881"); - config.setMchKey("dS1ngeN63JLr3NRbvPH9AJy3MyUxZdim"); -// config.setSignType(WxPayConstants.SignType.MD5); - config.setKeyPath("/Users/yunai/Downloads/wx_pay/apiclient_cert.p12"); - return config; - } - -} diff --git a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClientIntegrationTest.java b/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClientIntegrationTest.java deleted file mode 100644 index 5e73601c2..000000000 --- a/yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClientIntegrationTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; - -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.WxPayService; -import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.time.Duration; - -import static cn.iocoder.yudao.framework.pay.core.client.impl.weixin.AbstractWxPayClient.formatDateV3; - -/** - * {@link WxNativePayClient} 的集成测试,用于快速调试微信扫码支付 - * - * @author 芋道源码 - */ -@Disabled -public class WxNativePayClientIntegrationTest { - - @Test - public void testPayV3() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV3(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起支付 - WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request() - .setOutTradeNo(String.valueOf(System.currentTimeMillis())) - .setDescription("测试支付-body") - .setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(1)) // 单位分 - .setTimeExpire(formatDateV3(LocalDateTimeUtils.addTime(Duration.ofMinutes(2)))) - .setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp("127.0.0.1")) - .setNotifyUrl("http://127.0.0.1:48080"); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - String response = client.createOrderV3(TradeTypeEnum.NATIVE, request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - @Test - public void testRefundV3() throws WxPayException { - // 创建 config 配置 - WxPayConfig config = buildWxPayConfigV3(); - // 创建 WxPayService 客户端 - WxPayService client = new WxPayServiceImpl(); - client.setConfig(config); - - // 执行发起退款 - WxPayRefundV3Request request = new WxPayRefundV3Request() - .setOutTradeNo("1689545729695") - .setOutRefundNo(String.valueOf(System.currentTimeMillis())) - .setAmount(new WxPayRefundV3Request.Amount().setTotal(1).setRefund(1).setCurrency("CNY")) - .setReason("就是想退了"); - System.out.println("========= request =========="); - System.out.println(JsonUtils.toJsonPrettyString(request)); - WxPayRefundV3Result response = client.refundV3(request); - System.out.println("========= response =========="); - System.out.println(JsonUtils.toJsonPrettyString(response)); - } - - private WxPayConfig buildWxPayConfigV3() { - WxPayConfig config = new WxPayConfig(); - config.setAppId("wx62056c0d5e8db250"); - config.setMchId("1545083881"); - config.setApiV3Key("459arNsYHl1mgkiO6H9ZH5KkhFXSxaA4"); -// config.setCertSerialNo(serialNo); - config.setPrivateCertPath("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"); - config.setPrivateKeyPath("/Users/yunai/Downloads/wx_pay/apiclient_key.pem"); - return config; - } - -} diff --git a/yudao-module-report/pom.xml b/yudao-module-report/pom.xml deleted file mode 100644 index 2c8aecedc..000000000 --- a/yudao-module-report/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - cn.iocoder.cloud - yudao - ${revision} - - 4.0.0 - - yudao-module-report-api - yudao-module-report-biz - - yudao-module-report - pom - - ${project.artifactId} - - report 模块,主要实现数据可视化报表等功能。 - - - diff --git a/yudao-module-report/yudao-module-report-api/pom.xml b/yudao-module-report/yudao-module-report-api/pom.xml deleted file mode 100644 index 7d7135538..000000000 --- a/yudao-module-report/yudao-module-report-api/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-report - ${revision} - - 4.0.0 - - yudao-module-report-api - jar - - ${project.artifactId} - - report 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - diff --git a/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/api/package-info.java b/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/api/package-info.java deleted file mode 100644 index 827bef3fd..000000000 --- a/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位,避免 api 目录无文件时,git 无法提交 - */ -package cn.iocoder.yudao.module.report.api; diff --git a/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/enums/ErrorCodeConstants.java b/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/enums/ErrorCodeConstants.java deleted file mode 100644 index 25629760e..000000000 --- a/yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.report.enums; - -import cn.iocoder.yudao.framework.common.exception.ErrorCode; - -/** - * Report 错误码枚举类 - * - * report 系统,使用 1-003-000-000 段 - */ -public interface ErrorCodeConstants { - - // ========== GoView 模块 1-003-000-000 ========== - ErrorCode GO_VIEW_PROJECT_NOT_EXISTS = new ErrorCode(1_003_000_000, "GoView 项目不存在"); - -} diff --git a/yudao-module-report/yudao-module-report-biz/Dockerfile b/yudao-module-report/yudao-module-report-biz/Dockerfile deleted file mode 100644 index 06cee9c70..000000000 --- a/yudao-module-report/yudao-module-report-biz/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性 -## 感谢复旦核博士的建议!灰子哥,牛皮! -FROM eclipse-temurin:8-jre - -## 创建目录,并使用它作为工作目录 -RUN mkdir -p /yudao-module-report-biz -WORKDIR /yudao-module-report-biz -## 将后端项目的 Jar 文件,复制到镜像中 -COPY ./target/yudao-module-report-biz.jar app.jar - -## 设置 TZ 时区 -## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖 -ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms512m -Xmx512m" - -## 暴露后端项目的 48080 端口 -EXPOSE 48084 - -## 启动后端项目 -CMD java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar diff --git a/yudao-module-report/yudao-module-report-biz/pom.xml b/yudao-module-report/yudao-module-report-biz/pom.xml deleted file mode 100644 index 3b0439d7f..000000000 --- a/yudao-module-report/yudao-module-report-biz/pom.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - - cn.iocoder.cloud - yudao-module-report - ${revision} - - 4.0.0 - - yudao-module-report-biz - jar - - ${project.artifactId} - - report 模块,主要实现数据可视化报表等功能: - 1. 基于「积木报表」实现,打印设计、报表设计、图形设计、大屏设计等。 - - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - - cn.iocoder.cloud - yudao-module-report-api - ${revision} - - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - cn.iocoder.cloud - yudao-module-infra-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - org.jeecgframework.jimureport - jimureport-spring-boot-starter - - - - xerces - xercesImpl - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/ReportServerApplication.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/ReportServerApplication.java deleted file mode 100644 index 759482a31..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/ReportServerApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.report; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * 项目的启动类 - * - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - * - * @author 芋道源码 - */ -@SpringBootApplication -public class ReportServerApplication { - - public static void main(String[] args) { - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - - SpringApplication.run(ReportServerApplication.class, args); - - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章 - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ajreport/package-info.java deleted file mode 100644 index e32b8b916..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ajreport/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewDataController.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewDataController.java deleted file mode 100644 index 6b28d1f51..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewDataController.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataGetBySqlReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataRespVO; -import cn.iocoder.yudao.module.report.service.goview.GoViewDataService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import java.util.*; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - GoView 数据", description = "提供 SQL、HTTP 等数据查询的能力") -@RestController -@RequestMapping("/report/go-view/data") -@Validated -public class GoViewDataController { - - @Resource - private GoViewDataService goViewDataService; - - @RequestMapping("/get-by-sql") - @Operation(summary = "使用 SQL 查询数据") - @PreAuthorize("@ss.hasPermission('report:go-view-data:get-by-sql')") - public CommonResult getDataBySQL(@Valid @RequestBody GoViewDataGetBySqlReqVO reqVO) { - return success(goViewDataService.getDataBySQL(reqVO.getSql())); - } - - @RequestMapping("/get-by-http") - @Operation(summary = "使用 HTTP 查询数据", description = "这个只是示例接口,实际应该每个查询,都要写一个接口") - @PreAuthorize("@ss.hasPermission('report:go-view-data:get-by-http')") - public CommonResult getDataByHttp( - @RequestParam(required = false) Map params, - @RequestBody(required = false) String body) { // params、body 按照需要去接收,这里仅仅是示例 - GoViewDataRespVO respVO = new GoViewDataRespVO(); - // 1. 数据维度 - respVO.setDimensions(Arrays.asList("日期", "PV", "UV")); // PV 是每天访问次数;UV 是每天访问人数 - // 2. 明细数据列表 - // 目前通过随机的方式生成。一般来说,这里你可以写逻辑来实现数据的返回 - respVO.setSource(new LinkedList<>()); - for (int i = 1; i <= 12; i++) { - String date = "2021-" + (i < 10 ? "0" + i : i); - Integer pv = RandomUtil.randomInt(1000, 10000); - Integer uv = RandomUtil.randomInt(100, 1000); - respVO.getSource().add(MapUtil.builder().put("日期", date) - .put("PV", pv).put("UV", uv).build()); - } - return success(respVO); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewProjectController.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewProjectController.java deleted file mode 100644 index 1916f0d07..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/GoViewProjectController.java +++ /dev/null @@ -1,76 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview; - -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectRespVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.convert.goview.GoViewProjectConvert; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import cn.iocoder.yudao.module.report.service.goview.GoViewProjectService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; - -@Tag(name = "管理后台 - GoView 项目") -@RestController -@RequestMapping("/report/go-view/project") -@Validated -public class GoViewProjectController { - - @Resource - private GoViewProjectService goViewProjectService; - - @PostMapping("/create") - @Operation(summary = "创建项目") - @PreAuthorize("@ss.hasPermission('report:go-view-project:create')") - public CommonResult createProject(@Valid @RequestBody GoViewProjectCreateReqVO createReqVO) { - return success(goViewProjectService.createProject(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新项目") - @PreAuthorize("@ss.hasPermission('report:go-view-project:update')") - public CommonResult updateProject(@Valid @RequestBody GoViewProjectUpdateReqVO updateReqVO) { - goViewProjectService.updateProject(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除 GoView 项目") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('report:go-view-project:delete')") - public CommonResult deleteProject(@RequestParam("id") Long id) { - goViewProjectService.deleteProject(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得项目") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('report:go-view-project:query')") - public CommonResult getProject(@RequestParam("id") Long id) { - GoViewProjectDO project = goViewProjectService.getProject(id); - return success(GoViewProjectConvert.INSTANCE.convert(project)); - } - - @GetMapping("/my-page") - @Operation(summary = "获得我的项目分页") - @PreAuthorize("@ss.hasPermission('report:go-view-project:query')") - public CommonResult> getMyProjectPage(@Valid PageParam pageVO) { - PageResult pageResult = goViewProjectService.getMyProjectPage( - pageVO, getLoginUserId()); - return success(GoViewProjectConvert.INSTANCE.convertPage(pageResult)); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataGetBySqlReqVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataGetBySqlReqVO.java deleted file mode 100644 index 785a4c5e0..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataGetBySqlReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.data; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; - -@Schema(description = "管理后台 - GoView 使用 SQL 查询数据 Request VO") -@Data -public class GoViewDataGetBySqlReqVO { - - @Schema(description = "SQL 语句", requiredMode = Schema.RequiredMode.REQUIRED, example = "SELECT * FROM user") - @NotEmpty(message = "SQL 语句不能为空") - private String sql; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataRespVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataRespVO.java deleted file mode 100644 index 38251ddfa..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/data/GoViewDataRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.data; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.util.List; -import java.util.Map; - -@Schema(description = "管理后台 - GoView 数据 Response VO") -@Data -public class GoViewDataRespVO { - - @Schema(description = "数据维度", requiredMode = Schema.RequiredMode.REQUIRED, example = "['product', 'data1', 'data2']") - private List dimensions; - - @Schema(description = "数据明细列表", requiredMode = Schema.RequiredMode.REQUIRED) - private List> source; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectCreateReqVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectCreateReqVO.java deleted file mode 100644 index dce5d9227..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectCreateReqVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.project; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - GoView 项目创建 Request VO") -@Data -public class GoViewProjectCreateReqVO { - - @Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotEmpty(message = "项目名称不能为空") - private String name; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectRespVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectRespVO.java deleted file mode 100644 index 3197d995c..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectRespVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.project; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - GoView 项目 Response VO") -@Data -public class GoViewProjectRespVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18993") - private Long id; - - @Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - @Schema(description = "发布状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer status; - - @Schema(description = "报表内容") // JSON 格式 - private String content; - - @Schema(description = "预览图片 URL", example = "https://www.iocoder.cn") - private String picUrl; - - @Schema(description = "项目备注", example = "你猜") - private String remark; - - @Schema(description = "创建人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private String creator; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectUpdateReqVO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectUpdateReqVO.java deleted file mode 100644 index f5c20046b..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/goview/vo/project/GoViewProjectUpdateReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.report.controller.admin.goview.vo.project; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - GoView 项目更新 Request VO") -@Data -public class GoViewProjectUpdateReqVO { - - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18993") - @NotNull(message = "编号不能为空") - private Long id; - - @Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - private String name; - - @Schema(description = "发布状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = CommonStatusEnum.class, message = "发布状态必须是 {value}") - private Integer status; - - @Schema(description = "报表内容") // JSON 格式 - private String content; - - @Schema(description = "预览图片 URL", example = "https://www.iocoder.cn") - private String picUrl; - - @Schema(description = "项目备注", example = "你猜") - private String remark; - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/package-info.java deleted file mode 100644 index ccbf9bb19..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 RESTful API 给前端: - * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 - * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 - */ -package cn.iocoder.yudao.module.report.controller; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/ajreport/package-info.java deleted file mode 100644 index 72860791f..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/ajreport/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 占位,后续删除 - */ -package cn.iocoder.yudao.module.report.convert.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/goview/GoViewProjectConvert.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/goview/GoViewProjectConvert.java deleted file mode 100644 index 9c993a19c..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/convert/goview/GoViewProjectConvert.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.report.convert.goview; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectRespVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface GoViewProjectConvert { - - GoViewProjectConvert INSTANCE = Mappers.getMapper(GoViewProjectConvert.class); - - GoViewProjectDO convert(GoViewProjectCreateReqVO bean); - - GoViewProjectDO convert(GoViewProjectUpdateReqVO bean); - - GoViewProjectRespVO convert(GoViewProjectDO bean); - - PageResult convertPage(PageResult page); - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ajreport/package-info.java deleted file mode 100644 index 922ec6fd4..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ajreport/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占位,待删除 - */ -package cn.iocoder.yudao.module.report.dal.dataobject.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/goview/GoViewProjectDO.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/goview/GoViewProjectDO.java deleted file mode 100644 index 38730d29e..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/goview/GoViewProjectDO.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.report.dal.dataobject.goview; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -/** - * GoView 项目表 - * - * 每个大屏图标,对应一个项目 - * - * @author 芋道源码 - */ -@TableName(value = "report_go_view_project", autoResultMap = true) // 由于 SQL Server 的 system_user 是关键字,所以使用 system_users -@KeySequence("report_go_view_project_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class GoViewProjectDO extends BaseDO { - - /** - * 编号,数据库自增 - */ - @TableId - private Long id; - /** - * 项目名称 - */ - private String name; - /** - * 预览图片 URL - */ - private String picUrl; - /** - * 报表内容 - * - * JSON 配置,使用字符串存储 - */ - private String content; - /** - * 发布状态 - * - * 0 - 已发布 - * 1 - 未发布 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} - */ - private Integer status; - /** - * 项目备注 - */ - private String remark; -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/ajreport/package-info.java deleted file mode 100644 index 0fb86173d..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/ajreport/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占位,待删除 - */ -package cn.iocoder.yudao.module.report.dal.mysql.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/goview/GoViewProjectMapper.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/goview/GoViewProjectMapper.java deleted file mode 100644 index af1ca6345..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/goview/GoViewProjectMapper.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.module.report.dal.mysql.goview; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface GoViewProjectMapper extends BaseMapperX { - - default PageResult selectPage(PageParam reqVO, Long userId) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eq(GoViewProjectDO::getCreator, userId) - .orderByDesc(GoViewProjectDO::getId)); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/config/JmReportConfiguration.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/config/JmReportConfiguration.java deleted file mode 100644 index 1946d052e..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/config/JmReportConfiguration.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.jmreport.config; - -import cn.iocoder.yudao.framework.security.config.SecurityProperties; -import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; -import cn.iocoder.yudao.module.report.framework.jmreport.core.service.JmReportTokenServiceImpl; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import org.jeecg.modules.jmreport.api.JmReportTokenServiceI; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * 积木报表的配置类 - * - * @author 芋道源码 - */ -@Configuration(proxyBeanMethods = false) -@ComponentScan(basePackages = "org.jeecg.modules.jmreport") // 扫描积木报表的包 -public class JmReportConfiguration { - - @Bean - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") - public JmReportTokenServiceI jmReportTokenService(OAuth2TokenApi oAuth2TokenApi, - PermissionApi permissionApi, - SecurityProperties securityProperties) { - return new JmReportTokenServiceImpl(oAuth2TokenApi, permissionApi, securityProperties); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/service/JmReportTokenServiceImpl.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/service/JmReportTokenServiceImpl.java deleted file mode 100644 index f45a8c88c..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/service/JmReportTokenServiceImpl.java +++ /dev/null @@ -1,153 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.jmreport.core.service; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; -import cn.iocoder.yudao.framework.security.config.SecurityProperties; -import cn.iocoder.yudao.framework.security.core.LoginUser; -import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; -import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; -import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; -import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum; -import lombok.RequiredArgsConstructor; -import org.jeecg.modules.jmreport.api.JmReportTokenServiceI; -import org.springframework.http.HttpHeaders; - -import javax.servlet.http.HttpServletRequest; -import java.util.Objects; - -/** - * {@link JmReportTokenServiceI} 实现类,提供积木报表的 Token 校验、用户信息的查询等功能 - * - * @author 随心 - */ -@RequiredArgsConstructor -public class JmReportTokenServiceImpl implements JmReportTokenServiceI { - - /** - * 积木 token head 头 - */ - private static final String JM_TOKEN_HEADER = "X-Access-Token"; - /** - * auth 相关格式 - */ - private static final String AUTHORIZATION_FORMAT = SecurityFrameworkUtils.AUTHORIZATION_BEARER + " %s"; - - private final OAuth2TokenApi oauth2TokenApi; - private final PermissionApi permissionApi; - - private final SecurityProperties securityProperties; - - /** - * 自定义 API 数据集appian自定义 Header,解决 Token 传递。 - * 参考 api数据集token机制详解 文档 - * - * @return 新 head - */ - @Override - public HttpHeaders customApiHeader() { - // 读取积木标标系统的 token - HttpServletRequest request = ServletUtils.getRequest(); - String token = request.getHeader(JM_TOKEN_HEADER); - - // 设置到 yudao 系统的 token - HttpHeaders headers = new HttpHeaders(); - headers.add(securityProperties.getTokenHeader(), String.format(AUTHORIZATION_FORMAT, token)); - return headers; - } - - /** - * 校验 Token 是否有效,即验证通过 - * - * @param token JmReport 前端传递的 token - * @return 是否认证通过 - */ - @Override - public Boolean verifyToken(String token) { - Long userId = SecurityFrameworkUtils.getLoginUserId(); - if (!Objects.isNull(userId)) { - return true; - } - return buildLoginUserByToken(token) != null; - } - - /** - * 获得用户编号 - *

- * 虽然方法名获得的是 username,实际对应到项目中是用户编号 - * - * @param token JmReport 前端传递的 token - * @return 用户编号 - */ - @Override - public String getUsername(String token) { - Long userId = SecurityFrameworkUtils.getLoginUserId(); - if (ObjectUtil.isNotNull(userId)) { - return String.valueOf(userId); - } - LoginUser user = buildLoginUserByToken(token); - return user == null ? null : String.valueOf(user.getId()); - } - - /** - * 基于 token 构建登录用户 - * - * @param token token - * @return 返回 token 对应的用户信息 - */ - private LoginUser buildLoginUserByToken(String token) { - if (StrUtil.isEmpty(token)) { - return null; - } - // TODO 如下的实现不算特别优雅,主要咱是不想搞的太复杂,所以参考对应的 Filter 先实现了 - - // ① 参考 TokenAuthenticationFilter 的认证逻辑(Security 的上下文清理,交给 Spring Security 完成) - // 目的:实现基于 JmReport 前端传递的 token,实现认证 - TenantContextHolder.setIgnore(true); // 忽略租户,保证可查询到 token 信息 - LoginUser user = null; - try { - OAuth2AccessTokenCheckRespDTO accessToken = oauth2TokenApi.checkAccessToken(token).getCheckedData(); - if (accessToken == null) { - return null; - } - user = new LoginUser().setId(accessToken.getUserId()).setUserType(accessToken.getUserType()) - .setTenantId(accessToken.getTenantId()).setScopes(accessToken.getScopes()); - } catch (ServiceException ignored) { - // do nothing:如果报错,说明认证失败,则返回 false 即可 - } - if (user == null) { - return null; - } - SecurityFrameworkUtils.setLoginUser(user, WebFrameworkUtils.getRequest()); - - // ② 参考 TenantContextWebFilter 实现(Tenant 的上下文清理,交给 TenantContextWebFilter 完成) - // 目的:基于 LoginUser 获得到的租户编号,设置到 Tenant 上下文,避免查询数据库时的报错 - TenantContextHolder.setIgnore(false); - TenantContextHolder.setTenantId(user.getTenantId()); - return user; - } - - @Override - public String[] getRoles(String token) { - // 参见文档 https://help.jeecg.com/jimureport/prodSafe.html 文档 - // 适配:如果是本系统的管理员,则转换成 jimu 报表的管理员 - Long userId = SecurityFrameworkUtils.getLoginUserId(); - return permissionApi.hasAnyRoles(userId, RoleCodeEnum.SUPER_ADMIN.getCode()).getCheckedData() - ? new String[]{"admin"} : null; - } - - @Override - public String getTenantId() { - // 补充说明:不能直接通过 TenantContext 获取,因为 jimu 报表前端请求时,没有带上 tenant-id Header - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - if (loginUser == null) { - return null; - } - return StrUtil.toStringOrNull(loginUser.getTenantId()); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/web/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/web/package-info.java deleted file mode 100644 index e082e3bdc..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/web/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位,后续会基于 Filter 实现积木报表的认证等功能,替代 {@link cn.iocoder.yudao.module.report.framework.jmreport.core.service.JmReportTokenServiceImpl} - */ -package cn.iocoder.yudao.module.report.framework.jmreport.core.web; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/package-info.java deleted file mode 100644 index c2163d8cd..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 report 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.report.framework; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/config/SecurityConfiguration.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index 05b009661..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.report.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Report 模块的 Security 配置 - */ -@Configuration("reportSecurityConfiguration") -public class SecurityConfiguration { - - @Bean("reportAuthorizeRequestsCustomizer") - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // 积木报表 - registry.antMatchers("/jmreport/**").permitAll(); - } - - }; - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/core/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/core/package-info.java deleted file mode 100644 index 61083268f..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.report.framework.security.core; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/package-info.java deleted file mode 100644 index 3306c0ebb..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * report 模块,主要实现数据可视化报表等功能: - * 1. 基于「积木报表」实现,打印设计、报表设计、图形设计、大屏设计等。URL 前缀是 /jmreport,表名前缀是 jimu_ - * - * 由于「积木报表」的大屏设计器需要收费,后续会自研,对应的是: - * 1. Controller URL:以 /report/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 report_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.report; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ajreport/package-info.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ajreport/package-info.java deleted file mode 100644 index 2512e50ed..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ajreport/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:占位,待删除 - */ -package cn.iocoder.yudao.module.report.service.ajreport; diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataService.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataService.java deleted file mode 100644 index b912373b1..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataService.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataRespVO; - -/** - * GoView 数据 Service 接口 - * - * @author 芋道源码 - */ -public interface GoViewDataService { - - /** - * 使用 SQL 查询数据 - * - * @param sql SQL 语句 - * @return 数据 - */ - GoViewDataRespVO getDataBySQL(String sql); - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImpl.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImpl.java deleted file mode 100644 index 8938d3e74..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataRespVO; -import com.google.common.collect.Maps; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.support.rowset.SqlRowSet; -import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.Map; - -/** - * GoView 数据 Service 实现类 - * - * 补充说明: - * 1. 目前默认使用 jdbcTemplate 查询项目配置的数据源。如果你想查询其它数据源,可以新建对应数据源的 jdbcTemplate 来实现。 - * 2. 默认数据源是 MySQL 关系数据源,可能数据量比较大的情况下,会比较慢,可以考虑后续使用 Click House 等等。 - * - * @author 芋道源码 - */ -@Service -@Validated -public class GoViewDataServiceImpl implements GoViewDataService { - - @Resource - private JdbcTemplate jdbcTemplate; - - @Override - public GoViewDataRespVO getDataBySQL(String sql) { - // 1. 执行查询 - SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet(sql); - - // 2. 构建返回结果 - GoViewDataRespVO respVO = new GoViewDataRespVO(); - // 2.1 解析元数据 - SqlRowSetMetaData metaData = sqlRowSet.getMetaData(); - String[] columnNames = metaData.getColumnNames(); - respVO.setDimensions(Arrays.asList(columnNames)); - // 2.2 解析数据明细 - respVO.setSource(new LinkedList<>()); // 由于数据量不确认,使用 LinkedList 虽然内存占用大一点,但是不存在扩容复制的问题 - while (sqlRowSet.next()) { - Map data = Maps.newHashMapWithExpectedSize(columnNames.length); - for (String columnName : columnNames) { - data.put(columnName, sqlRowSet.getObject(columnName)); - } - respVO.getSource().add(data); - } - return respVO; - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectService.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectService.java deleted file mode 100644 index b171c5905..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectService.java +++ /dev/null @@ -1,57 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; - -import javax.validation.Valid; - -/** - * GoView 项目 Service 接口 - * - * @author 芋道源码 - */ -public interface GoViewProjectService { - - /** - * 创建项目 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createProject(@Valid GoViewProjectCreateReqVO createReqVO); - - /** - * 更新项目 - * - * @param updateReqVO 更新信息 - */ - void updateProject(@Valid GoViewProjectUpdateReqVO updateReqVO); - - /** - * 删除项目 - * - * @param id 编号 - */ - void deleteProject(Long id); - - /** - * 获得项目 - * - * @param id 编号 - * @return 项目 - */ - GoViewProjectDO getProject(Long id); - - /** - * 获得我的项目分页 - * - * @param pageReqVO 分页查询 - * @param userId 用户编号 - * @return GoView 项目分页 - */ - PageResult getMyProjectPage(PageParam pageReqVO, Long userId); - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImpl.java b/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImpl.java deleted file mode 100644 index 2b05052f7..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.convert.goview.GoViewProjectConvert; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import cn.iocoder.yudao.module.report.dal.mysql.goview.GoViewProjectMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.GO_VIEW_PROJECT_NOT_EXISTS; - -/** - * GoView 项目 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class GoViewProjectServiceImpl implements GoViewProjectService { - - @Resource - private GoViewProjectMapper goViewProjectMapper; - - @Override - public Long createProject(GoViewProjectCreateReqVO createReqVO) { - // 插入 - GoViewProjectDO goViewProject = GoViewProjectConvert.INSTANCE.convert(createReqVO) - .setStatus(CommonStatusEnum.DISABLE.getStatus()); - goViewProjectMapper.insert(goViewProject); - // 返回 - return goViewProject.getId(); - } - - @Override - public void updateProject(GoViewProjectUpdateReqVO updateReqVO) { - // 校验存在 - validateProjectExists(updateReqVO.getId()); - // 更新 - GoViewProjectDO updateObj = GoViewProjectConvert.INSTANCE.convert(updateReqVO); - goViewProjectMapper.updateById(updateObj); - } - - @Override - public void deleteProject(Long id) { - // 校验存在 - validateProjectExists(id); - // 删除 - goViewProjectMapper.deleteById(id); - } - - private void validateProjectExists(Long id) { - if (goViewProjectMapper.selectById(id) == null) { - throw exception(GO_VIEW_PROJECT_NOT_EXISTS); - } - } - - @Override - public GoViewProjectDO getProject(Long id) { - return goViewProjectMapper.selectById(id); - } - - @Override - public PageResult getMyProjectPage(PageParam pageReqVO, Long userId) { - return goViewProjectMapper.selectPage(pageReqVO, userId); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/application-dev.yaml b/yudao-module-report/yudao-module-report-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index 3508f409d..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,97 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - demo: true # 开启演示模式 diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/application-local.yaml b/yudao-module-report/yudao-module-report-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 286556d8e..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,120 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: 123456 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.report.dal.mysql: debug - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - security: - mock-enable: true - xss: - enable: false - exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 - - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/application.yaml b/yudao-module-report/yudao-module-report-biz/src/main/resources/application.yaml deleted file mode 100644 index f5e0022d7..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,106 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -# 积木报表配置 -jeecg: - jmreport: - saas-mode: tenant - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.report - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - tenant: # 多租户相关配置项 - enable: true - -debug: false diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/bootstrap-local.yaml b/yudao-module-report/yudao-module-report-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/bootstrap.yaml b/yudao-module-report/yudao-module-report-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index caf41b17b..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: report-server - - profiles: - active: local - -server: - port: 48084 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/logback-spring.xml b/yudao-module-report/yudao-module-report-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImplTest.java b/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImplTest.java deleted file mode 100644 index 87b78b8b8..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewDataServiceImplTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.data.GoViewDataRespVO; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.support.rowset.SqlRowSet; -import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; - -import javax.annotation.Resource; -import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -@Import(GoViewDataServiceImpl.class) -public class GoViewDataServiceImplTest extends BaseDbUnitTest { - - @Resource - private GoViewDataServiceImpl goViewDataService; - - @MockBean - private JdbcTemplate jdbcTemplate; - - @Test - public void testGetDataBySQL() { - // 准备参数 - String sql = "SELECT id, name FROM system_users"; - // mock 方法 - SqlRowSet sqlRowSet = mock(SqlRowSet.class); - when(jdbcTemplate.queryForRowSet(eq(sql))).thenReturn(sqlRowSet); - // mock 元数据 - SqlRowSetMetaData metaData = mock(SqlRowSetMetaData.class); - when(sqlRowSet.getMetaData()).thenReturn(metaData); - when(metaData.getColumnNames()).thenReturn(new String[]{"id", "name"}); - // mock 数据明细 - when(sqlRowSet.next()).thenReturn(true).thenReturn(true).thenReturn(false); - when(sqlRowSet.getObject("id")).thenReturn(1L).thenReturn(2L); - when(sqlRowSet.getObject("name")).thenReturn("芋道源码").thenReturn("芋道"); - - // 调用 - GoViewDataRespVO dataBySQL = goViewDataService.getDataBySQL(sql); - // 断言 - assertEquals(Arrays.asList("id", "name"), dataBySQL.getDimensions()); - assertEquals(2, dataBySQL.getDimensions().size()); - assertEquals(2, dataBySQL.getSource().get(0).size()); - assertEquals(1L, dataBySQL.getSource().get(0).get("id")); - assertEquals("芋道源码", dataBySQL.getSource().get(0).get("name")); - assertEquals(2, dataBySQL.getSource().get(1).size()); - assertEquals(2L, dataBySQL.getSource().get(1).get("id")); - assertEquals("芋道", dataBySQL.getSource().get(1).get("name")); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImplTest.java b/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImplTest.java deleted file mode 100644 index 2f6bfae7b..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/goview/GoViewProjectServiceImplTest.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.report.service.goview; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectCreateReqVO; -import cn.iocoder.yudao.module.report.controller.admin.goview.vo.project.GoViewProjectUpdateReqVO; -import cn.iocoder.yudao.module.report.dal.dataobject.goview.GoViewProjectDO; -import cn.iocoder.yudao.module.report.dal.mysql.goview.GoViewProjectMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.GO_VIEW_PROJECT_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link GoViewProjectServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(GoViewProjectServiceImpl.class) -public class GoViewProjectServiceImplTest extends BaseDbUnitTest { - - @Resource - private GoViewProjectServiceImpl goViewProjectService; - - @Resource - private GoViewProjectMapper goViewProjectMapper; - - @Test - public void testCreateProject_success() { - // 准备参数 - GoViewProjectCreateReqVO reqVO = randomPojo(GoViewProjectCreateReqVO.class); - - // 调用 - Long goViewProjectId = goViewProjectService.createProject(reqVO); - // 断言 - assertNotNull(goViewProjectId); - // 校验记录的属性是否正确 - GoViewProjectDO goViewProject = goViewProjectMapper.selectById(goViewProjectId); - assertPojoEquals(reqVO, goViewProject); - } - - @Test - public void testUpdateProject_success() { - // mock 数据 - GoViewProjectDO dbGoViewProject = randomPojo(GoViewProjectDO.class); - goViewProjectMapper.insert(dbGoViewProject);// @Sql: 先插入出一条存在的数据 - // 准备参数 - GoViewProjectUpdateReqVO reqVO = randomPojo(GoViewProjectUpdateReqVO.class, o -> { - o.setId(dbGoViewProject.getId()); // 设置更新的 ID - o.setStatus(randomCommonStatus()); - }); - - // 调用 - goViewProjectService.updateProject(reqVO); - // 校验是否更新正确 - GoViewProjectDO goViewProject = goViewProjectMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, goViewProject); - } - - @Test - public void testUpdateProject_notExists() { - // 准备参数 - GoViewProjectUpdateReqVO reqVO = randomPojo(GoViewProjectUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> goViewProjectService.updateProject(reqVO), GO_VIEW_PROJECT_NOT_EXISTS); - } - - @Test - public void testDeleteProject_success() { - // mock 数据 - GoViewProjectDO dbGoViewProject = randomPojo(GoViewProjectDO.class); - goViewProjectMapper.insert(dbGoViewProject);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbGoViewProject.getId(); - - // 调用 - goViewProjectService.deleteProject(id); - // 校验数据不存在了 - assertNull(goViewProjectMapper.selectById(id)); - } - - @Test - public void testDeleteProject_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> goViewProjectService.deleteProject(id), GO_VIEW_PROJECT_NOT_EXISTS); - } - - @Test - public void testGetProject() { - // mock 数据 - GoViewProjectDO dbGoViewProject = randomPojo(GoViewProjectDO.class); - goViewProjectMapper.insert(dbGoViewProject);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbGoViewProject.getId(); - - // 调用 - GoViewProjectDO goViewProject = goViewProjectService.getProject(id); - // 断言 - assertPojoEquals(dbGoViewProject, goViewProject); - } - - @Test - public void testGetMyGoViewProjectPage() { - // mock 数据 - GoViewProjectDO dbGoViewProject = randomPojo(GoViewProjectDO.class, o -> { // 等会查询到 - o.setCreator("1"); - }); - goViewProjectMapper.insert(dbGoViewProject); - // 测试 userId 不匹配 - goViewProjectMapper.insert(cloneIgnoreId(dbGoViewProject, o -> o.setCreator("2"))); - // 准备参数 - PageParam reqVO = new PageParam(); - Long userId = 1L; - - // 调用 - PageResult pageResult = goViewProjectService.getMyProjectPage(reqVO, userId); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbGoViewProject, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-report/yudao-module-report-biz/src/test/resources/application-unit-test.yaml b/yudao-module-report/yudao-module-report-biz/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 63ba0991f..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,51 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis-plus: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - global-config: - db-config: - id-type: AUTO # H2 主键递增 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module.report diff --git a/yudao-module-report/yudao-module-report-biz/src/test/resources/logback.xml b/yudao-module-report/yudao-module-report-biz/src/test/resources/logback.xml deleted file mode 100644 index daf756bff..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/clean.sql b/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/clean.sql deleted file mode 100644 index 152915143..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/clean.sql +++ /dev/null @@ -1 +0,0 @@ -DELETE FROM "report_go_view_project"; \ No newline at end of file diff --git a/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/create_tables.sql b/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/create_tables.sql deleted file mode 100644 index a77397fea..000000000 --- a/yudao-module-report/yudao-module-report-biz/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE IF NOT EXISTS "report_go_view_project" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar NOT NULL, - "pic_url" varchar, - "content" varchar, - "status" varchar NOT NULL, - "remark" varchar, - "creator" varchar DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT 'GoView 项目表'; diff --git a/yudao-ui/yudao-ui-admin-uniapp/README.md b/yudao-ui/yudao-ui-admin-uniapp/README.md deleted file mode 100644 index 9f722091f..000000000 --- a/yudao-ui/yudao-ui-admin-uniapp/README.md +++ /dev/null @@ -1,4 +0,0 @@ -基于 Vue + uni-app 实现的管理后台。仓库地址: - -* Gitee: -* GitHub: diff --git a/yudao-ui/yudao-ui-admin-vben/README.md b/yudao-ui/yudao-ui-admin-vben/README.md deleted file mode 100644 index c6a866cca..000000000 --- a/yudao-ui/yudao-ui-admin-vben/README.md +++ /dev/null @@ -1,4 +0,0 @@ -基于 Vue3 + vben(ant-design-vue) 实现的管理后台。仓库地址: - -* Gitee: -* GitHub: diff --git a/yudao-ui/yudao-ui-admin-vue2/README.md b/yudao-ui/yudao-ui-admin-vue2/README.md deleted file mode 100644 index f1fbdadd0..000000000 --- a/yudao-ui/yudao-ui-admin-vue2/README.md +++ /dev/null @@ -1,4 +0,0 @@ -基于 Vue2 + element-ui 实现的管理后台。仓库地址: - -* Gitee: -* GitHub: diff --git a/yudao-ui/yudao-ui-admin-vue3/README.md b/yudao-ui/yudao-ui-admin-vue3/README.md deleted file mode 100644 index 6983c52eb..000000000 --- a/yudao-ui/yudao-ui-admin-vue3/README.md +++ /dev/null @@ -1,4 +0,0 @@ -基于 Vue3 + element-plus 实现的管理后台。仓库地址: - -* Gitee: -* GitHub: diff --git a/yudao-ui/yudao-ui-mall-uniapp/README.md b/yudao-ui/yudao-ui-mall-uniapp/README.md deleted file mode 100644 index 57b18686a..000000000 --- a/yudao-ui/yudao-ui-mall-uniapp/README.md +++ /dev/null @@ -1,8 +0,0 @@ -仓库地址: - -* Gitee: -* GitHub: - -功能列表: -* 基于 uniapp 开发,支持微信小程序、微信公众号、H5 移动端,未来会支持支付宝小程序、抖音小程序等 -* 支持 SaaS 多租户,可满足商品、订单、支付、会员、优惠券、秒杀、拼团、砍价、分销、积分等多种经营需求