|
|
|
@ -20,14 +20,15 @@ package com.epmet.service.impl; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dao.CustomerFunctionDetailDao; |
|
|
|
import com.epmet.dao.FunctionCustomizedDao; |
|
|
|
import com.epmet.dao.FunctionDao; |
|
|
|
import com.epmet.dto.CustomerFunctionDetailDTO; |
|
|
|
import com.epmet.dto.CustomizedDTO; |
|
|
|
import com.epmet.dto.FunctionCustomizedDTO; |
|
|
|
import com.epmet.dto.form.CommonFunctionIdFormDTO; |
|
|
|
import com.epmet.dto.form.SaveFunctionCustomizedFormDTO; |
|
|
|
@ -36,6 +37,7 @@ import com.epmet.dto.result.FunctionCustomizedDetailResultDTO; |
|
|
|
import com.epmet.entity.FunctionCustomizedEntity; |
|
|
|
import com.epmet.entity.FunctionEntity; |
|
|
|
import com.epmet.redis.FunctionCustomizedRedis; |
|
|
|
import com.epmet.service.CustomerFunctionDetailService; |
|
|
|
import com.epmet.service.FunctionCustomizedService; |
|
|
|
import com.epmet.service.FunctionService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
@ -43,6 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
@ -62,6 +65,8 @@ public class FunctionCustomizedServiceImpl extends BaseServiceImpl<FunctionCusto |
|
|
|
private FunctionService functionService; |
|
|
|
@Autowired |
|
|
|
private CustomerFunctionDetailDao customerFunctionDetailDao; |
|
|
|
@Autowired |
|
|
|
private CustomerFunctionDetailService customerFunctionDetailService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<FunctionCustomizedDTO> page(Map<String, Object> params) { |
|
|
|
@ -142,7 +147,7 @@ public class FunctionCustomizedServiceImpl extends BaseServiceImpl<FunctionCusto |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result deleteFunctionCustomized(CommonFunctionIdFormDTO formDTO) { |
|
|
|
// 1.客户定制功能详情表 ,没查到就是没人在使用
|
|
|
|
List<String> customizedId = customerFunctionDetailDao.selectCustomerIdByFunctionId(formDTO.getFunctionId()); |
|
|
|
List<CustomerFunctionDetailDTO> customizedId = customerFunctionDetailDao.selectCustomerIdByFunctionId(formDTO.getFunctionId()); |
|
|
|
if (customizedId != null && customizedId.size() > NumConstant.ZERO){ |
|
|
|
return new Result<>().error(8000, "功能正在使用中,不允许删除!"); |
|
|
|
} else { |
|
|
|
@ -160,22 +165,63 @@ public class FunctionCustomizedServiceImpl extends BaseServiceImpl<FunctionCusto |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result updateCustomized(UpdateCustomizedFormDTO formDTO) { |
|
|
|
// 1.客户定制功能详情表 ,没查到就是没人在使用
|
|
|
|
List<String> customizedId = customerFunctionDetailDao.selectCustomerIdByFunctionId(formDTO.getFunctionId()); |
|
|
|
List<CustomerFunctionDetailDTO> customizedId = customerFunctionDetailDao.selectCustomerIdByFunctionId(formDTO.getFunctionId()); |
|
|
|
FunctionCustomizedEntity entity = new FunctionCustomizedEntity(); |
|
|
|
entity.setId(formDTO.getCustomizedId()); |
|
|
|
entity.setIconLargeImg(formDTO.getIconLargeImg()); |
|
|
|
entity.setIconSmallImg(formDTO.getIconSmallImg()); |
|
|
|
entity.setCustomizedName(formDTO.getCustomizedName()); |
|
|
|
if (customizedId != null && customizedId.size() > NumConstant.ZERO){ |
|
|
|
// 有客户正在使用该 功能,只能修改功能名称和大小图标, 需要批量更新客户数据
|
|
|
|
// 根据功能id,查询功能的详细信息
|
|
|
|
CustomizedDTO customizedDTO = baseDao.selectCustomized(formDTO.getFunctionId()); |
|
|
|
// 判断这个功能,用户使用的是默认的,还是自定义的
|
|
|
|
|
|
|
|
// 该集合,用户统一修改 客户定制功能详情表
|
|
|
|
List<String> upCustomizedInfoUserId = new ArrayList<>(); |
|
|
|
|
|
|
|
// 统一提示 不能进行修改的客户id
|
|
|
|
StringBuilder tipCustomizedInfoUserId = new StringBuilder(); |
|
|
|
|
|
|
|
// 如果这个功能,被客户重新定义了,则不会修改
|
|
|
|
for (int i = 0; i < customizedId.size(); i++){ |
|
|
|
if (null != customizedDTO){ |
|
|
|
if (customizedDTO.getCustomizedName().equals(customizedId.get(i).getFunctionName()) |
|
|
|
&& customizedDTO.getIconLargeImg().equals(customizedId.get(i).getIconLargeImg()) |
|
|
|
&& customizedDTO.getIconSmallImg().equals(customizedId.get(i).getIconSmallImg()) |
|
|
|
&& customizedDTO.getDomainName().equals(customizedId.get(i).getDomainName()) |
|
|
|
&& customizedDTO.getTargetLink().equals(customizedId.get(i).getTargetLink()) ){ |
|
|
|
// 这个功能,客户使用的是默认的,则修改
|
|
|
|
if (!formDTO.getShoppingStatus().equals(customizedDTO.getShoppingStatus()) |
|
|
|
|| !formDTO.getFunctionExplain().equals(customizedDTO.getFunctionExplain()) |
|
|
|
|| !formDTO.getTargetLink().equals(customizedDTO.getTargetLink()) |
|
|
|
|| !formDTO.getDomainName().equals(customizedDTO.getDomainName()) |
|
|
|
|| !formDTO.getFromApp().equals(customizedDTO.getFromApp()) ){ |
|
|
|
// 如果修改的内容是其他字段,则返回语句
|
|
|
|
tipCustomizedInfoUserId.append(customizedId.get(i).getId()); |
|
|
|
} else if (!formDTO.getCustomizedName().equals(customizedDTO.getCustomizedName()) |
|
|
|
|| !formDTO.getIconLargeImg().equals(customizedDTO.getIconLargeImg()) |
|
|
|
|| !formDTO.getIconSmallImg().equals(customizedDTO.getIconSmallImg())){ |
|
|
|
// 如果修改的内容只是:功能名称和大小图标,, 需要批量更新客户数据
|
|
|
|
upCustomizedInfoUserId.add(customizedId.get(i).getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 1.修改 客户定制功能详情表
|
|
|
|
if (upCustomizedInfoUserId != null && upCustomizedInfoUserId.size() > NumConstant.ZERO){ |
|
|
|
String[] ueserIds = new String[upCustomizedInfoUserId.size()]; |
|
|
|
customerFunctionDetailService.delete(upCustomizedInfoUserId.toArray(ueserIds)); |
|
|
|
} |
|
|
|
// 2.修改 功能表, 修改的字段范围,是:功能名称和大小图标
|
|
|
|
this.upFunction(formDTO); |
|
|
|
|
|
|
|
// 3.修改 定制功能表, 修改的字段范围,是:功能名称和大小图标
|
|
|
|
baseDao.updateById(entity); |
|
|
|
|
|
|
|
// 4.修改 客户定制功能详情表(多客户), 修改的字段范围,是:功能名称和大小图标
|
|
|
|
return new Result<>().error(8000, "客户正在使用该功能不允许修改上下架状态、业务域名和外链地址、所属端app!"); |
|
|
|
// 4.提示哪些用户不能被修改
|
|
|
|
if (tipCustomizedInfoUserId != null && tipCustomizedInfoUserId.length() >NumConstant.ZERO){ |
|
|
|
return new Result<>().error(8000, "客户正在使用该功能不允许修改上下架状态、业务域名和外链地址、所属端app!"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 没有客户正在使用该 功能
|
|
|
|
// 2.修改 功能表, 修改的字段范围,是所有入参字段
|
|
|
|
|