线索转换

 点击线索转换 收集到线索的id  同步请求跳转到线索转换页面

//给"转换"按钮添加单击事件
$("#convertClueBtn").click(function () {
   //收集参数
   var id='${clue.id}';
   //发送同步请求
   window.location.href="workbench/clue/toConvert.do?id="+id;
});

 controller层 

    根据同步请求发送的线索id查询出线索的明细信息

     在查出数据字典中的阶段stage的值 动态显示在下拉列表中

//给"转换"按钮添加单击事件
		$("#convertClueBtn").click(function () {
			//收集参数
			var id='${clue.id}';
			//发送同步请求
			window.location.href="workbench/clue/toConvert.do?id="+id;
		});

        @RequestMapping("/workbench/clue/toConvert.do")
        public String toConvert(String id,HttpServletRequest request){
            //调用service方法 查询线索的明细信息
            Clue clue=clueService.selectClueForDetailById(id);
            List<DicValue> stageList = dicValuleService.selectDicValueByTypeCode("stage");

            //把数据保存到request中
            request.setAttribute("clue",clue);
            request.setAttribute("stageList",stageList);
            //请求转发
            return "workbench/clue/convert";
        }

浏览器在工作区中显示线索转换页面 


用户点击市场活动源搜索按钮

//给"市场活动源"搜索按钮添加单击事件
$("#searchActivityBtn").click(function () {
   //初始化工作
   //清空搜索框
   $("#searchActivityTxt").val("");
   //清空搜索列表
   $("#tBody").html("");

   //弹出搜索市场活动的模态窗口
   $("#searchActivityModal").modal("show");
});

弹出搜索市场活动模态窗口

用户输入搜索条件

每次键盘弹起搜索出 和市场活动关联过的活动

//给"市场活动源"搜索框添加键盘弹起事件
$("#searchActivityTxt").keyup(function () {
   //收集参数
   var activityName=this.value;
   var clueId='${clue.id}';
   //发送请求
   $.ajax({
      url:'workbench/clue/queryActivityForConvertByNameClueId.do',
      data:{
         activityName:activityName,
         clueId:clueId
      },
      type:'post',
      dataType:'json',
      success:function (data) {
         //遍历data,显示所有搜索的市场活动
         var htmlStr="";
         $.each(data,function (index,obj) {
            htmlStr+="<tr>";
            htmlStr+="<td><input type=\"radio\" value=\""+obj.id+"\" activityName=\""+obj.name+"\" name=\"activity\"/></td>";
            htmlStr+="<td>"+obj.name+"</td>";
            htmlStr+="<td>"+obj.startDate+"</td>";
            htmlStr+="<td>"+obj.endDate+"</td>";
            htmlStr+="<td>"+obj.owner+"</td>";
            htmlStr+="</tr>";
         });
         $("#tBody").html(htmlStr);
      }
   });
});

controller层

 @RequestMapping("/workbench/clue/queryActivityForConvertByNameClueId.do")
        @ResponseBody
        public Object queryActivityForConvertByNameClueId(String activityName,
                                                     String clueId){
          //封装map
            Map<String,Object> map=new HashMap<>();
            map.put("activityName",activityName);
            map.put("clueId",clueId);
            //调用service方法 查询市场活动
         List<Activity> activityList=activityService.selectActivityForConvertByNameClueId(map);
          return  activityList;
      }

mapper

  

 /* 根据name查询市场活动,并且查询那些跟clueId关联过的市场活动*/
    List<Activity> selectActivityForConvertByNameClueId(Map<String,Object> map);
}
<select id="selectActivityForConvertByNameClueId" parameterType="map" resultMap="BaseResultMap">
   select a.id,a.name,a.start_date,a.end_date,u.name as owner

       from tbl_activity a
      join tbl_user u on  a.owner=u.id
 where a.name like '%' #{activityName} '%' and a.id in(
    select activity_id
     from
       tbl_clue_activity_relation
     where  clue_id=#{clueId}
 )

