|
|
@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.common.enums.CommonEnum;
|
|
|
+import org.springblade.common.enums.NumberEnum;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
@@ -18,6 +20,7 @@ import org.springblade.salesPart.brand.service.IBrandDescService;
|
|
|
import org.springblade.salesPart.corps.mapper.CorpsDescMapper;
|
|
|
import org.springblade.salesPart.corps.mapper.CorpsTypeDescMapper;
|
|
|
import org.springblade.salesPart.corps.mapper.CorpsTypeMapper;
|
|
|
+import org.springblade.salesPart.corps.mapper.CustomerReviewedParamMapper;
|
|
|
import org.springblade.salesPart.corps.service.ICorpsDescService;
|
|
|
import org.springblade.salesPart.corps.service.ICorpsVisitService;
|
|
|
import org.springblade.salesPart.entity.*;
|
|
|
@@ -68,6 +71,8 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
|
|
|
private final OrderMapper orderMapper;
|
|
|
|
|
|
+ private final CustomerReviewedParamMapper customerReviewedParamMapper;
|
|
|
+
|
|
|
static final int GB_SP_DIFF = 160;
|
|
|
// 存放国标一级汉字不同读音的起始区位码
|
|
|
static final int[] secPosValueList = {1601, 1637, 1833, 2078, 2274, 2302, 2433, 2594, 2787, 3106, 3212, 3472, 3635,
|
|
|
@@ -1243,6 +1248,31 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
return corpsDesc;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R submitCustomerReviewedParam(PjpfCustomerReviewedParam param) {
|
|
|
+ BladeUser nowUser = AuthUtil.getUser();
|
|
|
+ Date nowDate = new Date();
|
|
|
+ if (Objects.isNull(param.getId())) {
|
|
|
+ param.setTenantId(nowUser.getTenantId());
|
|
|
+ param.setCreateUser(nowUser.getUserId());
|
|
|
+ param.setCreateTime(nowDate);
|
|
|
+ int insertCount = customerReviewedParamMapper.insert(param);
|
|
|
+ return R.status(insertCount > 0);
|
|
|
+ }
|
|
|
+ param.setUpdateTime(nowDate);
|
|
|
+ param.setUpdateUser(nowUser.getUserId());
|
|
|
+ param.setVersion(param.getVersion() + 1);
|
|
|
+ int updateCount = customerReviewedParamMapper.update(param, new LambdaQueryWrapper<PjpfCustomerReviewedParam>()
|
|
|
+ .eq(PjpfCustomerReviewedParam::getId, param.getId()).eq(PjpfCustomerReviewedParam::getTenantId, nowUser.getTenantId()));
|
|
|
+ return R.status(updateCount > 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PjpfCustomerReviewedParam getCustomerReviewedParam() {
|
|
|
+ return customerReviewedParamMapper.selectOne(new LambdaQueryWrapper<PjpfCustomerReviewedParam>()
|
|
|
+ .eq(PjpfCustomerReviewedParam::getTenantId, AuthUtil.getTenantId()).orderByDesc(PjpfCustomerReviewedParam::getCreateTime).last("limit 1"));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 小程序新增或修改 客户详情
|
|
|
*
|
|
|
@@ -1252,36 +1282,36 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R saveCorpsDesc(PjCorpsDesc corpsDesc) {
|
|
|
+ if (StringUtils.isBlank(corpsDesc.getCname())) {
|
|
|
+ return R.fail("客户名称不能为空");
|
|
|
+ }
|
|
|
+ BladeUser nowUser = AuthUtil.getUser();
|
|
|
Long userId = SecureUtil.getUserId();
|
|
|
- Long deptId = Long.valueOf(AuthUtil.getDeptId());
|
|
|
+ Long deptId = Long.valueOf(nowUser.getDeptId());
|
|
|
Date date = new Date();
|
|
|
- if (null == corpsDesc.getInitials() || "".equals(corpsDesc.getInitials())) {//首字母为空
|
|
|
+ R<Dept> resDept = sysClient.getDept(deptId);
|
|
|
+ if (!resDept.isSuccess() || ObjectUtils.isNull(resDept.getData())) {
|
|
|
+ return R.fail("未找到小程序相关信息,请退出后重试");
|
|
|
+ }
|
|
|
+ String deptName = resDept.getData().getFullName();
|
|
|
+ if (null == corpsDesc.getInitials() || corpsDesc.getInitials().isEmpty()) {
|
|
|
//获得名称首字母
|
|
|
String initials = getSpells(corpsDesc.getCname());
|
|
|
corpsDesc.setInitials(initials.substring(0, 1));
|
|
|
}
|
|
|
- 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", "客户名称不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- PjCorpsDesc pjCorpsDesc = baseMapper.selectCorpsDescCname(corpsDesc.getCname(), AuthUtil.getDeptId(), AuthUtil.getTenantId());
|
|
|
+ PjCorpsDesc pjCorpsDesc = baseMapper.selectCorpsDescCname(corpsDesc.getCname(), nowUser.getDeptId(), nowUser.getTenantId());
|
|
|
if (ObjectUtils.isNotNull(pjCorpsDesc)) {
|
|
|
pjCorpsDesc.setSalesCompanyId(deptId);
|
|
|
pjCorpsDesc.setSalesCompanyName(deptName);
|
|
|
baseMapper.updateById(pjCorpsDesc);
|
|
|
List<PjCorpsAttn> corpsAttnList = corpsAttnService.list(new LambdaQueryWrapper<PjCorpsAttn>()
|
|
|
.eq(PjCorpsAttn::getIsDeleted, 0)
|
|
|
- .eq(PjCorpsAttn::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjCorpsAttn::getTenantId, nowUser.getTenantId())
|
|
|
.eq(PjCorpsAttn::getTel, corpsDesc.getTel()));
|
|
|
PjCorpsAttn corpsAttn = corpsAttnService.getOne(new LambdaQueryWrapper<PjCorpsAttn>().eq(PjCorpsAttn::getIsDeleted, 0)
|
|
|
- .eq(PjCorpsAttn::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjCorpsAttn::getTenantId, nowUser.getTenantId())
|
|
|
.eq(PjCorpsAttn::getPid, pjCorpsDesc.getId())
|
|
|
.eq(PjCorpsAttn::getTel, corpsDesc.getTel())
|
|
|
);
|
|
|
@@ -1306,24 +1336,24 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
}
|
|
|
//保存客户联系人信息
|
|
|
PjCorpsAttn corpsAttn1 = new PjCorpsAttn();
|
|
|
- User user = userClient.loginByAccount("", corpsDesc.getTel(), "4", AuthUtil.getTenantId(), resDept.getData().getAppletsId());
|
|
|
+ User user = userClient.loginByAccount("", corpsDesc.getTel(), "4", nowUser.getTenantId(), resDept.getData().getAppletsId());
|
|
|
if (ObjectUtils.isNotNull(user)) {
|
|
|
corpsAttn1.setUserId(user.getId());
|
|
|
userClient.updateUserStorageId(user.getId() + "", pjCorpsDesc.getDeliveryWarehouseId(), pjCorpsDesc.getDeliveryWarehouseName());
|
|
|
}
|
|
|
corpsAttn1.setCname(corpsDesc.getAttn());
|
|
|
corpsAttn1.setTel(corpsDesc.getTel());
|
|
|
- corpsAttn1.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAttn1.setTenantId(nowUser.getTenantId());
|
|
|
corpsAttn1.setPid(pjCorpsDesc.getId());
|
|
|
corpsAttn1.setCreateTime(new Date());
|
|
|
- corpsAttn1.setCreateUser(AuthUtil.getUserId());
|
|
|
+ corpsAttn1.setCreateUser(nowUser.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::getTenantId, nowUser.getTenantId())
|
|
|
.eq(PjCorpsAddr::getPid, pjCorpsDesc.getId())
|
|
|
.eq(PjCorpsAddr::getTel, corpsDesc.getTel()));
|
|
|
if (ObjectUtils.isNotNull(corpsAddr)) {
|
|
|
@@ -1341,11 +1371,11 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
corpsAddr1.setTel(corpsDesc.getTel());
|
|
|
corpsAddr1.setBelongtoarea(corpsDesc.getAddr());
|
|
|
corpsAddr1.setDetailedAddress(corpsDesc.getDetails());
|
|
|
- corpsAddr1.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAddr1.setTenantId(nowUser.getTenantId());
|
|
|
corpsAddr1.setPid(pjCorpsDesc.getId());
|
|
|
corpsAddr1.setCreateTime(new Date());
|
|
|
- corpsAddr1.setTenantId(AuthUtil.getTenantId());
|
|
|
- corpsAddr1.setCreateUser(AuthUtil.getUserId());
|
|
|
+ corpsAddr1.setTenantId(nowUser.getTenantId());
|
|
|
+ corpsAddr1.setCreateUser(nowUser.getUserId());
|
|
|
corpsAddr1.setSalesCompanyId(deptId);
|
|
|
corpsAddr1.setSalesCompanyName(deptName);
|
|
|
corpsAddr1.setDefaultAddres("0");
|
|
|
@@ -1353,11 +1383,26 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
}
|
|
|
} else {
|
|
|
if (null == corpsDesc.getId()) {
|
|
|
- corpsDesc.setTenantId(SecureUtil.getTenantId());
|
|
|
- corpsDesc.setCreateDept(Long.valueOf(SecureUtil.getDeptId()));
|
|
|
+ String customerNotReviewedParam = sysClient.getParamService("customer_not_reviewed");
|
|
|
+ if (Objects.equals(CommonEnum.ONE.info, customerNotReviewedParam)) {
|
|
|
+ PjpfCustomerReviewedParam pjpfCustomerReviewedParam = customerReviewedParamMapper.selectOne(new LambdaQueryWrapper<PjpfCustomerReviewedParam>()
|
|
|
+ .eq(PjpfCustomerReviewedParam::getTenantId, nowUser.getTenantId()).eq(PjpfCustomerReviewedParam::getIsDeleted, 0)
|
|
|
+ .orderByDesc(PjpfCustomerReviewedParam::getCreateTime).last(" limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(pjpfCustomerReviewedParam)) {
|
|
|
+ corpsDesc.setDeliveryWarehouseId(pjpfCustomerReviewedParam.getWarehouseId());
|
|
|
+ corpsDesc.setDeliveryWarehouseName(pjpfCustomerReviewedParam.getWarehouseName());
|
|
|
+ corpsDesc.setPriceSystem(pjpfCustomerReviewedParam.getPriceType());
|
|
|
+ corpsDesc.setSalesmanId(pjpfCustomerReviewedParam.getSalesMan());
|
|
|
+ corpsDesc.setSalesmanName(pjpfCustomerReviewedParam.getSalesManName());
|
|
|
+ corpsDesc.setCheckStatus("通过");
|
|
|
+ corpsDesc.setEnableOrNot(NumberEnum.ONE.number);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ corpsDesc.setTenantId(nowUser.getTenantId());
|
|
|
+ corpsDesc.setCreateDept(deptId);
|
|
|
corpsDesc.setCreateTime(date);
|
|
|
corpsDesc.setCreateUser(userId);
|
|
|
- corpsDesc.setPriceSystem("售价1");
|
|
|
+ corpsDesc.setPriceSystem(StringUtils.isNotBlank(corpsDesc.getPriceSystem()) ? corpsDesc.getPriceSystem() : "售价1");
|
|
|
corpsDesc.setSalesCompanyId(deptId);
|
|
|
corpsDesc.setSalesCompanyName(deptName);
|
|
|
baseMapper.insert(corpsDesc);
|
|
|
@@ -1368,7 +1413,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
PjCorpsAttn corpsAttn = new PjCorpsAttn();
|
|
|
List<PjCorpsAttn> corpsAttnList = corpsAttnService.list(new LambdaQueryWrapper<PjCorpsAttn>()
|
|
|
.eq(PjCorpsAttn::getTel, corpsDesc.getTel())
|
|
|
- .eq(PjCorpsAttn::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjCorpsAttn::getTenantId, nowUser.getTenantId())
|
|
|
.eq(PjCorpsAttn::getIsDeleted, 0));
|
|
|
if (!corpsAttnList.isEmpty()) {
|
|
|
PjCorpsDesc pjCorpsDesc1 = baseMapper.selectById(corpsAttnList.get(0).getPid());
|
|
|
@@ -1378,12 +1423,12 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
throw new RuntimeException("该手机号未查到客户信息");
|
|
|
}
|
|
|
}
|
|
|
- User user = userClient.loginByAccount("", corpsDesc.getTel(), "4", AuthUtil.getTenantId(), resDept.getData().getAppletsId());
|
|
|
+ User user = userClient.loginByAccount("", corpsDesc.getTel(), "4", nowUser.getTenantId(), resDept.getData().getAppletsId());
|
|
|
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::getTenantId, nowUser.getTenantId())
|
|
|
.eq(PjCorpsAttn::getIsDeleted, 0));
|
|
|
if (count > 0) {
|
|
|
throw new RuntimeException("手机号已存在,提交失败");
|
|
|
@@ -1393,11 +1438,11 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
}
|
|
|
corpsAttn.setCname(corpsDesc.getAttn());
|
|
|
corpsAttn.setTel(corpsDesc.getTel());
|
|
|
- corpsAttn.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAttn.setTenantId(nowUser.getTenantId());
|
|
|
corpsAttn.setPid(corpsDesc.getId());
|
|
|
corpsAttn.setCreateTime(new Date());
|
|
|
- corpsAttn.setTenantId(AuthUtil.getTenantId());
|
|
|
- corpsAttn.setCreateUser(AuthUtil.getUserId());
|
|
|
+ // corpsAttn.setTenantId(nowUser.getTenantId());
|
|
|
+ corpsAttn.setCreateUser(nowUser.getUserId());
|
|
|
corpsAttn.setSalesCompanyId(deptId);
|
|
|
corpsAttn.setSalesCompanyName(deptName);
|
|
|
corpsAttnService.save(corpsAttn);
|
|
|
@@ -1408,73 +1453,21 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
corpsAddr.setTel(corpsDesc.getTel());
|
|
|
corpsAddr.setBelongtoarea(corpsDesc.getAddr());
|
|
|
corpsAddr.setDetailedAddress(corpsDesc.getDetails());
|
|
|
- corpsAddr.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAddr.setTenantId(nowUser.getTenantId());
|
|
|
corpsAddr.setPid(corpsDesc.getId());
|
|
|
corpsAddr.setCreateTime(new Date());
|
|
|
- corpsAddr.setTenantId(AuthUtil.getTenantId());
|
|
|
- corpsAddr.setCreateUser(AuthUtil.getUserId());
|
|
|
+ //corpsAddr.setTenantId(nowUser.getTenantId());
|
|
|
+ corpsAddr.setCreateUser(nowUser.getUserId());
|
|
|
corpsAddr.setDefaultAddres("1");
|
|
|
corpsAddrService.save(corpsAddr);
|
|
|
//保存客户与类别对应关系
|
|
|
this.saveOrUpdateTypeDesc(corpsDesc, userId, pId, date, tenantId);
|
|
|
} else {
|
|
|
corpsDesc.setUpdateTime(new Date());
|
|
|
- corpsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ corpsDesc.setUpdateUser(nowUser.getUserId());
|
|
|
baseMapper.updateById(corpsDesc);
|
|
|
}
|
|
|
}
|
|
|
- /*PjShip item = new PjShip();
|
|
|
- //给角色为财务的人发送消息
|
|
|
- R<String> clientDeptIds = sysClient.getRoleIds(AuthUtil.getTenantId(), "客服");
|
|
|
- StringBuilder openIds = new StringBuilder();
|
|
|
- if (clientDeptIds.isSuccess() && StringUtils.isNotBlank(clientDeptIds.getData())) {
|
|
|
- R<List<User>> userList = userClient.listUserByRoleId(clientDeptIds.getData(), AuthUtil.getTenantId(), AuthUtil.getDeptId());
|
|
|
- if (userList.isSuccess() && CollectionUtils.isNotEmpty(userList.getData())) {
|
|
|
- for (User datum : userList.getData()) {
|
|
|
- if (ObjectUtils.isNotNull(datum.getOaOpenId())) {
|
|
|
- openIds.append(datum.getOaOpenId()).append(",");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
|
|
|
- String date1 = format.format(new Date());
|
|
|
- System.out.println("=========发送人openIds=========" + openIds);
|
|
|
- if (ObjectUtils.isNotNull(openIds)) {
|
|
|
- R<List<WechatMessageConfigurationItem>> res = wechatClient.getTemplateType("1", AuthUtil.getTenantId());
|
|
|
- if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
|
|
|
- item.setDate(date1);
|
|
|
- item.setGoodsNames("商品json");
|
|
|
- item.setCustomerName("客户名称");
|
|
|
- item.setBillno("13456");
|
|
|
- List<WxMpTemplateData> data = new ArrayList<>();
|
|
|
- for (WechatMessageConfigurationItem items : res.getData()) {
|
|
|
- try {
|
|
|
- // 根据方法名获取对应的Method对象
|
|
|
- Method method = item.getClass().getMethod(items.getMethod());
|
|
|
- // 调用get方法并打印结果
|
|
|
- Object result = method.invoke(item);
|
|
|
- System.out.println(result);
|
|
|
- if (ObjectUtils.isNotNull(result)) {
|
|
|
- data.add(new WxMpTemplateData(items.getDataValue(), result.toString()));
|
|
|
- } else {
|
|
|
- data.add(new WxMpTemplateData(items.getDataValue(), "无"));
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- if (!data.isEmpty()) {
|
|
|
- WxMpTemplateDto wxMpTemplateDto = new WxMpTemplateDto();
|
|
|
- wxMpTemplateDto.setOpenid(openIds.substring(0, openIds.length() - 1));
|
|
|
- wxMpTemplateDto.setTenantId(AuthUtil.getTenantId());
|
|
|
- wxMpTemplateDto.setType("1");
|
|
|
- wxMpTemplateDto.setData(data);
|
|
|
- String rest = wechatClient.sendMessageNew(wxMpTemplateDto);
|
|
|
- System.out.println("=========发送返回值=========" + rest);
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
return R.data(corpsDesc);
|
|
|
}
|
|
|
|