You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
6.6 KiB

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qniao.dam.infrastructure.persistent.dao.view.RevenueRewardViewDao">
<select id="getRevenueRewardAbstract"
resultType="com.qniao.dam.api.query.revenuereward.user.response.UseGetRevenueRewardAbstractVo">
select
drr.id,
SUM(drrr.revenue) as totalRevenue,
SUM(drrr.earnings) as totalEarnings
from da_revenue_reward_record as drrr
LEFT JOIN da_revenue_reward as drr on drr.id=drrr.revenue_reward_id
WHERE drr.is_delete=0
<if test="queryParams.queryUserId != null">
and drr.user_id = #{queryParams.queryUserId}
</if>
<if test="queryParams.queryOrgId != null">
and drr.org_id = #{queryParams.queryOrgId}
</if>
<if test="queryParams.tradeType != null">
and drrr.trade_type = #{queryParams.tradeType}
</if>
<if test="queryParams.revenueTimeFrom != null and queryParams.revenueTimeTo != null">
and drrr.create_time BETWEEN #{queryParams.revenueTimeFrom} and #{queryParams.revenueTimeTo}
</if>
GROUP BY drr.id
limit 1
</select>
<select id="pageRevenueRewardRecord"
resultType="com.qniao.dam.api.query.revenuereward.user.response.UseGetRevenueRewardRecordVo">
select
drrr.trade_type,
drrr.revenue,
drrr.earnings,
drrr.total_associate_order_amount as associateOrderAmount,
drrr.content,
drrr.create_time as revenueTime
from da_revenue_reward_record as drrr
LEFT JOIN da_revenue_reward as drr on drr.id=drrr.revenue_reward_id
WHERE drr.is_delete=0
<if test="queryParams.queryUserId != null">
and drr.user_id = #{queryParams.queryUserId}
</if>
<if test="queryParams.queryOrgId != null">
and drr.org_id = #{queryParams.queryOrgId}
</if>
<if test="queryParams.tradeType != null">
and drrr.trade_type = #{queryParams.tradeType}
</if>
<if test="queryParams.revenueTimeFrom != null and queryParams.revenueTimeTo != null">
and drrr.create_time BETWEEN #{queryParams.revenueTimeFrom} and #{queryParams.revenueTimeTo}
</if>
ORDER BY drrr.create_time desc
</select>
<select id="pageRevenueRewardRecordByOperator"
resultType="com.qniao.dam.api.query.revenuereward.user.response.UsePageRevenueRewardRecordByOperatorVo">
select
darrr.id as revenueRewardRecordId,
darrr.create_time,
dam.user_id as matchmakerUserId,
dam.type as matchmakerType,
dam.`name` as revenueOwnerName,
dam.phone as revenueOwnerPhone,
darrr.trade_type,
darrr.total_associate_order_amount,
darrr.revenue_pct,
darrr.revenue,
darrr.service_pct,
darrr.earnings,
dao1.full_name as storeName,
dao2.full_name as operationCenterName
from da_revenue_reward_record as darrr
INNER JOIN da_revenue_reward as darr on darrr.revenue_reward_id=darr.id
LEFT JOIN da_matchmaker as dam on dam.is_delete=0 and dam.user_id=darr.user_id
LEFT JOIN da_store as das on dam.store_id=das.id
LEFT JOIN da_organization dao1 on dao1.id= das.org_id
LEFT JOIN da_organization dao2 on dao2.id= das.operation_center_org_id
where darr.is_delete=0 and darr.identity_type=1
<if test="queryParams.revenueOwnerName != null and queryParams.revenueOwnerName != '' ">
AND dam.`name` LIKE CONCAT('%', TRIM(#{queryParams.revenueOwnerName}), '%')
</if>
<if test="queryParams.revenueOwnerPhone != null and queryParams.revenueOwnerPhone != '' ">
AND dam.phone LIKE CONCAT('%', TRIM(#{queryParams.revenueOwnerPhone}), '%')
</if>
<if test="queryParams.createTimeFrom != null and queryParams.createTimeTo != null">
and darrr.create_time BETWEEN #{queryParams.createTimeFrom} and #{queryParams.createTimeTo}
</if>
order by darrr.create_time desc
</select>
<select id="listAssociateOrderRecord"
resultType="com.qniao.dam.api.query.revenuereward.user.response.RevenueRewardAssociateOrderRecordVo">
select
darraor.revenue_reward_record_id,
darraor.associate_order_id,
dao.order_code,
darraor.associate_order_amount,
dao.paid_time as orderTime,
dapco.ext_order_no as wechatOrderNo,
dao.order_belong_name as serviceUserName,
daa.tid as serviceUserPhone
from da_revenue_reward_associate_order_record as darraor
LEFT JOIN da_order as dao on darraor.associate_order_id=dao.id
LEFT JOIN da_marriage_information as dami on dami.id=dao.id
LEFT JOIN da_payment_order as dapo on dapo.is_delete=0 and dapo.`status`=3 and dapo.order_id=dao.id
LEFT JOIN da_payment_channel_order as dapco on dapco.is_delete=0 and dapco.txn_order_id=dapo.id and dapco.`status`=2
LEFT JOIN da_account as daa on daa.is_delete=0 and daa.user_id=dao.user_id and daa.type=2
where darraor.revenue_reward_record_id in
<foreach collection="revenueRewardRecordIdList" item="revenueRewardRecordId" open="(" close=")" separator=",">
#{revenueRewardRecordId}
</foreach>
</select>
<select id="getRevenueRewardAbstractByOperator"
resultType="com.qniao.dam.api.query.revenuereward.user.response.UseGetRevenueRewardAbstractByOperatorVo">
select
SUM(IFNULL(darrr.revenue,0)) as totalRevenue,
SUM(IFNULL(darrr.earnings,0)) as totalEarnings
from da_revenue_reward as darr
LEFT JOIN da_revenue_reward_record as darrr on darrr.revenue_reward_id=darr.id
LEFT JOIN da_matchmaker as dam on dam.is_delete=0 and dam.user_id=darr.user_id
where darr.is_delete=0 and darr.identity_type=1
<if test="queryParams.revenueOwnerName != null and queryParams.revenueOwnerName != '' ">
AND dam.`name` LIKE CONCAT('%', TRIM(#{queryParams.revenueOwnerName}), '%')
</if>
<if test="queryParams.revenueOwnerPhone != null and queryParams.revenueOwnerPhone != '' ">
AND dam.phone LIKE CONCAT('%', TRIM(#{queryParams.revenueOwnerPhone}), '%')
</if>
<if test="queryParams.createTimeFrom != null and queryParams.createTimeTo != null">
and darrr.create_time BETWEEN #{queryParams.createTimeFrom} and #{queryParams.createTimeTo}
</if>
</select>
</mapper>