</select>

//给所有市场活动的单选按钮添加单击事件
$("#tBody").on("click","input[type='radio']",function () {
   //获取市场活动的id和name
   var id=this.value;
   var activityName=$(this).attr("activityName");
   //把市场活动的id写到隐藏域,把name写到输入框中
   $("#activityId").val(id);
   $("#activityName").val(activityName);
   //关闭搜索市场活动的模态窗口
   $("#searchActivityModal").modal("hide");
});

38.用户点击转换按钮

39.转换请求 异步请求 :(clueId请求:clueId交易表单中的参数,isCreateTran)

40.controller层获取参数 41 封装成map   42 saveConvertClue(map) 

43.根据id查询线索的信息  44.把该线索中有关个人的信息转换到客户表中

clueMapper    根据id查询线索的信息

Clue selectClueById(String id);
<select id="selectClueById" parameterType="string" resultMap="BaseResultMap">
  select <include refid="Base_Column_List"></include>
     from tbl_clue
  where id=#{id}
</select>

clueService

void saveConvert(Map<String,Object> map);

 实现类     

  @Autowired
    CustomerMapper customerMapper;

    @Override
    public void saveConvert(Map<String, Object> map) {
        String clueId = (String) map.get("clueId");
        User user=(User) map.get("user");
        //根据id查询线索的信息
        Clue clue = clueMapper.selectClueById(clueId);
        //把该线索中有关公司的信息转换到客户表中
        Customer c=new Customer();
        c.setAddress(clue.getAddress());
        c.setContactSummary(clue.getContactSummary());
        c.setCreateBy(user.getId());
        c.setCreateTime(DateUtils.formateDateTime());
        c.setDescription(clue.getDescription());
        c.setId(UUID.randomUUID().toString().replace("-",""));
        c.setName(clue.getCompany());
        c.setNextContactTime(clue.getNextContactTime());
        c.setOwner(user.getId());
        c.setPhone(clue.getPhone());
        c.setWebsite(clue.getWebsite());
        int count = customerMapper.insertCustomer(c);
    }

把该线索中有关个人的信息转换到客户表中  客户表 mybatis逆向工程生成

CustomerMapper      把线索信息中的有关个人信息  数据 封装成customer 把实体类保存到客户表中

