Commit 7c6471a2 authored by lcl's avatar lcl

客户认领补充

parent db83f983
......@@ -193,6 +193,15 @@ public class CustomerController extends BaseController {
return success;
}
/**
* 客户状态
*/
@GetMapping("/status/{customerId}")
@RepeatSubmit
public AjaxResult status(@PathVariable String customerId) {
return AjaxResult.success(baseService.status(customerId));
}
/**
* 取消认领
......
......@@ -3,6 +3,8 @@ package com.dsk.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dsk.system.domain.customer.CustomerUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
......@@ -14,5 +16,7 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CustomerUserMapper extends BaseMapper<CustomerUser> {
CustomerUser selectByCustomerIdAndUserId(@Param("customerId") String customerId,@Param("userId") Long userId);
}
......@@ -31,6 +31,8 @@ public interface ICustomerService {
List<String> selectUipIdList(List<String> uipIds);
Integer status(String customerId);
boolean cancelClaim(String customerId);
boolean historyClaim(String customerId);
......
......@@ -125,21 +125,31 @@ public class CustomerServiceImpl implements ICustomerService {
return baseMapper.selectUipIdList(uipIds, SecurityUtils.getUserId());
}
@Override
public Integer status(String customerId) {
CustomerUser customerUser = customerUserMapper.selectByCustomerIdAndUserId(customerId, SecurityUtils.getUserId());
if (ObjectUtils.isEmpty(customerUser)) {
return null;
}
return customerUser.getStatus();
}
@Override
public boolean cancelClaim(String customerId) {
return updateClaimStatus(customerId,1);
return updateClaimStatus(customerId, 1);
}
@Override
public boolean historyClaim(String customerId) {
return updateClaimStatus(customerId,0);
return updateClaimStatus(customerId, 0);
}
//修改客户认领状态
private boolean updateClaimStatus(String customerId,Integer status) {
CustomerUser customerUser = customerUserMapper.selectOne(Wrappers.<CustomerUser>lambdaQuery()
.eq(CustomerUser::getCustomerId, customerId)
.eq(CustomerUser::getUserId, SecurityUtils.getUserId()));
private boolean updateClaimStatus(String customerId, Integer status) {
CustomerUser customerUser = customerUserMapper.selectByCustomerIdAndUserId(customerId, SecurityUtils.getUserId());
if (ObjectUtils.isEmpty(customerUser)) {
throw new ServiceException("数据错误!");
}
customerUser.setStatus(status);
return customerUserMapper.updateById(customerUser) == 1;
}
......
......@@ -2,6 +2,13 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dsk.system.mapper.CustomerUserMapper">
<select id="selectByCustomerIdAndUserId" resultType="com.dsk.system.domain.customer.CustomerUser">
select
id, customer_id, user_id, status, create_time, update_time
from customer_user
where customer_id = #{customerId} and user_id = #{userId}
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment