EC CUBE2.1x のCSV出力で、発送情報も含めよ

さらに、発送情報も一緒に取り込みたい、というオーダー。別表からおまとめする感じ。いらないところは、のちのち削っていこう。


dtb_order.order_id,
dtb_order.customer_id,
dtb_order.message,
dtb_order.order_name01,
dtb_order.order_name02,
dtb_order.order_kana01,
dtb_order.order_kana02,
dtb_order.order_email,
dtb_order.order_tel01,
dtb_order.order_tel02,
dtb_order.order_tel03,
dtb_order.order_fax01,
dtb_order.order_fax02,
dtb_order.order_fax03,
dtb_order.order_zip01,
dtb_order.order_zip02,
(SELECT mtb_pref.name FROM mtb_pref WHERE mtb_pref.id = dtb_order.order_pref),
dtb_order.order_addr01,
dtb_order.order_addr02,
dtb_order.order_sex,
dtb_order.order_birth,
dtb_order.order_job,
dtb_order_detail.product_name,
dtb_order_detail.product_code,
dtb_order_detail.classcategory_name1,
dtb_order_detail.classcategory_name2,
dtb_order_detail.price,
dtb_order_detail.quantity,
dtb_order.subtotal,
dtb_order.discount,
dtb_order.deliv_fee,
dtb_order.charge,
dtb_order.use_point,
dtb_order.add_point,
dtb_order.tax,
dtb_order.total,
dtb_order.payment_total,
dtb_order.deliv_id,
dtb_order.payment_method,
dtb_order.note,
dtb_order.status,
dtb_order.create_date,
dtb_order.update_date,
dtb_order.commit_date,
dtb_order.device_type_id,
dtb_shipping.shipping_name01,
dtb_shipping.shipping_name02,
dtb_shipping.shipping_kana01,
dtb_shipping.shipping_kana02,
dtb_shipping.shipping_company_name,
dtb_shipping.shipping_tel01,
dtb_shipping.shipping_tel02,
dtb_shipping.shipping_tel03,
dtb_shipping.shipping_fax01,
dtb_shipping.shipping_fax02,
dtb_shipping.shipping_fax03,
dtb_shipping.shipping_country_id,
(SELECT mtb_pref.name FROM mtb_pref WHERE mtb_pref.id = dtb_shipping.shipping_pref),
dtb_shipping.shipping_zip01,
dtb_shipping.shipping_zip02,
dtb_shipping.shipping_zipcode,
dtb_shipping.shipping_addr01,
dtb_shipping.shipping_addr02,
dtb_shipping.time_id,
dtb_shipping.shipping_time,
dtb_shipping.shipping_date,
dtb_shipping.shipping_commit_date,
dtb_shipping.rank,
dtb_shipping.create_date,
dtb_shipping.update_date,
(SELECT count(*) FROM dtb_shipping WHERE dtb_shipping.order_id = dtb_order.order_id),
(SELECT array_to_string(array(SELECT dtb_shipping.shipping_id FROM dtb_shipping WHERE dtb_shipping.order_id = dtb_order.order_id), ',')),
(SELECT count(*) FROM dtb_shipping WHERE dtb_shipping.order_id),
(SELECT array_to_string(array(SELECT dtb_shipping.shipping_id FROM dtb_shipping WHERE dtb_shipping.order_id), ','))
FROM
dtb_order
INNER JOIN
dtb_order_detail
ON
dtb_order.order_id = dtb_order_detail.order_id
INNER JOIN
dtb_shipping
ON
dtb_order.order_id = dtb_shipping.order_id
AND
dtb_order.create_date > DATE_SUB(now(), INTERVAL 3 DAY)

6か月前