| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <?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="org.dromara.business.mapper.PayOrderMapper">
- <!-- 动态插入(非空字段) -->
- <insert id="insertPayOrder" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO pay_order
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="outTradeNo != null">out_trade_no,</if>
- <if test="subject != null">subject,</if>
- <if test="body != null">body,</if>
- <if test="totalAmount != null">total_amount,</if>
- <if test="currency != null">currency,</if>
- <if test="userId != null">user_id,</if>
- <if test="bizType != null">biz_type,</if>
- <if test="bizId != null">biz_id,</if>
- <if test="tradeNo != null">trade_no,</if>
- <if test="appId != null">app_id,</if>
- <if test="sellerId != null">seller_id,</if>
- <if test="status != null">status,</if>
- <if test="payTime != null">pay_time,</if>
- <if test="notifyTime != null">notify_time,</if>
- <if test="notifyType != null">notify_type,</if>
- <if test="tradeStatus != null">trade_status,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="productId != null">product_id,</if>
- <if test="relatedItemId != null">related_item_id,</if>
- <if test="payUrl != null">pay_url,</if>
- </trim>
- <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
- <if test="outTradeNo != null">#{outTradeNo},</if>
- <if test="subject != null">#{subject},</if>
- <if test="body != null">#{body},</if>
- <if test="totalAmount != null">#{totalAmount},</if>
- <if test="currency != null">#{currency},</if>
- <if test="userId != null">#{userId},</if>
- <if test="bizType != null">#{bizType},</if>
- <if test="bizId != null">#{bizId},</if>
- <if test="tradeNo != null">#{tradeNo},</if>
- <if test="appId != null">#{appId},</if>
- <if test="sellerId != null">#{sellerId},</if>
- <if test="status != null">#{status},</if>
- <if test="payTime != null">#{payTime},</if>
- <if test="notifyTime != null">#{notifyTime},</if>
- <if test="notifyType != null">#{notifyType},</if>
- <if test="tradeStatus != null">#{tradeStatus},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="productId != null">#{productId},</if>
- <if test="relatedItemId != null">#{relatedItemId},</if>
- <if test="payUrl != null">#{payUrl},</if>
- </trim>
- </insert>
- <!-- 根据主键更新(仅非空字段) -->
- <update id="updatePayOrder">
- UPDATE pay_order
- <set>
- <if test="outTradeNo != null">out_trade_no = #{outTradeNo},</if>
- <if test="subject != null">subject = #{subject},</if>
- <if test="body != null">body = #{body},</if>
- <if test="totalAmount != null">total_amount = #{totalAmount},</if>
- <if test="currency != null">currency = #{currency},</if>
- <if test="userId != null">user_id = #{userId},</if>
- <if test="bizType != null">biz_type = #{bizType},</if>
- <if test="bizId != null">biz_id = #{bizId},</if>
- <if test="tradeNo != null">trade_no = #{tradeNo},</if>
- <if test="appId != null">app_id = #{appId},</if>
- <if test="sellerId != null">seller_id = #{sellerId},</if>
- <if test="status != null">status = #{status},</if>
- <if test="payTime != null">pay_time = #{payTime},</if>
- <if test="notifyTime != null">notify_time = #{notifyTime},</if>
- <if test="notifyType != null">notify_type = #{notifyType},</if>
- <if test="tradeStatus != null">trade_status = #{tradeStatus},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="productId != null">product_id = #{productId},</if>
- <if test="relatedItemId != null">related_item_id = #{relatedItemId},</if>
- <if test="payUrl != null">pay_url = #{payUrl},</if>
- </set>
- WHERE id = #{id}
- </update>
- <!-- 根据 out_trade_no 更新 -->
- <update id="updatePayOrderByOutTradeNo">
- UPDATE pay_order
- <set>
- <if test="subject != null">subject = #{subject},</if>
- <if test="body != null">body = #{body},</if>
- <if test="totalAmount != null">total_amount = #{totalAmount},</if>
- <if test="currency != null">currency = #{currency},</if>
- <if test="userId != null">user_id = #{userId},</if>
- <if test="bizType != null">biz_type = #{bizType},</if>
- <if test="bizId != null">biz_id = #{bizId},</if>
- <if test="tradeNo != null">trade_no = #{tradeNo},</if>
- <if test="appId != null">app_id = #{appId},</if>
- <if test="sellerId != null">seller_id = #{sellerId},</if>
- <if test="status != null">status = #{status},</if>
- <if test="payTime != null">pay_time = #{payTime},</if>
- <if test="notifyTime != null">notify_time = #{notifyTime},</if>
- <if test="notifyType != null">notify_type = #{notifyType},</if>
- <if test="tradeStatus != null">trade_status = #{tradeStatus},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="productId != null">product_id = #{productId},</if>
- <if test="relatedItemId != null">related_item_id = #{relatedItemId},</if>
- <if test="payUrl != null">pay_url = #{payUrl},</if>
- </set>
- WHERE out_trade_no = #{outTradeNo}
- </update>
- <!-- 根据主键查询 -->
- <select id="selectPayOrderById" parameterType="java.lang.Long" resultType="org.dromara.business.domain.vo.PayOrderVo">
- SELECT
- id, out_trade_no, subject, body, total_amount, currency,
- user_id, biz_type, biz_id, trade_no, app_id, seller_id,
- status, pay_time, notify_time, notify_type, trade_status,
- create_time, update_time, product_id, related_item_id, pay_url
- FROM pay_order
- WHERE id = #{id}
- </select>
- <!-- 根据商户订单号查询 -->
- <select id="selectPayOrderByOutTradeNo" parameterType="java.lang.String" resultType="org.dromara.business.domain.vo.PayOrderVo">
- SELECT
- id, out_trade_no, subject, body, total_amount, currency,
- user_id, biz_type, biz_id, trade_no, app_id, seller_id,
- status, pay_time, notify_time, notify_type, trade_status,
- create_time, update_time, product_id, related_item_id, pay_url
- FROM pay_order
- WHERE out_trade_no = #{outTradeNo}
- </select>
- <!-- 查询所有(支持条件扩展) -->
- <select id="selectPayOrderAll" resultType="org.dromara.business.domain.vo.PayOrderVo">
- SELECT
- a.id, a.out_trade_no, a.subject, a.body, a.total_amount, a.currency,
- a.user_id, a.biz_type, a.biz_id, a.trade_no, a.app_id, a.seller_id,
- a.status, a.pay_time, a.notify_time, a.notify_type, a.trade_status,
- a.create_time, a.update_time, a.product_id, a.related_item_id, a.pay_url,b.phone,b.nick_name
- FROM pay_order a left join user b on a.user_id=b.id
- ${ew.customSqlSegment}
- </select>
- <delete id="deletePayOrderById">
- DELETE FROM pay_order
- <where>
- id IN
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- <if test="id > 0">
- #{id}
- </if>
- </foreach>
- </where>
- </delete>
- <select id="selectPayOrderList" resultType="org.dromara.business.domain.vo.PayOrderVo">
- SELECT
- id, out_trade_no, subject, body, total_amount, currency,
- user_id, biz_type, biz_id, trade_no, app_id, seller_id,
- status, pay_time, notify_time, notify_type, trade_status,
- create_time, update_time, product_id, related_item_id, pay_url
- FROM pay_order
- </select>
- <select id="selectPayOrderCountByTime" resultType="org.dromara.business.domain.vo.PayOrderVo">
- SELECT
- ifnull(count(distinct trade_no),0) as payOrderCount,
- ifnull(sum(total_amount),0) as payOrderAmount
- FROM pay_order where status= 'success' and pay_time >= #{beginTime} and pay_time < #{endTime}
- </select>
- <select id="selectPayOrderGraphByTime" resultType="org.dromara.business.domain.vo.PayOrderVo">
- SELECT
- DATE(pay_time) as dates,
- COUNT(DISTINCT trade_no) as payOrderCount,
- IFNULL(SUM(total_amount), 0) as payOrderAmount
- FROM pay_order
- WHERE status = 'success'
- AND pay_time >= #{beginTime}
- AND pay_time < #{endTime}
- GROUP BY DATE(pay_time)
- ORDER BY dates
- </select>
- </mapper>
|