功能需求
3.线索的备注信息--》客户备注
4.线索的备注---》联系人备注
5.线索市场活动关系---》联系人市场活动关系
流程图
代码实现:线索的备注转化为客户联系人的备注
1.clueRemarkMapper
/**
* 根据线索id 查询备注2
*/
List<ClueRemark> selectInitialClueRemarkByClueId(String clueId);
<select id="selectInitialClueRemarkByClueId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tbl_clue_remark
where clue_id=#{clueId}
</select>
2.CustomerRemarkMapper
/**
* 线索备注--客户备注
*/
int insertCustomerRemarkByList(List<CustomerRemark> customerRemarkList);
<insert id="insertCustomerRemarkByList">
insert into tbl_customer_remark (id, note_content, create_by,
create_time, edit_by, edit_time,
edit_flag, customer_id)
values
<foreach collection="list" separator="," item="obj">
(#{obj.id},#{obj.noteContent},#{obj.createBy},#{obj.createTime},#{obj.editBy},#{obj.editTime},#{obj.editFlag},#{obj.customerId})
</foreach>
</insert>
3.ContactsRemarkMapper
/**
* 线索备注--联系人备注
*/
int insertContactsRemarkByList(List<ContactsRemark> contactsRemarkList);
<insert id="insertContactsRemarkByList">
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>
4.ClueService
//3.线索评论--客户评论和联系人评论
List<ClueRemark> clueRemarkList = clueRemarkMapper.selectInitialClueRemarkByClueId(clueId);
// 如果线索不是空的
if (clueRemarkList != null && clueRemarkList.size() > 0) {
// 遍历线索备注
CustomerRemark customerRemark = null;
List<CustomerRemark> customerRemarkList = new ArrayList<>();
ContactsRemark contactsRemark = null;
List<ContactsRemark> contactsRemarkList = new ArrayList<>();
// 遍历备注信息
for (ClueRemark clueRemark : clueRemarkList) {
customerRemark = new CustomerRemark();
customerRemark.setId(UUIDUtils.getUUID());
customerRemark.setNoteContent(clueRemark.getNoteContent());
customerRemark.setCreateBy(clueRemark.getCreateBy());
customerRemark.setCreateTime(clueRemark.getCreateTime());
customerRemark.setEditBy(clueRemark.getEditBy());
customerRemark.setEditTime(clueRemark.getEditTime());
customerRemark.setEditFlag(clueRemark.getEditFlag());
customerRemark.setCustomerId(customer.getId());
customerRemarkList.add(customerRemark);
contactsRemark = new ContactsRemark();
contactsRemark.setId(UUIDUtils.getUUID());
contactsRemark.setNoteContent(clueRemark.getNoteContent());
contactsRemark.setCreateBy(clueRemark.getCreateBy());
contactsRemark.setCreateTime(clueRemark.getCreateTime());
contactsRemark.setEditBy(clueRemark.getEditBy());
contactsRemark.setEditTime(clueRemark.getEditTime());
contactsRemark.setEditFlag(clueRemark.getEditFlag());
contactsRemark.setContactsId(contacts.getId());
contactsRemarkList.add(contactsRemark);
}
// 调用sql插入
customerRemarkMapper.insertCustomerRemarkByList(customerRemarkList);
contactsRemarkMapper.insertContactsRemarkByList(contactsRemarkList);
}
代码实现:联系人市场活动关系
1.ClueActivityRelationMapper
/**
* 根据线索id查询关联得市场活动
*/
List<ClueActivityRelation> selectClueActivityRelationByClueId(String clueId);
<!--List<ClueActivityRelation> selectClueActivityRelationByClueId(String clueId);-->
<select id="selectClueActivityRelationByClueId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tbl_clue_activity_relation
where clue_id = #{clueId}
</select>
2.ContactsActivityRelationMapper
/**
* 批量插入 市场关联
*/
int insertContactsActivityRelationByList(List<ContactsActivityRelation> contactsActivityRelationList);
<!-- int insertContactsActivityRelationByList(List<ContactsActivityRelation> contactsActivityRelationList);-->
<insert id="insertContactsActivityRelationByList">
insert into tbl_contacts_activity_relation (id, contacts_id, activity_id
)
values
<foreach collection="list" item="obj" separator=",">
(#{obj.id}, #{obj.contactsId}, #{obj.activityId})
</foreach>
</insert>
3.ClueService
// 4.线索市场活动关系---联系人市场活动
List<ClueActivityRelation> clueActivityRelationList = clueActivityRelationMapper.selectClueActivityRelationByClueId(clueId);
// 查询得结果不为空
if (clueActivityRelationList != null && clueActivityRelationList.size() > 0) {
ContactsActivityRelation contactsActivityRelation = null;
List<ContactsActivityRelation> contactsActivityRelationList = new ArrayList<>();
for (ClueActivityRelation clueActivityRelation : clueActivityRelationList) {
contactsActivityRelation = new ContactsActivityRelation();
contactsActivityRelation.setId(UUIDUtils.getUUID());
contactsActivityRelation.setContactsId(contacts.getId());
contactsActivityRelation.setActivityId(clueActivityRelation.getActivityId());
contactsActivityRelationList.add(contactsActivityRelation);
}
// 插入市场活动
contactsActivityRelationMapper.insertContactsActivityRelationByList(contactsActivityRelationList);
}