/*线索转换中 有关客户的信息 保存到客户表中*/
int insertCustomer(Customer customer);
 <insert id="insertCustomer" parameterType="com.bjpowernode.crm.workbench.domain.Customer" >
      insert into tbl_customer(id, owner, name, website, phone, create_by, create_time, contact_summary,
    next_contact_time, description, address)
    values(#{id},#{owner},#{name},#{website},#{phone},#{createBy},#{createTime},#{contactSummary},#{nextContactTime},#{description},#{address})
   </insert>

       

 @RequestMapping("/workbench/clue/convertClue.do")
      @ResponseBody
       public Object convertClue(String clueId,String money,String name,String expectedDate,
                                 String stage,String activityId,String isCreateTran,HttpSession session){
            //异步请求 接受参数 clueId         交易表中的参数   isCreateTran
            //封装参数
          Map<String,Object> map=new HashMap<>();
          map.put("clueId",clueId);
          map.put("money",money);
          map.put("name",name);
          map.put("expectedDate",expectedDate);
          map.put("stage",stage);
          map.put("activityId",activityId);
          map.put("isCreateTran",isCreateTran);
          map.put("user",session.getAttribute("user"));
            ReturnObject returnObject=new ReturnObject();
          try{
              //调用service层方法 保存线索转换
              clueService.saveConvertClue(map);
              returnObject.setCode("1");
          }catch (Exception e){
              e.printStackTrace();
              returnObject.setCode("0");
              returnObject.setMessage("保存转换线索失败");
          }
          return  returnObject;
       }

保存转换线索 map参数  通过id查询线索信息 把信息封装成客户customer   把customer插入客户表


前端


		//给"转换"按钮添加单击事件
		$("#saveConvertClueBtn").click(function () {
			//收集参数
			var clueId='${clue.id}';
			var money=$.trim($("#amountOfMoney").val());
			var name=$.trim($("#tradeName").val());
			var expectedDate=$("#expectedClosingDate").val();
			var stage=$("#stage").val();
			var activityId=$("#activityId").val();
			var isCreateTran=$("#isCreateTransaction").prop("checked");
			//表单验证
			//money只能是非负整数

			//发送请求
			$.ajax({
				url:'workbench/clue/convertClue.do',
				data:{
					clueId:clueId,
					money:money,
					name:name,
					expectedDate:expectedDate,
					stage:stage,
					activityId:activityId,
					isCreateTran:isCreateTran
				},
				type:'post',
				dataType:'json',
				success:function (data) {
					if(data.code=="1"){
						//跳转到线索主页面
						window.location.href="workbench/clue/index.do";
					}else{
						//提示信息
						alert(data.message);
					}
				}
			});
		});

 点击转换按钮 跳转到线索主页面  clue/index.do

客户表中保存上 转换的客户信息

把线索中有关个人 的信息转换到联系人表中

创建联系人实体类 mapper 和xml文件

接口ContactsMapper 

/*保存创建的联系人 */
int insertContacts(Contacts contacts);
<insert id="insertContacts" parameterType="com.bjpowernode.crm.workbench.domain.Contacts">
        insert into tbl_contacts( id, owner, source, customer_id, fullname, appellation, email, mphone, job, create_by,
    create_time, description, contact_summary, next_contact_time,address)
       values(#{id},#{owner},#{source},#{customerId},#{fullname},#{appellation},#{email},#{mphone},#{job},#{createBy},#{
    createTime},#{description},#{contactSummary},#{nextContactTime},#{address})
  </insert>

service

void saveConvertClue(Map<String,Object> map);
  //把该线索中有关个人的信息转换到联系人表中
        Contacts co=new Contacts();
        co.setAddress(clue.getAddress());
        co.setAppellation(clue.getAppellation());
        co.setContactSummary(clue.getContactSummary());
        co.setCreateBy(user.getId());
        co.setCreateTime(DateUtils.formateDateTime());
        co.setCustomerId(c.getId());
        co.setDescription(clue.getDescription());
        co.setEmail(clue.getEmail());
        co.setFullname(clue.getFullname());
        co.setId(UUID.randomUUID().toString().replace("-",""));
        co.setJob(clue.getJob());
        co.setMphone(clue.getMphone());
        co.setNextContactTime(clue.getNextContactTime());
        co.setOwner(clue.getOwner());
        co.setSource(clue.getSource());
         contactsMapper.insertContacts(co);

 


46.根据clueId查询该线索下所有备注

mapper

/*根据clueId查询该线索下所有的备注信息  关联的字段使用id*/
List<ClueRemark> selectClueRemarkByClueId(String clueId);
<select id="selectClueRemarkByClueId" parameterType="string" resultMap="BaseResultMap">
       select  <include refid="Base_Column_List"></include>
         from tbl_clue_remark
        where clue_id=#{clueId}
  </select>

 客户备注表 mybatis逆向工程生成

  CustomerRemarkMapper           47把该线索下所有的备注转换到客户备注表中

/*批量保存创建的客户备注*/
int insertCustomerRemarkByList(List<CustomerRemark> list);
 <insert id="insertCustomerRemarkByList" parameterType="com.bjpowernode.crm.workbench.domain.CustomerRemark">
          insert into tbl_customer_remark(id, note_content, create_by, create_time, edit_by, edit_time, edit_flag, customer_id)
          values
           <foreach collection="list" item="obj" separator=",">
            (#{obj.id},#{ obj.noteContent},#{ obj.createBy},#{ obj.createTime},#{ obj.editBy},#{ obj.editTime},#{ obj.editFlag},#{ obj.customerId})
           </foreach>
       </insert>

根据clueId把线索备注查出来  遍历 每遍历一个线索备注 生成一个客户备注(客户备注中信息从线索备注中取)客户备注放到一个list中

 把客户备注表 保存到list

service

 //根据clueId来查询该线索下所有的备注
        List<ClueRemark> crList = clueRemarkMapper.selectClueRemarkByClueId(clueId);

        /*把该线索下所有的备注转换到客户备注表中*/
        if(crList!=null && crList.size()>0){
              //遍历clList 封装客户备注
            CustomerRemark cur=null;
            List<CustomerRemark> curList=new ArrayList<>();
            for (ClueRemark cr:crList){
                cur=new CustomerRemark();
                cur.setCreateBy(cr.getCreateBy());
                cur.setCreateTime(cr.getCreateTime());
                cur.setCustomerId(c.getId());
                cur.setEditBy(cr.getEditBy());
                cur.setEditFlag(cr.getEditFlag());
                cur.setEditTime(cr.getEditTime());
                cur.setId(UUID.randomUUID().toString().replace("-",""));
                cur.setNoteContent(cr.getNoteContent());
               curList.add(cur);
            }
             //调用客户备注的mapper

             customerRemarkMapper.insertCustomerRemarkByList(curList);
        }
    }

 联系人备注表 mybatis逆向工程生成

ContactsRemarkMapper           48把该线索下所有的备注转换到联系人备注表中

/*批量保存联系人备注*/
int insertContactsRemarkByList(List<ContactsRemark> list);
<insert id="insertContactsRemarkByList" parameterType="com.bjpowernode.crm.workbench.domain.ContactsRemark">
        insert into tbl_contacts_remark(    id, note_content, create_by, create_time, edit_by, edit_time, edit_flag, contacts_id
)values
      <foreach collection="list" item="obj" separator=",">
          (#{obj.id},#{ obj.noteContent},#{ obj.createBy},#{ obj.createTime},#{ obj.editBy},#{ obj.editTime},#{obj.editFlag},#{obj.contactsId}
        )
      </foreach>
  </insert>

根据clueId把线索备注查出来  遍历 每遍历一个线索备注 生成一个联系人备注(联系人备注中信息从线索备注中取)联系人备注放到一个list中

 把联系人备注 保存到list

service

//根据clueId来查询该线索下所有的备注
        List<ClueRemark> crList = clueRemarkMapper.selectClueRemarkByClueId(clueId);

        /*把该线索下所有的备注转换到客户备注表中 | 联系人备注*/
        if(crList!=null && crList.size()>0){
              //遍历clList 封装客户备注
            CustomerRemark cur=null;
            ContactsRemark cor=null;
            List<CustomerRemark> curList=new ArrayList<>();
            List<ContactsRemark> corList=new ArrayList<>();
            for (ClueRemark cr:crList){
                cur=new CustomerRemark();
                cur.setCreateBy(cr.getCreateBy());
                cur.setCreateTime(cr.getCreateTime());
                cur.setCustomerId(c.getId());
                cur.setEditBy(cr.getEditBy());
                cur.setEditFlag(cr.getEditFlag());
                cur.setEditTime(cr.getEditTime());
                cur.setId(UUID.randomUUID().toString().replace("-",""));
                cur.setNoteContent(cr.getNoteContent());
               curList.add(cur);

               //联系人备注
              cor =new ContactsRemark();
              cor.setContactsId(co.getId());
              cor.setCreateBy(cr.getCreateBy());
              cor.setCreateTime(cr.getCreateTime());
              cor.setEditBy(cr.getEditBy());
              cor.setEditTime(cr.getEditTime());
              cor.setId(UUID.randomUUID().toString().replace("-",""));
              cor.setNoteContent(cr.getNoteContent());
              corList.add(cor);
            }
             //调用客户备注的mapper
             customerRemarkMapper.insertCustomerRemarkByList(curList);
              //调用联系人备注的mapper
            contactsRemarkMapper.insertContactsRemarkByList(corList);
        }
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值