<?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.xzx.gc.pay.mapper.PayInfoMapper">
|
<resultMap id="PayMap" type="com.xzx.gc.model.pay.PayInfoVo">
|
<result column="pay_order_id" jdbcType="VARCHAR" property="payOrderId"/>
|
<result column="order_id" jdbcType="VARCHAR" property="orderId"/>
|
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId"/>
|
<result column="account_id" jdbcType="VARCHAR" property="accountId"/>
|
<result column="create_time" jdbcType="VARCHAR" property="createTime"/>
|
<result column="pay_type" jdbcType="VARCHAR" property="payType"/>
|
<result column="open_id" jdbcType="VARCHAR" property="openId"/>
|
</resultMap>
|
|
<resultMap id="AccountMap" type="com.xzx.gc.model.user.AccountVo">
|
<result column="account_id" jdbcType="VARCHAR" property="accountId"/>
|
<result column="account_name" jdbcType="VARCHAR" property="accountName"/>
|
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
|
<result column="pay_password" jdbcType="VARCHAR" property="payPassword"/>
|
<result column="freeze_money" jdbcType="VARCHAR" property="freezeMoney"/>
|
<result column="withdraw_money" jdbcType="VARCHAR" property="withdrawMoney"/>
|
<result column="overdraft_limit" jdbcType="VARCHAR" property="overdraftLimit"/>
|
<result column="lock_time" jdbcType="VARCHAR" property="lockTime"/>
|
</resultMap>
|
|
<!-- 支付信息录入 -->
|
<insert id="payInfoAdd" parameterType="map">
|
insert into xzx_pay_info(pay_order_id,order_id,create_user_id,money,
|
account_id,pay_type,open_id,status,create_time,fee)
|
values (#{payOrderId},#{orderId},#{createUserId},#{money},
|
#{accountId},#{payType},#{openId},#{status},#{createTime},#{fee} )
|
</insert>
|
|
<insert id="payRequestInfoAdd" parameterType="map">
|
insert into xzx_pay_request_info(pay_order_id,order_id,create_user_id,money,
|
account_id,pay_type,open_id,status,create_time,account_bind_id)
|
values (#{payOrderId},#{orderId},#{createUserId},#{money},
|
#{accountId},#{payType},#{openId},#{status},#{createTime},#{accountBindId} )
|
</insert>
|
|
<!-- 查询我的环保金 -->
|
<select id="queryMyMoney" parameterType="map" resultMap="AccountMap">
|
SELECT a.user_id,a.account_name,a.freeze_money,a.money,a.account_id,
|
a.withdraw_money,a.overdraft_limit,a.lock_time,a.pay_password
|
FROM xzx_account_info a
|
where del_flag=0 and is_prohibit='0'
|
<if test="userId!=null and userId!=''">
|
and a.user_id=#{userId}
|
</if>
|
<if test="createUserId!=null and createUserId!=''">
|
and a.user_id=#{createUserId}
|
</if>
|
</select>
|
|
|
<!-- 回收员支付环保金 订单创建人入账 -->
|
<update id="updateMyMoneyByOrder" parameterType="map">
|
update xzx_account_info
|
set money = cast((cast(money as DECIMAL(9,2))+#{money}) as CHAR)
|
where user_id=#{userId} and del_flag=0 and is_prohibit='0'
|
</update>
|
|
<!-- 支付信息查询 -->
|
<select id="queryPayInfo" parameterType="map" resultMap="PayMap">
|
SELECT a.pay_order_id,a.order_id,a.money,a.account_id,
|
a.pay_type,a.create_time,a.create_user_id,a.status,a.fee
|
FROM xzx_pay_info a
|
where 1=1
|
<if test="createUserId!=null and createUserId!=''">
|
and a.create_user_id=#{createUserId}
|
</if>
|
<if test="payOrderId!=null and payOrderId!=''">
|
and a.pay_order_id=#{payOrderId}
|
</if>
|
|
</select>
|
|
<select id="queryPayRequestInfo" parameterType="map" resultMap="PayMap">
|
SELECT a.pay_order_id,a.order_id,a.money,a.account_id,
|
a.pay_type,a.create_time,a.create_user_id,a.status
|
FROM xzx_pay_request_info a
|
where 1=1
|
<if test="createUserId!=null and createUserId!=''">
|
and a.create_user_id=#{createUserId}
|
</if>
|
<if test="payOrderId!=null and payOrderId!=''">
|
and a.pay_order_id=#{payOrderId}
|
</if>
|
|
</select>
|
|
<!-- 提现次数查询(一天只能提现一次) -->
|
<select id="queryWithdrawInfo" parameterType="map" resultMap="PayMap">
|
SELECT a.pay_order_id,a.order_id,a.money,
|
a.pay_type,a.create_time,a.account_id
|
FROM xzx_pay_request_info a
|
where a.create_user_id=#{createUserId} and a.pay_type='4' and (status!=2 or pay_flag!=3)
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d') =current_date
|
</select>
|
<!--提现记录审核 取状态不为2的记录-->
|
<insert id="withdrawInfoVerify" parameterType="map">
|
insert into xzx_pay_info(pay_order_id,order_id,create_user_id,money,
|
account_id,pay_type,open_id,status,create_time)
|
select pay_order_id,order_id,create_user_id,money,
|
account_id,pay_type,open_id,"3",create_time
|
from xzx_pay_request_info
|
where pay_order_id=#{payOrderId} and status!="2"
|
</insert>
|
|
<!--提现记录更新为审核状态 2为审核-->
|
<update id="updateWithdrawStatus" parameterType="map">
|
update xzx_pay_request_info set status=#{status}
|
where pay_order_id=#{payOrderId}
|
</update>
|
|
<!-- 充值记录更新为2(已支付) -->
|
<update id="updatePayInfoStatus" parameterType="map">
|
update xzx_pay_info set status=#{status}
|
where pay_order_id=#{payOrderId}
|
</update>
|
|
<select id="findForWeekByUserIdAndType" resultType="com.xzx.gc.entity.PayInfo">
|
SELECT
|
*
|
FROM
|
xzx_pay_info
|
WHERE
|
YEARWEEK( date_format( create_time, '%Y-%m-%d' ), 1 ) = YEARWEEK( now( ), 1 )
|
AND create_user_id = #{userId}
|
AND pay_type = #{payType}
|
AND (`status` =2 or status=5)
|
</select>
|
<select id="findPayMethod" resultType="com.xzx.gc.entity.AccountBindInfo">
|
SELECT
|
b.account_type AS accountType,
|
b.account_number AS accountNumber,
|
b.id,
|
b.account_name AS accountName,
|
b.bank_name AS bankName
|
FROM
|
xzx_pay_request_info a
|
INNER JOIN xzx_account_bind_info b ON a.account_bind_id = b.id
|
WHERE
|
a.pay_type = '4'
|
AND a.create_user_id = #{userId}
|
AND b.del_flag = 0
|
ORDER BY
|
a.create_time DESC limit 1
|
</select>
|
|
<insert id="addPayInfo">
|
INSERT INTO `xzx_pay_info` (`pay_order_id`, `order_id`, `create_user_id`, `money`,
|
`account_id`, `pay_type`, `open_id`, `status`, `create_time`, `check_num`, `pay_img`, `pay_time`)
|
VALUES (#{payOrderId}, NULL, #{createUserId}, #{money}, #{accountId},
|
'1', NULL, #{status}, SYSDATE(), NULL, #{payImg}, #{payTime})
|
</insert>
|
|
<select id="queryRechangeMoney" resultType="java.lang.String">
|
select sum(k.money) from ( select IFNULL(sum(a.money),0) as money
|
from xzx_pay_info a
|
left join xzx_user_info b on a.create_user_id=b.user_id
|
left join xzx_user_other_info c on a.create_user_id=c.user_id
|
where 1=1
|
<if test="status!= null and status.size() != 0">
|
and a.status in
|
<foreach collection="status" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="payType!= null and payType!=''">
|
and a.pay_type=#{payType}
|
</if>
|
<if test="startTime!= null and startTime!=''">
|
and a.create_time<![CDATA[>= ]]>#{startTime}
|
</if>
|
<if test="endTime!= null and endTime!=''">
|
and a.create_time<![CDATA[<= ]]>#{endTime}
|
</if>
|
<if test="partnerIds!= null and partnerIds.size() != 0">
|
and c.partner_id in
|
<foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
)k
|
</select>
|
|
|
<select id="queryRechangeApiList" parameterType="com.xzx.gc.model.admin.MoneyModel" resultType="com.xzx.gc.model.admin.MoneyModel">
|
select a.pay_order_id, a.create_time, a.money, IFNULL(b.nick_name,c.name) as nickName,
|
b.user_type,IFNULL(b.mobile_phone,c.mobile_phone) as mobilePhone,a.status, b.name,a.pay_time,a.create_user_id as createUserId,
|
IFNULL((select d.role_name from xzx_user_role_info d where role_code= c.user_type limit 1),'普通用户') as roleName,
|
e.partner_name as partnerName,e.mobile_phone as partnerPhone,e.partner_type as partnerType,a.pay_img,a.unpass_reason,a.fee,c.del_flag as delFlag
|
from xzx_pay_info a
|
left join xzx_user_info b on a.create_user_id=b.user_id
|
left join xzx_user_other_info c on a.create_user_id=c.user_id
|
left join xzx_city_partner e on a.create_user_id=e.user_id
|
where 1=1
|
<if test="status!= null and status != ''">
|
and a.status=#{status}
|
</if>
|
<if test="payType!= null and payType!=''">
|
and a.pay_type=#{payType}
|
</if>
|
<if test="nickName!= null and nickName!=''">
|
and (from_base64(b.nick_name) like concat("%",#{nickName},"%") or b.mobile_phone like concat("%",#{nickName},"%") or c.mobile_phone like concat("%",#{nickName},"%")
|
or e.mobile_phone like concat("%",#{nickName},"%") or e.partner_name like concat("%",#{nickName},"%") or c.name like concat("%",#{nickName},"%") )
|
</if>
|
<if test="name!= null and name != ''">
|
and b.name=#{name}
|
</if>
|
<if test="startTime!= null and startTime!=''">
|
and a.create_time<![CDATA[>= ]]>#{startTime}
|
</if>
|
<if test="endTime!= null and endTime!=''">
|
and a.create_time<![CDATA[<= ]]>#{endTime}
|
</if>
|
<if test="partnerIds!= null and partnerIds.size() != 0">
|
and c.partner_id in
|
<foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
|
order by a.create_time desc
|
</select>
|
|
|
<select id="queryRechangeApiDetail" parameterType="com.xzx.gc.model.admin.PayInfoModel" resultType="com.xzx.gc.model.admin.PayInfoModel">
|
select a.*,
|
b.nick_name as nickName,
|
b.user_type as userType,
|
b.mobile_phone as mobilePhone,
|
IFNULL((select d.role_name from xzx_user_role_info d where d.role_code= f.user_type),'普通用户') as roleName,
|
IFNULL(f.name,b.name) as name
|
from xzx_pay_info a
|
LEFT JOIN xzx_user_info b ON a.create_user_id = b.user_id
|
LEFT JOIN xzx_user_other_info f ON a.create_user_id = f.user_id
|
where a.pay_order_id=#{payOrderId}
|
and a.create_user_id = b.user_id
|
</select>
|
|
|
<select id="queryPayInfoById" resultType="com.xzx.gc.model.admin.PayInfoModel">
|
select *
|
from xzx_pay_info
|
where pay_order_id = #{payOrderId}
|
</select>
|
|
<update id="updatePayInfoPass">
|
update xzx_pay_info set
|
status=#{status}
|
<if test="unpassReason != null and unpassReason != ''">
|
, unpass_reason=#{unpassReason}
|
</if>
|
where pay_order_id=#{payOrderId}
|
</update>
|
|
<select id="scoreList" resultType="com.xzx.gc.model.pay.PayScoreResPerDTO">
|
SELECT
|
a.pay_order_id,
|
a.create_time,
|
a.money,
|
a.`status`,
|
b.channel_type,
|
b.role_type,
|
b.new_plat_score,
|
c.rela_name,
|
c.rela_phone
|
FROM
|
xzx_pay_info a
|
INNER JOIN xzx_account_score_log b ON a.pay_order_id = b.pay_id
|
LEFT JOIN xzx_order_info c ON b.order_id = c.order_id
|
LEFT JOIN xzx_user_info d on b.create_user_id=d.user_id
|
WHERE
|
a.pay_type = '17'
|
<if test="status != null and status != ''">
|
and a.status=#{status}
|
</if>
|
<if test="partnerId != null and partnerId != ''">
|
and locate(#{partnerId} ,d.partner_id)>0
|
</if>
|
<if test="channelType != null">
|
and b.channel_type=#{channelType}
|
</if>
|
<if test="roleType != null">
|
and b.role_type=#{roleType}
|
</if>
|
order by a.create_time desc
|
</select>
|
|
|
</mapper>
|