insert into business_agent(agent_id,b_id,name,address,tel,nearby_landmarks,map_x,map_y,month,operate)
values(#{agentId},#{bId},#{name},#{address},#{tel},#{nearbyLandmarks},#{mapX},#{mapY},#{month},#{operate})
insert into business_agent_attr(b_id,attr_id,agent_id,spec_cd,value,month,operate)
values(#{bId},#{attrId},#{agentId},#{specCd},#{value},#{month},#{operate})
insert into business_agent_photo(agent_photo_id,b_id,agent_id,agent_photo_type_cd,photo,month,operate)
values(#{agentPhotoId},#{bId},#{agentId},#{agentPhotoTypeCd},#{photo},#{month},#{operate})
insert into business_agent_cerdentials(agent_cerdentials_id,b_id,agent_id,credentials_cd,value,validity_period,positive_photo,negative_photo,month,operate)
values(#{agentCerdentialsId},#{bId},#{agentId},#{credentialsCd},#{value},#{validityPeriod},#{positivePhoto},#{negativePhoto},#{month},#{operate})
insert into business_agent_user(agent_user_id,b_id,agent_id,user_id,rel_cd,month,operate)
values(#{agentUserId},#{bId},#{agentId},#{userId},#{relCd},#{month},#{operate})
insert into business_agent_fee(fee_id,b_id,agent_id,fee_type_cd,fee_money,fee_time,start_time,end_time,month,operate)
values(#{feeId},#{bId},#{agentId},#{feeTypeCd},#{feeMoney},#{feeTime},#{startTime},#{endTime},#{month},#{operate})
insert into business_agent_house(house_id,agent_id,b_id,house_num,house_name,house_phone,house_area,fee_type_cd,fee_price,month,operate)
values(#{houseId},#{agentId},#{bId},#{houseNum},#{houseName},#{housePhone},#{houseArea},#{feeTypeCd},#{feePrice},#{month},#{operate})
insert into business_agent_house_attr(b_id,attr_id,house_id,spec_cd,value,month,operate)
values(#{bId},#{attrId},#{houseId},#{specCd},#{value},#{month},#{operate})
insert into a_agent(agent_id,b_id,name,address,tel,nearby_landmarks,map_x,map_y,status_cd)
select s.agent_id,s.b_id,s.name,s.address,s.tel,s.nearby_landmarks,s.map_x,s.map_y,'0'
from business_agent s where
s.operate = 'ADD' and s.b_id=#{bId}
insert into a_agent_attr(b_id,attr_id,agent_id,spec_cd,value,status_cd)
select sa.b_id,sa.attr_id,sa.agent_id,sa.spec_cd,sa.value,'0'
from business_agent_attr sa
where sa.operate = 'ADD' and sa.b_id=#{bId}
insert into a_agent_house(house_id,agent_id,b_id,house_num,house_name,house_phone,house_area,fee_type_cd,fee_price,status_cd)
select s.house_id,s.agent_id,s.b_id,s.house_num,s.house_name,s.house_phone,s.house_area,s.fee_type_cd,s.fee_price,'0'
from business_agent_house s where
s.operate = 'ADD' and s.b_id=#{bId}
insert into a_agent_house_attr(b_id,attr_id,house_id,spec_cd,value,status_cd)
select sa.b_id,sa.attr_id,sa.house_id,sa.spec_cd,sa.value,'0'
from business_agent_house_attr sa
where sa.operate = 'ADD' and sa.b_id=#{bId}
insert into a_agent_photo(agent_photo_id,b_id,agent_id,agent_photo_type_cd,photo,status_cd)
select sp.agent_photo_id,sp.b_id,sp.agent_id,sp.agent_photo_type_cd,sp.photo,'0'
from business_agent_photo sp
where sp.operate = 'ADD' and sp.b_id=#{bId}
insert into a_agent_cerdentials(agent_cerdentials_id,b_id,agent_id,credentials_cd,value,validity_period,positive_photo,negative_photo,status_cd)
select sc.agent_cerdentials_id,sc.b_id,sc.agent_id,sc.credentials_cd,sc.value,sc.validity_period,sc.positive_photo,sc.negative_photo,'0'
from business_agent_cerdentials sc
where sc.operate = 'ADD' and sc.b_id=#{bId}
insert into a_agent_user(agent_user_id,b_id,agent_id,user_id,rel_cd,status_cd)
select sc.agent_user_id,sc.b_id,sc.agent_id,sc.user_id,sc.rel_cd,'0'
from business_agent_user sc
where sc.operate = 'ADD' and sc.b_id=#{bId}
insert into a_agent_fee(fee_id,b_id,agent_id,fee_type_cd,fee_money,fee_time,start_time,end_time,status_cd)
select sc.fee_id,sc.b_id,sc.agent_id,sc.fee_type_cd,sc.fee_money,sc.fee_time,sc.start_time,sc.end_time,'0'
from business_agent_fee sc
where sc.operate = 'ADD' and sc.b_id=#{bId}
update a_agent s set s.status_cd = #{statusCd}
,s.b_id = #{newBId}
,s.name = #{name}
,s.address = #{address}
,s.tel = #{tel}
,s.nearby_landmarks = #{nearbyLandmarks}
,s.map_x = #{mapX}
,s.map_y = #{mapY}
where 1=1
and s.b_id = #{bId}
and s.agent_id = #{agentId}
update a_agent_attr sa set sa.status_cd = #{statusCd}
,sa.b_id = #{newBId}
,sa.value = #{value}
where 1=1
and sa.b_id = #{bId}
and sa.agent_id = #{agentId}
and sa.spec_cd = #{specCd}
and sa.attr_id = #{attrId}
update a_agent_house s set s.status_cd = #{statusCd}
,s.b_id = #{newBId}
,s.house_name = #{houseName}
,s.house_num = #{houseNum}
,s.house_phone = #{housePhone}
,s.house_area = #{houseArea}
,s.fee_type_cd = #{feeTypeCd}
,s.fee_price = #{feePrice}
where 1=1
and s.b_id = #{bId}
and s.agent_id = #{agentId}
and s.house_id = #{houseId}
update a_agent_house_attr sa set sa.status_cd = #{statusCd}
,sa.b_id = #{newBId}
,sa.value = #{value}
where 1=1
and sa.b_id = #{bId}
and sa.house_id = #{houseId}
and sa.spec_cd = #{specCd}
and sa.attr_id = #{attrId}
update a_agent_photo sp set sp.status_cd = #{statusCd}
,sp.b_id = #{newBId}
,sp.agent_photo_type_cd = #{agentPhotoTypeCd}
,sp.photo = #{photo}
where 1=1
and sp.b_id = #{bId}
and sp.agent_id = #{agentId}
and sp.agent_photo_id = #{agentPhotoId}
update a_agent_cerdentials sc set sc.status_cd = #{statusCd}
,sc.b_id = #{newBId}
,sc.credentials_cd = #{credentialsCd}
,sc.value = #{value}
,sc.validity_period = #{validityPeriod}
,sc.positive_photo = #{positivePhoto}
,sc.negative_photo = #{negativePhoto}
where 1=1
and sc.b_id = #{bId}
and sc.agent_id = #{agentId}
and sc.agent_cerdentials_id = #{agentCerdentialsId}
update a_agent_user sc set sc.status_cd = #{statusCd}
,sc.b_id = #{newBId}
,sc.rel_cd = #{relCd}
where 1=1
and sc.b_id = #{bId}
and sc.agent_id = #{agentId}
and sc.agent_user_id = #{agentUserId}
update a_agent_fee sc set sc.status_cd = #{statusCd}
,sc.b_id = #{newBId}
,sc.fee_money = #{feeMoney}
,sc.fee_time = #{feeTime}
,sc.start_time = #{startTime}
,sc.end_time = #{endTime}
where 1=1
and sc.b_id = #{bId}
and sc.agent_id = #{agentId}
and sc.fee_id = #{feeId}