SELECT shop_id as shopId,
sum(real_pay_amount) as payAmount,
count(0) as payCount
from order_master_v2
where order_status = 4 and order_type != '3'
and org_id = #{orgId}
and shop_id = #{shopId}
and created_at >= #{createBegin}
and created_at <= #{createEnd}
GROUP BY shop_id
ORDER BY shop_id asc
SELECT distinct pay_type as payType
from trade_mch_pay_channel
where org_id = #{orgId}
SELECT
pay_type_dict_v2.pay_type AS payType,
ifnull( payAmount, 0 )AS payAmount,
ifnull( discountAmount, 0 )AS discountAmount,
ifnull( payCount, 0 )AS payCount,
ifnull( refundAmount, 0 )AS refundAmount,
ifnull( refundCount, 0 )AS refundCount,
ifnull( ( ifnull(payAmount,0) - ifnull(refundAmount,0) ), 0 ) AS amount
FROM
pay_type_dict_v2
LEFT JOIN (
SELECT
ifnull( sum( pay_order_v2.pay_amount ) / 100, 0 ) AS payAmount,
count( 0 ) AS payCount,
0 AS discountAmount,
pay_type AS payType
FROM
pay_order_v2
LEFT JOIN order_master_v2 ON pay_order_v2.m_order_number = order_master_v2.order_number
where order_master_v2.order_type != '3' and pay_order_v2.pay_type not in ('29','30')
and order_master_v2.org_id = #{orgId}
and order_master_v2.shop_id = #{shopId}
and pay_order_v2.created_at >= #{createBegin}
and pay_order_v2.created_at <= #{createEnd}
and pay_order_v2.pay_type in
#{payTypeItem}
AND ( pay_order_v2.pay_status = 2 OR pay_order_v2.pay_status = 5 OR pay_order_v2.pay_status = 4 )
GROUP BY
pay_type
) AS paid ON pay_type_dict_v2.pay_type = paid.payType
LEFT JOIN (
SELECT
ifnull( sum( refunded_amount ) / 100, 0 ) refundAmount,
count( 0 ) refundCount,
pay_type AS payType
FROM
pay_refund_order_v2 AS pay_order_v2
LEFT JOIN order_master_v2 ON pay_order_v2.m_order_number = order_master_v2.order_number
where order_master_v2.order_type != '3' and pay_order_v2.pay_type not in ('29','30')
and order_master_v2.org_id = #{orgId}
and order_master_v2.shop_id = #{shopId}
and pay_order_v2.created_at >= #{createBegin}
and pay_order_v2.created_at <= #{createEnd}
and pay_order_v2.pay_type in
#{payTypeItem}
AND refund_status = 2
GROUP BY
pay_type
) AS refund ON pay_type_dict_v2.pay_type = refund.payType
where pay_type_dict_v2.pay_type not in ('29','30')
and pay_type_dict_v2.pay_type in
#{payTypeItem}
select sum(_temp.payAmount) as payAmount, sum(_temp.payCount) as payCount,sum(_temp.refundAmount) as refundAmount,
sum(_temp.refundCount) as refundCount
from
(
SELECT
pay_type_dict_v2.pay_type AS payType,
ifnull( payAmount, 0 )AS payAmount,
ifnull( discountAmount, 0 )AS discountAmount,
ifnull( payCount, 0 )AS payCount,
ifnull( refundAmount, 0 )AS refundAmount,
ifnull( refundCount, 0 )AS refundCount,
ifnull( ( ifnull(payAmount,0) - ifnull(refundAmount,0) ), 0 ) AS amount
FROM
pay_type_dict_v2
LEFT JOIN (
SELECT
ifnull( sum( pay_order_v2.pay_amount ) / 100, 0 ) AS payAmount,
count( 0 ) AS payCount,
0 AS discountAmount,
pay_type AS payType
FROM
pay_order_v2
LEFT JOIN order_master_v2 ON pay_order_v2.m_order_number = order_master_v2.order_number
where order_master_v2.order_type != '3' and pay_order_v2.pay_type not in ('29','30')
and order_master_v2.org_id = #{orgId}
and order_master_v2.shop_id = #{shopId}
and pay_order_v2.created_at >= #{createBegin}
and pay_order_v2.created_at <= #{createEnd}
and pay_order_v2.pay_type in
#{payTypeItem}
AND ( pay_order_v2.pay_status = 2 OR pay_order_v2.pay_status = 5 OR pay_order_v2.pay_status = 4 )
GROUP BY
pay_type
) AS paid ON pay_type_dict_v2.pay_type = paid.payType
LEFT JOIN (
SELECT
ifnull( sum( refunded_amount ) / 100, 0 ) refundAmount,
count( 0 ) refundCount,
pay_type AS payType
FROM
pay_refund_order_v2 AS pay_order_v2
LEFT JOIN order_master_v2 ON pay_order_v2.m_order_number = order_master_v2.order_number
where order_master_v2.order_type != '3' and pay_order_v2.pay_type not in ('29','30')
and order_master_v2.org_id = #{orgId}
and order_master_v2.shop_id = #{shopId}
and pay_order_v2.created_at >= #{createBegin}
and pay_order_v2.created_at <= #{createEnd}
and pay_order_v2.pay_type in
#{payTypeItem}
AND refund_status = 2
GROUP BY
pay_type
) AS refund ON pay_type_dict_v2.pay_type = refund.payType
where pay_type_dict_v2.pay_type not in ('29','30')
and pay_type_dict_v2.pay_type in
#{payTypeItem}
) as _temp
select id,name from `shop` where status = 1
and org = #{orgId}
order by name asc
select pay_type,name from `trade_pay_type_dict`
SELECT o.id,o.shop_id as shopId,o.paid_time AS paidTime,o.order_number AS orderNumber,o.serial_no AS serialNo,
o.order_amount/100 AS orderAmount,
sum( IF ( p.pay_type = 29, pay_amount, 0 ) )/100 AS discountAmount,
o.real_pay_amount / 100 AS realPayAmount,
o.order_status AS orderStatus,
p.pay_type as payType
FROM
order_master_v2 AS o
LEFT JOIN pay_order_v2 AS p ON o.order_number = p.m_order_number
where 1=1
and o.org_id = #{orgId}
and o.shop_id = #{shopId}
and o.created_at >= #{createBegin}
and o.created_at <= #{createEnd}
GROUP BY
o.order_number
ORDER BY o.created_at desc
select id,order_number as orderNumber,org_id as orgId,shop_id as shopId,buyer_id as buyerId,serial_no as serialNo,device_name as deviceName,
customer_number as customerNumber,seq_no as seqNo,(ifnull( order_amount, 0 )/100) AS orderAmount,(ifnull( real_pay_amount, 0 )/100) AS realPayAmount,
order_amount_unit as orderAmountUnit,paid_time as paidTime,refund_time as refundTime,order_status as orderStatus
from order_master_v2 where id=#{id}
update order_master_v2 set order_status=#{payStatus} where order_number=#{orderNumber}
select * from pay_order_v2 where m_order_number=#{orderNumber} and pay_status = #{payStatus}
insert into pay_order_v2(m_order_number,trade_id,device_id,device_name,description,pay_type,pay_type_name,pay_amount,refunded_amount,
time_expire,pay_status,pay_time,version,trade_type,created_at,created_by,updated_by,updated_at)
values (#{orderNumber},#{tradeId},#{deviceId},#{deviceName},#{description},#{payType},#{payTypeName},#{realPayAmount},#{refundAmount},
now(),#{payStatus},now(),1,"NATIVE",now(),"system","system",now())
select serial_no as serialNo,alias from device where status = 0 and organization_id = #{organizationId} and store_id = #{shopId}