insert into business_user_storehouse(
res_name,operate,b_id,store_id,stock,res_id,user_id,us_id
) values (
#{resName},#{operate},#{bId},#{storeId},#{stock},#{resId},#{userId},#{usId}
)
insert into user_storehouse(
res_name,b_id,store_id,stock,res_id,user_id,us_id
) values (
#{resName},'-1',#{storeId},#{stock},#{resId},#{userId},#{usId}
)
insert into user_storehouse(
res_name,status_cd,b_id,store_id,stock,res_id,user_id,us_id
) select t.res_name,'0',t.b_id,t.store_id,t.stock,t.res_id,t.user_id,t.us_id from business_user_storehouse t
where 1=1
and t.res_name= #{resName}
and t.operate= 'ADD'
and t.b_id= #{bId}
and t.store_id= #{storeId}
and t.stock= #{stock}
and t.res_id= #{resId}
and t.user_id= #{userId}
and t.us_id= #{usId}
update user_storehouse t set t.status_cd = #{statusCd}
,t.b_id = #{newBId}
, t.res_name= #{resName}
, t.store_id= #{storeId}
, t.stock= #{stock}
, t.res_id= #{resId}
, t.user_id= #{userId}
where 1=1
and t.b_id= #{bId}
and t.us_id= #{usId}