insert into business_allocation_storehouse_apply(
apply_id,start_user_id,operate,start_user_name,apply_count,remark,state,b_id,store_id,community_id,create_time,apply_type
) values (
#{applyId},#{startUserId},#{operate},#{startUserName},#{applyCount},#{remark},#{state},#{bId},#{storeId},#{communityId},#{createTime},#{applyType}
)
insert into allocation_storehouse_apply(
apply_id,b_id,start_user_id,start_user_name,remark,apply_count,store_id,create_time,state,community_id,apply_type
) values (
#{applyId},#{bId},#{startUserId},#{startUserName},#{remark},#{applyCount},#{storeId},#{createTime},#{state},#{communityId},#{applyType}
)
insert into allocation_storehouse_apply(
apply_id,start_user_id,start_user_name,apply_count,remark,status_cd,state,b_id,store_id,community_id,create_time,apply_type
) select
t.apply_id,t.start_user_id,t.start_user_name,t.apply_count,t.remark,'0',t.state,t.b_id,t.store_id,t.community_id,t.create_time,t.apply_type
from business_allocation_storehouse_apply t where 1=1
and t.apply_id= #{applyId}
and t.start_user_id= #{startUserId}
and t.operate= 'ADD'
and t.start_user_name= #{startUserName}
and t.apply_count= #{applyCount}
and t.remark= #{remark}
and t.state= #{state}
and t.b_id= #{bId}
and t.store_id= #{storeId}
and t.community_id= #{communityId}
and t.apply_type= #{applyType}
update allocation_storehouse_apply t set t.status_cd = #{statusCd}
,t.b_id = #{newBId}
, t.start_user_id= #{startUserId}
, t.start_user_name= #{startUserName}
, t.apply_count= #{applyCount}
, t.remark= #{remark}
, t.state= #{state}
, t.store_id= #{storeId}
, t.community_id= #{communityId}
, t.apply_type= #{applyType}
where 1=1
and t.apply_id= #{applyId}
and t.b_id= #{bId}