select
  a.orderNo
, from_unixtime(cast(left(a.createTime,10) as unsigned integer)) createTime -- 创建时间
, from_unixtime(cast(left(a.confirmTime,10) as unsigned integer)) confirmTime -- 收货时间
, a.orderStatus -- 订单状态
, a.vid -- 项目id
, a.vidName -- 项目名称
, b.salePrice -- 销售金额
, c.refundCash -- 退款金额
from ods_weimob_order_listsearch_orderinfo_d a
left join (
	select orderNo, sum(salePrice*skuNum) salePrice
	from ods_weimob_order_listsearch_orderinfo_items_d
	group by orderNo
) b
on a.orderNo = b.orderNo
left join (
	select orderNo, sum(refundCash) refundCash
	from ods_weimob_rights_list_d
	where rightsstatus = '6'
	group by orderNo
) c
on a.orderNo = c.orderNo
where a.isDeleted = 0 and a.orderStatus != 9