|
@@ -20,6 +20,24 @@
|
|
|
<result column="update_time_" property="updateTime" />
|
|
|
</resultMap>
|
|
|
|
|
|
+ <resultMap id="SysCouponCodeDto" type="com.ym.mec.biz.dal.dto.SysCouponCodeDto">
|
|
|
+ <result column="organ_id_" property="organId"/>
|
|
|
+ <result column="organ_name_" property="organName"/>
|
|
|
+ <result column="user_id_" property="userId"/>
|
|
|
+ <result column="user_name_" property="userName"/>
|
|
|
+ <result column="phone_" property="phone"/>
|
|
|
+ <result column="coupon_id_" property="couponId"/>
|
|
|
+ <result column="coupon_type_" property="couponType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
|
|
|
+ <result column="coupon_name_" property="couponName"/>
|
|
|
+ <result column="coupon_description_" property="couponDescription"/>
|
|
|
+ <result column="code_" property="code"/>
|
|
|
+ <result column="payment_order_id_" property="paymentOrderId"/>
|
|
|
+ <result column="usage_status_" property="usageStatus"/>
|
|
|
+ <result column="used_time_" property="usedTime"/>
|
|
|
+ <result column="use_start_date_" property="useStartDate"/>
|
|
|
+ <result column="use_deadline_date_" property="useDeadlineDate"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
<!-- 根据主键查询一条记录 -->
|
|
|
<select id="get" resultMap="SysCouponCode" >
|
|
|
SELECT * FROM sys_coupon_code WHERE id_ = #{id}
|
|
@@ -33,50 +51,47 @@
|
|
|
<!-- 向数据库增加一条记录 -->
|
|
|
<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.SysCouponCode" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
|
|
<!--
|
|
|
- <selectKey resultClass="int" keyProperty="id" >
|
|
|
- SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
|
|
|
+ <selectKey resultClass="int" keyProperty="id" >
|
|
|
+ SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
|
|
|
</selectKey>
|
|
|
-->
|
|
|
- INSERT INTO sys_coupon_code (id_,coupon_id_,code_,usage_status_,user_id_,used_time_,use_start_date_,use_deadline_date_,payment_order_id_,create_time_,update_time_) VALUES(#{id},#{couponId},#{code},#{usageStatus},#{userId},#{usedTime},#{useStartDate},#{useDeadlineDate},#{paymentOrderId},#{createTime},#{updateTime})
|
|
|
+ INSERT INTO sys_coupon_code (id_,coupon_id_,code_,usage_status_,user_id_,used_time_,use_start_date_,use_deadline_date_,
|
|
|
+ payment_order_id_,create_time_,update_time_)
|
|
|
+ VALUES(#{id},#{couponId},#{code},#{usageStatus},#{userId},#{usedTime},#{useStartDate},#{useDeadlineDate},
|
|
|
+ #{paymentOrderId},NOW(),NOW())
|
|
|
</insert>
|
|
|
|
|
|
<!-- 根据主键查询一条记录 -->
|
|
|
<update id="update" parameterType="com.ym.mec.biz.dal.entity.SysCouponCode">
|
|
|
- UPDATE sys_coupon_code <set>
|
|
|
- <if test="couponId != null">
|
|
|
- coupon_id_ = #{couponId},
|
|
|
- </if>
|
|
|
- <if test="usageStatus != null">
|
|
|
- usage_status_ = #{usageStatus},
|
|
|
- </if>
|
|
|
- <if test="useStartDate != null">
|
|
|
- use_start_date_ = #{useStartDate},
|
|
|
- </if>
|
|
|
- <if test="userId != null">
|
|
|
- user_id_ = #{userId},
|
|
|
- </if>
|
|
|
- <if test="usedTime != null">
|
|
|
- used_time_ = #{usedTime},
|
|
|
- </if>
|
|
|
- <if test="id != null">
|
|
|
- id_ = #{id},
|
|
|
- </if>
|
|
|
- <if test="code != null">
|
|
|
- code_ = #{code},
|
|
|
- </if>
|
|
|
- <if test="updateTime != null">
|
|
|
- update_time_ = #{updateTime},
|
|
|
- </if>
|
|
|
- <if test="paymentOrderId != null">
|
|
|
- payment_order_id_ = #{paymentOrderId},
|
|
|
- </if>
|
|
|
- <if test="useDeadlineDate != null">
|
|
|
- use_deadline_date_ = #{useDeadlineDate},
|
|
|
- </if>
|
|
|
- <if test="createTime != null">
|
|
|
- create_time_ = #{createTime},
|
|
|
- </if>
|
|
|
- </set> WHERE id_ = #{id}
|
|
|
+ UPDATE sys_coupon_code
|
|
|
+ <set>
|
|
|
+ <if test="couponId != null">
|
|
|
+ coupon_id_ = #{couponId},
|
|
|
+ </if>
|
|
|
+ <if test="usageStatus != null">
|
|
|
+ usage_status_ = #{usageStatus},
|
|
|
+ </if>
|
|
|
+ <if test="useStartDate != null">
|
|
|
+ use_start_date_ = #{useStartDate},
|
|
|
+ </if>
|
|
|
+ <if test="userId != null">
|
|
|
+ user_id_ = #{userId},
|
|
|
+ </if>
|
|
|
+ <if test="code != null">
|
|
|
+ code_ = #{code},
|
|
|
+ </if>
|
|
|
+ <if test="updateTime != null">
|
|
|
+ update_time_ = #{updateTime},
|
|
|
+ </if>
|
|
|
+ <if test="paymentOrderId != null">
|
|
|
+ payment_order_id_ = #{paymentOrderId},
|
|
|
+ </if>
|
|
|
+ <if test="useDeadlineDate != null">
|
|
|
+ use_deadline_date_ = #{useDeadlineDate},
|
|
|
+ </if>
|
|
|
+ used_time_ = NOW()
|
|
|
+ </set>
|
|
|
+ WHERE id_ = #{id}
|
|
|
</update>
|
|
|
|
|
|
<!-- 根据主键删除一条记录 -->
|
|
@@ -93,4 +108,62 @@
|
|
|
<select id="queryCount" resultType="int">
|
|
|
SELECT COUNT(*) FROM sys_coupon_code
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="countWithUserAndCoupon" resultType="int">
|
|
|
+ SELECT COUNT(id_) FROM sys_coupon_code WHERE user_id_=#{userId} AND coupon_id_=#{couponId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <sql id="querySysCouponUseListCondition">
|
|
|
+ <where>
|
|
|
+ <if test="couponName!=null and couponName!=''">
|
|
|
+ AND sc.name_ LIKE CONCAT('%', #{couponName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="paymentOrderId!=null">
|
|
|
+ AND scc.payment_order_id_=#{paymentOrderId}
|
|
|
+ </if>
|
|
|
+ <if test="usageStatus!=null">
|
|
|
+ AND scc.usage_status_=#{usageStatus}
|
|
|
+ </if>
|
|
|
+ <if test="organId!=null">
|
|
|
+ AND su.organ_id_=#{organId}
|
|
|
+ </if>
|
|
|
+ <if test="search!=null and search!=''">
|
|
|
+ AND (scc.user_id_=#{search} OR su.phone_=#{search} OR su.username_ LIKE CONCAT('%', #{search}, '%'))
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="querySysCouponUseList" resultMap="SysCouponCodeDto">
|
|
|
+ SELECT
|
|
|
+ organ.name_ organ_name_,
|
|
|
+ su.username_,
|
|
|
+ su.phone_,
|
|
|
+ scc.coupon_id_,
|
|
|
+ sc.type_ coupon_type_,
|
|
|
+ sc.name_ coupon_name_,
|
|
|
+ sc.description_ coupon_description_,
|
|
|
+ scc.code_,
|
|
|
+ scc.payment_order_id_,
|
|
|
+ scc.use_start_date_,
|
|
|
+ scc.use_deadline_date_,
|
|
|
+ scc.used_time_,
|
|
|
+ scc.usage_status_
|
|
|
+ FROM sys_coupon_code scc
|
|
|
+ LEFT JOIN sys_coupon sc ON scc.coupon_id_=sc.id_
|
|
|
+ LEFT JOIN sys_user su ON scc.user_id_=su.id_
|
|
|
+ LEFT JOIN organization organ ON su.organ_id_=organ.id_
|
|
|
+ <include refid="querySysCouponUseListCondition"></include>
|
|
|
+ ORDER BY scc.id_ DESC
|
|
|
+ <include refid="global.limit"></include>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="countSysCouponUseList" resultType="java.lang.Integer">
|
|
|
+ SELECT
|
|
|
+ COUNT(scc.id_)
|
|
|
+ FROM sys_coupon_code scc
|
|
|
+ LEFT JOIN sys_coupon sc ON scc.coupon_id_=sc.id_
|
|
|
+ LEFT JOIN sys_user su ON scc.user_id_=su.id_
|
|
|
+ LEFT JOIN organization organ ON su.organ_id_=organ.id_
|
|
|
+ <include refid="querySysCouponUseListCondition"></include>
|
|
|
+ </select>
|
|
|
</mapper>
|