Advertisement
dimonbb

Untitled

Sep 23rd, 2016
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 5.68 KB | None | 0 0
  1. SELECT  co.id, co.route, co.price, DATE_FORMAT(co.orderdate, '%d%m%y%H%i'), NULL, NULL, NULL, co.desc, co.commission, NULL, IF(43460, NULL, NULL),  (UNIX_TIMESTAMP(co.orderdate)-UNIX_TIMESTAMP(NOW()))/60, co.userid, co.fromdriver, co.status, co.finalprice, NULL, UNIX_TIMESTAMP(co.updatetime), NULL, c.typeid, p.name, co.route_from_name, co.route_to_name, co.route_from_address, co.route_to_address, co.route_from_type, co.route_to_type, co.tariff, co.paytypeid, NULL, NULL, UNIX_TIMESTAMP(co.createdate), (UNIX_TIMESTAMP(orderdate)-UNIX_TIMESTAMP(NOW()))/60 AS timetoorder,  NULL,(select shortnum from driver where id=co.fromdriver), co.route_from_latitude, co.route_from_longitude, co.route_to_latitude, co.route_to_longitude, co.smoking,co.require_conditioner, co.animals, co.require_check, co.require_card, co.require_yamoney, co.luggage, co.require_child_chair,co.route_from_housing, co.route_from_structure, co.route_from_entrance , cdv.distance, co.frommobileapp, cbp.bonus_pay, co.adsourceid, CASE WHEN (co.urgent='yes' AND co.restricted_driver_view='yes' AND cdv.driverid IS NOT NULL AND cdv.delay IS NOT NULL AND ADDDATE(co.createdate, INTERVAL cdv.delay SECOND) < NOW()) THEN 'yes' ELSE 'no' END AS show_as_nearest_for_driver, CASE WHEN (co.frommobileapp='yes' AND (co.fromdriver=0 OR co.fromdriver=16)) THEN 'yes' ELSE 'no' END AS can_cappmaxcommisiont, co.iscombo, co.inapp_payment, IF (tya.day_city_calculation_type IS NOT NULL, tya.day_city_calculation_type, tyamain.day_city_calculation_type) dcalc, co.approximate_price, (SELECT COUNT(*) FROM carorder_via_point cvp WHERE cvp.orderid=co.id) as via_points_count  FROM driver_tariff_ya AS dt, carorder AS co LEFT JOIN partner AS p ON p.id=co.partner LEFT JOIN client AS c ON c.userid = co.userid LEFT JOIN driver AS d ON d.id = 43460 LEFT JOIN driver AS do ON d.driver_owner = do.id LEFT JOIN carorder_driver_view AS cdv ON cdv.driverid=d.id AND cdv.orderid=co.id LEFT JOIN carorder_bonus_pay AS cbp ON cbp.orderid=co.id LEFT JOIN chronopay_accounts AS cacc ON d.reporttypeid=cacc.reporttypeid LEFT JOIN chronopay_accounts AS caccdo ON do.reporttypeid=caccdo.reporttypeid LEFT JOIN alfabank_accounts AS aacc ON d.reporttypeid=aacc.reporttypeid AND aacc.type='auto' LEFT JOIN alfabank_accounts AS aaccdo ON do.reporttypeid=aaccdo.reporttypeid AND aaccdo.type='auto' LEFT JOIN tariff_ya tya ON tya.partner_id=co.fromdriver AND tya.id=co.tariff LEFT JOIN tariff_ya tyamain ON tyamain.partner_id=0 AND tyamain.id=co.tariff LEFT JOIN carorder_card_processing cprocess ON cprocess.orderid=co.id WHERE co.mobileaccess = 1 AND co.type2id = 1 AND (co.driverid is null OR co.driverid = 0) AND co.status = 1 AND ( (0 = 0) OR (0 > 0 AND co.zoneid = 0)) AND co.orderdate >= NOW() AND co.orderdate <= ADDDATE(now(), INTERVAL 96 HOUR) AND (ADDDATE( co.createdate, INTERVAL 0 MINUTE) < now() OR co.fromdriver=43460 OR co.fromdriver=1131 OR (co.urgent='yes' AND co.restricted_driver_view='yes')) AND (co.partner!=0 OR co.fromdriver!=0 OR (HOUR(co.orderdate) BETWEEN 2 AND 10) OR ADDDATE(NOW(), INTERVAL 500000 MINUTE) > co.orderdate OR (co.urgent='yes'  AND co.restricted_driver_view='yes')) AND co.updatetime>=FROM_UNIXTIME(0) AND dt.driverid = 43460 AND (d.test = 'yes' OR (d.test <> 'yes' AND (co.adsourceid IS NULL OR co.adsourceid <> 200))) AND co.tariff = dt.tariff_ya_id AND (d.yamoney = 'yes' OR co.require_yamoney <> 'yes') AND (co.require_yellownumbers <> 'yes' OR d.car_number REGEXP '[^0-9]{2}[0-9]{5}$') AND (co.require_conditioner = 'no' OR (co.require_conditioner='yes' AND d.isConditioner='1')) AND (co.fromdriver=1131 OR co.urgent <> 'yes' OR (d.orders_view_delay = 0 OR d.ishipriority = '1') OR (co.fromdriver<>1131 AND co.urgent = 'yes' AND d.orders_view_delay>0 AND ADDDATE(co.createdate, INTERVAL 60 SECOND) < NOW())) AND (co.fromdriver=1131 OR co.urgent = 'yes' OR (d.orders_view_delay = 0 OR d.ishipriority = '1') OR (co.fromdriver<>1131 AND co.urgent <> 'yes' AND d.orders_view_delay>0 AND (UNIX_TIMESTAMP(co.orderdate) - UNIX_TIMESTAMP(NOW())) < ((30 - d.orders_view_delay) * 60))) AND (co.require_child_chair = 0 OR (d.isChildChair = '1' AND co.require_child_chair >= CAST(SUBSTRING_INDEX(d.child_chair_age, '-', 1) AS DECIMAL(3,1)) AND co.require_child_chair <= CAST(SUBSTRING_INDEX(d.child_chair_age, '-', -1) AS DECIMAL(3,1)))) AND (co.iscombo = 'no' OR (co.iscombo = 'yes' AND d.isCombo = '1')) AND (co.require_check = 'no' OR d.check = 'yes') AND (co.require_card = 'no' OR d.card = 'yes') AND (co.for_children='no' OR co.fromdriver=d.driver_owner) AND (co.for_partners='yes' OR (do.driverownertype!=1 OR do.driverownertype IS NULL)) AND (ADDDATE(co.createdate, INTERVAL 120 SECOND) < NOW() OR ((co.urgent <> 'yes' OR co.restricted_driver_view <> 'yes') OR (co.urgent='yes' AND co.restricted_driver_view='yes'  AND cdv.driverid IS NOT NULL AND cdv.delay IS NOT NULL AND ADDDATE(co.createdate, INTERVAL cdv.delay SECOND) < NOW()))) AND (cbp.bonus_pay = 'no' OR cbp.bonus_pay IS NULL OR do.children_virtual_balance='yes' OR (cbp.bonus_pay = 'yes' AND 2 <> 1)) AND (co.inapp_payment = 'no'             OR             ((cprocess.card_processing_id = 1 OR cprocess.card_processing_id IS NULL) AND                 (                    ((do.driverownertype!=1 OR do.driverownertype IS NULL) AND cacc.id IS NOT NULL) OR                     (do.driverownertype=1 AND caccdo.id IS NOT NULL)                )            )            OR             ((cprocess.card_processing_id = 2) AND                 (                    ((do.driverownertype!=1 OR do.driverownertype IS NULL) AND aacc.id IS NOT NULL) OR                     (do.driverownertype=1 AND aaccdo.id IS NOT NULL)                )            )            OR            (cprocess.card_processing_id = 3)    ) AND ((1) OR co.orderdate<DATE_ADD(NOW(), INTERVAL 2 HOUR)) ORDER BY co.orderdate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement