feat(work): 实现订单指派时自动改价功能

在订单指派给设计师时,自动计算改价金额。使用jsPrice或price作为基准价,按10%比例计算改价,结果四舍五入到最接近的10的倍数。同时更新多个配置文件以适配新环境。
This commit is contained in:
huacracker
2026-03-10 11:23:34 +08:00
parent 4cb6d6fd20
commit 259526b31b
12 changed files with 107 additions and 65 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

BIN
ruoyi-admin/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -127,6 +127,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
<executions>
<execution>
<goals>

View File

@@ -8,25 +8,25 @@ spring.boot.admin.client:
metadata:
username: ${spring.boot.admin.client.username}
userpassword: ${spring.boot.admin.client.password}
username: @monitor.username@
password: @monitor.password@
username: admin
password: admin
--- # snail-job 配置
snail-job:
enabled: false
# 需要在 SnailJob 后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务
group: "ruoyi_group"
# SnailJob 接入验证令牌 详见 script/sql/snail_job.sql `sj_group_config` 表
token: "SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT"
server:
host: 127.0.0.1
port: 17888
# 详见 script/sql/snail_job.sql `sj_namespace` 表
namespace: ${spring.profiles.active}
# 随主应用端口飘逸
port: 2${server.port}
# 客户端ip指定
host: 127.0.0.1
#--- # snail-job 配置
#snail-job:
# enabled: false
# # 需要在 SnailJob 后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务
# group: "ruoyi_group"
# # SnailJob 接入验证令牌 详见 script/sql/snail_job.sql `sj_group_config` 表
# token: "SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT"
# server:
# host: 127.0.0.1
# port: 17888
# # 详见 script/sql/snail_job.sql `sj_namespace` 表
# namespace: ${spring.profiles.active}
# # 随主应用端口飘逸
# port: 2${server.port}
# # 客户端ip指定
# host: 127.0.0.1
--- # 数据源配置
spring:
@@ -47,22 +47,18 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://192.168.1.203:3306/oademo?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
url: jdbc:mysql://220.205.16.51:23306/oademo?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: oademo
password: 68i5XDFNXwWX2Fxd
# url: jdbc:mysql://localhost:13306/new_xgt?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username: root
# password: root
password: djj7z3dY6YkSEzeS
# 从库数据源
slave:
lazy: false
type: ${spring.datasource.type}
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://jcs-mysql.52o.site:13306/erpdemo20260109?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: erpdemo20260109
password: s5y46y76P2S5753T
url: jdbc:mysql://220.205.16.51:23306/oademo?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: oademo
password: djj7z3dY6YkSEzeS
hikari:
# 最大连接池数量
@@ -107,7 +103,7 @@ redisson:
# 单节点配置
singleServerConfig:
# 客户端名称
clientName: ${ruoyi.name}
clientName: XGT-ADMIN
# 最小空闲连接数
connectionMinimumIdleSize: 8
# 连接池大小

View File

@@ -11,8 +11,8 @@ spring.boot.admin.client:
metadata:
username: ${spring.boot.admin.client.username}
userpassword: ${spring.boot.admin.client.password}
username: @monitor.username@
password: @monitor.password@
username: admin
password: admin
--- # snail-job 配置
snail-job:
@@ -50,9 +50,9 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://123.60.57.176:3306/sjzxerp20250618?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: sjzx0618
password: 2b1%Hk3#1Uolol
url: jdbc:mysql://220.205.16.51:23306/oademo?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: oademo
password: djj7z3dY6YkSEzeS
# url: jdbc:mysql://localhost:13306/new_xgt?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username: root
@@ -63,9 +63,9 @@ spring:
lazy: false
type: ${spring.datasource.type}
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://jcs-mysql.52o.site:13306/erpdemo20260109?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: erpdemo20260109
password: s5y46y76P2S5753T
url: jdbc:mysql://220.205.16.51:23306/oademo?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: oademo
password: djj7z3dY6YkSEzeS
# url: jdbc:mysql://localhost:3306/new_xgt?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username: root

View File

