|
|
|
@@ -24,101 +24,143 @@ |
|
|
|
ORDER BY shop_id asc |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectOrgPayType" parameterType="Integer" resultType="String"> |
|
|
|
SELECT distinct pay_type as payType |
|
|
|
from trade_mch_pay_channel |
|
|
|
where org_id = #{orgId} |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="queryShopPayOrderList" parameterType="com.iformall.domain.po.NeuPosOrderMasterExt" resultType="java.util.Map"> |
|
|
|
select ifnull(sum(order_amount),0) as payAmount, |
|
|
|
ifnull(sum(discount_amount),0) as discountAmount, |
|
|
|
count(order_amount) as payCount, |
|
|
|
ifnull(sum(if(order_status=4,real_pay_amount,0)),0) refundAmount, |
|
|
|
count(if(order_status=4,true,null)) refundCount, |
|
|
|
ifnull(sum(if(order_status=2,real_pay_amount,0)),0) as amount, |
|
|
|
pay_type as payType |
|
|
|
from order_master_v2 |
|
|
|
where pay_status = 4 and order_type != '3' |
|
|
|
<if test=" orgId != null"> |
|
|
|
and org_id = #{orgId} |
|
|
|
</if> |
|
|
|
<if test=" shopId != null"> |
|
|
|
and shop_id = #{shopId} |
|
|
|
</if> |
|
|
|
<if test=" createBegin != null"> |
|
|
|
and created_at >= #{createBegin} |
|
|
|
</if> |
|
|
|
<if test=" createEnd != null"> |
|
|
|
and created_at <= #{createEnd} |
|
|
|
</if> |
|
|
|
GROUP BY pay_type |
|
|
|
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' |
|
|
|
<if test=" orgId != null"> |
|
|
|
and order_master_v2.org_id = #{orgId} |
|
|
|
</if> |
|
|
|
<if test=" shopId != null"> |
|
|
|
and order_master_v2.shop_id = #{shopId} |
|
|
|
</if> |
|
|
|
<if test=" createBegin != null"> |
|
|
|
and pay_order_v2.created_at >= #{createBegin} |
|
|
|
</if> |
|
|
|
<if test=" createEnd != null"> |
|
|
|
and pay_order_v2.created_at <= #{createEnd} |
|
|
|
</if> |
|
|
|
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' |
|
|
|
<if test=" orgId != null"> |
|
|
|
and order_master_v2.org_id = #{orgId} |
|
|
|
</if> |
|
|
|
<if test=" shopId != null"> |
|
|
|
and order_master_v2.shop_id = #{shopId} |
|
|
|
</if> |
|
|
|
<if test=" createBegin != null"> |
|
|
|
and pay_order_v2.created_at >= #{createBegin} |
|
|
|
</if> |
|
|
|
<if test=" createEnd != null"> |
|
|
|
and pay_order_v2.created_at <= #{createEnd} |
|
|
|
</if> |
|
|
|
AND refund_status = 2 |
|
|
|
GROUP BY |
|
|
|
pay_type |
|
|
|
) AS refund ON pay_type_dict_v2.pay_type = refund.payType |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="queryShopPayOrderSum" parameterType="com.iformall.domain.po.NeuPosOrderMasterExt" resultType="java.util.Map"> |
|
|
|
select _temp.payType as payType, sum(_temp.payAmount) as payAmount, sum(_temp.payCount) as payCount from |
|
|
|
select sum(_temp.payAmount) as payAmount, sum(_temp.payCount) as payCount,sum(_temp.refundAmount) as refundAmount, |
|
|
|
sum(_temp.refundCount) as refundCount |
|
|
|
from |
|
|
|
( |
|
|
|
SELECT |
|
|
|
ifnull( refund.shop_id, paid.shop_id ) AS shopId, |
|
|
|
pay_type_dict_v2.pay_type AS payType, |
|
|
|
ifnull( payAmount, 0 ) - ifnull( refundAmount, 0 ) AS payAmount, |
|
|
|
ifnull( payCount, 0 ) + ifnull( refundCount, 0 ) AS payCount |
|
|
|
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_type_dict_v2 |
|
|
|
LEFT JOIN ( |
|
|
|
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' |
|
|
|
<if test=" orgId != null"> |
|
|
|
and order_master_v2.org_id = #{orgId} |
|
|
|
</if> |
|
|
|
<if test=" shopId != null"> |
|
|
|
and order_master_v2.shop_id = #{shopId} |
|
|
|
</if> |
|
|
|
<if test=" createBegin != null"> |
|
|
|
and pay_order_v2.created_at >= #{createBegin} |
|
|
|
</if> |
|
|
|
<if test=" createEnd != null"> |
|
|
|
and pay_order_v2.created_at <= #{createEnd} |
|
|
|
</if> |
|
|
|
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 |
|
|
|
shop_id, |
|
|
|
pay_type AS payType, |
|
|
|
ifnull( sum( pay_order_v2.pay_amount ) / 100, 0 ) AS payAmount, |
|
|
|
count( 0 ) AS payCount, |
|
|
|
0 AS discountAmount |
|
|
|
ifnull( sum( refunded_amount ) / 100, 0 ) refundAmount, |
|
|
|
count( 0 ) refundCount, |
|
|
|
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 |
|
|
|
<if test=" orgId != null"> |
|
|
|
and order_master_v2.org_id = #{orgId} |
|
|
|
</if> |
|
|
|
<if test=" shopId != null"> |
|
|
|
and order_master_v2.shop_id = #{shopId} |
|
|
|
</if> |
|
|
|
<if test=" createBegin != null"> |
|
|
|
and order_master_v2.created_at >= #{createBegin} |
|
|
|
</if> |
|
|
|
<if test=" createEnd != null"> |
|
|
|
and order_master_v2.created_at <= #{createEnd} |
|
|
|
</if> |
|
|
|
AND ( pay_order_v2.pay_status = 2 OR pay_order_v2.pay_status = 5 OR pay_order_v2.pay_status = 4 ) |
|
|
|
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' |
|
|
|
<if test=" orgId != null"> |
|
|
|
and order_master_v2.org_id = #{orgId} |
|
|
|
</if> |
|
|
|
<if test=" shopId != null"> |
|
|
|
and order_master_v2.shop_id = #{shopId} |
|
|
|
</if> |
|
|
|
<if test=" createBegin != null"> |
|
|
|
and pay_order_v2.created_at >= #{createBegin} |
|
|
|
</if> |
|
|
|
<if test=" createEnd != null"> |
|
|
|
and pay_order_v2.created_at <= #{createEnd} |
|
|
|
</if> |
|
|
|
AND refund_status = 2 |
|
|
|
GROUP BY |
|
|
|
pay_type, |
|
|
|
shop_id |
|
|
|
) AS paid ON pay_type_dict_v2.pay_type = paid.payType |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT |
|
|
|
shop_id, |
|
|
|
pay_type AS payType, |
|
|
|
ifnull( sum( refunded_amount ) / 100, 0 ) refundAmount, |
|
|
|
count( 0 ) refundCount |
|
|
|
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 |
|
|
|
<if test=" orgId != null"> |
|
|
|
and order_master_v2.org_id = #{orgId} |
|
|
|
</if> |
|
|
|
<if test=" shopId != null"> |
|
|
|
and order_master_v2.shop_id = #{shopId} |
|
|
|
</if> |
|
|
|
<if test=" createBegin != null"> |
|
|
|
and order_master_v2.created_at >= #{createBegin} |
|
|
|
</if> |
|
|
|
<if test=" createEnd != null"> |
|
|
|
and order_master_v2.created_at <= #{createEnd} |
|
|
|
</if> |
|
|
|
AND refund_status = 2 |
|
|
|
GROUP BY |
|
|
|
pay_type, |
|
|
|
shop_id |
|
|
|
) AS refund ON pay_type_dict_v2.pay_type = refund.payType |
|
|
|
AND paid.shop_id = refund.shop_id |
|
|
|
ORDER BY |
|
|
|
payType, |
|
|
|
shopId ASC |
|
|
|
pay_type |
|
|
|
) AS refund ON pay_type_dict_v2.pay_type = refund.payType |
|
|
|
) as _temp |
|
|
|
where _temp.payType in (select pay_type from trade_mch_pay_channel where org_id = #{orgId}) |
|
|
|
group by _temp.payType |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectShopList" parameterType="Integer" resultType="java.util.Map"> |
|
|
|
|