id, order_no, salesman_id, finance_id, salesman_name, finance_name, final_receivables,
final_Receivables_time, invoice_amount, create_time, buyer_name, order_receivables,
order_arrears, payment_amount, cost_amount, dep_name, province_name, legal_affairs,
dun_start_time, legal_affairs_type, operation_time, legal_affairs_status, project_type,
service_type, service_project, patent_cost, patent_cost_actual, soft_cost, soft_cost_actual,
audit_cost, audit_cost_actual, other_cost, other_cost_actual, expect_profit, actual_profit,
stop_project
delete from t_order_mid
where id = #{id,jdbcType=INTEGER}
insert into t_order_mid (order_no, salesman_id, finance_id,
salesman_name, finance_name, final_receivables,
final_Receivables_time, invoice_amount,
create_time, buyer_name, order_receivables,
order_arrears, payment_amount, cost_amount,
dep_name, province_name, legal_affairs,
dun_start_time, legal_affairs_type, operation_time,
legal_affairs_status, project_type, service_type,
service_project, patent_cost, patent_cost_actual,
soft_cost, soft_cost_actual, audit_cost,
audit_cost_actual, other_cost, other_cost_actual,
expect_profit, actual_profit, stop_project
)
values (#{orderNo,jdbcType=VARCHAR}, #{salesmanId,jdbcType=VARCHAR}, #{financeId,jdbcType=VARCHAR},
#{salesmanName,jdbcType=VARCHAR}, #{financeName,jdbcType=VARCHAR}, #{finalReceivables,jdbcType=DECIMAL},
#{finalReceivablesTime,jdbcType=TIMESTAMP}, #{invoiceAmount,jdbcType=DECIMAL},
#{createTime,jdbcType=TIMESTAMP}, #{buyerName,jdbcType=VARCHAR}, #{orderReceivables,jdbcType=DECIMAL},
#{orderArrears,jdbcType=DECIMAL}, #{paymentAmount,jdbcType=DECIMAL}, #{costAmount,jdbcType=DECIMAL},
#{depName,jdbcType=VARCHAR}, #{provinceName,jdbcType=VARCHAR}, #{legalAffairs,jdbcType=INTEGER},
#{dunStartTime,jdbcType=TIMESTAMP}, #{legalAffairsType,jdbcType=INTEGER}, #{operationTime,jdbcType=DATE},
#{legalAffairsStatus,jdbcType=INTEGER}, #{projectType,jdbcType=INTEGER}, #{serviceType,jdbcType=VARCHAR},
#{serviceProject,jdbcType=VARCHAR}, #{patentCost,jdbcType=DECIMAL}, #{patentCostActual,jdbcType=DECIMAL},
#{softCost,jdbcType=DECIMAL}, #{softCostActual,jdbcType=DECIMAL}, #{auditCost,jdbcType=DECIMAL},
#{auditCostActual,jdbcType=DECIMAL}, #{otherCost,jdbcType=DECIMAL}, #{otherCostActual,jdbcType=DECIMAL},
#{expectProfit,jdbcType=DECIMAL}, #{actualProfit,jdbcType=DECIMAL}, #{stopProject,jdbcType=INTEGER}
)
insert into t_order_mid
order_no,
salesman_id,
finance_id,
salesman_name,
finance_name,
final_receivables,
final_Receivables_time,
invoice_amount,
create_time,
buyer_name,
order_receivables,
order_arrears,
payment_amount,
cost_amount,
dep_name,
province_name,
legal_affairs,
dun_start_time,
legal_affairs_type,
operation_time,
legal_affairs_status,
project_type,
service_type,
service_project,
patent_cost,
patent_cost_actual,
soft_cost,
soft_cost_actual,
audit_cost,
audit_cost_actual,
other_cost,
other_cost_actual,
expect_profit,
actual_profit,
stop_project,
#{orderNo,jdbcType=VARCHAR},
#{salesmanId,jdbcType=VARCHAR},
#{financeId,jdbcType=VARCHAR},
#{salesmanName,jdbcType=VARCHAR},
#{financeName,jdbcType=VARCHAR},
#{finalReceivables,jdbcType=DECIMAL},
#{finalReceivablesTime,jdbcType=TIMESTAMP},
#{invoiceAmount,jdbcType=DECIMAL},
#{createTime,jdbcType=TIMESTAMP},
#{buyerName,jdbcType=VARCHAR},
#{orderReceivables,jdbcType=DECIMAL},
#{orderArrears,jdbcType=DECIMAL},
#{paymentAmount,jdbcType=DECIMAL},
#{costAmount,jdbcType=DECIMAL},
#{depName,jdbcType=VARCHAR},
#{provinceName,jdbcType=VARCHAR},
#{legalAffairs,jdbcType=INTEGER},
#{dunStartTime,jdbcType=TIMESTAMP},
#{legalAffairsType,jdbcType=INTEGER},
#{operationTime,jdbcType=DATE},
#{legalAffairsStatus,jdbcType=INTEGER},
#{projectType,jdbcType=INTEGER},
#{serviceType,jdbcType=VARCHAR},
#{serviceProject,jdbcType=VARCHAR},
#{patentCost,jdbcType=DECIMAL},
#{patentCostActual,jdbcType=DECIMAL},
#{softCost,jdbcType=DECIMAL},
#{softCostActual,jdbcType=DECIMAL},
#{auditCost,jdbcType=DECIMAL},
#{auditCostActual,jdbcType=DECIMAL},
#{otherCost,jdbcType=DECIMAL},
#{otherCostActual,jdbcType=DECIMAL},
#{expectProfit,jdbcType=DECIMAL},
#{actualProfit,jdbcType=DECIMAL},
#{stopProject,jdbcType=INTEGER},
update t_order_mid
order_no = #{orderNo,jdbcType=VARCHAR},
salesman_id = #{salesmanId,jdbcType=VARCHAR},
finance_id = #{financeId,jdbcType=VARCHAR},
salesman_name = #{salesmanName,jdbcType=VARCHAR},
finance_name = #{financeName,jdbcType=VARCHAR},
final_receivables = #{finalReceivables,jdbcType=DECIMAL},
final_Receivables_time = #{finalReceivablesTime,jdbcType=TIMESTAMP},
invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
create_time = #{createTime,jdbcType=TIMESTAMP},
buyer_name = #{buyerName,jdbcType=VARCHAR},
order_receivables = #{orderReceivables,jdbcType=DECIMAL},
order_arrears = #{orderArrears,jdbcType=DECIMAL},
payment_amount = #{paymentAmount,jdbcType=DECIMAL},
cost_amount = #{costAmount,jdbcType=DECIMAL},
dep_name = #{depName,jdbcType=VARCHAR},
province_name = #{provinceName,jdbcType=VARCHAR},
legal_affairs = #{legalAffairs,jdbcType=INTEGER},
dun_start_time = #{dunStartTime,jdbcType=TIMESTAMP},
legal_affairs_type = #{legalAffairsType,jdbcType=INTEGER},
operation_time = #{operationTime,jdbcType=DATE},
legal_affairs_status = #{legalAffairsStatus,jdbcType=INTEGER},
project_type = #{projectType,jdbcType=INTEGER},
service_type = #{serviceType,jdbcType=VARCHAR},
service_project = #{serviceProject,jdbcType=VARCHAR},
patent_cost = #{patentCost,jdbcType=DECIMAL},
patent_cost_actual = #{patentCostActual,jdbcType=DECIMAL},
soft_cost = #{softCost,jdbcType=DECIMAL},
soft_cost_actual = #{softCostActual,jdbcType=DECIMAL},
audit_cost = #{auditCost,jdbcType=DECIMAL},
audit_cost_actual = #{auditCostActual,jdbcType=DECIMAL},
other_cost = #{otherCost,jdbcType=DECIMAL},
other_cost_actual = #{otherCostActual,jdbcType=DECIMAL},
expect_profit = #{expectProfit,jdbcType=DECIMAL},
actual_profit = #{actualProfit,jdbcType=DECIMAL},
stop_project = #{stopProject,jdbcType=INTEGER},
where id = #{id,jdbcType=INTEGER}
update t_order_mid
set order_no = #{orderNo,jdbcType=VARCHAR},
salesman_id = #{salesmanId,jdbcType=VARCHAR},
finance_id = #{financeId,jdbcType=VARCHAR},
salesman_name = #{salesmanName,jdbcType=VARCHAR},
finance_name = #{financeName,jdbcType=VARCHAR},
final_receivables = #{finalReceivables,jdbcType=DECIMAL},
final_Receivables_time = #{finalReceivablesTime,jdbcType=TIMESTAMP},
invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
create_time = #{createTime,jdbcType=TIMESTAMP},
buyer_name = #{buyerName,jdbcType=VARCHAR},
order_receivables = #{orderReceivables,jdbcType=DECIMAL},
order_arrears = #{orderArrears,jdbcType=DECIMAL},
payment_amount = #{paymentAmount,jdbcType=DECIMAL},
cost_amount = #{costAmount,jdbcType=DECIMAL},
dep_name = #{depName,jdbcType=VARCHAR},
province_name = #{provinceName,jdbcType=VARCHAR},
legal_affairs = #{legalAffairs,jdbcType=INTEGER},
dun_start_time = #{dunStartTime,jdbcType=TIMESTAMP},
legal_affairs_type = #{legalAffairsType,jdbcType=INTEGER},
operation_time = #{operationTime,jdbcType=DATE},
legal_affairs_status = #{legalAffairsStatus,jdbcType=INTEGER},
project_type = #{projectType,jdbcType=INTEGER},
service_type = #{serviceType,jdbcType=VARCHAR},
service_project = #{serviceProject,jdbcType=VARCHAR},
patent_cost = #{patentCost,jdbcType=DECIMAL},
patent_cost_actual = #{patentCostActual,jdbcType=DECIMAL},
soft_cost = #{softCost,jdbcType=DECIMAL},
soft_cost_actual = #{softCostActual,jdbcType=DECIMAL},
audit_cost = #{auditCost,jdbcType=DECIMAL},
audit_cost_actual = #{auditCostActual,jdbcType=DECIMAL},
other_cost = #{otherCost,jdbcType=DECIMAL},
other_cost_actual = #{otherCostActual,jdbcType=DECIMAL},
expect_profit = #{expectProfit,jdbcType=DECIMAL},
actual_profit = #{actualProfit,jdbcType=DECIMAL},
stop_project = #{stopProject,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
update t_order_mid a ,admin b set a.salesman_id=#{transferId},a.salesman_name=b.name
where b.id=#{transferId} and a.salesman_id=#{aid}
update t_order_new a ,t_order_mid b,admin c set b.finance_id=#{financeId},b.finance_name=c.name
where a.order_dep=#{id} and a.order_no=b.order_no and c.id= #{financeId}
update t_order_mid set final_receivables= #{amount},`final_Receivables_time`= #{receivablesTime},
order_arrears=if(order_arrears- #{amount} < 0,0,order_arrears- #{amount}),
actual_profit=#{count}-payment_amount
where order_no= #{orderNo}
update t_order_mid m,(select order_no,sum(amount)amount from t_order_invoice where status=2 group by order_no)b
set m.invoice_amount=b.amount where m.order_no= #{orderNo} and m.order_no=b.order_no
update t_order_mid x,(select x.order_no,sum(cost)cost,sum(party)party, sum(if(type = 1, cost, 0))zlc, sum(if(type = 1, party, 0))zlf,
sum(if(type = 2, cost, 0))rzc, sum(if(type = 2, party, 0))rzf, sum(if(type = 3, cost, 0))sjc, sum(if(type = 3, party, 0))sjf,
sum(if(type = 0 or type>3, cost, 0))qtc, sum(if(type = 0 or type>3, party, 0))qtf
from(select b.order_no, c.`type`, sum(cost_amount)cost, sum(party_amount)party
from t_task_mid a left join t_order_task b on a.tid = b.id left join business_project c on b.commodity_id = c.id
left join t_order_new d on b.order_no = d.order_no left join t_order_outsource too on a.tid =too.tid
where too.`type` =1 and too.refund_status =1 and d.delete_sign in (0,2) and b.order_no = #{orderNo}
group by b.order_no , c.`type`)x group by x.order_no)y,t_order_new z
set x.cost_amount =y.cost,x.payment_amount =y.party,x.patent_cost =y.zlc,x.patent_cost_actual =y.zlf,
x.soft_cost =y.rzc,x.soft_cost_actual =y.rzf,x.audit_cost =y.sjc,x.audit_cost_actual =y.sjf,
x.other_cost =qtc,x.other_cost_actual =y.qtf,x.expect_profit =z.total_amount-y.cost,
x.actual_profit =z.settlement_amount-y.party
where x.order_no =y.order_no and x.order_no=z.order_no
update t_order_mid
salesman_id = #{salesmanId,jdbcType=VARCHAR},
finance_id = #{financeId,jdbcType=VARCHAR},
salesman_name = #{salesmanName,jdbcType=VARCHAR},
finance_name = #{financeName,jdbcType=VARCHAR},
final_receivables = #{finalReceivables,jdbcType=DECIMAL},
final_Receivables_time = #{finalReceivablesTime,jdbcType=TIMESTAMP},
invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
create_time = #{createTime,jdbcType=TIMESTAMP},
buyer_name = #{buyerName,jdbcType=VARCHAR},
order_receivables = #{orderReceivables,jdbcType=DECIMAL},
order_arrears = #{orderArrears,jdbcType=DECIMAL},
payment_amount = #{paymentAmount,jdbcType=DECIMAL},
cost_amount = #{costAmount,jdbcType=DECIMAL},
dep_name = #{depName,jdbcType=VARCHAR},
province_name = #{provinceName,jdbcType=VARCHAR},
legal_affairs = #{legalAffairs,jdbcType=INTEGER},
dun_start_time = #{dunStartTime,jdbcType=TIMESTAMP},
legal_affairs_type = #{legalAffairsType,jdbcType=INTEGER},
operation_time = #{operationTime,jdbcType=DATE},
legal_affairs_status = #{legalAffairsStatus,jdbcType=INTEGER},
project_type = #{projectType,jdbcType=INTEGER},
service_type = #{serviceType,jdbcType=VARCHAR},
service_project = #{serviceProject,jdbcType=VARCHAR},
patent_cost = #{patentCost,jdbcType=DECIMAL},
patent_cost_actual = #{patentCostActual,jdbcType=DECIMAL},
soft_cost = #{softCost,jdbcType=DECIMAL},
soft_cost_actual = #{softCostActual,jdbcType=DECIMAL},
audit_cost = #{auditCost,jdbcType=DECIMAL},
audit_cost_actual = #{auditCostActual,jdbcType=DECIMAL},
other_cost = #{otherCost,jdbcType=DECIMAL},
other_cost_actual = #{otherCostActual,jdbcType=DECIMAL},
expect_profit = #{expectProfit,jdbcType=DECIMAL},
actual_profit = #{actualProfit,jdbcType=DECIMAL},
stop_project = #{stopProject,jdbcType=INTEGER},
where order_no = #{orderNo,jdbcType=VARCHAR}
update t_order_mid
set legal_affairs=1,legal_affairs_type =0
where order_no in(
#{item}
)
update t_order_mid a ,(select order_no ,ifnull(sum(money),0)money from new_order_dun where status =1 group by order_no)b,
t_order_new c
set a.order_receivables=b.money,a.order_arrears =(b.money-c.settlement_amount)
where a.order_no =b.order_no and a.order_no =c.order_no and a.order_receivables !=b.money;
update t_order_mid a,(select x.order_no,max(ps)ps from (select a.order_no ,if(a.project_status=29,1,0)ps
from t_order_task a where a.order_no = #{orderNo} )x group by order_no) b
set a.stop_project =b.ps
where a.order_no =b.order_no