insert into business_purchase_apply(
operate,apply_detail_id,res_order_type,description,apply_order_id,state,store_id,entry_person,b_id,user_id
) values (
#{operate},#{applyDetailId},#{resOrderType},#{description},#{applyOrderId},#{state},#{storeId},#{entryPerson},#{bId},#{userId}
)
insert into purchase_apply(
apply_detail_id,res_order_type,description,apply_order_id,status_cd,state,store_id,entry_person,b_id,user_id
) select t.apply_detail_id,t.res_order_type,t.description,t.apply_order_id,'0',t.state,t.store_id,t.entry_person,t.b_id,t.user_id from business_purchase_apply t where 1=1
and t.operate= 'ADD'
and t.apply_detail_id= #{applyDetailId}
and t.res_order_type= #{resOrderType}
and t.description= #{description}
and t.apply_order_id= #{applyOrderId}
and t.state= #{state}
and t.store_id= #{storeId}
and t.entry_person= #{entryPerson}
and t.b_id= #{bId}
and t.user_id= #{userId}
update purchase_apply t set t.status_cd = #{statusCd}
,t.b_id = #{newBId}
, t.apply_detail_id= #{applyDetailId}
, t.res_order_type= #{resOrderType}
, t.description= #{description}
, t.state= #{state}
, t.store_id= #{storeId}
, t.entry_person= #{entryPerson}
, t.user_id= #{userId}
where 1=1
and t.apply_order_id= #{applyOrderId}
and t.b_id= #{bId}