|
@@ -90,7 +90,6 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public R<String> saveUnifiedSettlement(UnifiedSettlementParam param, Long sysUserId) {
|
|
@@ -107,14 +106,14 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
entity.setUpdateTime(new Date());
|
|
|
entity.setUpdateUserId(sysUserId);
|
|
|
|
|
|
- entity.setProgrammeNo("PR"+ DateUtil.format(new Date(), "yyyyMM")+ GenRandomHelper.genRandomNum(6) );
|
|
|
+ entity.setProgrammeNo("PR" + DateUtil.format(new Date(), "yyyyMM") + GenRandomHelper.genRandomNum(6));
|
|
|
SettlementExportFieldVo vo = new SettlementExportFieldVo();
|
|
|
BeanUtils.copyProperties(param, vo);
|
|
|
entity.setExportField(JSON.toJSONString(vo));
|
|
|
unifiedSettlementProgrammeMapper.insertSelective(entity);
|
|
|
|
|
|
if (param.getSettlementScope().intValue() == SettlementScopeEnum.部分订单不参与结算.getKey().intValue()
|
|
|
- && CollectionUtils.isNotEmpty(param.getUnifiedSettlementRangeRuleParam1List())) {
|
|
|
+ && CollectionUtils.isNotEmpty(param.getUnifiedSettlementRangeRuleParam1List())) {
|
|
|
|
|
|
//结算范围 部分订单不参与结算
|
|
|
for (UnifiedSettlementRangeRuleParam unifiedSettlementRangeRuleParam : param.getUnifiedSettlementRangeRuleParam1List()) {
|
|
@@ -138,7 +137,7 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
for (UnifiedSettlementAmountRuleParam amountRuleParam : param.getUnifiedSettlementAmountRuleParamList()) {
|
|
|
UnifiedSettlementProgrammeAmountRule rule = new UnifiedSettlementProgrammeAmountRule();
|
|
|
|
|
|
- BeanUtils.copyProperties(amountRuleParam,rule);
|
|
|
+ BeanUtils.copyProperties(amountRuleParam, rule);
|
|
|
rule.setCreateUserId(sysUserId);
|
|
|
rule.setCreateTime(new Date());
|
|
|
rule.setProgrammeId(entity.getId());
|
|
@@ -170,7 +169,9 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
|
|
|
UnifiedCenterCustomer customer = new UnifiedCenterCustomer();
|
|
|
customer.setId(param.getCustomerId());
|
|
|
- customer.setIsSettlementMethod((byte)1);
|
|
|
+ customer.setIsSettlementMethod((byte) 1);
|
|
|
+ customer.setUpdateUserId(sysUserId);
|
|
|
+ customer.setUpdateTime(new Date());
|
|
|
unifiedCenterCustomerMapper.updateByPrimaryKeySelective(customer);
|
|
|
|
|
|
//更改客户主体 结算方案已配置
|
|
@@ -202,7 +203,7 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
&& CollectionUtils.isNotEmpty(param.getUnifiedSettlementRangeRuleParam1List())) {
|
|
|
|
|
|
//先删除
|
|
|
- UnifiedSettlementProgrammeRangeRuleExample example =new UnifiedSettlementProgrammeRangeRuleExample();
|
|
|
+ UnifiedSettlementProgrammeRangeRuleExample example = new UnifiedSettlementProgrammeRangeRuleExample();
|
|
|
example.createCriteria().andProgrammeIdEqualTo(param.getId());
|
|
|
unifiedSettlementProgrammeRangeRuleMapper.deleteByExample(example);
|
|
|
|
|
@@ -235,7 +236,7 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
for (UnifiedSettlementAmountRuleParam amountRuleParam : param.getUnifiedSettlementAmountRuleParamList()) {
|
|
|
UnifiedSettlementProgrammeAmountRule rule = new UnifiedSettlementProgrammeAmountRule();
|
|
|
|
|
|
- BeanUtils.copyProperties(amountRuleParam,rule);
|
|
|
+ BeanUtils.copyProperties(amountRuleParam, rule);
|
|
|
rule.setCreateUserId(sysUserId);
|
|
|
rule.setCreateTime(new Date());
|
|
|
rule.setProgrammeId(entity.getId());
|
|
@@ -248,7 +249,7 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
|
|
|
if (param.getSupnameDisplayRule().intValue() == SupnameDisplayRuleEnum.部分按原供应商名称导出.getKey().intValue()
|
|
|
&& CollectionUtils.isNotEmpty(param.getUnifiedSettlementRangeRuleParam1List())) {
|
|
|
- UnifiedSettlementProgrammeRangeRuleExample example =new UnifiedSettlementProgrammeRangeRuleExample();
|
|
|
+ UnifiedSettlementProgrammeRangeRuleExample example = new UnifiedSettlementProgrammeRangeRuleExample();
|
|
|
example.createCriteria().andProgrammeIdEqualTo(param.getId());
|
|
|
unifiedSettlementProgrammeRangeRuleMapper.deleteByExample(example);
|
|
|
|
|
@@ -286,7 +287,7 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
//主体
|
|
|
UnifiedCenterCustomer customer = unifiedCenterCustomerMapper.selectByPrimaryKey(programme.getCustomerId());
|
|
|
vo.setCustomerName(customer.getCustomerName());
|
|
|
- vo.setTypeDesc(SettlementProgrammeTypeEnum.getDescByKey((int)customer.getType()));
|
|
|
+ vo.setTypeDesc(SettlementProgrammeTypeEnum.getDescByKey((int) customer.getType()));
|
|
|
|
|
|
List<UnifiedSettlementRangeRuleParam> unifiedSettlementRangeRuleParam1List = new ArrayList<>();
|
|
|
|
|
@@ -295,14 +296,13 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
List<UnifiedSettlementRangeRuleParam> unifiedSettlementRangeRuleParam2List = new ArrayList<>();
|
|
|
|
|
|
|
|
|
-
|
|
|
- UnifiedSettlementProgrammeRangeRuleExample example1 =new UnifiedSettlementProgrammeRangeRuleExample();
|
|
|
+ UnifiedSettlementProgrammeRangeRuleExample example1 = new UnifiedSettlementProgrammeRangeRuleExample();
|
|
|
example1.createCriteria().andProgrammeIdEqualTo(id).andTypeEqualTo((byte) 1);
|
|
|
List<UnifiedSettlementProgrammeRangeRule> rangeRules1 = unifiedSettlementProgrammeRangeRuleMapper.selectByExampleWithBLOBs(example1);
|
|
|
|
|
|
for (UnifiedSettlementProgrammeRangeRule voRangeRule : rangeRules1) {
|
|
|
UnifiedSettlementRangeRuleParam RangeRuleParam = new UnifiedSettlementRangeRuleParam();
|
|
|
- BeanUtils.copyProperties(voRangeRule,RangeRuleParam);
|
|
|
+ BeanUtils.copyProperties(voRangeRule, RangeRuleParam);
|
|
|
if (StringUtils.isNotBlank(voRangeRule.getNotJoiningRangeJson())) {
|
|
|
|
|
|
RangeRuleParam.setSysSelectVoList(JSON.parseArray(voRangeRule.getNotJoiningRangeJson(), OperationCenterVo.class));
|
|
@@ -311,13 +311,13 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
}
|
|
|
|
|
|
|
|
|
- UnifiedSettlementProgrammeRangeRuleExample example2 =new UnifiedSettlementProgrammeRangeRuleExample();
|
|
|
+ UnifiedSettlementProgrammeRangeRuleExample example2 = new UnifiedSettlementProgrammeRangeRuleExample();
|
|
|
example2.createCriteria().andProgrammeIdEqualTo(id).andTypeEqualTo((byte) 2);
|
|
|
List<UnifiedSettlementProgrammeRangeRule> rangeRules2 = unifiedSettlementProgrammeRangeRuleMapper.selectByExampleWithBLOBs(example2);
|
|
|
|
|
|
for (UnifiedSettlementProgrammeRangeRule voRangeRule : rangeRules2) {
|
|
|
UnifiedSettlementRangeRuleParam RangeRuleParam = new UnifiedSettlementRangeRuleParam();
|
|
|
- BeanUtils.copyProperties(voRangeRule,RangeRuleParam);
|
|
|
+ BeanUtils.copyProperties(voRangeRule, RangeRuleParam);
|
|
|
if (StringUtils.isNotBlank(voRangeRule.getNotJoiningRangeJson())) {
|
|
|
List<OperationCenterVo> operationCenterVos = JSON.parseArray(voRangeRule.getNotJoiningRangeJson(), OperationCenterVo.class);
|
|
|
RangeRuleParam.setSysSelectVoList(operationCenterVos);
|
|
@@ -342,7 +342,7 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R<String> setDefault(Long id,Long userId) {
|
|
|
+ public R<String> setDefault(Long id, Long userId) {
|
|
|
UnifiedSettlementProgrammeExample example = new UnifiedSettlementProgrammeExample();
|
|
|
example.createCriteria().andDeletedEqualTo((byte) 0)
|
|
|
.andIdEqualTo(id);
|
|
@@ -352,6 +352,13 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
}
|
|
|
Integer isDefault = unifiedSettlementProgrammes.get(0).getIsDefault();
|
|
|
|
|
|
+ //设置该结算方案为默认
|
|
|
+ if (0 == isDefault) {
|
|
|
+ //将该客户下的所有 设为非默认
|
|
|
+ Long customerId = unifiedSettlementProgrammes.get(0).getCustomerId();
|
|
|
+ unifiedSettlementProgrammeMapperEx.updateIsDefaultByCustomerId(customerId, 0, userId);
|
|
|
+ }
|
|
|
+
|
|
|
UnifiedSettlementProgramme entity = new UnifiedSettlementProgramme();
|
|
|
entity.setId(id);
|
|
|
entity.setIsDefault(isDefault == 1 ? 0 : 1);
|
|
@@ -363,7 +370,26 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteByIds(List<Long> idsList,Long userId) {
|
|
|
+ public R<String> deleteByIds(List<Long> idsList, Long userId) {
|
|
|
+ //删除前 检查 要删除的 有没有开启状态的
|
|
|
+ UnifiedSettlementProgrammeExample example1 = new UnifiedSettlementProgrammeExample();
|
|
|
+ example1.createCriteria().andIdIn(idsList)
|
|
|
+ .andEnabledEqualTo((byte)1);
|
|
|
+ List<UnifiedSettlementProgramme> unifiedSettlementProgrammes = unifiedSettlementProgrammeMapper.selectByExample(example1);
|
|
|
+ if (CollectionUtils.isNotEmpty(unifiedSettlementProgrammes)) {
|
|
|
+ return new R<>("500", "不允许删除启用状态的结算方案,请先停用", false);
|
|
|
+ }
|
|
|
+
|
|
|
+ example1 = new UnifiedSettlementProgrammeExample();
|
|
|
+ example1.createCriteria().andIdIn(idsList)
|
|
|
+ .andIsDefaultEqualTo((byte) 1);
|
|
|
+ List<UnifiedSettlementProgramme> unifiedSettlementProgrammes1 = unifiedSettlementProgrammeMapper.selectByExample(example1);
|
|
|
+ if (CollectionUtils.isNotEmpty(unifiedSettlementProgrammes1)) {
|
|
|
+ return new R<>("500", "不允许删除默认结算方案,请先取消默认", false);
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO 该结算方案已被账单关联使用,不允许删除,停用方案即可
|
|
|
+
|
|
|
UnifiedSettlementProgrammeExample example = new UnifiedSettlementProgrammeExample();
|
|
|
example.createCriteria().andIdIn(idsList);
|
|
|
UnifiedSettlementProgramme record = new UnifiedSettlementProgramme();
|
|
@@ -371,5 +397,21 @@ public class UnifiedSettlementProgrammeServiceImpl implements UnifiedSettlementP
|
|
|
record.setUpdateUserId(userId);
|
|
|
record.setUpdateTime(new Date());
|
|
|
unifiedSettlementProgrammeMapper.updateByExampleSelective(record, example);
|
|
|
+
|
|
|
+ //判断该客户所关联的“未删除”结算方案数量=0时,即为“未配置”;
|
|
|
+ UnifiedSettlementProgramme unifiedSettlementProgramme = unifiedSettlementProgrammeMapper.selectByPrimaryKey(idsList.get(0));
|
|
|
+ OperationCenterCustomerParam param = new OperationCenterCustomerParam();
|
|
|
+ param.setCustomerId(unifiedSettlementProgramme.getCustomerId());
|
|
|
+ List<UnifiedSettlementVo> list = unifiedSettlementProgrammeMapperEx.list(param);
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ UnifiedCenterCustomer customer = new UnifiedCenterCustomer();
|
|
|
+ customer.setId(param.getCustomerId());
|
|
|
+ customer.setIsSettlementMethod((byte) 0);
|
|
|
+ customer.setUpdateTime(new Date());
|
|
|
+ customer.setUpdateUserId(userId);
|
|
|
+ unifiedCenterCustomerMapper.updateByPrimaryKeySelective(customer);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new R<>("删除成功");
|
|
|
}
|
|
|
}
|