123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <?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.caimei.modules.coupon.dao.CmCouponOrderRecordDao">
-
- <sql id="cmCouponOrderRecordColumns">
- a.id AS "id",
- a.orderCode AS "orderCode",
- a.totalAmount AS "totalAmount",
- a.refundAmount AS "refundAmount",
- a.paymentTime AS "paymentTime",
- a.refundTime AS "refundTime",
- a.couponCode AS "couponCode",
- a.discountAmount AS "discountAmount",
- a.status AS "status",
- a.customerCode AS "customerCode",
- a.customerName AS "customerName",
- a.customerMobile AS "customerMobile",
- a.refundFlag AS "refundFlag",
- a.createTime AS "createTime",
- a.updateTime AS "updateTime",
- a.delFlag AS "delFlag",
- u.userName AS "clubName",
- ccrs.mobile AS "couponMobile"
- </sql>
-
- <sql id="cmCouponOrderRecordJoins">
- LEFT JOIN cm_coupon_record ccr ON ccr.couponCode = a.couponCode
- LEFT JOIN cm_coupon_record_scan ccrs ON ccrs.couponCode = a.couponCode
- LEFT JOIN user u ON u.userID = ccr.userID
- LEFT JOIN club c on c.userID = u.companyUserID
- </sql>
-
- <select id="get" resultType="CmCouponOrderRecord">
- SELECT
- <include refid="cmCouponOrderRecordColumns"/>
- FROM cm_coupon_order_record a
- <include refid="cmCouponOrderRecordJoins"/>
- WHERE a.id = #{id}
- </select>
-
- <select id="findList" resultType="CmCouponOrderRecord">
- SELECT
- <include refid="cmCouponOrderRecordColumns"/>
- FROM cm_coupon_order_record a
- <include refid="cmCouponOrderRecordJoins"/>
- <where>
-
- <if test="orderCode != null and orderCode != ''">
- AND a.orderCode = #{orderCode}
- </if>
- <if test="clubName != null and clubName != ''">
- AND (u.userName LIKE concat('%',#{clubName},'%') OR ccrs.mobile = #{clubName} OR c.name LIKE concat('%',#{clubName},'%'))
- </if>
- <if test="startTime != null and startTime != ''">
- AND a.paymentTime <![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND a.paymentTime <![CDATA[ <= ]]> #{endTime}
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY a.paymentTime DESC
- </otherwise>
- </choose>
- </select>
- <select id="findListBuyAgain" resultType="CmCouponOrderRecord">
- SELECT
- a.*,
- u.username AS "clubName",
- c.name AS "companyName",
- ccrs.mobile AS "couponMobile"
- FROM cm_coupon_order_record a
- LEFT JOIN cm_coupon_record ccr ON ccr.couponCode = a.couponCode
- LEFT JOIN cm_coupon_record_scan ccrs ON ccrs.couponCode = a.couponCode
- LEFT JOIN user u ON u.userID = ccr.sharerUserId
- LEFT JOIN club c on c.userID = u.companyUserID
- WHERE
- a.customerMobile = #{customerMobile}
- AND ( c.name is NOT NULL OR ccrs.mobile is NOT NULL )
- </select>
-
- <select id="findAllList" resultType="CmCouponOrderRecord">
- SELECT
- <include refid="cmCouponOrderRecordColumns"/>
- FROM cm_coupon_order_record a
- <include refid="cmCouponOrderRecordJoins"/>
- <where>
-
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
-
- <insert id="insert" parameterType="CmCouponOrderRecord" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_coupon_order_record(
- id,
- orderCode,
- totalAmount,
- refundAmount,
- paymentTime,
- refundTime,
- couponCode,
- discountAmount,
- status,
- customerCode,
- customerName,
- customerMobile,
- refundFlag,
- createTime,
- updateTime,
- delFlag
- ) VALUES (
- #{id},
- #{orderCode},
- #{totalAmount},
- #{refundAmount},
- #{paymentTime},
- #{refundTime},
- #{couponCode},
- #{discountAmount},
- #{status},
- #{customerCode},
- #{customerName},
- #{customerMobile},
- #{refundFlag},
- #{createTime},
- #{updateTime},
- #{delFlag}
- )
- </insert>
-
- <update id="update">
- UPDATE cm_coupon_order_record SET
- orderCode = #{orderCode},
- totalAmount = #{totalAmount},
- refundAmount = #{refundAmount},
- paymentTime = #{paymentTime},
- refundTime = #{refundTime},
- couponCode = #{couponCode},
- discountAmount = #{discountAmount},
- status = #{status},
- customerCode = #{customerCode},
- customerName = #{customerName},
- customerMobile = #{customerMobile},
- refundFlag = #{refundFlag},
- createTime = #{createTime},
- updateTime = #{updateTime},
- delFlag = #{delFlag}
- WHERE id = #{id}
- </update>
-
- <delete id="delete">
- DELETE FROM cm_coupon_order_record
- WHERE id = #{id}
- </delete>
-
- </mapper>
|