Commit ca0baf6c by 程裕兵

feat:refund statistic

parent 00bcfb01
...@@ -55,7 +55,7 @@ public class StudioMerchantRefundVO { ...@@ -55,7 +55,7 @@ public class StudioMerchantRefundVO {
NOT_CURRENT_MERCHANT("不是当前商户号收款,金额无法线上原路退回。如仍需退款请私下处理,系统会产生新的收支"), NOT_CURRENT_MERCHANT("不是当前商户号收款,金额无法线上原路退回。如仍需退款请私下处理,系统会产生新的收支"),
DATE_LIMIT("仅支持350天内交易进行退款,金额无法线上原路退回。如仍需退款请私下处理,系统会产生新的收支"), DATE_LIMIT("仅支持350天内交易进行退款,金额无法线上原路退回。如仍需退款请私下处理,系统会产生新的收支"),
TIME_LIMIT("当前时间段不支持退款,金额无法线上原路退回。如仍需退款请私下处理,系统会产生新的收支"), TIME_LIMIT("当前时间段不支持退款,金额无法线上原路退回。如仍需退款请私下处理,系统会产生新的收支"),
AMOUNT_LIMIT("乐动收银可退金额不足"), AMOUNT_LIMIT("乐动收银可退金额不足,请先通过扫码收款收款后再进行退款或者线下处理退款"),
OTHER_ERROR("其他错误"), OTHER_ERROR("其他错误"),
; ;
......
...@@ -51,4 +51,6 @@ public interface StudioCashierRecordMapper extends XBaseMapper<StudioCashierReco ...@@ -51,4 +51,6 @@ public interface StudioCashierRecordMapper extends XBaseMapper<StudioCashierReco
BigDecimal sumRefundTransAmountByPayTransNo(@Param("payTransNo") String payTransNo); BigDecimal sumRefundTransAmountByPayTransNo(@Param("payTransNo") String payTransNo);
StudioCashierStatisticVO statisticRefund(PageBrandCashierRecordQuery query);
} }
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
sum(fee) as total_fee, count(id) as total sum(fee) as total_fee, count(id) as total
from studio_cashier_record from studio_cashier_record
<where> <where>
and trans_type = 'PAY'
<if test="query.studioId != null"> <if test="query.studioId != null">
and studio_id = #{query.studioId} and studio_id = #{query.studioId}
</if> </if>
...@@ -107,7 +108,7 @@ ...@@ -107,7 +108,7 @@
and trans_state = #{query.transState} and trans_state = #{query.transState}
</if> </if>
<if test="query.transState == null or query.transState == ''"> <if test="query.transState == null or query.transState == ''">
and trans_state in ('PAY_SUCCESS', 'PAY_IN', 'REFUNDING', 'REFUND_SUCCESS', 'REFUND_FAIL') and trans_state in ('PAY_SUCCESS', 'PAY_IN')
</if> </if>
<if test="query.transStateList != null"> <if test="query.transStateList != null">
and trans_state in and trans_state in
...@@ -115,9 +116,6 @@ ...@@ -115,9 +116,6 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="query.orderType != null and query.orderType != ''">
and order_type = #{query.orderType}
</if>
<if test="query.transType != null and query.transType != ''"> <if test="query.transType != null and query.transType != ''">
and trans_type = #{query.transType} and trans_type = #{query.transType}
</if> </if>
...@@ -140,7 +138,59 @@ ...@@ -140,7 +138,59 @@
and success_time &lt;= #{query.successEndTime} and success_time &lt;= #{query.successEndTime}
</if> </if>
</where> </where>
</select>
<!-- 退款统计需求见:https://xiaomai.yuque.com/staff-hl0xgq/lm2735/rgdxgugugggpehe1 -->
<select id="statisticRefund"
resultType="com.jiejing.fitness.finance.api.cashier.vo.StudioCashierStatisticVO">
select sum(trans_amount) as total_trans_amount,
sum(case when trans_state = 'REFUND_SUCCESS' then actual_amount else 0 end) as total_actual_amount,
sum(case when trans_state = 'REFUND_SUCCESS' then fee else 0 end) as total_fee,
count(id) as total
from studio_cashier_record
<where>
and trans_type = 'REFUND'
and trans_state in ('REFUNDING', 'REFUND_SUCCESS')
<if test="query.studioId != null">
and studio_id = #{query.studioId}
</if>
<if test="query.buyerName != null and query.buyerName != ''">
and buyer_name like concat('%', #{query.buyerName}, '%')
</if>
<if test="query.orderNo != null and query.orderNo != ''">
and order_no = #{query.orderNo}
</if>
<if test="query.businessNo != null and query.businessNo != ''">
and business_no = #{query.businessNo}
</if>
<if test="query.transNo != null and query.transNo != ''">
and trans_no = #{query.transNo}
</if>
<if test="query.thirdTransNo != null and query.thirdTransNo != ''">
and third_trans_no = #{query.thirdTransNo}
</if>
<if test="query.transType != null and query.transType != ''">
and trans_type = #{query.transType}
</if>
<if test="query.subChannel != null and query.subChannel != ''">
and sub_channel = #{query.subChannel}
</if>
<if test="query.studioName != null and query.studioName != ''">
and studio_name like concat('%', #{query.studioName}, '%')
</if>
<if test="query.createStartTime != null">
and create_time >= #{query.createStartTime}
</if>
<if test="query.createEndTime != null">
and create_time &lt;= #{query.createEndTime}
</if>
<if test="query.successStartTime != null">
and success_time >= #{query.successStartTime}
</if>
<if test="query.successEndTime != null">
and success_time &lt;= #{query.successEndTime}
</if>
</where>
</select> </select>
</mapper> </mapper>
...@@ -17,6 +17,7 @@ package com.jiejing.fitness.finance.repository.service; ...@@ -17,6 +17,7 @@ package com.jiejing.fitness.finance.repository.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jiejing.common.utils.collection.CollectionUtil; import com.jiejing.common.utils.collection.CollectionUtil;
import com.jiejing.common.utils.text.StringUtil; import com.jiejing.common.utils.text.StringUtil;
import com.jiejing.fitness.enums.finance.BrandCashierTransTypeEnum;
import com.jiejing.fitness.finance.api.cashier.vo.StudioCashierStatisticVO; import com.jiejing.fitness.finance.api.cashier.vo.StudioCashierStatisticVO;
import com.jiejing.fitness.finance.api.cashier.vo.StudioSettleVO; import com.jiejing.fitness.finance.api.cashier.vo.StudioSettleVO;
import com.jiejing.fitness.finance.repository.entity.StudioCashierRecord; import com.jiejing.fitness.finance.repository.entity.StudioCashierRecord;
...@@ -177,8 +178,12 @@ public class StudioCashierRecordRpService extends ...@@ -177,8 +178,12 @@ public class StudioCashierRecordRpService extends
} }
public StudioCashierStatisticVO statistic(PageBrandCashierRecordQuery query) { public StudioCashierStatisticVO statistic(PageBrandCashierRecordQuery query) {
if (null == query.getTransType() || BrandCashierTransTypeEnum.PAY.getCode()
.equals(query.getTransType())) {
return this.baseMapper.statistic(query); return this.baseMapper.statistic(query);
} }
return this.baseMapper.statisticRefund(query);
}
public List<StudioCashierRecord> listByRelatedTransNo(Long relatedTransNo) { public List<StudioCashierRecord> listByRelatedTransNo(Long relatedTransNo) {
QueryWrapper<StudioCashierRecord> wrapper = new QueryWrapper<>(); QueryWrapper<StudioCashierRecord> wrapper = new QueryWrapper<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment