insert into business_allocation_storehouse_apply(
apply_id,start_user_id,operate,start_user_name,apply_count,remark,state,b_id,store_id
) values (
#{applyId},#{startUserId},#{operate},#{startUserName},#{applyCount},#{remark},#{state},#{bId},#{storeId}
)
insert into allocation_storehouse_apply(
apply_id,start_user_id,start_user_name,apply_count,remark,status_cd,state,b_id,store_id
) 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 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}
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}
where 1=1
and t.apply_id= #{applyId}
and t.b_id= #{bId}