客户健康信息修改

This commit is contained in:
xiezhijun
2021-02-02 20:29:53 +08:00
parent 851802861f
commit b89225bc6a
21 changed files with 1959 additions and 857 deletions

View File

@ -30,14 +30,6 @@ public interface ISysCustomerHealthyService
*/
public List<SysCustomerHealthy> selectSysCustomerHealthyList(SysCustomerHealthy sysCustomerHealthy);
/**
* 新增或修改客户健康(已弃用)
*
* @param sysCustomerHealthy 客户健康
* @return 结果
*/
public AjaxResult insertOrUpdateSysCustomerHealthy(SysCustomerHealthy sysCustomerHealthy);
/**
* 新增客户健康
*
@ -46,6 +38,13 @@ public interface ISysCustomerHealthyService
*/
public AjaxResult insertSysCustomerHealthy(SysCustomerHealthy sysCustomerHealthy);
/**
* 编辑客户健康
* @param sysCustomerHealthy
* @return
*/
public int updateSysCustomerHealthy(SysCustomerHealthy sysCustomerHealthy);
/**
* 批量删除客户健康
*

View File

@ -54,72 +54,6 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService
return sysCustomerHealthyMapper.selectSysCustomerHealthyList(sysCustomerHealthy);
}
/**
* 新增客户健康(已弃用)
*
* @param sysCustomerHealthy 客户健康
* @return 结果
*/
@Override
public AjaxResult insertOrUpdateSysCustomerHealthy(SysCustomerHealthy sysCustomerHealthy)
{
//当前登录用户
//LoginUser loginUser = SecurityUtils.getLoginUser();
Long cutomerId = 0L;
//新增
if(sysCustomerHealthy.getId() == null){
//根据手机号查询客户健康信息,判断是否已存在
SysCustomerHealthy customerHealthy = selectSysCustomerHealthyByPhone(sysCustomerHealthy.getPhone());
if(customerHealthy != null){
return AjaxResult.error("该手机号已存在");
}
//根据手机号查询客户基础信息,判断是否已存在
SysCustomer phoneCustomer = sysCustomerService.getCustomerByPhone(sysCustomerHealthy.getPhone());
if(phoneCustomer != null){
if(!sysCustomerHealthy.getName().equals(phoneCustomer.getName())){
return AjaxResult.error("该手机号与姓名不符");
}
cutomerId = phoneCustomer.getId();
}else{
SysCustomer newSysCustomer = new SysCustomer();
newSysCustomer.setName(sysCustomerHealthy.getName());
newSysCustomer.setPhone(sysCustomerHealthy.getPhone());
if(sysCustomerService.insertSysCustomer(newSysCustomer) > 0){
cutomerId = newSysCustomer.getId();
}
}
}
//更新
else{
SysCustomer oldCustomer = sysCustomerService.selectSysCustomerById(sysCustomerHealthy.getCustomerId());
//如果修改了手机号,则需要判断手机号是否已经存在
if(oldCustomer != null && !oldCustomer.getPhone().equals(sysCustomerHealthy.getPhone())) {
//验证该手机号是否已存在客户健康信息
SysCustomerHealthy customerHealthy = selectSysCustomerHealthyByPhone(sysCustomerHealthy.getPhone());
if (customerHealthy != null) {
return AjaxResult.error("该手机号已存在");
}
//根据手机号查询客户基础信息,判断是否已存在
SysCustomer phoneCustomer = sysCustomerService.getCustomerByPhone(sysCustomerHealthy.getPhone());
if(phoneCustomer != null) {
return AjaxResult.error("该手机号已存在");
}
}
SysCustomer newSysCustomer = new SysCustomer();
newSysCustomer.setId(sysCustomerHealthy.getCustomerId());
newSysCustomer.setName(sysCustomerHealthy.getName());
newSysCustomer.setPhone(sysCustomerHealthy.getPhone());
if(sysCustomerService.updateSysCustomer(newSysCustomer) > 0){
cutomerId = newSysCustomer.getId();
}
}
int rows = 0;
if(cutomerId != null && cutomerId > 0){
sysCustomerHealthy.setCustomerId(cutomerId);
rows = sysCustomerHealthy.getId() == null ? sysCustomerHealthyMapper.insertSysCustomerHealthy(sysCustomerHealthy) : sysCustomerHealthyMapper.updateSysCustomerHealthy(sysCustomerHealthy);
}
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
}
/**
* 新增客户健康
@ -130,7 +64,7 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService
public AjaxResult insertSysCustomerHealthy(SysCustomerHealthy sysCustomerHealthy){
//客户ID解密
String customerId = StringUtils.isNotEmpty(sysCustomerHealthy.getCustomerEncId()) ? AesUtils.decrypt(sysCustomerHealthy.getCustomerEncId(), null) : "";
if(StringUtils.isEmpty(customerId)){
if(sysCustomerHealthy.getCustomerId() == null && StringUtils.isEmpty(customerId)){
return AjaxResult.error("客户不存在");
}
//判断客户是否存在
@ -149,6 +83,16 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
}
/**
* 编辑客户健康
* @param sysCustomerHealthy
* @return
*/
@Override
public int updateSysCustomerHealthy(SysCustomerHealthy sysCustomerHealthy){
return sysCustomerHealthyMapper.updateSysCustomerHealthy(sysCustomerHealthy);
}
/**
* 批量删除客户健康
*

View File

@ -153,7 +153,7 @@
from sys_customer_healthy as sch
left join sys_customer sc on sc.id = sch.customer_id
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'conditioning_project') AS cp ON cp.dict_value = sch.conditioning_project_id
where sch.del_flag = 0 and sc.del_flag = 0 and sch.customer_id = #{customerId}
where sch.del_flag = 0 and sc.del_flag = 0 and sch.customer_id = #{customerId} order by sch.id desc limit 1
</select>
<insert id="insertSysCustomerHealthy" parameterType="SysCustomerHealthy">

View File

@ -69,7 +69,9 @@
<!-- 根据客户ID查询用户体征 -->
<select id="selectSysCustomerPhysicalSignsByCusId" parameterType="Long" resultMap="SysCustomerSignResult">
<include refid="selectSysCustomerPhysicalSigns"/> where scps.del_flag = 0 and sc.del_flag = 0 and scps.customer_id = #{id}
<include refid="selectSysCustomerPhysicalSigns"/>
where scps.del_flag = 0 and sc.del_flag = 0 and scps.customer_id = #{id}
order by scps.id desc limit 1
</select>
<insert id="insertSysCustomerPhysicalSigns" parameterType="SysCustomerPhysicalSigns" useGeneratedKeys="true" keyProperty="id">

View File

@ -327,9 +327,9 @@
<if test="userId != null">
and (su_sale.user_id = #{userId} or su_nutritionist.user_id = #{userId})
</if>
<if test="beginTime != null and beginTime != ''">
<!--<if test="beginTime != null and beginTime != ''">
AND o.order_time &gt;= #{beginTime}
</if>
</if>-->
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(o.order_time,'%Y-%m-%d') &lt;= #{endTime}
</if>