Browse Source

1.pc品牌保存增加回滚
2.pc增加审核通过批量生成用户接口
3.pc门店标签检索条件修改
4.pc门店列表权限修改

纪新园 1 week ago
parent
commit
7f5da734d4

+ 11 - 14
blade-service/gubersail-dealer-admin/src/main/java/com/gubersail/admin/corp/controller/CorpsDescController.java

@@ -390,25 +390,22 @@ public class CorpsDescController extends BladeController {
 	}
 
 	/**
-	 * app新增或修改客户
+	 * 提交申请
 	 */
-	@PostMapping("/appSubmitV1")
-	@ApiOperationSupport(order = 16)
-	@ApiOperation(value = "新增或修改", notes = "传入corpsDesc")
-	@RepeatSubmit
-	public R appSubmitV1(@Valid @RequestBody CorpsDescVO corpsDescVO) {
-		if (StringUtils.isBlank(corpsDescVO.getTenantId())) {
-			corpsDescVO.setTenantId(SecureUtil.getTenantId());
-		}
-		return corpsDescService.saveCorpsDescApp(corpsDescVO);
+	@GetMapping("/submitApply")
+	public R submitApply(@RequestParam("id") Long id) {
+		return corpsDescService.submitApply(id);
 	}
 
 	/**
-	 * app客户详情
+	 * 审核
+	 * @param id 门店id
+	 * @param type 1=审核通过,2=审核驳回
+	 * @return
 	 */
-	@GetMapping("/appDetailsV1")
-	public R appDetailsV1(Long id) {
-		return corpsDescService.appDetailsV1(id);
+	@GetMapping("/review")
+	public R review(@RequestParam("id") Long id,@RequestParam("type") String type) {
+		return corpsDescService.review(id,type);
 	}
 
 }

+ 7 - 1
blade-service/gubersail-dealer-admin/src/main/java/com/gubersail/admin/corp/controller/CorpsLabelController.java

@@ -16,6 +16,8 @@
  */
 package com.gubersail.admin.corp.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -66,7 +68,11 @@ public class CorpsLabelController extends BladeController {
 	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "分页", notes = "传入corpsLabel")
 	public R<IPage<CorpsLabel>> list(CorpsLabel corpsLabel, Query query) {
-		IPage<CorpsLabel> pages = corpsLabelService.page(Condition.getPage(query), Condition.getQueryWrapper(corpsLabel));
+		LambdaQueryWrapper<CorpsLabel> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+		lambdaQueryWrapper.eq(CorpsLabel::getIsDeleted,0)
+			.eq(ObjectUtils.isNotNull(corpsLabel.getStatus()),CorpsLabel::getStatus,corpsLabel.getStatus())
+			.like(ObjectUtils.isNotNull(corpsLabel.getLabel()),CorpsLabel::getLabel,corpsLabel.getLabel());
+		IPage<CorpsLabel> pages = corpsLabelService.page(Condition.getPage(query), lambdaQueryWrapper);
 		return R.data(pages);
 	}
 

+ 9 - 0
blade-service/gubersail-dealer-admin/src/main/java/com/gubersail/admin/corp/mapper/CorpsDescMapper.xml

@@ -81,12 +81,21 @@
         <if test="corpsDesc.isDeleted!=null">
             and is_deleted = #{corpsDesc.isDeleted}
         </if>
+        <if test="corpsDesc.srcDistributorId!=null">
+            and (src_distributor_id = #{corpsDesc.srcDistributorId} or src_distributor_id is null)
+        </if>
         <if test="corpsDesc.salesCompanyId != null">
             and sales_company_id = #{corpsDesc.salesCompanyId}
         </if>
         <if test="corpsDesc.corpType!=null and corpsDesc.corpType != ''">
             and corp_type like CONCAT(CONCAT('%', #{corpsDesc.corpType}), '%')
         </if>
+        <if test="corpsDesc.brandId!=null and corpsDesc.brandId != ''">
+            and brand_id like CONCAT(CONCAT('%', #{corpsDesc.brandId}), '%')
+        </if>
+        <if test="corpsDesc.brandName!=null and corpsDesc.brandName != ''">
+            and brand_name like CONCAT(CONCAT('%', #{corpsDesc.brandName}), '%')
+        </if>
         <if test="corpsDesc.checkStatus != null and corpsDesc.checkStatus != ''">
             and check_status = #{corpsDesc.checkStatus}
         </if>

+ 7 - 0
blade-service/gubersail-dealer-admin/src/main/java/com/gubersail/admin/corp/service/ICorpsAttnService.java

@@ -22,6 +22,8 @@ import com.gubersail.dealer.admin.api.corps.entity.PjCorpsAttn;
 import com.gubersail.dealer.admin.api.corps.vo.CorpsAttnVO;
 import org.springblade.core.tool.api.R;
 
+import java.util.List;
+
 /**
  * 配件批发客户明细联系人 服务类
  *
@@ -51,4 +53,9 @@ public interface ICorpsAttnService extends IService<PjCorpsAttn> {
 	 * 根据当前登陆人获得客户联系人
 	 */
 	PjCorpsAttn getAttn(Long userId);
+
+	/**
+	 * 根据当前登陆人获得客户联系人-批量
+	 */
+	void createUserBatch(List<PjCorpsAttn> corpsAttnList);
 }

+ 2 - 2
blade-service/gubersail-dealer-admin/src/main/java/com/gubersail/admin/corp/service/ICorpsDescService.java

@@ -66,7 +66,7 @@ public interface ICorpsDescService extends IService<PjCorpsDesc> {
 	 */
 	List<CorpsDescVO> selectCorpsDescAll(CorpsDescVO corpsDesc);
 
-	R saveCorpsDescApp(CorpsDescVO corpsDescVO);
+	R submitApply(Long id);
 
-	R appDetailsV1(Long id);
+	R review(Long id,String type);
 }

+ 36 - 5
blade-service/gubersail-dealer-admin/src/main/java/com/gubersail/admin/corp/service/impl/CorpsAttnServiceImpl.java

@@ -24,14 +24,12 @@ import com.gubersail.admin.corp.mapper.CorpsAttnMapper;
 import com.gubersail.admin.corp.service.ICorpsAttnService;
 import com.gubersail.dealer.admin.api.corps.entity.PjCorpsAttn;
 import com.gubersail.dealer.admin.api.corps.vo.CorpsAttnVO;
-import io.seata.spring.annotation.GlobalTransactional;
 import lombok.AllArgsConstructor;
 import org.springblade.common.constant.LandConstant;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.ObjectUtil;
-import org.springblade.system.entity.Dept;
 import org.springblade.system.feign.ISysClient;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
@@ -77,12 +75,12 @@ public class CorpsAttnServiceImpl extends ServiceImpl<CorpsAttnMapper, PjCorpsAt
 		user.setUserType(1);
 		user.setPhone(attn.getTel());
 		user.setUserTypeRole(3);
-		R<String> resRole = sysClient.getRoleIds(AuthUtil.getTenantId(),"门店");
-		if (!resRole.isSuccess() || ObjectUtils.isNull(resRole.getData())){
+		R<String> resRole = sysClient.getRoleIds(AuthUtil.getTenantId(), "门店");
+		if (!resRole.isSuccess() || ObjectUtils.isNull(resRole.getData())) {
 			throw new RuntimeException("请先维护门店角色信息");
 		}
 		user.setRoleId(resRole.getData());
-		user.setDeptId(attn.getCreateDept()+"");
+		user.setDeptId(attn.getCreateDept() + "");
 		if (ObjectUtil.isNotEmpty(attn.getUserId())) {
 			R<User> userR = userClient.userInfoById(attn.getUserId());
 			if (ObjectUtil.isNotEmpty(userR.getData())) {
@@ -133,4 +131,37 @@ public class CorpsAttnServiceImpl extends ServiceImpl<CorpsAttnMapper, PjCorpsAt
 		return corpsAttn;
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void createUserBatch(List<PjCorpsAttn> corpsAttnList) {
+		R<String> resRole = sysClient.getRoleIds(AuthUtil.getTenantId(), "门店");
+		if (!resRole.isSuccess() || ObjectUtils.isNull(resRole.getData())) {
+			throw new RuntimeException("请先维护门店角色信息");
+		}
+		for (PjCorpsAttn attn : corpsAttnList) {
+			User user = new User();
+			user.setTenantId(AuthUtil.getTenantId());
+			user.setAccount(attn.getTel());
+			user.setName(attn.getCname());
+			user.setRealName(attn.getCname());
+			user.setUserType(1);
+			user.setPhone(attn.getTel());
+			user.setUserTypeRole(3);
+
+			user.setRoleId(resRole.getData());
+			user.setDeptId(attn.getCreateDept() + "");
+			user.setPassword(LandConstant.USER_PASSWORD);
+			R<Boolean> result = userClient.saveUser(user);
+			if (!result.isSuccess()) {
+				throw new ServiceException(result.getMsg());
+			}
+			R<User> userTemp = userClient.userByAccount(AuthUtil.getTenantId(), attn.getTel());
+			if (!userTemp.isSuccess()) {
+				throw new ServiceException(userTemp.getMsg());
+			}
+			attn.setUserId(userTemp.getData().getId());
+		}
+		this.updateBatchById(corpsAttnList);
+	}
+
 }

+ 32 - 269
blade-service/gubersail-dealer-admin/src/main/java/com/gubersail/admin/corp/service/impl/CorpsDescServiceImpl.java

@@ -1,6 +1,5 @@
 package com.gubersail.admin.corp.service.impl;
 
-import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -16,7 +15,6 @@ import com.gubersail.dealer.admin.api.corps.entity.*;
 import com.gubersail.dealer.admin.api.corps.vo.CorpsDescVO;
 import com.gubersail.dealer.admin.api.excel.CorpsDescImportExcel;
 import com.gubersail.dealer.admin.api.goods.entity.PjBrandDesc;
-import com.gubersail.dealer.admin.api.zcrm.customer.entity.ViewCustomerSel;
 import lombok.AllArgsConstructor;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.secure.utils.SecureUtil;
@@ -33,7 +31,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
-import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -144,7 +141,9 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
 				corpsDesc.setSalesmanId(AuthUtil.getUserId());
 			}
 		}
-		corpsDesc.setSalesCompanyId(Long.parseLong(AuthUtil.getDeptId()));
+		if (AuthUtil.getUserRole().contains("dealer")) {
+			corpsDesc.setSrcDistributorId(AuthUtil.getUserId());
+		}
 		IPage<CorpsDescVO> page1 = page.setRecords(baseMapper.selectCorpsDescPage(page, corpsDesc));
 		return page1;
 
@@ -187,7 +186,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
 			corpsDesc.setCreateUser(userId);
 			corpsDesc.setSalesCompanyId(Long.valueOf(AuthUtil.getDeptId()));
 			corpsDesc.setSalesCompanyName(sysClient.getDept(Long.valueOf(AuthUtil.getDeptId())).getData().getFullName());
-			corpsDesc.setEnableOrNot(1);
+			corpsDesc.setEnableOrNot(0);
 			//查询当前登录人信息
 			R<User> userR = userClient.userInfoById(AuthUtil.getUserId());
 			if (!userR.isSuccess() || ObjectUtils.isNull(userR.getData())) {
@@ -282,7 +281,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
 			.apply("find_in_set(cname,'" + brandName + "')"));
 		R<String> r = sysClient.getRoleIds(AuthUtil.getTenantId(), "客户");
 		List<String> cname = data.stream().map(CorpsDescImportExcel::getCname).filter(Objects::nonNull).distinct().collect(Collectors.toList());
-		if (cname.isEmpty()){
+		if (cname.isEmpty()) {
 			throw new RuntimeException("客户名称不能为空");
 		}
 		LambdaQueryWrapper<PjCorpsDesc> queryWrapper = new LambdaQueryWrapper<>();
@@ -332,13 +331,13 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
 				}
 			}
 			//名称相等视为重复数据
-			PjCorpsDesc selectOne = selectList.stream().filter(i-> i.getCname().equals(corpsDesc.getCname()))
+			PjCorpsDesc selectOne = selectList.stream().filter(i -> i.getCname().equals(corpsDesc.getCname()))
 				.findFirst().orElse(null);
 			if (selectOne == null) {
 				corpsDesc.setCreateTime(new Date());
 				corpsDesc.setCreateUser(AuthUtil.getUserId());
 				corpsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
-				corpsDesc.setCheckStatus("通过");
+				corpsDesc.setCheckStatus("审核通过");
 				baseMapper.insert(corpsDesc);
 				PjCorpsTypeDesc middle = new PjCorpsTypeDesc();
 				middle.setCorpId(corpsDesc.getId());
@@ -478,273 +477,37 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
 	}
 
 	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public R saveCorpsDescApp(CorpsDescVO corpsDescVO) {
+	public R submitApply(Long id) {
 		PjCorpsDesc corpsDesc = new PjCorpsDesc();
-		BeanUtil.copyProperties(corpsDescVO, corpsDesc);
-		Long userId = SecureUtil.getUserId();
-		Long deptId = Long.valueOf(AuthUtil.getDeptId());
-		Date date = new Date();
-
-		if (ObjectUtils.isNotNull(corpsDesc.getBrandId())) {
-			List<PjBrandDesc> pjBrandDescList = brandDescService.list(new LambdaQueryWrapper<PjBrandDesc>()
-				.eq(PjBrandDesc::getTenantId, AuthUtil.getTenantId())
-				.eq(PjBrandDesc::getIsDeleted, 0)
-				.eq(PjBrandDesc::getType, "PP")
-				.eq(PjBrandDesc::getEnableOrNot, 1)
-				.apply("find_in_set(id,'" + corpsDesc.getBrandId() + "')"));
-			if (!pjBrandDescList.isEmpty()) {
-				corpsDesc.setBrandName(pjBrandDescList.stream().map(PjBrandDesc::getCname).collect(Collectors.joining(",")));
-			}
-		}
-
-		R<Dept> resDept = sysClient.getDept(Long.parseLong(AuthUtil.getDeptId()));
-		if (!resDept.isSuccess() || ObjectUtils.isNull(resDept.getData())) {
-			throw new RuntimeException("未找到小程序id");
-		}
-		String deptName = resDept.getData().getFullName();
-		//保存客户信息
-		corpsDesc.setCorpType("KH");
-		if (StringUtils.isBlank(corpsDesc.getCname())) {
-			return R.data(200, "error", "客户名称不能为空");
-		}
-		User user = userClient.loginByAccount("", corpsDesc.getTel(), "4", AuthUtil.getTenantId(), resDept.getData().getAppletsId());
-		if (ObjectUtils.isNull(user)) {
-			//用户不存在,注册用户
-			User saveUser = new User();
-			saveUser.setAppletsId(resDept.getData().getAppletsId());
-			saveUser.setTenantId(AuthUtil.getTenantId());
-			saveUser.setAccount(corpsDesc.getTel());
-			saveUser.setName(corpsDesc.getTel());
-			saveUser.setRealName(corpsDesc.getTel());
-			saveUser.setUserType(4);
-			saveUser.setPhone(corpsDesc.getTel());
-			saveUser.setDeptId(AuthUtil.getDeptId());
-			//获取注册用户类型
-			R<String> r = sysClient.getRoleIds(AuthUtil.getTenantId(), "客户");
-			if (r.isSuccess() && ObjectUtils.isNotNull(r.getData())) {
-				saveUser.setRoleId(r.getData());
-			} else {
-				saveUser.setRoleId("");
-			}
-			saveUser.setPassword("123456");
-			R<Boolean> result = userClient.saveUser(saveUser);
-			if (!result.isSuccess()) {
-				throw new RuntimeException(result.getMsg());
-			}
-			R<UserInfo> resu = userClient.userInfo(AuthUtil.getTenantId(), corpsDesc.getTel(), UserEnum.WECHAT.getName());
-			if (resu.isSuccess()) {
-				user = resu.getData().getUser();
-			} else {
-				throw new RuntimeException("创建用户失败");
-			}
-		}
-		List<PjCorpsDesc> pjCorpsDesc = baseMapper.selectList(new LambdaQueryWrapper<PjCorpsDesc>()
-			.eq(PjCorpsDesc::getTenantId, AuthUtil.getTenantId())
-			.eq(PjCorpsDesc::getIsDeleted, 0)
-			.eq(PjCorpsDesc::getCname, corpsDesc.getCname()));
-		List<PjCorpsDesc> corpsDescTel = baseMapper.selectList(new LambdaQueryWrapper<PjCorpsDesc>()
-			.eq(PjCorpsDesc::getTenantId, AuthUtil.getTenantId())
-			.eq(PjCorpsDesc::getIsDeleted, 0)
-			.eq(PjCorpsDesc::getTel, corpsDesc.getTel()));
-		if (null == corpsDesc.getId()) {
-			if (!pjCorpsDesc.isEmpty()) {
-				throw new RuntimeException("客户" + corpsDesc.getCname() + "已存在,请勿重复添加!");
-			}
-			if (!corpsDescTel.isEmpty()) {
-				throw new RuntimeException("客户" + corpsDesc.getTel() + "已存在,请勿重复添加!");
-			}
-			corpsDesc.setTenantId(SecureUtil.getTenantId());
-			corpsDesc.setCreateDept(Long.valueOf(SecureUtil.getDeptId()));
-			corpsDesc.setCreateTime(date);
-			corpsDesc.setCreateUser(userId);
-			corpsDesc.setPriceSystem("售价1");
-			corpsDesc.setSalesCompanyId(deptId);
-			corpsDesc.setSalesCompanyName(deptName);
-			baseMapper.insert(corpsDesc);
-			Long pId = corpsDesc.getId();
-			String tenantId = corpsDesc.getTenantId();
-
-			//保存客户联系人信息
-			PjCorpsAttn corpsAttn = new PjCorpsAttn();
-			if (ObjectUtils.isNotNull(user)) {
-				long count = corpsAttnService.count(new LambdaQueryWrapper<PjCorpsAttn>()
-					.eq(PjCorpsAttn::getUserId, user.getId())
-					.eq(PjCorpsAttn::getTel, corpsDesc.getTel())
-					.eq(PjCorpsAttn::getTenantId, AuthUtil.getTenantId())
-					.eq(PjCorpsAttn::getIsDeleted, 0));
-				if (count > 0) {
-					throw new RuntimeException("手机号已存在,提交失败");
-				}
-				corpsAttn.setUserId(user.getId());
-			}
-			List<PjCorpsAttn> corpsAttnList = corpsAttnService.list(new LambdaQueryWrapper<PjCorpsAttn>()
-				.eq(PjCorpsAttn::getTel, corpsDesc.getTel())
-				.eq(PjCorpsAttn::getTenantId, AuthUtil.getTenantId())
-				.eq(PjCorpsAttn::getIsDeleted, 0));
-			if (!corpsAttnList.isEmpty()) {
-				PjCorpsDesc pjCorpsDesc1 = baseMapper.selectById(corpsAttnList.get(0).getPid());
-				if (pjCorpsDesc1 != null) {
-					throw new RuntimeException("该手机号:" + corpsDesc.getTel() + "已经在客户:" + pjCorpsDesc1.getCname() + "注册,请修改客户名称");
-				} else {
-					throw new RuntimeException("该手机号未查到客户信息");
-				}
-			}
-			corpsAttn.setCname(corpsDescVO.getAttn());
-			corpsAttn.setTel(corpsDesc.getTel());
-			corpsAttn.setTenantId(AuthUtil.getTenantId());
-			corpsAttn.setPid(corpsDesc.getId());
-			corpsAttn.setCreateTime(new Date());
-			corpsAttn.setTenantId(AuthUtil.getTenantId());
-			corpsAttn.setCreateUser(AuthUtil.getUserId());
-			corpsAttn.setSalesCompanyId(deptId);
-			corpsAttn.setSalesCompanyName(deptName);
-			corpsAttnService.save(corpsAttn);
-
-			//保存客户地址信息
-			PjCorpsAddr corpsAddr = new PjCorpsAddr();
-			corpsAddr.setContacts(corpsDescVO.getAttn());
-			corpsAddr.setTel(corpsDesc.getTel());
-			corpsAddr.setBelongtoarea(corpsDescVO.getAddr());
-			corpsAddr.setDetailedAddress(corpsDescVO.getDetails());
-			corpsAddr.setTenantId(AuthUtil.getTenantId());
-			corpsAddr.setPid(corpsDesc.getId());
-			corpsAddr.setCreateTime(new Date());
-			corpsAddr.setTenantId(AuthUtil.getTenantId());
-			corpsAddr.setCreateUser(AuthUtil.getUserId());
-			corpsAddr.setDefaultAddres("1");
-			corpsAddrService.save(corpsAddr);
-			//保存客户与类别对应关系
-			this.saveOrUpdateTypeDesc(corpsDescVO, userId, pId, date, tenantId);
-		} else {
-			List<Long> ids = pjCorpsDesc.stream().map(PjCorpsDesc::getId).distinct().collect(Collectors.toList());
-			if (!pjCorpsDesc.isEmpty() && !ids.contains(corpsDesc.getId())) {
-				throw new RuntimeException("客户" + corpsDesc.getCname() + "已存在,请勿重复添加!");
-			}
-			List<Long> idList = corpsDescTel.stream().map(PjCorpsDesc::getId).distinct().collect(Collectors.toList());
-			if (!corpsDescTel.isEmpty() && !idList.contains(corpsDesc.getId())) {
-				throw new RuntimeException("客户" + corpsDesc.getTel() + "已存在,请勿重复添加!");
-			}
-			corpsDesc.setUpdateTime(new Date());
-			corpsDesc.setUpdateUser(AuthUtil.getUserId());
-			baseMapper.updateById(corpsDesc);
-			List<PjCorpsAttn> corpsAttnList = corpsAttnService.list(new LambdaQueryWrapper<PjCorpsAttn>()
-				.eq(PjCorpsAttn::getIsDeleted, 0)
-				.eq(PjCorpsAttn::getTenantId, AuthUtil.getTenantId())
-				.eq(PjCorpsAttn::getTel, corpsDesc.getTel()));
-			PjCorpsAttn corpsAttn = corpsAttnService.getOne(new LambdaQueryWrapper<PjCorpsAttn>().eq(PjCorpsAttn::getIsDeleted, 0)
-				.eq(PjCorpsAttn::getTenantId, AuthUtil.getTenantId())
-				.eq(PjCorpsAttn::getPid, corpsDesc.getId())
-				.eq(PjCorpsAttn::getTel, corpsDesc.getTel()));
-			if (ObjectUtils.isNotNull(corpsAttn)) {
-				List<Long> idLists = corpsAttnList.stream().map(PjCorpsAttn::getId).distinct().collect(Collectors.toList());
-				if (!corpsAttnList.isEmpty() && !idLists.contains(corpsAttn.getId())) {
-					throw new RuntimeException("客户" + corpsDesc.getTel() + "已存在,请勿重复添加!");
-				}
-				if (ObjectUtils.isNotNull(user)) {
-					corpsAttn.setUserId(user.getId());
-				}
-				corpsAttn.setCname(corpsDescVO.getAttn());
-				corpsAttn.setTel(corpsDesc.getTel());
-				corpsAttn.setSalesCompanyId(deptId);
-				corpsAttn.setSalesCompanyName(deptName);
-				corpsAttnService.updateById(corpsAttn);
-			} else {
-				if (!corpsAttnList.isEmpty()) {
-					throw new RuntimeException("客户" + corpsDesc.getTel() + "已存在,请勿重复添加!");
-				}
-				//保存客户联系人信息
-				PjCorpsAttn corpsAttn1 = new PjCorpsAttn();
-				if (ObjectUtils.isNotNull(user)) {
-					corpsAttn1.setUserId(user.getId());
-				}
-				corpsAttn1.setCname(corpsDescVO.getAttn());
-				corpsAttn1.setTel(corpsDesc.getTel());
-				corpsAttn1.setTenantId(AuthUtil.getTenantId());
-				corpsAttn1.setPid(corpsDesc.getId());
-				corpsAttn1.setCreateTime(new Date());
-				corpsAttn1.setCreateUser(AuthUtil.getUserId());
-				corpsAttn1.setSalesCompanyId(deptId);
-				corpsAttn1.setSalesCompanyName(deptName);
-				corpsAttnService.save(corpsAttn1);
-			}
-
-			PjCorpsAddr corpsAddr = corpsAddrService.getOne(new LambdaQueryWrapper<PjCorpsAddr>().eq(PjCorpsAddr::getIsDeleted, 0)
-				.eq(PjCorpsAddr::getTenantId, AuthUtil.getTenantId())
-				.eq(PjCorpsAddr::getPid, corpsDesc.getId())
-				.eq(PjCorpsAddr::getTel, corpsDesc.getTel()));
-			if (ObjectUtils.isNotNull(corpsAddr)) {
-				corpsAddr.setContacts(corpsDescVO.getAttn());
-				corpsAddr.setTel(corpsDesc.getTel());
-				corpsAddr.setBelongtoarea(corpsDescVO.getAddr());
-				corpsAddr.setDetailedAddress(corpsDescVO.getDetails());
-				corpsAddr.setSalesCompanyId(deptId);
-				corpsAddr.setSalesCompanyName(deptName);
-				corpsAddrService.updateById(corpsAddr);
-			} else {
-				//保存客户地址信息
-				PjCorpsAddr corpsAddr1 = new PjCorpsAddr();
-				corpsAddr1.setContacts(corpsDescVO.getAttn());
-				corpsAddr1.setTel(corpsDesc.getTel());
-				corpsAddr1.setBelongtoarea(corpsDescVO.getAddr());
-				corpsAddr1.setDetailedAddress(corpsDescVO.getDetails());
-				corpsAddr1.setTenantId(AuthUtil.getTenantId());
-				corpsAddr1.setPid(corpsDesc.getId());
-				corpsAddr1.setCreateTime(new Date());
-				corpsAddr1.setTenantId(AuthUtil.getTenantId());
-				corpsAddr1.setCreateUser(AuthUtil.getUserId());
-				corpsAddr1.setSalesCompanyId(deptId);
-				corpsAddr1.setSalesCompanyName(deptName);
-				corpsAddr1.setDefaultAddres("0");
-				corpsAddrService.save(corpsAddr1);
-			}
-		}
-		//保存客户与类别对应关系
-		this.saveOrUpdateTypeDesc(corpsDescVO, userId, corpsDesc.getId(), date, AuthUtil.getTenantId());
+		corpsDesc.setId(id);
+		corpsDesc.setUpdateTime(new Date());
+		corpsDesc.setUpdateUser(AuthUtil.getUserId());
+		corpsDesc.setCheckStatus("提交");
+		baseMapper.updateById(corpsDesc);
 		return R.data(corpsDesc);
 	}
 
 	@Override
-	public R appDetailsV1(Long id) {
-		CorpsDescVO corpsDescVO = new CorpsDescVO();
+	public R review(Long id, String type) {
 		PjCorpsDesc corpsDesc = baseMapper.selectById(id);
-		BeanUtil.copyProperties(corpsDesc, corpsDescVO);
-		if (ObjectUtils.isNotNull(corpsDesc)) {
-			PjCorpsAddr corpsAddr = corpsAddrService.getOne(new LambdaQueryWrapper<PjCorpsAddr>().eq(PjCorpsAddr::getIsDeleted, 0)
-				.eq(PjCorpsAddr::getTenantId, AuthUtil.getTenantId())
-				.eq(PjCorpsAddr::getPid, corpsDesc.getId())
-				.eq(PjCorpsAddr::getDefaultAddres, "1"));
-			if (ObjectUtils.isNotNull(corpsAddr)) {
-				corpsDescVO.setAddr(corpsAddr.getBelongtoarea());
-				corpsDescVO.setDetails(corpsAddr.getDetailedAddress());
-			}
-			PjCorpsAttn pjCorpsAttn = corpsAttnService.getOne(new LambdaQueryWrapper<PjCorpsAttn>().eq(PjCorpsAttn::getIsDeleted, 0)
+		if ("1".equals(type)) {
+			corpsDesc.setUpdateTime(new Date());
+			corpsDesc.setUpdateUser(AuthUtil.getUserId());
+			corpsDesc.setCheckStatus("审核通过");
+			List<PjCorpsAttn> corpsAttnList = corpsAttnService.list(new LambdaQueryWrapper<PjCorpsAttn>()
+				.eq(PjCorpsAttn::getPid, id)
+				.eq(PjCorpsAttn::getIsDeleted, 0)
 				.eq(PjCorpsAttn::getTenantId, AuthUtil.getTenantId())
-				.eq(PjCorpsAttn::getPid, corpsDesc.getId())
-				.eq(PjCorpsAttn::getTel, corpsDesc.getTel()));
-			if (ObjectUtils.isNotNull(pjCorpsAttn)) {
-				corpsDescVO.setAttn(pjCorpsAttn.getCname());
-				corpsDesc.setTel(pjCorpsAttn.getTel());
-			}
-			List<PjCorpsAttn> attnList = corpsAttnService.list(new LambdaQueryWrapper<PjCorpsAttn>().eq(PjCorpsAttn::getIsDeleted, 0)
-				.eq(PjCorpsAttn::getTenantId, AuthUtil.getTenantId())
-				.eq(PjCorpsAttn::getPid, corpsDesc.getId()));
-			corpsDescVO.setNumber(new BigDecimal(attnList.size()));
-			//获取客户类别
-			List<String> longs = corpsTypeDescService.selectTypeId(corpsDesc.getId());
-			corpsDescVO.setCorpsTypeId(String.join(",", longs));
-			StringBuilder corpsTypeName = new StringBuilder();
-			if (ObjectUtils.isNotNull(longs)) {
-				for (String item : longs) {
-					String name = corpsTypeService.getById(Long.parseLong(item)) == null ? "" : corpsTypeService.getById(Long.parseLong(item)).getCname();
-					corpsTypeName.append(name).append(",");
-				}
-				String corpsName = corpsTypeName.substring(0, corpsTypeName.length() - 1);
-				corpsDescVO.setCorpsTypeName(corpsName);
-			} else {
-				corpsDescVO.setCorpsTypeName("");
+				.and(i -> i.isNull(PjCorpsAttn::getUserId).or().eq(PjCorpsAttn::getUserId, 0)));
+			if (!corpsAttnList.isEmpty()){
+				corpsAttnService.createUserBatch(corpsAttnList);
 			}
+		} else {
+			corpsDesc.setUpdateTime(new Date());
+			corpsDesc.setUpdateUser(AuthUtil.getUserId());
+			corpsDesc.setCheckStatus("审核驳回");
 		}
+		baseMapper.updateById(corpsDesc);
 		return R.data(corpsDesc);
 	}
 
@@ -866,7 +629,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
 			return;
 		}
 		List<String> list = Arrays.asList(corpsDesc.getCorpsTypeId().split(","));
-		corpsTypeDescService.remove(new QueryWrapper<PjCorpsTypeDesc>().eq("corp_id", corpsDesc.getId()));
+		corpsTypeDescService.remove(new QueryWrapper<PjCorpsTypeDesc>().eq("corp_id", pId));
 		List<PjCorpsTypeDesc> typeDescList = corpsTypeDescService.list(new QueryWrapper<PjCorpsTypeDesc>().eq("corp_id", pId)
 			.in("corp_type_id", list));
 		List<PjCorpsTypeDesc> typeDescListNew = new ArrayList<>();
@@ -874,13 +637,13 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
 			PjCorpsTypeDesc typeDesc = typeDescList.stream().filter(e -> item.equals(e.getCorpTypeId() + "")).findFirst().orElse(null);
 			if (typeDesc != null) {
 				typeDesc.setCorpTypeId(Long.valueOf(item));
-				typeDesc.setCorpId(corpsDesc.getId());
+				typeDesc.setCorpId(pId);
 				typeDesc.setUpdateTime(date);
 				typeDesc.setUpdateUser(userId);
 				typeDescListNew.add(typeDesc);
 			} else {
 				PjCorpsTypeDesc corpsTypeDesc = new PjCorpsTypeDesc();
-				corpsTypeDesc.setCorpId(corpsDesc.getId());
+				corpsTypeDesc.setCorpId(pId);
 				corpsTypeDesc.setCorpTypeId(Long.valueOf(item));
 				corpsTypeDesc.setCreateUser(userId);
 				corpsTypeDesc.setCreateTime(date);

+ 2 - 0
blade-service/gubersail-dealer-admin/src/main/java/com/gubersail/admin/goods/service/impl/BrandDescServiceImpl.java

@@ -40,6 +40,7 @@ import org.springblade.system.feign.ISysClient;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
 import java.util.List;
@@ -95,6 +96,7 @@ public class BrandDescServiceImpl extends ServiceImpl<BrandDescMapper, PjBrandDe
 	 * @return
 	 */
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public PjBrandDesc saveMessage(PjBrandDesc brandDesc) {
 
 		if (brandDesc.getId() != null) {