-- View: "v_payment_list"

DROP VIEW v_payment_list;

CREATE OR REPLACE VIEW v_payment_list AS
SELECT
    o.orderno,
    o.itemcd,
    o.structcd,
    o.stockcd,
    d.depositstate,
    s.sellercd,
    m.lastnm,
    m.firstnm,
    d.depositdate,
    d.sellerpaydate,
    o.typediv,
    n.name,
    o.price,
    d.updcnt

FROM
    t_ex_stock_detail s

    INNER JOIN t_order_detail o
              ON  s.itemcd   = o.itemcd
              AND s.structcd = o.structcd
              AND s.stockcd  = o.stockcd
              AND o.typediv = 1
              AND o.preorderflg = FALSE 
--            AND o.delflg   = false

    LEFT JOIN t_deposit d
              ON  o.orderno   = d.orderno
              AND d.depositstate = 2
--            AND d.delflg   = false

    LEFT JOIN t_member_basic_attr m
              ON  s.sellercd   = m.membercd
--            AND m.delflg   = false

    LEFT JOIN t_name n
              ON  n.namediv =11
              AND n.namecd = o.typediv
--            AND m.delflg   = false


  WHERE
    --s.delflg = false
      s.sellercd IS NOT NULL

ORDER BY o.orderno, o.structcd, o.stockcd, s.sellercd;
