Compare commits
1 Commits
259526b31b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d6efb3e4e |
@@ -130,6 +130,7 @@
|
||||
<configuration>
|
||||
<fork>true</fork>
|
||||
<addResources>true</addResources>
|
||||
<mainClass>org.dromara.XgtAdminApplication</mainClass>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -80,13 +80,13 @@ spring:
|
||||
spring.data:
|
||||
redis:
|
||||
# 地址
|
||||
host: jcs-mysql.52o.site
|
||||
host: 220.205.16.51
|
||||
# 端口,默认为6379
|
||||
port: 26739
|
||||
# 数据库索引
|
||||
database: 1
|
||||
# redis 密码必须配置
|
||||
password: 3NpZYtRLr6EnfASr
|
||||
password: yahsj5EpPJzpG4cY
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
@@ -102,6 +102,12 @@ redisson:
|
||||
nettyThreads: 8
|
||||
# 单节点配置
|
||||
singleServerConfig:
|
||||
# 服务器地址
|
||||
address: redis://220.205.16.51:26739
|
||||
# 密码
|
||||
password: yahsj5EpPJzpG4cY
|
||||
# 数据库
|
||||
database: 1
|
||||
# 客户端名称
|
||||
clientName: XGT-ADMIN
|
||||
# 最小空闲连接数
|
||||
|
||||
@@ -88,6 +88,7 @@ public class SysDeptController extends BaseController {
|
||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysDeptBo dept) {
|
||||
// System.out.println("[Controller] 接收到的部门数据: deptId=" + dept.getDeptId() + ", isAutoChangePrice=" + dept.getIsAutoChangePrice() + ", changePriceRate=" + dept.getChangePriceRate());
|
||||
Long deptId = dept.getDeptId();
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
if (!deptService.checkDeptNameUnique(dept)) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.dromara.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@@ -8,6 +9,7 @@ import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.tenant.core.TenantEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 部门表 sys_dept
|
||||
@@ -75,6 +77,18 @@ public class SysDept extends TenantEntity {
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 是否自动改价(1=否,2=是)
|
||||
*/
|
||||
@TableField("is_auto_change_price")
|
||||
private Integer isAutoChangePrice;
|
||||
|
||||
/**
|
||||
* 改价比例(如0.1000表示10%)
|
||||
*/
|
||||
@TableField("change_price_rate")
|
||||
private BigDecimal changePriceRate;
|
||||
|
||||
/**
|
||||
* 祖级列表
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,8 @@ import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.system.domain.SysDept;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 部门业务对象 sys_dept
|
||||
*
|
||||
@@ -93,4 +95,14 @@ public class SysDeptBo extends BaseEntity {
|
||||
*/
|
||||
private Integer isNull;
|
||||
|
||||
/**
|
||||
* 是否自动改价(1=否,2=是)
|
||||
*/
|
||||
private Integer isAutoChangePrice;
|
||||
|
||||
/**
|
||||
* 改价比例(如0.1000表示10%)
|
||||
*/
|
||||
private BigDecimal changePriceRate;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.dromara.system.domain.SysDept;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -99,4 +100,14 @@ public class SysDeptVo implements Serializable {
|
||||
@ExcelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 是否自动改价(1=否,2=是)
|
||||
*/
|
||||
private Integer isAutoChangePrice;
|
||||
|
||||
/**
|
||||
* 改价比例(如0.1000表示10%)
|
||||
*/
|
||||
private BigDecimal changePriceRate;
|
||||
|
||||
}
|
||||
|
||||
@@ -272,11 +272,28 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
*/
|
||||
@Caching(evict = {
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#bo.deptId"),
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, allEntries = true)
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, allEntries = true),
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, allEntries = true)
|
||||
})
|
||||
@Override
|
||||
public int updateDept(SysDeptBo bo) {
|
||||
SysDept dept = MapstructUtils.convert(bo, SysDept.class);
|
||||
// 强制清除所有部门缓存,避免改价配置缓存问题
|
||||
CacheUtils.clear(CacheNames.SYS_DEPT);
|
||||
// System.out.println("[部门更新] 接收到的数据: deptId=" + bo.getDeptId() + ", isAutoChangePrice=" + bo.getIsAutoChangePrice() + ", changePriceRate=" + bo.getChangePriceRate());
|
||||
SysDept dept = new SysDept();
|
||||
// 手动复制所有字段
|
||||
dept.setDeptId(bo.getDeptId());
|
||||
dept.setParentId(bo.getParentId());
|
||||
dept.setDeptName(bo.getDeptName());
|
||||
dept.setDeptCategory(bo.getDeptCategory());
|
||||
dept.setOrderNum(bo.getOrderNum());
|
||||
dept.setLeader(bo.getLeader());
|
||||
dept.setPhone(bo.getPhone());
|
||||
dept.setEmail(bo.getEmail());
|
||||
dept.setStatus(bo.getStatus());
|
||||
dept.setIsAutoChangePrice(bo.getIsAutoChangePrice());
|
||||
dept.setChangePriceRate(bo.getChangePriceRate());
|
||||
// System.out.println("[部门更新] 转换后的数据: isAutoChangePrice=" + dept.getIsAutoChangePrice() + ", changePriceRate=" + dept.getChangePriceRate());
|
||||
SysDept oldDept = baseMapper.selectById(dept.getDeptId());
|
||||
if (ObjectUtil.isNull(oldDept)) {
|
||||
throw new ServiceException("部门不存在,无法修改");
|
||||
@@ -294,6 +311,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
} else {
|
||||
dept.setAncestors(oldDept.getAncestors());
|
||||
}
|
||||
// System.out.println("[部门更新] 即将执行updateById, dept=" + dept);
|
||||
int result = baseMapper.updateById(dept);
|
||||
if (SystemConstants.NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
||||
&& !StringUtils.equals(SystemConstants.NORMAL, dept.getAncestors())) {
|
||||
|
||||
@@ -774,8 +774,26 @@ public class TpOrderServiceImpl extends MPJBaseServiceImpl<TpOrderMapper,TpOrder
|
||||
|
||||
SysUser user = sysUserMapper.selectById(userId);
|
||||
|
||||
// 获取默认改价比例(10%)
|
||||
// 获取用户所属部门的改价配置
|
||||
SysDept userDept = deptMapper.selectById(user.getDeptId());
|
||||
// 默认不改价,比例10%
|
||||
boolean isAutoChangePrice = false;
|
||||
BigDecimal discountRate = new BigDecimal("0.10");
|
||||
|
||||
if (userDept != null) {
|
||||
// 检查部门类别是否为技术 (deptCategory = "3")
|
||||
if ("3".equals(userDept.getDeptCategory())) {
|
||||
// 是技术部门,检查是否开启自动改价 (2=是)
|
||||
if (userDept.getIsAutoChangePrice() != null && userDept.getIsAutoChangePrice() == 2) {
|
||||
isAutoChangePrice = true;
|
||||
}
|
||||
// 使用部门配置的改价比例
|
||||
if (userDept.getChangePriceRate() != null && userDept.getChangePriceRate().compareTo(BigDecimal.ZERO) > 0) {
|
||||
discountRate = userDept.getChangePriceRate();
|
||||
}
|
||||
}
|
||||
}
|
||||
// System.out.println("[部门改价配置] 用户ID=" + userId + ", 部门ID=" + user.getDeptId() + ", 类别=" + (userDept != null ? userDept.getDeptCategory() : "null") + ", 自动改价=" + isAutoChangePrice + ", 比例=" + discountRate + ", 部门改价比例=" + (userDept != null ? userDept.getChangePriceRate() : "null"));
|
||||
|
||||
List<TpOrder> orderList = new ArrayList<>();
|
||||
for (Long orderId : orderIds){
|
||||
@@ -787,34 +805,48 @@ public class TpOrderServiceImpl extends MPJBaseServiceImpl<TpOrderMapper,TpOrder
|
||||
order.setDeptIdJs(dept.getDeptId());
|
||||
order.setAncestorsJs(dept.getAncestors());
|
||||
|
||||
// ===== 自动改价逻辑开始 =====
|
||||
// 启用自动改价
|
||||
order.setIsC(2);
|
||||
// 根据部门配置决定是否启用自动改价
|
||||
if (isAutoChangePrice) {
|
||||
order.setIsC(2);
|
||||
} else {
|
||||
order.setIsC(1);
|
||||
}
|
||||
|
||||
// 计算自动改价价格(优先使用jsPrice,如果为空则使用price)
|
||||
BigDecimal basePrice = order.getJsPrice();
|
||||
System.out.println("[自动改价调试] 订单ID=" + order.getId() + ", jsPrice=" + order.getJsPrice() + ", price=" + order.getPrice());
|
||||
// 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);
|
||||
// System.out.println("[自动改价调试] jsPrice为空或<=0,使用price=" + basePrice);
|
||||
}
|
||||
|
||||
if (basePrice != null && basePrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 只有开启自动改价时才计算改价
|
||||
if (isAutoChangePrice && 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);
|
||||
// System.out.println("[自动改价调试] 计算改价: " + basePrice + " * " + discountRate + " = " + zGjPrice);
|
||||
// 抹零到十位数(舍去个位数)
|
||||
zGjPrice = zGjPrice.divide(new BigDecimal("10"), 0, BigDecimal.ROUND_DOWN).multiply(new BigDecimal("10"));
|
||||
// System.out.println("[自动改价调试] 抹零到十位数后改价: " + zGjPrice);
|
||||
|
||||
order.setZGjPrice(zGjPrice);
|
||||
order.setGjPrice(zGjPrice);
|
||||
if (order.getPayState() != null && !order.getPayState().equals(1)) {
|
||||
order.setGjPrice(zGjPrice);
|
||||
BigDecimal jsBasePrice = order.getPrice().subtract(order.getCdPrice()).subtract(zGjPrice);
|
||||
order.setJsPrice(jsBasePrice);
|
||||
order.setGpay(getGjPayPrice(order.getPrice(), order.getPayPrice().add(order.getCoupon()), zGjPrice));
|
||||
BigDecimal jsPayPrice = getJsPayPrice(order.getPrice(), order.getPayPrice(), jsBasePrice);
|
||||
order.setJsPayPrice(jsPayPrice.subtract(order.getBreach()));
|
||||
} else {
|
||||
order.setGjPrice(zGjPrice);
|
||||
BigDecimal jsBasePrice = order.getPrice().subtract(order.getCdPrice()).subtract(zGjPrice);
|
||||
order.setJsPrice(jsBasePrice);
|
||||
}
|
||||
System.out.println("[自动改价调试] 设置成功: zGjPrice=" + zGjPrice + ", gjPrice=" + zGjPrice);
|
||||
} else if (!isAutoChangePrice) {
|
||||
System.out.println("[自动改价调试] 部门未开启自动改价,跳过改价计算");
|
||||
} else {
|
||||
System.out.println("[自动改价调试] 未设置改价: basePrice=" + basePrice);
|
||||
}
|
||||
// ===== 自动改价逻辑结束 =====
|
||||
|
||||
boolean res = saveOrderRecord(order.getId(),"订单分图","订单:"+order.getOrderId()+" 指派给"+user.getNickName()+" 成功",1,null);
|
||||
if(!res){
|
||||
|
||||
Reference in New Issue
Block a user