2021-07-24 18:07:51 +08:00
<?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.xhpc.payment.mapper.XhpcRefundOrderMapper" >
2022-01-09 21:04:08 +08:00
<resultMap type= "com.xhpc.common.domain.XhpcRefundOrder" id= "XhpcRefundOrderResult" >
2021-07-24 18:07:51 +08:00
<result column= "refund_order_id" property= "refundOrderId" />
<result column= "refund_order_number" property= "refundOrderNumber" />
<result column= "user_id" property= "userId" />
2021-07-28 18:33:37 +08:00
<result column= "open_id" property= "openId" />
<result column= "alipay_id" property= "alipayId" />
2021-07-24 18:07:51 +08:00
<result column= "amount" property= "amount" />
<result column= "type" property= "type" />
2021-07-27 18:38:32 +08:00
<result column= "examine_status" property= "examineStatus" />
2021-07-24 18:07:51 +08:00
<result column= "status" property= "status" />
<result column= "del_flag" property= "delFlag" />
<result column= "create_time" property= "createTime" />
<result column= "create_by" property= "createBy" />
<result column= "update_time" property= "updateTime" />
<result column= "update_by" property= "updateBy" />
<result column= "remark" property= "remark" />
2021-12-23 09:37:28 +08:00
<result column= "source" property= "source" />
2021-12-24 18:14:26 +08:00
<result column= "payment_no" property= "paymentNo" />
<result column= "payment_time" property= "paymentTime" />
<result column= "order_id" property= "orderId" />
<result column= "pay_fund_order_id" property= "payFundOrderId" />
<result column= "trans_pay_time" property= "transPayTime" />
2021-07-24 18:07:51 +08:00
</resultMap>
2022-01-09 21:04:08 +08:00
<insert id= "insert" parameterType= "com.xhpc.common.domain.XhpcRefundOrder" useGeneratedKeys= "true"
2021-07-27 18:38:32 +08:00
keyProperty="refundOrderId">
2021-07-29 14:56:41 +08:00
INSERT INTO xhpc_refund_order
2021-07-24 18:07:51 +08:00
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "null != refundOrderNumber and '' != refundOrderNumber" >
refund_order_number,
</if>
<if test= "null != userId and '' != userId" >
user_id,
</if>
2021-07-28 18:33:37 +08:00
<if test= "null != openId and '' != openId" >
open_id,
2021-07-24 18:07:51 +08:00
</if>
2021-07-28 18:33:37 +08:00
<if test= "null != alipayId and '' != alipayId" >
alipay_id,
2021-07-24 18:07:51 +08:00
</if>
<if test= "null != amount and '' != amount" >
amount,
</if>
<if test= "null != type and '' != type" >
type,
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != examineStatus and '' != examineStatus" >
examine_status,
</if>
2021-07-24 18:07:51 +08:00
<if test= "null != status and '' != status" >
status,
</if>
<if test= "null != delFlag and '' != delFlag" >
del_flag,
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != createTime" >
2021-07-24 18:07:51 +08:00
create_time,
</if>
<if test= "null != createBy and '' != createBy" >
create_by,
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != updateTime" >
2021-07-24 18:07:51 +08:00
update_time,
</if>
<if test= "null != updateBy and '' != updateBy" >
update_by,
</if>
<if test= "null != remark and '' != remark" >
2021-12-23 09:37:28 +08:00
remark,
</if>
<if test= "null != source" >
source
2021-07-24 18:07:51 +08:00
</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "null != refundOrderNumber and '' != refundOrderNumber" >
#{refundOrderNumber},
</if>
<if test= "null != userId and '' != userId" >
#{userId},
</if>
2021-07-28 18:33:37 +08:00
<if test= "null != openId and '' != openId" >
#{openId},
2021-07-24 18:07:51 +08:00
</if>
2021-07-28 18:33:37 +08:00
<if test= "null != alipayId and '' != alipayId" >
#{alipayId},
2021-07-24 18:07:51 +08:00
</if>
<if test= "null != amount and '' != amount" >
#{amount},
</if>
<if test= "null != type and '' != type" >
#{type},
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != examineStatus and '' != examineStatus" >
#{examineStatus},
</if>
2021-07-24 18:07:51 +08:00
<if test= "null != status and '' != status" >
#{status},
</if>
<if test= "null != delFlag and '' != delFlag" >
#{delFlag},
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != createTime" >
2021-07-24 18:07:51 +08:00
#{createTime},
</if>
<if test= "null != createBy and '' != createBy" >
#{createBy},
</if>
2021-07-27 18:38:32 +08:00
<if test= "null != updateTime" >
2021-07-24 18:07:51 +08:00
#{updateTime},
</if>
<if test= "null != updateBy and '' != updateBy" >
#{updateBy},
</if>
<if test= "null != remark and '' != remark" >
2021-12-23 09:37:28 +08:00
#{remark},
</if>
<if test= "null != source" >
#{source}
2021-07-24 18:07:51 +08:00
</if>
</trim>
</insert>
2022-01-09 21:04:08 +08:00
<update id= "update" parameterType= "com.xhpc.common.domain.XhpcRefundOrder" >
2021-07-29 14:56:41 +08:00
UPDATE xhpc_refund_order
2021-07-24 18:07:51 +08:00
<set >
2021-12-24 18:14:26 +08:00
<if test= "null != refundOrderNumber and '' != refundOrderNumber" > refund_order_number =#{refundOrderNumber},</if>
2021-07-24 18:07:51 +08:00
<if test= "null != userId and '' != userId" > user_id = #{userId},</if>
2021-07-28 18:33:37 +08:00
<if test= "null != openId and '' != openId" > open_id = #{openId},</if>
<if test= "null != alipayId and '' != alipayId" > alipay_id = #{alipayId},</if>
2021-07-27 18:38:32 +08:00
<if test= "null != amount " > amount = #{amount},</if>
<if test= "null != type " > type = #{type},</if>
<if test= "null != examineStatus " > examine_status = #{examineStatus},</if>
<if test= "null != status" > status = #{status},</if>
2021-07-24 18:07:51 +08:00
<if test= "null != delFlag and '' != delFlag" > del_flag = #{delFlag},</if>
2021-07-27 18:38:32 +08:00
<if test= "null != createTime" > create_time = #{createTime},</if>
2021-07-24 18:07:51 +08:00
<if test= "null != createBy and '' != createBy" > create_by = #{createBy},</if>
2021-07-27 18:38:32 +08:00
<if test= "null != updateTime" > update_time = #{updateTime},</if>
2021-07-24 18:07:51 +08:00
<if test= "null != updateBy and '' != updateBy" > update_by = #{updateBy},</if>
2021-12-24 18:14:26 +08:00
<if test= "null != remark and '' != remark" > remark = #{remark},</if>
<if test= "null != paymentNo and '' != paymentNo" > payment_no = #{paymentNo},</if>
<if test= "null != paymentTime and '' != paymentTime" > payment_time = #{paymentTime},</if>
<if test= "null != orderId and '' != orderId" > order_id = #{orderId},</if>
<if test= "null != payFundOrderId and '' != payFundOrderId" > pay_fund_order_id = #{payFundOrderId},</if>
<if test= "null != transPayTime and '' != transPayTime" > trans_pay_time = #{transPayTime}</if>
2021-07-24 18:07:51 +08:00
</set>
WHERE refund_order_id = #{refundOrderId}
</update>
2022-01-09 21:04:08 +08:00
<update id= "updateStatus" parameterType= "com.xhpc.common.domain.XhpcRefundOrder" >
2021-08-02 18:36:17 +08:00
UPDATE xhpc_refund_order
<set >
<if test= "null != status" > status = #{status},</if>
2021-10-11 15:56:44 +08:00
<if test= "null != examineStatus" > examine_status = #{examineStatus},</if>
2021-08-02 18:36:17 +08:00
</set>
2021-08-03 16:25:22 +08:00
WHERE refund_order_id = #{refundOrderId} and examine_status = 0
</update>
2022-01-09 21:04:08 +08:00
<update id= "updateExamineStatus" parameterType= "com.xhpc.common.domain.XhpcRefundOrder" >
2021-08-03 16:25:22 +08:00
UPDATE xhpc_refund_order
<set >
<if test= "null != status" > examine_status = #{examineStatus},</if>
</set>
2021-08-02 18:36:17 +08:00
WHERE refund_order_id = #{refundOrderId} and status = #{status}
</update>
2021-07-24 18:07:51 +08:00
<select id= "info" parameterType= "java.lang.Long" resultType= "java.util.Map" >
2022-01-11 16:40:12 +08:00
select xro.refund_order_id refundOrderId ,xro.refund_order_number refundOrderNumber,xro.tenant_id tenantId,
2022-01-28 15:39:25 +08:00
xro.alipay_id alipayId ,xro.open_id openId,xro.user_id userId,xro.amount,xro.source source,cop.phone communityPhone,cop.account communityAccount,
cup.phone customersPhone,cup.account customersAccount,
2022-03-04 11:02:35 +08:00
xro.type,xro.examine_status examineStatus,xro.`status`,xro.source source,xro.create_time createTime,xau.phone,xau.phone appUserPhone,
2021-07-28 17:36:39 +08:00
sdd.dict_label statusName,sdds.dict_label examineStatusName
2021-07-24 18:07:51 +08:00
from xhpc_refund_order xro
2021-12-24 18:14:26 +08:00
LEFT JOIN xhpc_app_user xau on xau.app_user_id = xro.user_id and xro.source=0
LEFT JOIN xhpc_community_personnel cop on cop.community_personnel_id = xro.user_id and xro.source=2
2022-01-28 15:39:25 +08:00
LEFT JOIN xhpc_customers_personnel cup on cup.customers_personnel_id = xro.user_id and xro.source=3
2021-07-28 17:36:39 +08:00
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'refund_order_status' and sdd.dict_value = xro.`status`
LEFT JOIN sys_dict_data sdds on sdds.`dict_type` = 'refund_examine_status' and sdds.dict_value = xro.examine_status
2021-07-24 18:07:51 +08:00
where xro.del_flag = 0 and xro.refund_order_id = #{refundOrderId}
</select>
<select id= "page" parameterType= "java.lang.String" resultType= "java.util.Map" >
select xro.refund_order_id refundOrderId ,xro.refund_order_number refundOrderNumber,
2021-07-28 18:33:37 +08:00
xro.alipay_id alipayId ,xro.open_id openId,xro.user_id userId,xro.amount,
2021-12-23 09:37:28 +08:00
xro.type,xro.examine_status examineStatus,xro.`status`,xro.source source,xro.create_time createTime,
2022-03-04 11:02:35 +08:00
xau.phone,xau.phone appUserPhone,sdd.dict_label statusName,sdds.dict_label examineStatusName,cop.account communityAccount,cup.account customersAccount
2021-07-24 18:07:51 +08:00
from xhpc_refund_order xro
2021-12-23 18:22:42 +08:00
LEFT JOIN xhpc_app_user xau on xau.app_user_id = xro.user_id and xro.source =0
LEFT JOIN xhpc_community_personnel cop on cop.community_personnel_id = xro.user_id and xro.source =2
LEFT JOIN xhpc_customers_personnel cup on cup.customers_personnel_id = xro.user_id and xro.source =3
2021-07-28 17:36:39 +08:00
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'refund_order_status' and sdd.dict_value = xro.`status`
2021-12-24 18:14:26 +08:00
LEFT JOIN sys_dict_data sdds on sdds.`dict_type` = 'refund_examine_status' and sdds.dict_value =xro.examine_status
2021-12-27 15:45:06 +08:00
<if test= "source == null and phone != null and phone !=''" >
inner join (
2022-01-28 15:39:25 +08:00
select ro.refund_order_id as refund_order_id from xhpc_refund_order as ro INNER JOIN xhpc_app_user as xau on xau.app_user_id = ro.user_id where ro.source=0 and xau.phone LIKE concat('%',#{phone}, '%')
union
select ro.refund_order_id as refund_order_id from xhpc_refund_order as ro INNER JOIN xhpc_community_personnel as xcp on xcp.community_personnel_id = ro.user_id where ro.source=2 and xcp.account LIKE concat('%',#{phone}, '%')
union
select ro.refund_order_id as refund_order_id from xhpc_refund_order as ro INNER JOIN xhpc_customers_personnel as xcup on xcup.customers_personnel_id = ro.user_id where ro.source=3 and xcup.account LIKE concat('%',#{phone}, '%')
) ut on ut.refund_order_id = xro.refund_order_id
2021-12-27 15:45:06 +08:00
</if>
2021-07-24 18:07:51 +08:00
where xro.del_flag = 0
2021-12-23 18:22:42 +08:00
<if test= "source != null and phone != null" >
<if test= "source==0 " >
2021-12-27 15:45:06 +08:00
and xro.source=#{source} and xau.phone like concat('%', #{phone}, '%')
2021-12-23 18:22:42 +08:00
</if>
<if test= "source=2" >
2021-12-27 15:45:06 +08:00
and xro.source=#{source} and cop.account like concat('%', #{phone}, '%')
2021-12-23 18:22:42 +08:00
</if>
<if test= "source=3" >
2021-12-27 15:45:06 +08:00
and xro.source=#{source} and cup.account like concat('%', #{phone}, '%')
2021-12-23 18:22:42 +08:00
</if>
</if>
2021-12-27 15:45:06 +08:00
<if test= "source != null" >
2021-12-23 18:22:42 +08:00
and xro.source=#{source}
</if>
2022-03-01 16:42:08 +08:00
<if test= "tenantId != null and tenantId != ''" >
and xro.tenant_id=#{tenantId}
</if>
2021-07-24 18:07:51 +08:00
<if test= "refundOrderNumber != null and refundOrderNumber != ''" >
2021-12-27 15:45:06 +08:00
and xro.refund_order_number like concat('%', #{refundOrderNumber}, '%')
2021-07-24 18:07:51 +08:00
</if>
<if test= "status != null and status != ''" >
2021-12-27 15:45:06 +08:00
and xro.status like concat('%', #{status}, '%')
2021-07-24 18:07:51 +08:00
</if>
<if test= "createTimeStart != null and createTimeStart != ''" > <!-- 开始时间检索 -->
AND xro.create_time > = #{createTimeStart}
</if>
<if test= "createTimeEnd != null and createTimeEnd != ''" > <!-- 结束时间检索 -->
AND xro.create_time < = #{createTimeEnd}
</if>
2021-11-16 01:04:17 +08:00
<if test= "type != null " >
and xro.type = #{type}
</if>
2022-01-09 21:04:08 +08:00
<if test= "userId != null " >
and xro.user_id = #{userId}
</if>
2021-11-16 01:04:17 +08:00
ORDER BY xro.create_time DESC
</select>
<select id= "sumMoney" resultType= "String" >
select sum(xro.amount) amount
from xhpc_refund_order xro
LEFT JOIN xhpc_app_user xau on xau.app_user_id = xro.user_id
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'refund_order_status' and sdd.dict_value = xro.`status`
LEFT JOIN sys_dict_data sdds on sdds.`dict_type` = 'refund_examine_status' and sdds.dict_value =
xro.examine_status
2022-06-14 10:44:35 +08:00
where xro.del_flag = 0 and xro.examine_status=1 and xro.status =1
2021-11-16 01:04:17 +08:00
<if test= "phone != null and phone != ''" >
2021-12-27 15:45:06 +08:00
and xau.phone like concat('%', #{phone}, '%')
2021-11-16 01:04:17 +08:00
</if>
2022-03-01 16:42:08 +08:00
<if test= "tenantId != null and tenantId != ''" >
and xro.tenant_id=#{tenantId}
</if>
2021-11-16 01:04:17 +08:00
<if test= "refundOrderNumber != null and refundOrderNumber != ''" >
2021-12-27 15:45:06 +08:00
and xro.refund_order_number like concat('%', #{refundOrderNumber}, '%')
2021-11-16 01:04:17 +08:00
</if>
<if test= "status != null and status != ''" >
2021-12-27 15:45:06 +08:00
and xro.status like concat('%', #{status}, '%')
2021-11-16 01:04:17 +08:00
</if>
<if test= "createTimeStart != null and createTimeStart != ''" > <!-- 开始时间检索 -->
AND xro.create_time > = #{createTimeStart}
</if>
<if test= "createTimeEnd != null and createTimeEnd != ''" > <!-- 结束时间检索 -->
AND xro.create_time < = #{createTimeEnd}
</if>
<if test= "type != null and type != ''" >
and xro.type = #{type}
</if>
2021-07-24 18:07:51 +08:00
ORDER BY xro.create_time DESC
</select>
2021-08-02 11:42:20 +08:00
<select id= "getNotChargeOrder" parameterType= "java.lang.Long" resultType= "java.util.Map" >
select xco.*
from xhpc_charge_order xco
where xco.del_flag = 0 and xco.status IN (0,2)
<if test= "userId != null and userId != ''" >
and xco.user_id = #{userId}
</if>
2022-01-11 16:40:12 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and xco.tenant_id = #{tenantId}
</if>
2022-01-25 16:19:23 +08:00
<if test= "userType !=null" >
and xco.source = #{userType}
2022-01-11 16:40:12 +08:00
</if>
2021-08-02 11:42:20 +08:00
ORDER BY xco.create_time DESC
</select>
2021-08-02 18:36:17 +08:00
2021-08-03 16:25:22 +08:00
<select id= "getNotRefundOrder" parameterType= "java.lang.Long" resultType= "java.util.Map" >
2021-08-02 18:36:17 +08:00
select xro.refund_order_id refundOrderId ,xro.refund_order_number refundOrderNumber,
xro.alipay_id alipayId ,xro.open_id openId,xro.user_id userId,xro.amount,
xro.type,xro.examine_status examineStatus,xro.`status`,xro.create_time createTime,
2022-01-09 21:04:08 +08:00
xro.source source,sdd.dict_label statusName,sdds.dict_label examineStatusName
2021-08-02 18:36:17 +08:00
from xhpc_refund_order xro
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'refund_order_status' and sdd.dict_value = xro.`status`
LEFT JOIN sys_dict_data sdds on sdds.`dict_type` = 'refund_examine_status' and sdds.dict_value =
xro.examine_status
2021-08-03 16:25:22 +08:00
where xro.del_flag = 0 and xro.examine_status = 0 and xro.status = 0
2021-08-02 18:36:17 +08:00
<if test= "userId != null and userId != ''" >
2022-01-09 21:04:08 +08:00
and xro.user_id = #{userId}
</if>
<if test= "tenantId != null and tenantId != ''" >
and xro.tenant_id = #{tenantId}
</if>
<if test= "userType != null" >
and xro.source = #{userType}
2021-08-02 18:36:17 +08:00
</if>
ORDER BY xro.create_time DESC LIMIT 1
</select>
2021-10-11 15:56:44 +08:00
<select id= "countXhpcRealTimeOrder" resultType= "int" >
2022-01-11 16:40:12 +08:00
select
count(charge_order_id)
from xhpc_charge_order
where user_id =#{userId}
and status=0 and del_flag =0
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id=#{tenantId}
</if>
<if test= "source !=null" >
and source=#{source}
</if>
limit 1
2021-10-11 15:56:44 +08:00
</select>
<select id= "countXhpcChargeOrder" resultType= "int" >
2022-01-11 16:40:12 +08:00
select
count(charge_order_id)
from xhpc_charge_order
where user_id =#{userId} and status =2 and del_flag =0
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id=#{tenantId}
</if>
<if test= "source !=null" >
and source=#{source}
</if>
2021-10-11 15:56:44 +08:00
</select>
2021-10-29 10:39:29 +08:00
<select id= "moneyPage" resultType= "long" >
select xro.refund_order_id refundOrderId
from xhpc_refund_order xro
2022-06-06 17:48:41 +08:00
where xro.del_flag = 0 and xro.examine_status=0 and xro.status=0
<if test= "type==1" >
and amount < =100
</if>
<if test= "type=2" >
and amount > 100
</if>
2021-10-29 10:39:29 +08:00
</select>
2022-01-11 16:40:12 +08:00
<update id= "updateRefundApplication" >
UPDATE xhpc_community_personnel set is_refund_application=#{isRefundApplication} where community_personnel_id=#{userId}
</update>
2021-07-24 18:07:51 +08:00
</mapper>