中扬CRM客户关系管理系统
#
luxiaotao1123
2022-09-12 c10d897c5d72fe80f271acbd909107e42dccff1c
#
5个文件已修改
61 ■■■■ 已修改文件
src/main/java/com/zy/crm/manager/controller/CstmrController.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/mapper/CstmrMapper.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/service/CstmrService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/CstmrMapper.xml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/controller/CstmrController.java
@@ -9,6 +9,7 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
import com.core.exception.CoolException;
import com.zy.crm.common.web.BaseController;
import com.zy.crm.manager.entity.Cstmr;
import com.zy.crm.manager.service.CstmrService;
@@ -61,8 +62,12 @@
    @RequestMapping(value = "/cstmr/add/auth")
    @ManagerAuth
    public R add(Cstmr cstmr) {
        cstmr.setHostId(getHostId());
        cstmr.setUuid(cstmrService.getNextUuid());  // 客户代号
        Long hostId = getHostId();
        if (cstmrService.selectByUuid(hostId, cstmr.getUuid()) != null) {
            throw new CoolException("客户已存在");
        }
        cstmr.setHostId(hostId);
        cstmr.setUuid(cstmrService.getNextUuid(hostId));  // 客户代号
        cstmr.setDeptId(getDeptId());               // 所属部门
        cstmr.setUserId(getUserId());               // 所属人员
src/main/java/com/zy/crm/manager/mapper/CstmrMapper.java
@@ -3,12 +3,15 @@
import com.zy.crm.manager.entity.Cstmr;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface CstmrMapper extends BaseMapper<Cstmr> {
    Cstmr selectCstmrByNewestUuid();
    Cstmr selectByUuid(@Param("hostId") Long hostId, @Param("uuid") String uuid);
    Cstmr selectCstmrByNewestUuid(Long hostId);
}
src/main/java/com/zy/crm/manager/service/CstmrService.java
@@ -5,6 +5,8 @@
public interface CstmrService extends IService<Cstmr> {
    String getNextUuid();
    Cstmr selectByUuid(Long hostId, String uuid);
    String getNextUuid(Long hostId);
}
src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java
@@ -10,11 +10,32 @@
public class CstmrServiceImpl extends ServiceImpl<CstmrMapper, Cstmr> implements CstmrService {
    @Override
    public String getNextUuid() {
        Cstmr cstmr = this.baseMapper.selectCstmrByNewestUuid();
    public Cstmr selectByUuid(Long hostId, String uuid) {
        return this.baseMapper.selectByUuid(hostId, uuid);
    }
    @Override
    public String getNextUuid(Long hostId) {
        Cstmr cstmr = this.baseMapper.selectCstmrByNewestUuid(hostId);
        if (cstmr == null) {
            return "0001";
        }
        return String.valueOf(Integer.parseInt(cstmr.getUuid()) + 1);
        return zerofill(String.valueOf(Integer.parseInt(cstmr.getUuid()) + 1), 4);
    }
    public static String zerofill(String msg, Integer count){
        if (msg.length() == count){
            return msg;
        } else if (msg.length() > count){
            return msg.substring(0, 16);
        } else {
            StringBuilder msgBuilder = new StringBuilder(msg);
            for (int i = 0; i<count-msg.length(); i++){
                msgBuilder.insert(0,"0");
            }
            return msgBuilder.toString();
        }
    }
}
src/main/resources/mapper/CstmrMapper.xml
@@ -33,8 +33,22 @@
    </resultMap>
    <select id="selectByUuid" resultMap="BaseResultMap">
        select * from man_cstmr
        where 1=1
        and uuid = #{uuid}
        <if test="hostId != null">
            and host_id = #{hostId}
        </if>
    </select>
    <select id="selectCstmrByNewestUuid" resultMap="BaseResultMap">
        select * from man_cstmr where 1=1 order by uuid + 0 desc
        select * from man_cstmr
        where 1=1
        <if test="hostId != null">
            and host_id = #{hostId}
        </if>
        order by uuid + 0 desc
    </select>
</mapper>