| | |
| | | <if test="req.orderSource != null and req.orderSource == 3 "> |
| | | and t1.tripartite_platform_name = 'XinDianTu' |
| | | </if> |
| | | <if test="req.isWhitelist != null"> |
| | | and t1.is_whitelist = #{req.isWhitelist} |
| | | </if> |
| | | <if test="req.paymentType != null and req.paymentType == 1 "> |
| | | and t1.recharge_payment_type = 1 |
| | | </if> |
| | |
| | | </select> |
| | | <select id="charge" resultType="com.ruoyi.order.dto.SixChargingDto"> |
| | | SELECT |
| | | DATE_FORMAT( subquery.create_time, '%m' ) AS MONTH, |
| | | SUM(electrovalence) AS electrovalence, |
| | | DATE_FORMAT(a.create_time, '%m') AS MONTH, |
| | | SUM(IFNULL(b.period_electric_price, 0)) AS electrovalence, |
| | | SUM( |
| | | CASE |
| | | WHEN subquery.order_source = 0 THEN subquery.service_charge |
| | | WHEN subquery.order_source = 1 THEN subquery.service_charge |
| | | ELSE subquery.service_charge * 0.8 |
| | | END |
| | | CASE |
| | | WHEN a.order_source = 0 THEN IFNULL(b.period_service_price, 0) |
| | | WHEN a.order_source = 1 THEN IFNULL(b.period_service_price, 0) |
| | | ELSE IFNULL(b.period_service_price, 0) * 0.8 |
| | | END |
| | | ) AS service_charge |
| | | |
| | | FROM |
| | | ( |
| | | SELECT |
| | | a.create_time, |
| | | b.period_electric_price as electrovalence, |
| | | b.period_service_price as service_charge, |
| | | a.order_source |
| | | FROM |
| | | t_charging_order a |
| | | left join (select charging_order_id, sum(period_electric_price) as period_electric_price, |
| | | sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money |
| | | from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id) |
| | | LEFT JOIN t_charging_order_accounting_strategy b ON a.id = b.charging_order_id |
| | | <where> |
| | | a.del_flag = 0 and a.recharge_payment_status = 2 and a.status = 5 |
| | | <if test="sixBefore != null"> |
| | |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | ) AS subquery |
| | | GROUP BY |
| | | DATE_FORMAT( subquery.create_time, '%m' ) |
| | | DATE_FORMAT(a.create_time, '%m') |
| | | |
| | | |
| | | </select> |
| | | <select id="circle" resultType="com.ruoyi.order.dto.SixCircleDto"> |
| | | SELECT |
| | | site_id as siteId, |
| | | a.site_id as siteId, |
| | | ROUND(SUM(CASE |
| | | WHEN a.order_source = 0 THEN b.money |
| | | WHEN a.order_source = 1 THEN b.money |
| | | ELSE (b.period_electric_price + b.period_service_price * 0.8) |
| | | WHEN a.order_source = 0 THEN IFNULL(b.period_electric_price, 0) + IFNULL(b.period_service_price, 0) |
| | | WHEN a.order_source = 1 THEN IFNULL(b.period_electric_price, 0) + IFNULL(b.period_service_price, 0) |
| | | ELSE (IFNULL(b.period_electric_price, 0) + IFNULL(b.period_service_price, 0) * 0.8) |
| | | END), 2) AS paymentAmount |
| | | FROM |
| | | t_charging_order a |
| | | left join (select charging_order_id, sum(period_electric_price) as period_electric_price, |
| | | sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money |
| | | from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id) |
| | | LEFT JOIN t_charging_order_accounting_strategy b ON a.id = b.charging_order_id |
| | | <where> |
| | | a.del_flag = 0 and a.recharge_payment_status = 2 and a.status = 5 |
| | | <if test="siteIds != null and siteIds.size() > 0"> |
| | |
| | | </foreach> |
| | | </if> |
| | | <if test="sixBefore != null"> |
| | | AND create_time >= #{sixBefore} |
| | | AND a.create_time >= #{sixBefore} |
| | | </if> |
| | | </where> |
| | | GROUP BY a.site_id |
| | |
| | | |
| | | </select> |
| | | <select id="countAll" resultType="java.util.Map"> |
| | | select sum(electrovalence) as electrovalence,sum(service_charge) as |
| | | service_charge,ROUND(sum(electrovalence+service_charge) * 0.006, 2) as commission_amount,sum(sharing_amount) as |
| | | sharing_amount |
| | | from t_charging_order |
| | | where del_flag = 0 and recharge_payment_status = 2 and status = 5 |
| | | SELECT |
| | | ROUND(SUM(IFNULL(b.period_electric_price, 0)), 2) AS electrovalence, |
| | | ROUND(SUM(CASE |
| | | WHEN a.order_source = 2 THEN IFNULL(b.period_service_price, 0) * 0.8 |
| | | ELSE IFNULL(b.period_service_price, 0) |
| | | END), 2) AS service_charge, |
| | | ROUND(SUM(CASE |
| | | WHEN a.order_source = 2 THEN 0 |
| | | ELSE IFNULL(b.period_electric_price, 0) + IFNULL(b.period_service_price, 0) |
| | | END) * 0.006, 2) AS commission_amount, |
| | | ROUND(SUM(CASE |
| | | WHEN a.order_source = 2 THEN IFNULL(b.period_service_price, 0) * 0.2 |
| | | ELSE 0 |
| | | END), 2) AS sharing_amount |
| | | FROM t_charging_order a |
| | | LEFT JOIN t_charging_order_accounting_strategy b ON a.id = b.charging_order_id |
| | | WHERE a.del_flag = 0 AND a.recharge_payment_status = 2 AND a.status = 5 |
| | | <if test="siteIds != null and siteIds.size() > 0"> |
| | | AND site_id IN |
| | | AND a.site_id IN |
| | | <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> |
| | | #{siteId} |
| | | </foreach> |
| | |
| | | FROM |
| | | t_charging_order_accounting_strategy t1 |
| | | LEFT JOIN t_charging_order t2 on t1.charging_order_id = t2.id |
| | | where t2.del_flag = 0 and t2.recharge_payment_status = 2 and t2.start_time between #{start} and #{end} |
| | | where t2.del_flag = 0 and t2.recharge_payment_status = 2 and t2.start_time IS NOT NULL and t2.end_time is not null and t2.pay_time between #{start} and #{end} |
| | | <if test="null != siteIds and siteIds.size() > 0"> |
| | | and t2.site_id in |
| | | <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index"> |
| | |
| | | </select> |
| | | <select id="getDateData" resultType="java.util.Map"> |
| | | SELECT |
| | | DATE_FORMAT(a.create_time, '%H:00' ) as time, |
| | | DATE_FORMAT(a.pay_time, '%H:00' ) as time, |
| | | SUM(CASE |
| | | WHEN a.order_source = 0 THEN b.period_service_price |
| | | WHEN a.order_source = 1 THEN b.period_service_price |
| | |
| | | sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money |
| | | from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id) |
| | | <where> |
| | | a.del_flag = 0 and a.recharge_payment_status = 2 and DATE(a.create_time) = CURDATE() |
| | | and a.start_time between #{start} and #{end} |
| | | a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null |
| | | and a.pay_time between #{start} and #{end} |
| | | <if test="null != siteIds and siteIds.size() > 0"> |
| | | and a.site_id in |
| | | <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index"> |
| | |
| | | </select> |
| | | <select id="getWeekData" resultType="java.util.Map"> |
| | | SELECT |
| | | DATE_FORMAT(a.create_time, '%Y-%m-%d' ) as time, |
| | | DATE_FORMAT(a.pay_time, '%Y-%m-%d' ) as time, |
| | | SUM(CASE |
| | | WHEN a.order_source = 0 THEN b.period_service_price |
| | | WHEN a.order_source = 1 THEN b.period_service_price |
| | |
| | | sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money |
| | | from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id) |
| | | <where> |
| | | a.del_flag = 0 and a.recharge_payment_status = 2 and YEARWEEK(DATE_FORMAT(a.create_time, |
| | | '%Y-%m-%d'), 1) = YEARWEEK(NOW(), 1) |
| | | and a.start_time between #{start} and #{end} |
| | | a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null |
| | | and a.pay_time between #{start} and #{end} |
| | | <if test="null != siteIds and siteIds.size() > 0"> |
| | | and a.site_id in |
| | | <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index"> |
| | |
| | | </select> |
| | | <select id="getMonthData" resultType="java.util.Map"> |
| | | SELECT |
| | | DATE_FORMAT(a.create_time, '%Y-%m-%d' ) as time, |
| | | DATE_FORMAT(a.pay_time, '%Y-%m-%d' ) as time, |
| | | SUM(CASE |
| | | WHEN a.order_source = 0 THEN b.period_service_price |
| | | WHEN a.order_source = 1 THEN b.period_service_price |
| | |
| | | sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money |
| | | from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id) |
| | | <where> |
| | | a.del_flag = 0 and a.recharge_payment_status = 2 and MONTH(a.create_time) = MONTH(NOW()) |
| | | AND YEAR(a.create_time) = YEAR(NOW()) |
| | | and a.start_time between #{start} and #{end} |
| | | a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null |
| | | and a.pay_time between #{start} and #{end} |
| | | <if test="null != siteIds and siteIds.size() > 0"> |
| | | and a.site_id in |
| | | <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index"> |
| | |
| | | </select> |
| | | <select id="getYearData" resultType="java.util.Map"> |
| | | SELECT |
| | | DATE_FORMAT(a.create_time, '%Y-%m-%d' ) as time, |
| | | DATE_FORMAT(a.pay_time, '%Y-%m-%d' ) as time, |
| | | SUM(CASE |
| | | WHEN a.order_source = 0 THEN b.period_service_price |
| | | WHEN a.order_source = 1 THEN b.period_service_price |
| | |
| | | sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money |
| | | from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id) |
| | | <where> |
| | | a.del_flag = 0 and a.recharge_payment_status = 2 and YEAR(a.create_time) = YEAR(NOW()) |
| | | and a.start_time between #{start} and #{end} |
| | | a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null |
| | | and a.pay_time between #{start} and #{end} |
| | | <if test="null != siteIds and siteIds.size() > 0"> |
| | | and a.site_id in |
| | | <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index"> |
| | |
| | | </select> |
| | | <select id="getByDate" resultType="java.util.Map"> |
| | | SELECT |
| | | DATE_FORMAT(a.create_time, '%Y-%m-%d' ) as time, |
| | | DATE_FORMAT(a.pay_time, '%Y-%m-%d' ) as time, |
| | | SUM(CASE |
| | | WHEN a.order_source = 0 THEN b.period_service_price |
| | | WHEN a.order_source = 1 THEN b.period_service_price |
| | |
| | | sum(period_service_price) as period_service_price, sum(period_electric_price + period_service_price) as money |
| | | from t_charging_order_accounting_strategy group by charging_order_id) b on (a.id = b.charging_order_id) |
| | | <where> |
| | | a.del_flag = 0 and a.recharge_payment_status = 2 |
| | | and a.start_time between #{start} and #{end} |
| | | a.del_flag = 0 and a.recharge_payment_status = 2 and a.start_time IS NOT NULL and a.end_time is not null |
| | | and a.pay_time between #{start} and #{end} |
| | | <if test="null != siteIds and siteIds.size() > 0"> |
| | | and a.site_id in |
| | | <foreach collection="siteIds" separator="," open="(" close=")" item="item" index="index"> |
| | |
| | | e.refund_amount as residualAmount, |
| | | h.electrovalence as electrovalence, |
| | | CASE WHEN a.order_source = 1 THEN h.serviceCharge ELSE h.serviceCharge * 0.8 END as serviceCharge, |
| | | CASE WHEN a.order_source = 2 THEN h.serviceCharge * 0.2 ELSE 0 END as sharingAmount, |
| | | 0 as commissionAmount, |
| | | <!-- 引流平台分佣按三方订单原始服务费的20%计算,导出需展示在白名单字段前。 --> |
| | | CASE WHEN a.order_source = 2 THEN IFNULL(h.serviceCharge, 0) * 0.2 ELSE 0 END as sharingAmount, |
| | | a.tripartite_platform_name as tripartitePlatformName, |
| | | a.create_time as createTime, |
| | | a.start_time as startTime, |
| | |
| | | and a.site_id = #{req.siteId} |
| | | </if> |
| | | <if test="startTime1 != null and startTime1!=''"> |
| | | and (a.create_time between #{startTime1} and #{startTime2}) |
| | | and (a.pay_time between #{startTime1} and #{startTime2}) |
| | | </if> |
| | | <if test="endTime1 != null and endTime1!=''"> |
| | | and (a.end_time between #{endTime1} and #{endTime2}) |
| | |
| | | and b.site_id = #{req.siteId} |
| | | </if> |
| | | <if test="startTime1 != null and startTime1!=''"> |
| | | and b.start_time between #{startTime1} and #{startTime2} |
| | | and b.pay_time between #{startTime1} and #{startTime2} |
| | | </if> |
| | | <if test="endTime1 != null and endTime2!=''"> |
| | | and b.end_time between #{endTime1} and #{endTime2} |
| | |
| | | and co.site_id = #{req.siteId} |
| | | </if> |
| | | <if test="startTime1 != null and startTime1!=''"> |
| | | and co.start_time between #{startTime1} and #{startTime2} |
| | | and co.pay_time between #{startTime1} and #{startTime2} |
| | | </if> |
| | | <if test="endTime1 != null and endTime2!=''"> |
| | | and co.end_time between #{endTime1} and #{endTime2} |
| | |
| | | and co.site_id = #{req.siteId} |
| | | </if> |
| | | <if test="startTime1 != null and startTime1!=''"> |
| | | and co.start_time between #{startTime1} and #{startTime2} |
| | | and co.pay_time between #{startTime1} and #{startTime2} |
| | | </if> |
| | | <if test="endTime1 != null and endTime2!=''"> |
| | | and co.end_time between #{endTime1} and #{endTime2} |
| | |
| | | <if test="req.orderSource != null and req.orderSource == 3 "> |
| | | and b.tripartite_platform_name = 'XinDianTu' |
| | | </if> |
| | | <if test="req.isWhitelist != null"> |
| | | and b.is_whitelist = #{req.isWhitelist} |
| | | </if> |
| | | <if test="req.paymentType != null and req.paymentType == 1 "> |
| | | and b.recharge_payment_type = 1 |
| | | </if> |
| | |
| | | |
| | | <select id="exchangeCodeBalanceSummary" resultType="map"> |
| | | select |
| | | sum(CASE WHEN change_type = 2 THEN IFNULL(used_amount, 0) WHEN change_type = 3 THEN -IFNULL(used_amount, 0) ELSE 0 END) as balanceIncome, |
| | | sum(CASE WHEN change_type = 2 THEN IFNULL(used_amount, 0) - IFNULL(gift_used_amount, 0) WHEN change_type = 3 THEN -(IFNULL(used_amount, 0) - IFNULL(gift_used_amount, 0)) ELSE 0 END) as balanceIncome, |
| | | sum(CASE WHEN change_type = 2 THEN IFNULL(gift_used_amount, 0) WHEN change_type = 3 THEN -IFNULL(gift_used_amount, 0) ELSE 0 END) as balanceGiftIncome |
| | | from `charging_pile_other`.t_exchange_code_use_record |
| | | where del_flag = 0 and change_type in (2, 3) |
| | |
| | | <select id="exchangeCodeBalanceIncomeByOrderIds" resultType="map"> |
| | | select |
| | | order_id as orderId, |
| | | sum(CASE WHEN change_type = 2 THEN IFNULL(used_amount, 0) WHEN change_type = 3 THEN -IFNULL(used_amount, 0) ELSE 0 END) as balanceIncome, |
| | | sum(CASE WHEN change_type = 2 THEN IFNULL(used_amount, 0) - IFNULL(gift_used_amount, 0) WHEN change_type = 3 THEN -(IFNULL(used_amount, 0) - IFNULL(gift_used_amount, 0)) ELSE 0 END) as balanceIncome, |
| | | sum(CASE WHEN change_type = 2 THEN IFNULL(gift_used_amount, 0) WHEN change_type = 3 THEN -IFNULL(gift_used_amount, 0) ELSE 0 END) as balanceGiftIncome |
| | | from `charging_pile_other`.t_exchange_code_use_record |
| | | where del_flag = 0 and order_id is not null and order_id != 0 and change_type in (2, 3) |
| | |
| | | select |
| | | p.id as packageId, |
| | | p.package_name as packageName, |
| | | sum(CASE WHEN r.change_type = 2 THEN IFNULL(r.used_amount, 0) WHEN r.change_type = 3 THEN -IFNULL(r.used_amount, 0) ELSE 0 END) as balanceIncome, |
| | | sum(CASE WHEN r.change_type = 2 THEN IFNULL(r.used_amount, 0) - IFNULL(r.gift_used_amount, 0) WHEN r.change_type = 3 THEN -(IFNULL(r.used_amount, 0) - IFNULL(r.gift_used_amount, 0)) ELSE 0 END) as balanceIncome, |
| | | sum(CASE WHEN r.change_type = 2 THEN IFNULL(r.gift_used_amount, 0) WHEN r.change_type = 3 THEN -IFNULL(r.gift_used_amount, 0) ELSE 0 END) as giftIncome |
| | | from `charging_pile_other`.t_exchange_code_use_record r |
| | | left join `charging_pile_other`.t_exchange_code_detail d on r.detail_id = d.id |
| | |
| | | group by orderId,recharge_payment_type,site_id,recharge_amount,refund_amount,platformFee |
| | | ) as aa group by aa.site_id,aa.recharge_payment_type order by aa.site_id |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="getSiteChargingCapacity" resultType="map"> |
| | | select b.site_id as siteId, sum(a.charging_capacity) as chargingCapacity |
| | | from t_charging_order_accounting_strategy a |
| | | left join t_charging_order b on (a.charging_order_id = b.id) |
| | | where b.status = 5 |
| | | <if test="null != siteIds and siteIds.size() > 0"> |
| | | and b.site_id in |
| | | <foreach collection="siteIds" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | group by b.site_id |
| | | </select> |
| | | </mapper> |