where clearing_order_id = #{clearingOrderId,jdbcType=BIGINT}
</update>
<updateid="updateCheckoutByOperator">
update xhpc_clearing_history_order set clearing_checkout_id=#{checkoutId}
where del_flag=0 and check_status=2 and clearing_checkout_id is null and operator_id=#{operatorId}
</update>
<updateid="updateCheckoutByOrderId">
update xhpc_clearing_history_order set clearing_checkout_id=#{checkoutId}
where find_in_set(clearing_order_id, #{orderIds})
</update>
<selectid="getLandUser"resultType="map">
select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId}
</select>
<selectid="getOrderListPage"resultType="map">
select
ho.clearing_order_id as clearingOrderId,
co.charge_order_id as chargeOrderId,
ho.serial_number as serialNumber,
ct.name as chargingStationName,
ter.pile_serial_number as pileSerialNumber,
ter.name as terminalName,
op.operator_id as operatorId,
op.name as operatorName,
cp.power as power,
cp.type as type,
ho.type as orderType,
ho.start_soc as startSoc,
ho.end_soc as endSoc,
ho.vin_normal as vinCode,
ho.internet_serial_number as internetSerialNumber,
ho.evcs_order_no as evcsOrderNo,
ho.total_price as totalPrice,
ho.act_price as actPrice,
ho.confirm_Result as confirmResult,
co.charging_time as chargingTime,
co.charging_degree as chargingDegree,
co.start_time as startTime,
co.end_time as endTime,
co.update_time as updateTime,
co.source as source,
co.Plate_num as plateNum,
dispute_order_status as disputeOrderStatus,
inu.phone as internetUserPhone,
inu.name as internetName,
apu.phone as appUserPhone,
ho.power_price_total as powerPriceTotal,
ho.service_price_total as servicePriceTotal,
ho.promotion_discount as promotionDiscount,
ho.act_power_price as actPowerPrice,
ho.act_service_price as actServicePrice,
(ho.act_power_price+ho.act_service_price) as actSumPrice,
ho.internet_commission as internetCommission,
ho.internet_svc_commission as internetSvcCommission,
ho.internet_degree_commission as internetDegreeCommission,
ho.platform_commission as platformCommission,
ho.platform_svc_commisssion as platformSvcCommisssion,
ho.operation_commission as operationCommission,
ho.operation_svc_commission as operationSvcCommission,
cop.account as communityAccount,
cup.account as customersAccount,
case when co.source=0 then "C端用户"
when co.source=1 then "流量方用户"
when co.source=2 then "社区用户"
else "B端客户!"
end sourceName,
case when ho.charging_mode="1" then "快电"
when ho.charging_mode="2" then "恒大"
when ho.charging_mode="3" then "新电途"
when ho.charging_mode="4" then "小桔"
when ho.charging_mode="微信" then "微信"
when ho.charging_mode="支付宝" then "支付宝"
else "刷卡"
end chargingModeName
from xhpc_clearing_history_order as ho
left join xhpc_charging_station as ct on ct.charging_station_id = ho.charging_station_id
left join xhpc_operator as op on op.operator_id = ct.operator_id
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_terminal as ter on ter.terminal_id = ho.terminal_id
left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id
left join et_dispute_orders as ed on ed.start_charge_seq = ho.internet_serial_number and ed.dispute_order_status !=2
left join xhpc_internet_user as inu on inu.internet_user_id = ho.user_id and ho.internet_serial_number is not null and ho.source=1
left join xhpc_app_user as apu on apu.app_user_id = ho.user_id and ho.internet_serial_number is null and ho.source=0
left join xhpc_community_personnel as cop on cop.community_personnel_id = ho.user_id and ho.internet_serial_number is null and ho.source=2
left join xhpc_customers_personnel as cup on cup.customers_personnel_id = ho.user_id and ho.internet_serial_number is null and ho.source=3
<iftest="number==1">
inner join (
select hio.clearing_order_id as clearing_order_id from xhpc_clearing_history_order as hio INNER JOIN xhpc_app_user as xau on xau.app_user_id = hio.user_id where hio.source=0 and xau.phone LIKE concat('%',#{phone}, '%')
union
select hio.clearing_order_id as clearing_order_id from xhpc_clearing_history_order as hio INNER JOIN xhpc_internet_user as xiu on xiu.internet_user_id = hio.user_id where hio.source=1 and xiu.phone LIKE concat('%',#{phone}, '%')
union
select hio.clearing_order_id as clearing_order_id from xhpc_clearing_history_order as hio INNER JOIN xhpc_community_personnel as xcp on xcp.community_personnel_id = hio.user_id where hio.source=2 and xcp.account LIKE concat('%',#{phone}, '%')
union
select hio.clearing_order_id as clearing_order_id from xhpc_clearing_history_order as hio INNER JOIN xhpc_customers_personnel as xcup on xcup.customers_personnel_id = hio.user_id where hio.source=3 and xcup.account LIKE concat('%',#{phone}, '%')
) ut on ut.clearing_order_id = ho.clearing_order_id
</if>
where ho.status =0 and ho.del_flag=0 and ho.clearing_checkout_id = #{checkoutId}
<iftest="confirmResult !=null">
and ho.confirm_Result =#{confirmResult}
</if>
<iftest="type !=null">
and ho.type=#{type}
</if>
<iftest="source !=null">
and ho.source=#{source}
</if>
<iftest="plateNum !=null and plateNum !=''">
and co.Plate_num like concat('%', #{plateNum}, '%')
</if>
<iftest="internetId !=null">
and inu.internet_user_id=#{internetId}
</if>
<iftest="internetSerialNumber !=null and internetSerialNumber !=''">
and ho.internet_serial_number like concat('%', #{internetSerialNumber}, '%')
</if>
<iftest="terminalName !=null and terminalName !=''">
and ter.name like concat(#{terminalName}, '%')
</if>
<iftest="vinCode !=null and vinCode !=''">
and ho.vin_normal like concat('%', #{vinCode}, '%')
</if>
<iftest="evcsOrderNo !=null and evcsOrderNo !=''">
and co.evcs_order_no like concat('%', #{evcsOrderNo}, '%')
</if>
<iftest="beginStartTime !=null and beginStartTime !=''">
and ho.start_time >= #{beginStartTime}
</if>
<iftest="beginEndTime !=null and beginEndTime !=''">
and ho.start_time <= #{beginEndTime}
</if>
<iftest="overStartTime !=null and overStartTime !=''">
and ho.end_time >= #{overStartTime}
</if>
<iftest="overEndTime !=null and overEndTime !=''">
and ho.end_time <= #{overEndTime}
</if>
<iftest="transactionNumber !=null and transactionNumber !=''">
and ho.serial_number like concat('%', #{transactionNumber}, '%')
</if>
<iftest="chargingStationName !=null and chargingStationName !=''">
and ct.name like concat('%', #{chargingStationName}, '%')
</if>
<iftest="operatorId !=null">
and op.operator_id =#{operatorId}
</if>
<iftest="number==2">
<iftest="source ==0">
and ho.clearing_order_id in (select hio.clearing_order_id as clearing_order_id from xhpc_clearing_history_order as hio INNER JOIN xhpc_app_user as xau on xau.app_user_id = hio.user_id where hio.source=0)
</if>
<iftest="source ==1">
and ho.clearing_order_id in(select hio.clearing_order_id as clearing_order_id from xhpc_clearing_history_order as hio INNER JOIN xhpc_internet_user as xiu on xiu.internet_user_id = hio.user_id where hio.source=1)
</if>
<iftest="source ==2">
and ho.clearing_order_id in (select hio.clearing_order_id as clearing_order_id from xhpc_clearing_history_order as hio INNER JOIN xhpc_community_personnel as xcp on xcp.community_personnel_id = hio.user_id where hio.source=2)
</if>
<iftest="source ==3">
and ho.clearing_order_id in (select hio.clearing_order_id as clearing_order_id from xhpc_clearing_history_order as hio INNER JOIN xhpc_customers_personnel as xcup on xcup.customers_personnel_id = hio.user_id where hio.source=3)
</if>
</if>
<iftest="number==3">
<iftest="source ==0">
and ho.clearing_order_id in(select hio.clearing_order_id as clearing_order_id from xhpc_clearing_history_order as hio INNER JOIN xhpc_app_user as xau on xau.app_user_id = hio.user_id where hio.source=0 and xau.phone LIKE concat('%',#{phone}, '%'))
</if>
<iftest="source ==1">
and ho.clearing_order_id in(select hio.clearing_order_id as clearing_order_id from xhpc_clearing_history_order as hio INNER JOIN xhpc_internet_user as xiu on xiu.internet_user_id = hio.user_id where hio.source=1 and xiu.phone LIKE concat('%',#{phone}, '%'))
</if>
<iftest="source ==2">
and ho.clearing_order_id in(select hio.clearing_order_id as clearing_order_id from xhpc_clearing_history_order as hio INNER JOIN xhpc_community_personnel as xcp on xcp.community_personnel_id = hio.user_id where hio.source=2 and xcp.account LIKE concat('%',#{phone}, '%'))
</if>
<iftest="source ==3">
and ho.clearing_order_id in(select hio.clearing_order_id as clearing_order_id from xhpc_clearing_history_order as hio INNER JOIN xhpc_customers_personnel as xcup on xcup.customers_personnel_id = hio.user_id where hio.source=3 and xcup.account LIKE concat('%',#{phone}, '%'))
</if>
</if>
<iftest="status==1">
and co.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if>
<iftest="status==2">
and co.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})