@@ -3,7 +3,7 @@ ruoyi:
# 名称
name: XGT-ADMIN
# 版本
version: ${revision}
version: 5.2.3
# 版权年份
copyrightYear: 2024
@@ -44,7 +44,7 @@ server:
# 日志配置
logging:
level:
org.dromara: @logging.level@
org.dromara: info
org.springframework: warn
org.mybatis.spring.mapper: error
org.apache.fury: warn
@@ -71,7 +71,7 @@ spring:
# 国际化资源文件路径
basename: i18n/messages
profiles:
active: @profiles.active@
active: dev
# 文件上传
servlet:
multipart:
@@ -200,11 +200,11 @@ springdoc:
# persistAuthorization: true
info:
# 标题
title: '标题:${ruoyi.name}效果图业务系统_接口文档'
title: '标题:若依效果图业务系统_接口文档'
# 描述
description: '描述:效果图业务系统接口文档'
# 版本
version: '版本号: ${ruoyi.version}'
version: '版本号: 5.2.3'
# 作者信息
contact:
name: Maosw

View File

@@ -1,4 +1,4 @@
Application Version: ${revision}
Application Version: 5.2.3
Spring Boot Version: ${spring-boot.version}
__________ _____.___.__ ____ ____ __________.__
\______ \__ __ ____\__ | |__| \ \ / /_ __ ____ \______ \ | __ __ ______

BIN
ruoyi-common/.DS_Store vendored Normal file

Binary file not shown.

BIN
ruoyi-extend/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -4,7 +4,7 @@ spring:
application:
name: ruoyi-monitor-admin
profiles:
active: @profiles.active@
active: dev
logging:
config: classpath:logback-plus.xml
@@ -13,8 +13,8 @@ logging:
spring:
security:
user:
name: @monitor.username@
password: @monitor.password@
name: admin
password: admin
boot:
admin:
ui:

BIN
ruoyi-modules/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -774,6 +774,9 @@ public class TpOrderServiceImpl extends MPJBaseServiceImpl<TpOrderMapper,TpOrder
SysUser user = sysUserMapper.selectById(userId);
// 获取默认改价比例10%
BigDecimal discountRate = new BigDecimal("0.10");
List<TpOrder> orderList = new ArrayList<>();
for (Long orderId : orderIds){
TpOrder order = baseMapper.selectById(orderId);
@@ -784,6 +787,35 @@ public class TpOrderServiceImpl extends MPJBaseServiceImpl<TpOrderMapper,TpOrder
order.setDeptIdJs(dept.getDeptId());
order.setAncestorsJs(dept.getAncestors());
// ===== 自动改价逻辑开始 =====
// 启用自动改价
order.setIsC(2);
// 计算自动改价价格优先使用jsPrice如果为空则使用price
BigDecimal basePrice = order.getJsPrice();
System.out.println("[自动改价调试] 订单ID=" + order.getId() + ", jsPrice=" + order.getJsPrice() + ", price=" + order.getPrice());
if (basePrice == null || basePrice.compareTo(BigDecimal.ZERO) <= 0) {
basePrice = order.getPrice();
System.out.println("[自动改价调试] jsPrice为空或<=0使用price=" + basePrice);
}
if (basePrice != null && basePrice.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal zGjPrice = basePrice.multiply(discountRate);
System.out.println("[自动改价调试] 计算改价: " + basePrice + " * 10% = " + zGjPrice);
// 10取整处理四舍五入到最接近的10的倍数
zGjPrice = roundToNearestTen(zGjPrice);
System.out.println("[自动改价调试] 取整后改价: " + zGjPrice);
order.setZGjPrice(zGjPrice);
order.setGjPrice(zGjPrice);
System.out.println("[自动改价调试] 设置成功: zGjPrice=" + zGjPrice + ", gjPrice=" + zGjPrice);
} else {
System.out.println("[自动改价调试] 未设置改价: basePrice=" + basePrice);
}
// ===== 自动改价逻辑结束 =====
boolean res = saveOrderRecord(order.getId(),"订单分图","订单:"+order.getOrderId()+" 指派给"+user.getNickName()+" 成功",1,null);
if(!res){
throw new ServiceException("订单指派失败");
@@ -793,6 +825,16 @@ public class TpOrderServiceImpl extends MPJBaseServiceImpl<TpOrderMapper,TpOrder
return baseMapper.updateBatchById(orderList);
}
/**
* 将金额四舍五入到最接近的10的倍数
* @param amount 原始金额
* @return 取整后的金额
*/
private BigDecimal roundToNearestTen(BigDecimal amount) {
return amount.divide(new BigDecimal("10"), 0, RoundingMode.HALF_UP)
.multiply(new BigDecimal("10"));
}
/**
* 订单取消指派
* @param orderId