Browse Source

feat(all): 修改价格体系保存逻辑

dist.1.3.0
zhaoqiaobo 8 months ago
parent
commit
ad62312e9f
  1. 2
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataPriceMapper.xml
  2. 33
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java

2
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataPriceMapper.xml

@ -11,6 +11,7 @@
select t.id,
cli.client_name,
t.brand_id,
t.client_id,
t.template_id,
ldb.brand_name,
lbpt.service_type,
@ -48,6 +49,7 @@
select t.id,
cli.client_name,
t.brand_id,
t.client_id,
t.template_id,
ldb.brand_name,
lbpt.service_type,

33
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java

@ -208,6 +208,39 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
if (DateUtil.compare(vo.getEffectiveTime(), vo.getExpiryTime()) > 0) {
throw new ServiceException("生效时间大于到期时间,请检查。");
}
Long clientId1 = vo.getClientId();
Long brandId1 = vo.getBrandId();
List<BasicdataPriceEntity> list1 = this.list(Wrappers.<BasicdataPriceEntity>lambdaQuery()
.eq(BasicdataPriceEntity::getClientId, clientId1)
.eq(BasicdataPriceEntity::getBrandId, brandId1)
.eq(BasicdataPriceEntity::getIsDeleted, 0)
);
// 修改的当前版本时间控制
Date start1 = vo.getEffectiveTime();
Date end1 = vo.getExpiryTime();
int flag = 0;
if (CollUtil.isNotEmpty(list1)) {
for (BasicdataPriceEntity priceEntity : list1) {
Date start2 = priceEntity.getEffectiveTime();
Date end2 = priceEntity.getExpiryTime();
if (start1.after(priceEntity.getEffectiveTime())) {
// 交换 interval1 的开始和结束时间
Date temp = start1;
start1 = start2;
start2 = temp;
temp = end1;
end1 = end2;
end2 = temp;
}
// 计算交集
if (!end1.before(start2)) {
flag += 1;
}
}
}
if (flag > 1) {
throw new ServiceException("生效时间与截至时间范围在系统中存在多个价格体系,请确认");
}
// 如果是切换模版,则删除所有本价格相关的数据
BasicdataPriceEntity entity = null;
if (ObjectUtil.isNotEmpty(vo.getId())) {

Loading…
Cancel
Save