select order_id, order_no, out_trade_no, user_id, user_name, real_name, phone, rule_id, device_mac, sn, pay_time, pay_type, paid, type, total_fee, pay_fee, deposit, overdue_fee, dispatch_fee,delivery_fee,
lease_fee, mark, duration, status, create_time, return_time, deposit_deduction, deposit_order_no, deduction_amount, used_sn, change_reason,
auto_refund_deposit, rental_unit, handling_charge, platform_service_fee, operator_dividend, pay_channel, delivery_method, pickup_time,
agent_id, store_id, merchant_id, pickup_city, pickup_loc, pickup_lon, pickup_lat, model_id, model, expiry_time, original_order_no, num, price, `explain`,
instructions, out_unit, out_price,return_type,return_method,address,auto_cancel_time,cost, is_overdue from rl_order
SELECT
o.order_id,
o.order_no,
o.out_trade_no,
o.user_id,
o.user_name,
o.real_name,
o.phone,
o.rule_id,
o.device_mac,
o.sn,
o.pay_time,
o.pay_type,
o.paid,
o.type,
o.total_fee,
o.pay_fee,
o.deposit,
o.overdue_fee,
o.dispatch_fee,
o.delivery_fee,
o.lease_fee,
o.model_id,
o.model,
o.mark,
o.duration,
o.status,
o.create_time,
o.return_time,
o.deposit_deduction,
o.deposit_order_no,
o.deduction_amount,
o.used_sn,
o.change_reason,
o.auto_refund_deposit,
o.rental_unit,
o.handling_charge,
o.platform_service_fee,
o.operator_dividend,
o.pay_channel,
o.delivery_method,
o.pickup_time,
o.agent_id,
o.store_id,
o.pickup_city,
o.pickup_loc,
o.pickup_lon,
o.pickup_lat,
o.expiry_time,
o.original_order_no,
o.num,
o.price,
o.`explain`,
o.instructions,
o.out_unit,
o.out_price,
u.user_name as userName,
s.name as storeName,
s.simple_address as storeAddress,
m.model,
a.name agentName,
r.rental_unit as rentalUnit,
o.return_type,
o.return_method,
o.address,
o.auto_cancel_time,
o.merchant_id,
o.cost,
o.is_overdue,
CONCAT(
CASE
WHEN r.rental_unit = 'hours' THEN '时租'
WHEN r.rental_unit = 'day' THEN '日租'
WHEN r.rental_unit = 'week' THEN '周租'
WHEN r.rental_unit = 'month' THEN '月租'
WHEN r.rental_unit = 'quarter' THEN '季租'
WHEN r.rental_unit = 'year' THEN '年租'
ELSE r.rental_unit
END,
'(', o.num, '',
CASE
WHEN r.rental_unit = 'hours' THEN '小时'
WHEN r.rental_unit = 'day' THEN '天'
WHEN r.rental_unit = 'week' THEN '周'
WHEN r.rental_unit = 'month' THEN '天'
WHEN r.rental_unit = 'quarter' THEN '天'
WHEN r.rental_unit = 'year' THEN '天'
ELSE ''
END, ')'
) AS rentalPeriodText
FROM
rl_order o
left join rl_user u on o.user_id = u.user_id
left join rl_fee_rule r on o.rule_id = r.rule_id
left join rl_store s on o.store_id = s.store_id
left join rl_agent a on o.agent_id = a.agent_id
left join rl_model m on o.model_id = m.model_id
insert into rl_order
order_no,
out_trade_no,
user_id,
user_name,
real_name,
phone,
rule_id,
device_mac,
sn,
pay_time,
pay_type,
paid,
type,
total_fee,
pay_fee,
deposit,
overdue_fee,
dispatch_fee,
delivery_fee,
lease_fee,
model_id,
model,
mark,
duration,
status,
create_time,
return_time,
deposit_deduction,
deposit_order_no,
deduction_amount,
used_sn,
change_reason,
auto_refund_deposit,
rental_unit,
handling_charge,
platform_service_fee,
operator_dividend,
pay_channel,
delivery_method,
pickup_time,
agent_id,
store_id,
merchant_id,
pickup_city,
pickup_loc,
pickup_lon,
pickup_lat,
expiry_time,
original_order_no,
num,
price,
`explain`,
instructions,
out_unit,
out_price,
return_type,
return_method,
address,
auto_cancel_time,
cost,
#{orderNo},
#{outTradeNo},
#{userId},
#{userName},
#{realName},
#{phone},
#{ruleId},
#{deviceMac},
#{sn},
#{payTime},
#{payType},
#{paid},
#{type},
#{totalFee},
#{payFee},
#{deposit},
#{overdueFee},
#{dispatchFee},
#{deliveryFee},
#{leaseFee},
#{modelId},
#{model},
#{mark},
#{duration},
#{status},
#{createTime},
#{returnTime},
#{depositDeduction},
#{depositOrderNo},
#{deductionAmount},
#{usedSn},
#{changeReason},
#{autoRefundDeposit},
#{rentalUnit},
#{handlingCharge},
#{platformServiceFee},
#{operatorDividend},
#{payChannel},
#{deliveryMethod},
#{pickupTime},
#{agentId},
#{storeId},
#{merchantId},
#{pickupCity},
#{pickupLoc},
#{pickupLon},
#{pickupLat},
#{expiryTime},
#{originalOrderNo},
#{num},
#{price},
#{explain},
#{instructions},
#{outUnit},
#{outPrice},
#{returnType},
#{returnMethod},
#{address},
#{autoCancelTime},
#{cost},
update rl_order
order_no = #{orderNo},
out_trade_no = #{outTradeNo},
user_id = #{userId},
user_name = #{userName},
real_name = #{realName},
phone = #{phone},
rule_id = #{ruleId},
device_mac = #{deviceMac},
sn = #{sn},
pay_time = #{payTime},
pay_type = #{payType},
paid = #{paid},
type = #{type},
total_fee = #{totalFee},
pay_fee = #{payFee},
deposit = #{deposit},
overdue_fee = #{overdueFee},
dispatch_fee = #{dispatchFee},
delivery_fee = #{deliveryFee},
lease_fee = #{leaseFee},
model_id = #{modelId},
model = #{model},
mark = #{mark},
duration = #{duration},
status = #{status},
create_time = #{createTime},
return_time = #{returnTime},
deposit_deduction = #{depositDeduction},
deposit_order_no = #{depositOrderNo},
deduction_amount = #{deductionAmount},
used_sn = #{usedSn},
change_reason = #{changeReason},
auto_refund_deposit = #{autoRefundDeposit},
rental_unit = #{rentalUnit},
handling_charge = #{handlingCharge},
platform_service_fee = #{platformServiceFee},
operator_dividend = #{operatorDividend},
pay_channel = #{payChannel},
delivery_method = #{deliveryMethod},
pickup_time = #{pickupTime},
agent_id = #{agentId},
store_id = #{storeId},
merchant_id = #{merchantId},
pickup_city = #{pickupCity},
pickup_loc = #{pickupLoc},
pickup_lon = #{pickupLon},
pickup_lat = #{pickupLat},
expiry_time = #{expiryTime},
original_order_no = #{originalOrderNo},
num = #{num},
price = #{price},
`explain` = #{explain},
instructions = #{instructions},
out_unit = #{outUnit},
out_price = #{outPrice},
return_type = #{returnType},
return_method = #{returnMethod},
address = #{address},
auto_cancel_time = #{autoCancelTime},
is_overdue = #{isOverdue},
cost = #{cost},
where order_id = #{orderId}
update rl_order
order_no = #{orderNo},
out_trade_no = #{outTradeNo},
user_id = #{userId},
user_name = #{userName},
real_name = #{realName},
phone = #{phone},
rule_id = #{ruleId},
device_mac = #{deviceMac},
sn = #{sn},
pay_time = #{payTime},
pay_type = #{payType},
paid = #{paid},
type = #{type},
total_fee = #{totalFee},
pay_fee = #{payFee},
deposit = #{deposit},
overdue_fee = #{overdueFee},
dispatch_fee = #{dispatchFee},
delivery_fee = #{deliveryFee},
lease_fee = #{leaseFee},
model_id = #{modelId},
model,
mark = #{mark},
duration = #{duration},
status = #{status},
create_time = #{createTime},
return_time = #{returnTime},
deposit_deduction = #{depositDeduction},
deposit_order_no = #{depositOrderNo},
deduction_amount = #{deductionAmount},
used_sn = #{usedSn},
change_reason = #{changeReason},
auto_refund_deposit = #{autoRefundDeposit},
rental_unit = #{rentalUnit},
handling_charge = #{handlingCharge},
platform_service_fee = #{platformServiceFee},
operator_dividend = #{operatorDividend},
pay_channel = #{payChannel},
delivery_method = #{deliveryMethod},
pickup_time = #{pickupTime},
agent_id = #{agentId},
store_id = #{storeId},
merchant_id = #{merchantId},
pickup_city = #{pickupCity},
pickup_loc = #{pickupLoc},
pickup_lon = #{pickupLon},
pickup_lat = #{pickupLat},
expiry_time = #{expiryTime},
original_order_no = #{originalOrderNo},
num = #{num},
price = #{price},
`explain` = #{explain},
instructions = #{instructions},
out_unit = #{outUnit},
out_price = #{outPrice},
return_type = #{returnType},
cost = #{cost},
where order_no = #{orderNo}
delete from rl_order where order_id = #{orderId}
delete from rl_order where order_id in
#{orderId}