2021-07-22 19:03:27 +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.XhpcRechargeOrderMapper" >
<resultMap type= "com.xhpc.payment.domain.XhpcRechargeOrder" id= "XhpcRechargeOrderResult" >
<result column= "recharge_order_id" property= "rechargeOrderId" />
<result column= "user_id" property= "userId" />
2021-07-28 17:36:39 +08:00
<result column= "recharge_order_number" property= "rechargeOrderNumber" />
2021-07-22 19:03:27 +08:00
<result column= "prepay_id" property= "prepayId" />
<result column= "alipay_number" property= "alipayNumber" />
<result column= "amount" property= "amount" />
<result column= "type" property= "type" />
<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-07-22 19:03:27 +08:00
</resultMap>
2021-07-24 18:07:51 +08:00
<insert id= "insert" parameterType= "com.xhpc.payment.domain.XhpcRechargeOrder" useGeneratedKeys= "true"
2021-07-27 18:38:32 +08:00
keyProperty="rechargeOrderId">
2021-07-22 19:03:27 +08:00
INSERT INTO xhpc_recharge_order
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "null != userId and '' != userId" >
user_id,
</if>
2021-07-24 18:07:51 +08:00
<if test= "null != rechargeOrderNumber and '' != rechargeOrderNumber" >
recharge_order_number,
</if>
2021-07-22 19:03:27 +08:00
<if test= "null != prepayId and '' != prepayId" >
prepay_id,
</if>
<if test= "null != alipayNumber and '' != alipayNumber" >
alipay_number,
</if>
<if test= "null != amount and '' != amount" >
amount,
</if>
<if test= "null != type and '' != type" >
type,
</if>
<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-22 19:03:27 +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-22 19:03:27 +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-22 19:03:27 +08:00
</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "null != userId and '' != userId" >
#{userId},
</if>
2021-07-24 18:07:51 +08:00
<if test= "null != rechargeOrderNumber and '' != rechargeOrderNumber" >
#{rechargeOrderNumber},
</if>
2021-07-22 19:03:27 +08:00
<if test= "null != prepayId and '' != prepayId" >
#{prepayId},
</if>
<if test= "null != alipayNumber and '' != alipayNumber" >
#{alipayNumber},
</if>
<if test= "null != amount and '' != amount" >
#{amount},
</if>
<if test= "null != type and '' != type" >
#{type},
</if>
<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-22 19:03:27 +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-22 19:03:27 +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-22 19:03:27 +08:00
</if>
</trim>
</insert>
2021-07-23 18:55:28 +08:00
<update id= "update" parameterType= "com.xhpc.payment.domain.XhpcRechargeOrder" >
2021-07-22 19:03:27 +08:00
UPDATE xhpc_recharge_order
<set >
<if test= "null != userId and '' != userId" > user_id = #{userId},</if>
2021-07-24 18:07:51 +08:00
<if test= "null != rechargeOrderNumber and '' != rechargeOrderNumber" > recharge_order_number =
#{rechargeOrderNumber},
</if>
2021-07-22 19:03:27 +08:00
<if test= "null != prepayId and '' != prepayId" > prepay_id = #{prepayId},</if>
<if test= "null != alipayNumber and '' != alipayNumber" > alipay_number = #{alipayNumber},</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 != status " > status = #{status},</if>
2021-07-22 19:03:27 +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-22 19:03:27 +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-22 19:03:27 +08:00
<if test= "null != updateBy and '' != updateBy" > update_by = #{updateBy},</if>
<if test= "null != remark and '' != remark" > remark = #{remark}</if>
</set>
WHERE recharge_order_id = #{rechargeOrderId}
</update>
<select id= "info" parameterType= "java.lang.Long" resultType= "java.util.Map" >
2021-07-28 17:36:39 +08:00
select xro.recharge_order_id rechargeOrderId ,xro.recharge_order_number rechargeOrderNumber,
2021-07-24 18:07:51 +08:00
xro.alipay_number alipayNumber ,xro.prepay_id prepayid,xro.user_id userId,xro.amount,
2021-12-23 09:37:28 +08:00
xro.type ,xro.`status`,xro.create_time createTime,xro.source source,xau.phone,sdd.dict_label statusName
2021-07-24 18:07:51 +08:00
from xhpc_recharge_order xro
LEFT JOIN xhpc_app_user xau on xau.app_user_id = xro.user_id
2021-07-28 17:36:39 +08:00
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'recharge_order_status' and sdd.dict_value = xro.`status`
2021-07-24 18:07:51 +08:00
where xro.del_flag = 0 and xro.recharge_order_id = #{rechargeOrderId}
</select>
<select id= "page" parameterType= "java.lang.Long" resultType= "java.util.Map" >
2021-12-23 18:22:42 +08:00
select
xro.recharge_order_id rechargeOrderId ,xro.recharge_order_number rechargeOrderNumber,
xro.alipay_number alipayNumber ,xro.prepay_id prepayid,xro.user_id userId,xro.amount,
xro.type ,xro.`status`,xro.create_time createTime,xro.source source,
xau.phone,cop.account communityAccount,cup.account customersAccount,
sdd.dict_label statusName
2021-07-24 18:07:51 +08:00
from xhpc_recharge_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` = 'recharge_order_status' and sdd.dict_value = xro.`status`
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 " >
and xro.source=#{source} and xau.phone like concat(concat('%', #{phone}), '%')
</if>
<if test= "source=2" >
and xro.source=#{source} and cop.account like concat(concat('%', #{phone}), '%')
</if>
<if test= "source=3" >
and xro.source=#{source} and cup.account like concat(concat('%', #{phone}), '%')
</if>
</if>
<if test= "source != null and phone == null" >
and xro.source=#{source}
</if>
<if test= "source == null and and phone != null" >
and xau.app_user_id in (
select app_user_id from xhpc_app_user where phone like concat(concat('%', #{phone}), '%') and app_user_id in (select user_id from xhpc_recharge_order where source=0)
union
select community_personnel_id as app_user_id from xhpc_community_personnel where account like concat(concat('%', #{phone}), '%') and community_personnel_id in (select user_id from xhpc_recharge_order where source=2)
union
select customers_personnel_id from xhpc_customers_personnel where account like concat(concat('%', #{phone}), '%') and community_personnel_id in (select user_id from xhpc_recharge_order where source=3)
)
2021-07-24 18:07:51 +08:00
</if>
<if test= "rechargeOrderNumber != null and rechargeOrderNumber != ''" >
2021-07-28 17:36:39 +08:00
and xro.recharge_order_number like concat(concat('%', #{rechargeOrderNumber}), '%')
2021-07-24 18:07:51 +08:00
</if>
<if test= "status != null and status != ''" >
and xro.status like concat(concat('%', #{status}), '%')
</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 type != ''" >
AND xro.type = #{type}
</if>
2021-12-23 18:22:42 +08:00
<if test= "userId != null" >
and xro.userId=#{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_recharge_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` = 'recharge_order_status' and sdd.dict_value = xro.`status`
where xro.del_flag = 0
<if test= "phone != null and phone != ''" >
and xau.phone like concat(concat('%', #{phone}), '%')
</if>
<if test= "rechargeOrderNumber != null and rechargeOrderNumber != ''" >
and xro.recharge_order_number like concat(concat('%', #{rechargeOrderNumber}), '%')
</if>
<if test= "status != null and status != ''" >
and xro.status like concat(concat('%', #{status}), '%')
</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
2021-07-22 19:03:27 +08:00
</select>
2021-11-16 01:04:17 +08:00
2021-07-28 18:33:37 +08:00
<select id= "infoRechargeOrderNumber" parameterType= "java.lang.String" resultMap= "XhpcRechargeOrderResult" >
2021-07-28 17:36:39 +08:00
select *
from xhpc_recharge_order xro
where xro.del_flag = 0 and xro.recharge_order_number = #{rechargeOrderNumber}
</select>
2021-10-25 15:43:58 +08:00
<update id= "updateRechargeOrderStatus" >
update xhpc_recharge_order set del_flag =1 where status=0 and TIMESTAMPDIFF(MINUTE,create_time,now())>30
</update>
2021-07-22 19:03:27 +08:00
</mapper>