id, order_no, process_state, status, type, create_time, remarks, voucher_url, total_amount, settlement_amount, change_amount, applicant, dep_name, project_state, zxs_cost, zxs_remarks, payment_time, payment_amount, invoice_time, invoice_amount, invoice_type, cw_cost, refundable_amount, cw_remarks, estimate_cost, estimate_refundable, refund_Invoice, used_order, refund_status, refund_url, back_status, attachment_url, contract_picture_url, first_amount, examine_name, cw_indirect_cost, contacts, contact_mobile, manager_contacts, manager_contact_mobile, nda, nda_url, breach_clause, breach_clause_url delete from new_order_change where id = #{id,jdbcType=INTEGER} insert into new_order_change (order_no, process_state, `status`, `type`, create_time, remarks, voucher_url, total_amount, settlement_amount, change_amount, applicant, dep_name, project_state, zxs_cost, zxs_remarks, payment_time, payment_amount, invoice_time, invoice_amount, invoice_type, cw_cost, refundable_amount, cw_remarks, estimate_cost, estimate_refundable, refund_Invoice, used_order, refund_status, refund_url, back_status, attachment_url, contract_picture_url, first_amount, examine_name,cw_indirect_cost,contacts,contact_mobile, manager_contacts,manager_contact_mobile, nda, nda_url, breach_clause, breach_clause_url ) values (#{orderNo,jdbcType=VARCHAR}, #{processState,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR}, #{voucherUrl,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL}, #{settlementAmount,jdbcType=DECIMAL}, #{changeAmount,jdbcType=DECIMAL}, #{applicant,jdbcType=VARCHAR}, #{depName,jdbcType=VARCHAR}, #{projectState,jdbcType=VARCHAR}, #{zxsCost,jdbcType=DECIMAL}, #{zxsRemarks,jdbcType=VARCHAR}, #{paymentTime,jdbcType=TIMESTAMP}, #{paymentAmount,jdbcType=DECIMAL}, #{invoiceTime,jdbcType=TIMESTAMP}, #{invoiceAmount,jdbcType=DECIMAL}, #{invoiceType,jdbcType=VARCHAR}, #{cwCost,jdbcType=DECIMAL}, #{refundableAmount,jdbcType=DECIMAL}, #{cwRemarks,jdbcType=VARCHAR}, #{estimateCost,jdbcType=DECIMAL}, #{estimateRefundable,jdbcType=DECIMAL}, #{refundInvoice,jdbcType=DECIMAL}, #{usedOrder,jdbcType=VARCHAR}, #{refundStatus,jdbcType=INTEGER}, #{refundUrl,jdbcType=VARCHAR}, #{backStatus,jdbcType=INTEGER}, #{attachmentUrl,jdbcType=VARCHAR}, #{contractPictureUrl,jdbcType=VARCHAR}, #{firstAmount,jdbcType=DECIMAL}, #{examineName,jdbcType=VARCHAR},#{cwIndirectCost,jdbcType=DECIMAL},#{contacts,jdbcType=VARCHAR},#{contactMobile,jdbcType=VARCHAR}, #{managerContacts,jdbcType=VARCHAR},#{managerContactMobile,jdbcType=VARCHAR} #{nda,jdbcType=INTEGER}, #{ndaUrl,jdbcType=VARCHAR}, #{breachClause,jdbcType=INTEGER}, #{breachClauseUrl,jdbcType=VARCHAR}) insert into new_order_change order_no, process_state, `status`, `type`, create_time, remarks, voucher_url, total_amount, settlement_amount, change_amount, applicant, dep_name, project_state, zxs_cost, zxs_remarks, payment_time, payment_amount, invoice_time, invoice_amount, invoice_type, cw_cost, refundable_amount, cw_remarks, estimate_cost, estimate_refundable, refund_Invoice, used_order, refund_status, refund_url, back_status, attachment_url, contract_picture_url, first_amount, examine_name, cw_indirect_cost, contacts, contact_mobile, manager_contacts, manager_contact_mobile, nda, nda_url, breach_clause, breach_clause_url, #{orderNo,jdbcType=VARCHAR}, #{processState,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR}, #{voucherUrl,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL}, #{settlementAmount,jdbcType=DECIMAL}, #{changeAmount,jdbcType=DECIMAL}, #{applicant,jdbcType=VARCHAR}, #{depName,jdbcType=VARCHAR}, #{projectState,jdbcType=VARCHAR}, #{zxsCost,jdbcType=DECIMAL}, #{zxsRemarks,jdbcType=VARCHAR}, #{paymentTime,jdbcType=TIMESTAMP}, #{paymentAmount,jdbcType=DECIMAL}, #{invoiceTime,jdbcType=TIMESTAMP}, #{invoiceAmount,jdbcType=DECIMAL}, #{invoiceType,jdbcType=VARCHAR}, #{cwCost,jdbcType=DECIMAL}, #{refundableAmount,jdbcType=DECIMAL}, #{cwRemarks,jdbcType=VARCHAR}, #{estimateCost,jdbcType=DECIMAL}, #{estimateRefundable,jdbcType=DECIMAL}, #{refundInvoice,jdbcType=DECIMAL}, #{usedOrder,jdbcType=VARCHAR}, #{refundStatus,jdbcType=INTEGER}, #{refundUrl,jdbcType=VARCHAR}, #{backStatus,jdbcType=INTEGER}, #{attachmentUrl,jdbcType=VARCHAR}, #{contractPictureUrl,jdbcType=VARCHAR}, #{firstAmount,jdbcType=DECIMAL}, #{examineName,jdbcType=VARCHAR}, #{cwIndirectCost,jdbcType=DECIMAL}, #{contacts,jdbcType=VARCHAR}, #{contactMobile,jdbcType=VARCHAR}, #{managerContacts,jdbcType=VARCHAR}, #{managerContactMobile,jdbcType=VARCHAR}, #{nda,jdbcType=INTEGER}, #{ndaUrl,jdbcType=VARCHAR}, #{breachClause,jdbcType=INTEGER}, #{breachClauseUrl,jdbcType=VARCHAR}, update new_order_change order_no = #{orderNo,jdbcType=VARCHAR}, process_state = #{processState,jdbcType=INTEGER}, `status` = #{status,jdbcType=INTEGER}, `type` = #{type,jdbcType=INTEGER}, create_time = #{createTime,jdbcType=TIMESTAMP}, remarks = #{remarks,jdbcType=VARCHAR}, voucher_url = #{voucherUrl,jdbcType=VARCHAR}, total_amount = #{totalAmount,jdbcType=DECIMAL}, settlement_amount = #{settlementAmount,jdbcType=DECIMAL}, change_amount = #{changeAmount,jdbcType=DECIMAL}, applicant = #{applicant,jdbcType=VARCHAR}, dep_name = #{depName,jdbcType=VARCHAR}, project_state = #{projectState,jdbcType=VARCHAR}, zxs_cost = #{zxsCost,jdbcType=DECIMAL}, zxs_remarks = #{zxsRemarks,jdbcType=VARCHAR}, payment_time = #{paymentTime,jdbcType=TIMESTAMP}, payment_amount = #{paymentAmount,jdbcType=DECIMAL}, invoice_time = #{invoiceTime,jdbcType=TIMESTAMP}, invoice_amount = #{invoiceAmount,jdbcType=DECIMAL}, invoice_type = #{invoiceType,jdbcType=VARCHAR}, cw_cost = #{cwCost,jdbcType=DECIMAL}, refundable_amount = #{refundableAmount,jdbcType=DECIMAL}, cw_remarks = #{cwRemarks,jdbcType=VARCHAR}, estimate_cost = #{estimateCost,jdbcType=DECIMAL}, estimate_refundable = #{estimateRefundable,jdbcType=DECIMAL}, refund_Invoice = #{refundInvoice,jdbcType=DECIMAL}, used_order = #{usedOrder,jdbcType=VARCHAR}, refund_status = #{refundStatus,jdbcType=INTEGER}, refund_url = #{refundUrl,jdbcType=VARCHAR}, back_status = #{backStatus,jdbcType=INTEGER}, attachment_url = #{attachmentUrl,jdbcType=VARCHAR}, contract_picture_url = #{contractPictureUrl,jdbcType=VARCHAR}, first_amount = #{firstAmount,jdbcType=DECIMAL}, examine_name = #{examineName,jdbcType=VARCHAR}, cw_indirect_cost=#{cwIndirectCost,jdbcType=DECIMAL}, contacts=#{contacts,jdbcType=VARCHAR}, contact_mobile=#{contactMobile,jdbcType=VARCHAR}, manager_contacts=#{managerContacts,jdbcType=VARCHAR}, manager_contact_mobile=#{managerContactMobile,jdbcType=VARCHAR}, nda= #{nda,jdbcType=INTEGER}, nda_url=#{ndaUrl,jdbcType=VARCHAR}, breach_clause=#{ breachClause ,jdbcType=INTEGER}, breach_clause_url=#{ breachClauseUrl ,jdbcType=VARCHAR}, where id = #{id,jdbcType=INTEGER} update new_order_change set order_no = #{orderNo,jdbcType=VARCHAR}, process_state = #{processState,jdbcType=INTEGER}, `status` = #{status,jdbcType=INTEGER}, `type` = #{type,jdbcType=INTEGER}, create_time = #{createTime,jdbcType=TIMESTAMP}, remarks = #{remarks,jdbcType=VARCHAR}, voucher_url = #{voucherUrl,jdbcType=VARCHAR}, total_amount = #{totalAmount,jdbcType=DECIMAL}, settlement_amount = #{settlementAmount,jdbcType=DECIMAL}, change_amount = #{changeAmount,jdbcType=DECIMAL}, applicant = #{applicant,jdbcType=VARCHAR}, dep_name = #{depName,jdbcType=VARCHAR}, project_state = #{projectState,jdbcType=VARCHAR}, zxs_cost = #{zxsCost,jdbcType=DECIMAL}, zxs_remarks = #{zxsRemarks,jdbcType=VARCHAR}, payment_time = #{paymentTime,jdbcType=TIMESTAMP}, payment_amount = #{paymentAmount,jdbcType=DECIMAL}, invoice_time = #{invoiceTime,jdbcType=TIMESTAMP}, invoice_amount = #{invoiceAmount,jdbcType=DECIMAL}, invoice_type = #{invoiceType,jdbcType=VARCHAR}, cw_cost = #{cwCost,jdbcType=DECIMAL}, refundable_amount = #{refundableAmount,jdbcType=DECIMAL}, cw_remarks = #{cwRemarks,jdbcType=VARCHAR}, estimate_cost = #{estimateCost,jdbcType=DECIMAL}, estimate_refundable = #{estimateRefundable,jdbcType=DECIMAL}, refund_Invoice = #{refundInvoice,jdbcType=DECIMAL}, used_order = #{usedOrder,jdbcType=VARCHAR}, refund_status = #{refundStatus,jdbcType=INTEGER}, refund_url = #{refundUrl,jdbcType=VARCHAR}, back_status = #{backStatus,jdbcType=INTEGER}, attachment_url = #{attachmentUrl,jdbcType=VARCHAR}, contract_picture_url = #{contractPictureUrl,jdbcType=VARCHAR}, first_amount = #{firstAmount,jdbcType=DECIMAL}, examine_name = #{examineName,jdbcType=VARCHAR}, cw_indirect_cost=#{cwIndirectCost,jdbcType=DECIMAL}, contacts=#{contacts,jdbcType=VARCHAR}, contact_mobile=#{contactMobile,jdbcType=VARCHAR}, manager_contacts=#{managerContacts,jdbcType=VARCHAR}, manager_contact_mobile=#{managerContactMobile,jdbcType=VARCHAR}, nda= #{nda,jdbcType=INTEGER}, nda_url=#{ndaUrl,jdbcType=VARCHAR}, breach_clause=#{breachClause,jdbcType=INTEGER}, breach_clause_url=#{breachClauseUrl,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} and b.salesman_id= #{aid} and d.manager_id= #{aid} and x.aid=#{aid} and a.process_state >= #{processState} and x.aid=#{aid} and a.process_state >= #{processState} and x.aid=#{aid} and a.back_status >= #{processState} and x.aid=#{aid} and a.back_status >= #{processState} and e.finance_id =#{aid} and e.finance_id in #{id} and e.operation_guarantee_id=#{aid} and e.approval_aid =#{aid} and c.nickname like concat('%',#{userName},'%') and a.order_no like concat('%',#{orderNo},'%') and b.contract_no like concat('%',#{contractNo},'%') and a.type = #{type} and a.create_time between #{startTime} and #{endTime} and b.create_time between #{startTime} and #{endTime} and b.order_dep in #{depId} and d.name like concat('%',#{salesmanName},'%') and ((a.process_state >= #{processState} or a.back_status >= #{processState})) and ((a.process_state >= #{processState} and a.process_state < 10)or a.back_status >= #{processState}) and ((a.process_state >= 9 and a.process_state < 11)or a.back_status >= #{processState}) and ((a.process_state = 10 )or a.back_status >= #{processState}) and a.process_state = #{processState} and a.status in (0,1,2,3) and (a.process_state in(6) and a.status in (0,1,2,3,5,6)) and (a.process_state = #{processState} and a.status =1) and a.process_state = #{processState} and a.status =1 and a.process_state > #{processState} and((a.process_state > 6 and a.process_state < 10) or (a.process_state =6 and a.status=4)) and e.operation_guarantee_id=#{aid} and a.process_state > 7 and a.status in (2,4) and ((a.process_state = 9 and a.status in(2,4))or a.process_state > 9) and a.process_state = 10 and a.status in (2,4) and a.status = 2 and a.status = 4 and a.back_status = #{processState} and a.status = 6 update new_order_change set `refund_Invoice`=ifnull(`refund_Invoice`,0)+ #{amount} where order_no= #{orderNo} update new_order_change set `refund_Invoice`=ifnull(`refund_Invoice`,0)- #{amount} where order_no= #{orderNo} update new_order_change n left join (select c.id from t_order_new a left join t_order_task b on a.order_no =b.order_no left join new_order_change c on a.order_no =c.order_no where (b.consultant_id in (#{aid},#{taskReceiverId}) or b.manager_id in (#{aid},#{taskReceiverId})) and c.process_state in (#{type}) group by c.id)x on n.id =x.id left join (select a.order_no ,group_concat(DISTINCT b.name)name from order_examine a left join admin b on a.aid=b.id where 1=1 and a.type=0 and a.type=1 group by a.order_no ) a on n.order_no =a.order_no set n.examine_name =a.name where n.process_state =#{type} update new_order_change a left join t_order_new b on a.order_no =b.order_no left join admin c on b.salesman_id =c.id left join admin d on c.manager_id =d.id set a.examine_name=d.name where a.process_state =1 and d.id = #{id} left join admin c on b.salesman_id =c.id set a.examine_name=c.name where a.process_state =1 and c.manager_id = #{id} left join (select a.department_id depId,group_concat(a.name) name from admin a left join admin b on a.department_id =b.department_id left join user_role c on a.id=c.uid left join `role` d on c.rid =d.id where b.id= #{id} and d.role_type ='9996' and a.status ='0' group by b.department_id )x on b.order_dep=x.depId set a.examine_name=x.name where a.process_state =2 left join t_order_task c on a.order_no =c.order_no left join (select a.order_no ,a.`type` ,GROUP_CONCAT(distinct b.name) name from order_examine a left join admin b on a.aid=b.id where a.`type` =0 group by order_no ,type)d on a.order_no =d.order_no set a.examine_name =d.name where a.process_state =3 and c.manager_id = #{id} left join t_order_task c on a.order_no =c.order_no left join (select a.order_no ,a.`type` ,GROUP_CONCAT(distinct b.name) name from order_examine a left join admin b on a.aid=b.id where a.`type` =1 group by order_no ,type)d on a.order_no =d.order_no set a.examine_name =d.name where a.process_state =3 and c.consultant_id = #{id} left join department c on b.order_dep =c.id left join admin d on c.finance_id =d.id set a.examine_name=d.name where a.process_state =6 and d.id = #{id} left join (select group_concat(a.name) name from admin a left join user_role b on a.id=b.uid left join `role` c on b.rid =c.id where c.role_type in ('9998') and a.status ='0' where c.role_type in ('9997') and a.status ='0' )c on 1=1 set a.examine_name =c.name where a.process_state = #{type}