|
|
|
@ -18,15 +18,28 @@ package com.logpm.basicdata.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataClientEntity; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataClientLogEntity; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataStorageServicesEntity; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataTripartiteMallEntity; |
|
|
|
|
import com.logpm.basicdata.excel.BasicdataTripartiteMallExcel; |
|
|
|
|
import com.logpm.basicdata.mapper.BasicdataTripartiteMallMapper; |
|
|
|
|
import com.logpm.basicdata.service.IBasicdataClientLogService; |
|
|
|
|
import com.logpm.basicdata.service.IBasicdataClientService; |
|
|
|
|
import com.logpm.basicdata.service.IBasicdataTripartiteMallService; |
|
|
|
|
import com.logpm.basicdata.vo.BasicdataTripartiteMallVO; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 客户三方商城 服务实现类 |
|
|
|
@ -35,8 +48,15 @@ import java.util.List;
|
|
|
|
|
* @since 2023-06-21 |
|
|
|
|
*/ |
|
|
|
|
@Service |
|
|
|
|
@AllArgsConstructor |
|
|
|
|
@Slf4j |
|
|
|
|
public class BasicdataTripartiteMallServiceImpl extends BaseServiceImpl<BasicdataTripartiteMallMapper, BasicdataTripartiteMallEntity> implements IBasicdataTripartiteMallService { |
|
|
|
|
|
|
|
|
|
private IBasicdataClientService basicdataClientService; |
|
|
|
|
|
|
|
|
|
private IBasicdataClientLogService basicdataClientLogService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<BasicdataTripartiteMallVO> selectBasicdataTripartiteMallPage(IPage<BasicdataTripartiteMallVO> page, BasicdataTripartiteMallVO basicdataTripartiteMall) { |
|
|
|
|
return page.setRecords(baseMapper.selectBasicdataTripartiteMallPage(page, basicdataTripartiteMall)); |
|
|
|
@ -54,7 +74,7 @@ public class BasicdataTripartiteMallServiceImpl extends BaseServiceImpl<Basicdat
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Long getClientIdByNameAndBrand(String name, String brand) { |
|
|
|
|
return baseMapper.getClientIdByNameAndBrand(name,brand); |
|
|
|
|
return baseMapper.getClientIdByNameAndBrand(name, brand); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -64,10 +84,116 @@ public class BasicdataTripartiteMallServiceImpl extends BaseServiceImpl<Basicdat
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Long getClientIdByNameAndBrandAndCode(String name, String code, String brand) { |
|
|
|
|
if("".equals(code)){ |
|
|
|
|
code=null; |
|
|
|
|
if ("".equals(code)) { |
|
|
|
|
code = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return baseMapper.getClientIdByNameAndBrandAndCode(name, code, brand); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public R saveOrUpdateClientTripartiteMall(BasicdataTripartiteMallEntity basicdataTripartiteMall) { |
|
|
|
|
String method = "##############################BasicdataTripartiteMallServiceImpl.saveOrUpdateClientTripartiteMall"; |
|
|
|
|
if (Objects.isNull(basicdataTripartiteMall.getBrandId())) { |
|
|
|
|
log.error(method + "BrandId参数缺失"); |
|
|
|
|
return R.fail("操作失败,参数缺失"); |
|
|
|
|
} |
|
|
|
|
if (Objects.isNull(basicdataTripartiteMall.getTripartiteMall())) { |
|
|
|
|
log.error(method + "TripartiteMall参数缺失"); |
|
|
|
|
return R.fail("操作失败,请输入商城名称"); |
|
|
|
|
} |
|
|
|
|
if (Objects.isNull(basicdataTripartiteMall.getClientId())) { |
|
|
|
|
log.error(method + "ClientId参数缺失"); |
|
|
|
|
return R.fail("操作失败,参数缺失"); |
|
|
|
|
} |
|
|
|
|
BasicdataClientEntity clientEntity = basicdataClientService.getById(basicdataTripartiteMall.getClientId()); |
|
|
|
|
if (Objects.isNull(clientEntity)) { |
|
|
|
|
log.error(method + "查询客户信息错误,clientId:{}", basicdataTripartiteMall.getClientId()); |
|
|
|
|
return R.fail("操作失败,参数缺失"); |
|
|
|
|
} |
|
|
|
|
BasicdataClientLogEntity basicdataClientLogEntity = new BasicdataClientLogEntity(); |
|
|
|
|
basicdataClientLogEntity.setClientId(clientEntity.getId()); |
|
|
|
|
basicdataClientLogEntity.setClientName(clientEntity.getClientName()); |
|
|
|
|
basicdataClientLogEntity.setOperator(AuthUtil.getNickName()); |
|
|
|
|
String content = ""; |
|
|
|
|
if (Objects.isNull(basicdataTripartiteMall.getId())) { |
|
|
|
|
String str = basicdataTripartiteMall.getTripartiteCoding().isEmpty() ? "空" : basicdataTripartiteMall.getTripartiteCoding(); |
|
|
|
|
//新增
|
|
|
|
|
content = "新增三方商场-->[名称:" + basicdataTripartiteMall.getTripartiteMall() + ",编码:" + str + ",品牌:" + basicdataTripartiteMall.getBrandName() + "]"; |
|
|
|
|
basicdataClientLogEntity.setContent(content); |
|
|
|
|
basicdataClientLogService.save(basicdataClientLogEntity); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
//修改
|
|
|
|
|
BasicdataTripartiteMallEntity entity = this.getById(basicdataTripartiteMall.getId()); |
|
|
|
|
Boolean flag = judgeComparisonBasicdataTripartiteMall(entity, basicdataTripartiteMall); |
|
|
|
|
if (flag) { |
|
|
|
|
content = comparisonBasicdataTripartiteMall(entity, basicdataTripartiteMall); |
|
|
|
|
basicdataClientLogEntity.setContent(content); |
|
|
|
|
basicdataClientLogService.save(basicdataClientLogEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return R.status(this.saveOrUpdate(basicdataTripartiteMall)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Boolean judgeComparisonBasicdataTripartiteMall(BasicdataTripartiteMallEntity entity, BasicdataTripartiteMallEntity basicdataTripartiteMall) { |
|
|
|
|
String str1 = entity.getTripartiteCoding().isEmpty() ? "空" : entity.getTripartiteCoding(); |
|
|
|
|
String str2 = basicdataTripartiteMall.getTripartiteCoding().isEmpty() ? "空" : basicdataTripartiteMall.getTripartiteCoding(); |
|
|
|
|
String oldTripartiteMall = "[名称:" + entity.getTripartiteMall() + ",编码:" + str1 + ",品牌:" + entity.getBrandName() + "]"; |
|
|
|
|
String newTripartiteMall = "[名称:" + basicdataTripartiteMall.getTripartiteMall() + ",编码:" + str2 + ",品牌:" + basicdataTripartiteMall.getBrandName() + "]"; |
|
|
|
|
|
|
|
|
|
return !oldTripartiteMall.equals(newTripartiteMall); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R removeClientTripartiteMall(String ids) { |
|
|
|
|
String method = "#####################BasicdataStoreBrandServiceImpl.removeClientStorageServices"; |
|
|
|
|
List<Long> list = Func.toLongList(ids); |
|
|
|
|
if (list.isEmpty()) { |
|
|
|
|
log.error(method + "参数缺少"); |
|
|
|
|
return R.fail("参数缺少"); |
|
|
|
|
} |
|
|
|
|
List<BasicdataTripartiteMallEntity> basicdataStorageServicesEntities = this.listByIds(list); |
|
|
|
|
if (basicdataStorageServicesEntities.isEmpty()) { |
|
|
|
|
log.error("查询目标删除客户三方信息错误,ids:{}", list); |
|
|
|
|
return R.fail("查询目标删除客户三方信息错误"); |
|
|
|
|
} |
|
|
|
|
List<Long> clientIds = basicdataStorageServicesEntities.stream().map(BasicdataTripartiteMallEntity::getClientId).distinct().collect(Collectors.toList()); |
|
|
|
|
if (!clientIds.isEmpty()) { |
|
|
|
|
if (clientIds.size() != 1) { |
|
|
|
|
log.error(method + "当前删除客户三方商城存在多个客户信息"); |
|
|
|
|
return R.fail("当前删除客户三方商城存在多个客户信息"); |
|
|
|
|
} |
|
|
|
|
Long clientId = clientIds.get(0); |
|
|
|
|
BasicdataClientEntity clientEntity = basicdataClientService.getById(clientId); |
|
|
|
|
if (Objects.isNull(clientEntity)) { |
|
|
|
|
log.error(method + "查询客户信息错误"); |
|
|
|
|
return R.fail("查询客户信息错误"); |
|
|
|
|
} |
|
|
|
|
BasicdataClientLogEntity basicdataClientLogEntity = new BasicdataClientLogEntity(); |
|
|
|
|
basicdataClientLogEntity.setClientId(clientId); |
|
|
|
|
basicdataClientLogEntity.setClientName(clientEntity.getClientName()); |
|
|
|
|
basicdataClientLogEntity.setOperator(AuthUtil.getNickName()); |
|
|
|
|
StringBuilder builder = new StringBuilder(); |
|
|
|
|
for (BasicdataTripartiteMallEntity basicdataTripartiteMall : basicdataStorageServicesEntities) { |
|
|
|
|
builder.append("[名称:").append(basicdataTripartiteMall.getTripartiteMall()).append(",编码:").append(basicdataTripartiteMall.getTripartiteCoding()).append(",品牌:").append(basicdataTripartiteMall.getBrandName()).append("],"); |
|
|
|
|
} |
|
|
|
|
String content = "删除三方商城配置-->" + builder.deleteCharAt(builder.lastIndexOf(",")); |
|
|
|
|
basicdataClientLogEntity.setContent(content); |
|
|
|
|
basicdataClientLogService.saveAppointLog(basicdataClientLogEntity); |
|
|
|
|
} |
|
|
|
|
return R.status(this.removeByIds(list)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return baseMapper.getClientIdByNameAndBrandAndCode(name,code,brand); |
|
|
|
|
private String comparisonBasicdataTripartiteMall(BasicdataTripartiteMallEntity entity, BasicdataTripartiteMallEntity basicdataTripartiteMall) { |
|
|
|
|
StringBuilder builder = new StringBuilder(); |
|
|
|
|
String str1 = entity.getTripartiteCoding().isEmpty() ? "空" : entity.getTripartiteCoding(); |
|
|
|
|
String str2 = basicdataTripartiteMall.getTripartiteCoding().isEmpty() ? "空" : basicdataTripartiteMall.getTripartiteCoding(); |
|
|
|
|
String oldTripartiteMall = "[名称:" + entity.getTripartiteMall() + ",编码:" + str1 + ",品牌:" + entity.getBrandName() + "]"; |
|
|
|
|
String newTripartiteMall = "[名称:" + basicdataTripartiteMall.getTripartiteMall() + ",编码:" + str2 + ",品牌:" + basicdataTripartiteMall.getBrandName() + "]"; |
|
|
|
|
builder.append("编辑三方商城-->").append(oldTripartiteMall).append(",变更为").append(newTripartiteMall); |
|
|
|
|
return builder.toString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|