|
@@ -65,7 +65,9 @@
|
|
|
|
|
|
<!-- 根据主键查询一条记录 -->
|
|
|
<select id="get" resultMap="StudentPaymentOrder">
|
|
|
- SELECT * FROM student_payment_order WHERE id_ = #{id}
|
|
|
+ SELECT *
|
|
|
+ FROM student_payment_order
|
|
|
+ WHERE id_ = #{id}
|
|
|
</select>
|
|
|
|
|
|
<!-- 全查询 -->
|
|
@@ -79,14 +81,16 @@
|
|
|
<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder" useGeneratedKeys="true"
|
|
|
keyColumn="id" keyProperty="id">
|
|
|
INSERT INTO student_payment_order
|
|
|
- (id_,group_type_,user_id_,type_,expect_amount_,actual_amount_,com_amount_,per_amount_,balance_payment_amount_,trans_no_,
|
|
|
- status_,memo_,create_time_,update_time_,payment_channel_,payment_business_channel_,
|
|
|
- payment_account_no_,order_no_,music_group_id_,class_group_id_)
|
|
|
- VALUES(#{id},#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
|
|
|
- #{userId},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
|
|
|
- #{expectAmount},#{actualAmount},#{comAmount},#{perAmount},#{balancePaymentAmount},#{transNo},
|
|
|
- #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{memo},now(),now(),
|
|
|
- #{paymentChannel},#{paymentBusinessChannel},#{paymentAccountNo},#{orderNo},#{musicGroupId},#{classGroupId})
|
|
|
+ (id_, group_type_, user_id_, type_, expect_amount_, actual_amount_, com_amount_, per_amount_,
|
|
|
+ balance_payment_amount_, trans_no_,
|
|
|
+ status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
|
|
|
+ payment_account_no_, order_no_, music_group_id_, class_group_id_)
|
|
|
+ VALUES (#{id}, #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
|
|
|
+ #{userId}, #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
|
|
|
+ #{expectAmount}, #{actualAmount}, #{comAmount}, #{perAmount}, #{balancePaymentAmount}, #{transNo},
|
|
|
+ #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, now(), now(),
|
|
|
+ #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{orderNo}, #{musicGroupId},
|
|
|
+ #{classGroupId})
|
|
|
</insert>
|
|
|
|
|
|
<!-- 根据主键查询一条记录 -->
|
|
@@ -165,7 +169,9 @@
|
|
|
|
|
|
<!-- 根据主键删除一条记录 -->
|
|
|
<delete id="delete">
|
|
|
- DELETE FROM student_payment_order WHERE id_ = #{id}
|
|
|
+ DELETE
|
|
|
+ FROM student_payment_order
|
|
|
+ WHERE id_ = #{id}
|
|
|
</delete>
|
|
|
|
|
|
<!-- 分页查询 -->
|
|
@@ -220,59 +226,73 @@
|
|
|
</sql>
|
|
|
|
|
|
<select id="queryApplyGoodsList" resultMap="Goods" parameterType="map">
|
|
|
- select g.* from goods g where g.id_ in (SELECT spod.goods_id_list_ FROM student_payment_order spo left join
|
|
|
- student_payment_order_detail spod on spo.id_ = spod.payment_order_id_ where spo.music_group_id_ =
|
|
|
- #{musicGroupId} and spo.type_ = 'APPLY' and spod.type_ =
|
|
|
- #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
|
|
|
+ select g.*
|
|
|
+ from goods g
|
|
|
+ where g.id_ in (SELECT spod.goods_id_list_
|
|
|
+ FROM student_payment_order spo
|
|
|
+ left join
|
|
|
+ student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
|
|
|
+ where spo.music_group_id_ =
|
|
|
+ #{musicGroupId}
|
|
|
+ and spo.type_ = 'APPLY'
|
|
|
+ and spod.type_ =
|
|
|
+ #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
|
|
|
</select>
|
|
|
<select id="findByStudentVipGroup" resultMap="StudentPaymentOrder">
|
|
|
SELECT
|
|
|
- spo.*
|
|
|
+ spo.*
|
|
|
FROM
|
|
|
- student_payment_order spo
|
|
|
+ student_payment_order spo
|
|
|
WHERE spo.user_id_=#{userId}
|
|
|
- AND spo.music_group_id_=#{vipGroupId}
|
|
|
- <if test="status!=null and status!=''">
|
|
|
- AND spo.status_=#{status}
|
|
|
- </if>
|
|
|
- AND spo.type_ = 'SMALL_CLASS_TO_BUY'
|
|
|
+ AND spo.music_group_id_=#{vipGroupId}
|
|
|
+ <if test="status!=null and status!=''">
|
|
|
+ AND spo.status_=#{status}
|
|
|
+ </if>
|
|
|
+ AND spo.type_ = 'SMALL_CLASS_TO_BUY'
|
|
|
</select>
|
|
|
<select id="sumSurplusCourseFee" resultType="java.math.BigDecimal">
|
|
|
- SELECT
|
|
|
- SUM(cssp.expect_price_)
|
|
|
- FROM
|
|
|
- course_schedule_student_payment cssp
|
|
|
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
|
|
|
- WHERE
|
|
|
- cssp.user_id_ = #{userId}
|
|
|
- AND cssp.music_group_id_ = #{vipGroupId}
|
|
|
- AND CONCAT(cs.class_date_ ,' ',cs.start_class_time_) > NOW()
|
|
|
+ SELECT SUM(cssp.expect_price_)
|
|
|
+ FROM course_schedule_student_payment cssp
|
|
|
+ LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
|
|
|
+ WHERE cssp.user_id_ = #{userId}
|
|
|
+ AND cssp.music_group_id_ = #{vipGroupId}
|
|
|
+ AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) > NOW()
|
|
|
</select>
|
|
|
<select id="findNotFailedOrderByStudentVipGroup" resultMap="StudentPaymentOrder">
|
|
|
- SELECT
|
|
|
- spo.*
|
|
|
- FROM
|
|
|
- student_payment_order spo
|
|
|
- WHERE spo.user_id_=#{userId}
|
|
|
- AND spo.music_group_id_=#{vipGroupId}
|
|
|
- AND spo.status_!='FAILED'
|
|
|
- AND spo.type_ = 'SMALL_CLASS_TO_BUY'
|
|
|
+ SELECT spo.*
|
|
|
+ FROM student_payment_order spo
|
|
|
+ WHERE spo.user_id_ = #{userId}
|
|
|
+ AND spo.music_group_id_ = #{vipGroupId}
|
|
|
+ AND spo.status_ != 'FAILED'
|
|
|
+ AND spo.type_ = 'SMALL_CLASS_TO_BUY'
|
|
|
</select>
|
|
|
<!-- 查询报名订单 -->
|
|
|
<select id="findMusicGroupApplyOrderByStatus" resultMap="StudentPaymentOrder">
|
|
|
- SELECT * FROM student_payment_order WHERE music_group_id_= #{musicGroupId} AND user_id_=#{userId} AND type_ =
|
|
|
- 'APPLY' AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
|
|
|
- ORDER BY id_ DESC LIMIT 1
|
|
|
+ SELECT *
|
|
|
+ FROM student_payment_order
|
|
|
+ WHERE music_group_id_ = #{musicGroupId}
|
|
|
+ AND user_id_ = #{userId}
|
|
|
+ AND type_ =
|
|
|
+ 'APPLY'
|
|
|
+ AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
|
|
|
+ ORDER BY id_ DESC
|
|
|
+ LIMIT 1
|
|
|
</select>
|
|
|
|
|
|
<!-- 根据订单号查询订单 -->
|
|
|
<select id="findOrderByOrderNo" resultMap="StudentPaymentOrder">
|
|
|
- SELECT * FROM student_payment_order WHERE order_no_ = #{orderNo}
|
|
|
+ SELECT *
|
|
|
+ FROM student_payment_order
|
|
|
+ WHERE order_no_ = #{orderNo}
|
|
|
</select>
|
|
|
|
|
|
<select id="queryByDealStatus" resultMap="StudentPaymentOrder" parameterType="map">
|
|
|
- SELECT * FROM student_payment_order WHERE music_group_id_= #{musicGroupId} AND type_ =
|
|
|
- #{type} AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
|
|
|
+ SELECT *
|
|
|
+ FROM student_payment_order
|
|
|
+ WHERE music_group_id_ = #{musicGroupId}
|
|
|
+ AND type_ =
|
|
|
+ #{type}
|
|
|
+ AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
|
|
|
</select>
|
|
|
|
|
|
<!-- 查找支付成功和支付中订单 -->
|
|
@@ -280,7 +300,7 @@
|
|
|
<![CDATA[
|
|
|
SELECT COUNT(*)
|
|
|
FROM student_payment_order
|
|
|
- WHERE FIND_IN_SET(status_,'SUCCESS,ING,WAIT_PAY')
|
|
|
+ WHERE FIND_IN_SET(status_, 'SUCCESS,ING,WAIT_PAY')
|
|
|
]]>
|
|
|
</select>
|
|
|
|
|
@@ -292,17 +312,24 @@
|
|
|
</resultMap>
|
|
|
|
|
|
<select id="findGoodsIds" resultMap="userGoodsDto">
|
|
|
- SELECT g.id_ goods_id_,g.name_ goods_name_ FROM student_payment_order spo
|
|
|
- LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
|
|
|
- LEFT JOIN goods g ON FIND_IN_SET(g.id_,spod.goods_id_list_)
|
|
|
- WHERE spo.type_ = 'APPLY' AND spo.status_ = 'SUCCESS' AND spod.goods_id_list_ IS NOT NULL
|
|
|
- AND spo.music_group_id_ = #{musicGroupId} AND spo.user_id_ = #{userId}
|
|
|
+ SELECT g.id_ goods_id_, g.name_ goods_name_
|
|
|
+ FROM student_payment_order spo
|
|
|
+ LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
|
|
|
+ LEFT JOIN goods g ON FIND_IN_SET(g.id_, spod.goods_id_list_)
|
|
|
+ WHERE spo.type_ = 'APPLY'
|
|
|
+ AND spo.status_ = 'SUCCESS'
|
|
|
+ AND spod.goods_id_list_ IS NOT NULL
|
|
|
+ AND spo.music_group_id_ = #{musicGroupId}
|
|
|
+ AND spo.user_id_ = #{userId}
|
|
|
</select>
|
|
|
|
|
|
<select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
|
|
|
- SELECT * FROM student_payment_order
|
|
|
- WHERE status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} AND payment_channel_ =
|
|
|
- #{paymentChannel} LIMIT 100
|
|
|
+ SELECT *
|
|
|
+ FROM student_payment_order
|
|
|
+ WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
|
|
|
+ AND payment_channel_ =
|
|
|
+ #{paymentChannel}
|
|
|
+ LIMIT 100
|
|
|
</select>
|
|
|
|
|
|
<!-- 查询支付中超时订单 -->
|
|
@@ -315,35 +342,39 @@
|
|
|
<![CDATA[ AND create_time_ <= ]]> #{beforeTime}
|
|
|
</select>
|
|
|
<select id="countStudentPaymentNum" resultType="int">
|
|
|
- select count(1) from student_payment_order
|
|
|
- where music_group_id_=#{musicGroupId}
|
|
|
- AND status_ = 'SUCCESS' AND type_='SMALL_CLASS_TO_BUY'
|
|
|
+ select count(1)
|
|
|
+ from student_payment_order
|
|
|
+ where music_group_id_ = #{musicGroupId}
|
|
|
+ AND status_ = 'SUCCESS'
|
|
|
+ AND type_ = 'SMALL_CLASS_TO_BUY'
|
|
|
</select>
|
|
|
|
|
|
<select id="countSurplusCourseByMusicGroupAndUser" resultType="int">
|
|
|
- SELECT
|
|
|
- COUNT(*)
|
|
|
- FROM
|
|
|
- course_schedule_student_payment cssp
|
|
|
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
|
|
|
- WHERE
|
|
|
- cssp.user_id_ = #{userId}
|
|
|
- AND cssp.music_group_id_ = #{musicGroupId}
|
|
|
- AND CONCAT(cs.class_date_ ,' ',cs.start_class_time_) > NOW()
|
|
|
+ SELECT COUNT(*)
|
|
|
+ FROM course_schedule_student_payment cssp
|
|
|
+ LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
|
|
|
+ WHERE cssp.user_id_ = #{userId}
|
|
|
+ AND cssp.music_group_id_ = #{musicGroupId}
|
|
|
+ AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) > NOW()
|
|
|
</select>
|
|
|
<select id="sumGroupIncomeFee" resultType="java.math.BigDecimal">
|
|
|
- SELECT
|
|
|
- SUM(expect_amount_)
|
|
|
- FROM
|
|
|
- student_payment_order
|
|
|
- WHERE
|
|
|
- group_type_ = #{groupType}
|
|
|
- AND music_group_id_ = #{musicGroupId}
|
|
|
+ SELECT SUM(expect_amount_)
|
|
|
+ FROM student_payment_order
|
|
|
+ WHERE group_type_ = #{groupType}
|
|
|
+ AND music_group_id_ = #{musicGroupId}
|
|
|
</select>
|
|
|
<select id="findStudentPaymentOrder" resultMap="StudentPaymentOrder">
|
|
|
- SELECT * FROM student_payment_order WHERE id_ IN (SELECT MAX(sp.id_) FROM (SELECT * FROM student_payment_order
|
|
|
- WHERE group_type_ = #{groupType} AND type_ = 'APPLY' AND music_group_id_ = #{musicGroupId} AND status_ = 'SUCCESS'
|
|
|
- ORDER BY id_ DESC) sp GROUP BY sp.user_id_)
|
|
|
+ SELECT *
|
|
|
+ FROM student_payment_order
|
|
|
+ WHERE id_ IN (SELECT MAX(sp.id_)
|
|
|
+ FROM (SELECT *
|
|
|
+ FROM student_payment_order
|
|
|
+ WHERE group_type_ = #{groupType}
|
|
|
+ AND type_ = 'APPLY'
|
|
|
+ AND music_group_id_ = #{musicGroupId}
|
|
|
+ AND status_ = 'SUCCESS'
|
|
|
+ ORDER BY id_ DESC) sp
|
|
|
+ GROUP BY sp.user_id_)
|
|
|
</select>
|
|
|
<select id="findOrderByGroupType" resultType="int">
|
|
|
SELECT COUNT(id_) FROM student_payment_order
|
|
@@ -364,8 +395,34 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="findFixOrder" resultMap="StudentPaymentOrder">
|
|
|
- SELECT * FROM student_payment_order
|
|
|
- WHERE status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} AND payment_channel_ =
|
|
|
- #{paymentChannel} AND com_amount_ IS NULL LIMIT 100
|
|
|
+ SELECT *
|
|
|
+ FROM student_payment_order
|
|
|
+ WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
|
|
|
+ AND payment_channel_ =
|
|
|
+ #{paymentChannel}
|
|
|
+ AND com_amount_ IS NULL
|
|
|
+ LIMIT 100
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto" id="orderAndDetail"
|
|
|
+ extends="StudentPaymentOrder">
|
|
|
+ <result column="organ_name" property="organName"/>
|
|
|
+ <result column="username_" property="user.username"/>
|
|
|
+ <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
|
|
|
+ <result column="detail_type_" property="type"/>
|
|
|
+ <result column="detail_price_" property="price"/>
|
|
|
+ </collection>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 分页查询 -->
|
|
|
+ <select id="ExportQueryPage" resultMap="orderAndDetail" parameterType="map">
|
|
|
+ SELECT spo.*,u.username_,spod.type_ detail_type_,spod.price_ detail_price_,o.name_ organ_name
|
|
|
+ FROM student_payment_order spo
|
|
|
+ LEFT JOIN sys_user u on spo.user_id_ = u.id_
|
|
|
+ LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
|
|
|
+ LEFT JOIN organization o on spo.organ_id_ = o.id_
|
|
|
+ <include refid="queryPaymentOrder"/>
|
|
|
+ ORDER BY spo.id_ ASC
|
|
|
</select>
|
|
|
</mapper>
|