|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167 |
- <?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.iformall.mapper.WxCouponOrderMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponOrder">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
- <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
- <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
- <result column="b_merchant_id" jdbcType="BIGINT" property="bMerchantId" />
- <result column="b_tenant_id" jdbcType="VARCHAR" property="bTenantId" />
- <result column="a_user_id" jdbcType="BIGINT" property="aUserId" />
- <result column="order_id" jdbcType="BIGINT" property="orderId" />
- <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
- <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="create_date_times" jdbcType="BIGINT" property="createDateTimes" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
- <result column="auto_refund" jdbcType="INTEGER" property="autoRefund" />
- <result column="verify_type" jdbcType="INTEGER" property="verifyType" />
- <result column="verify_remark" jdbcType="VARCHAR" property="verifyRemark" />
- <result column="pay_vendor" jdbcType="INTEGER" property="payVendor" />
- <result column="pay_version" jdbcType="INTEGER" property="payVersion" />
- <result column="send_merchant_id" jdbcType="INTEGER" property="sendMerchantId" />
- <result column="send_merchant_user_id" jdbcType="INTEGER" property="sendMerchantUserId" />
- <result column="compose_order_type" jdbcType="INTEGER" property="composeOrderType" />
- <result column="compose_order_id" jdbcType="BIGINT" property="composeOrderId" />
- <result column="parent_coupon_order_id" jdbcType="BIGINT" property="parentCouponOrderId" />
- <result column="coupon_number" jdbcType="BIGINT" property="couponNumber" />
- <result column="subsidy" jdbcType="INTEGER" property="subsidy" />
- <result column="ext_param" jdbcType="VARCHAR" property="extParam" />
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/>
- <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/>
- <result column="shipping_status" jdbcType="INTEGER" property="shippingStatus"/>
- <result column="delivery_info" jdbcType="VARCHAR" property="deliveryInfo"/>
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`coupon_type`,`c_user_id`,`owner_id`,`b_user_id`,`b_merchant_id`,`b_tenant_id`,`order_id`,`expired_time`,`coupon_order_status`,`create_date`,`update_date`,`coupon_price`, `auto_refund`,
- `verify_type`,`verify_remark`,`pay_vendor`,`pay_version`,`send_merchant_id`,`send_merchant_user_id`,`compose_order_type`,`compose_order_id`,`parent_coupon_order_id`,`coupon_number`,
- `freight_price`,`shipping_type`,`shipping_address`,`shipping_status`,`delivery_info`,`subsidy`,`ext_param`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where `tenant_id` = #{tenantId}
- <if test=" null != id ">
- and `id` = #{id}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != couponId ">
- and `coupon_id` = #{couponId}
- </if>
-
- <if test=" null != couponType ">
- and `coupon_type` = #{couponType}
- </if>
-
- <if test=" null != cUserId ">
- and `c_user_id` = #{cUserId}
- </if>
-
- <if test=" null != ownerId ">
- and `owner_id` = #{ownerId}
- </if>
-
- <if test=" null != bUserId ">
- and `b_user_id` = #{bUserId}
- </if>
-
- <if test=" null != bMerchantId ">
- and `b_merchant_id` = #{bMerchantId}
- </if>
-
- <if test=" null != bTenantId ">
- and `b_tenant_id` = #{bTenantId}
- </if>
-
- <if test=" null != aUserId ">
- and `a_user_id` = #{aUserId}
- </if>
-
- <if test=" null != orderId ">
- and `order_id` = #{orderId}
- </if>
-
- <if test=" null != expiredTime ">
- and `expired_time` = #{expiredTime}
- </if>
-
- <if test=" null != couponOrderStatus ">
- and `coupon_order_status` = #{couponOrderStatus}
- </if>
-
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
- </if>
-
- <if test=" null != couponPrice ">
- and `coupon_price` = #{couponPrice}
- </if>
-
- <if test=" null != autoRefund ">
- and `auto_refund` = #{autoRefund}
- </if>
-
- <if test=" null != payVendor ">
- and `pay_vendor` = #{payVendor}
- </if>
-
- <if test=" null != payVersion ">
- and `pay_version` = #{payVersion}
- </if>
-
- <if test=" null != sendMerchantId ">
- and `send_merchant_id` = #{sendMerchantId}
- </if>
-
- <if test=" null != sendMerchantUserId ">
- and `send_merchant_user_id` = #{sendMerchantUserId}
- </if>
-
- <if test=" null != composeOrderType ">
- and `compose_order_type` = #{composeOrderType}
- </if>
-
- <if test=" null != composeOrderId ">
- and `compose_order_id` = #{composeOrderId}
- </if>
-
- <if test=" null != parentCouponOrderId ">
- and `parent_coupon_order_id` = #{parentCouponOrderId}
- </if>
-
- <if test=" null != shippingType ">
- and `shipping_type` = #{shippingType}
- </if>
-
- <if test=" null != shippingStatus ">
- and `shipping_status` = #{shippingStatus}
- </if>
-
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </sql>
-
- <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_order where id = #{id} and tenant_id=#{tenantId}
- </select>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_order
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="findListOfVerifiedByDateForBUser" parameterType="map" resultMap="BaseResultMap">
- select co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.b_merchant_id,co.b_tenant_id,co.order_id,co.expired_time,
- co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,co.pay_version,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,co.ext_param
- from wx_coupon_order co
- where co.tenant_id = #{tenantId}
- AND co.coupon_order_status = '1'
- <if test=" null != bMerchantId ">
- and co.b_merchant_id = #{bMerchantId}
- </if>
- <if test="startDate != null">
- AND co.update_date > #{startDate,jdbcType=TIMESTAMP}
- </if>
- <if test="endDate != null">
- AND co.update_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
- order by co.update_date desc
- </select>
-
- <select id="findListOfOrderedByDateForBUser" parameterType="map" resultMap="BaseResultMap">
- select co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.b_merchant_id,co.b_tenant_id,co.order_id,co.expired_time,
- co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,co.pay_version,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,co.ext_param
- from wx_coupon_order co
- where co.tenant_id = #{tenantId}
- <if test="startDateTimes != null">
- AND co.create_date_times > #{startDateTimes}
- </if>
- <if test="endDateTimes != null">
- AND co.create_date_times < #{endDateTimes}
- </if>
- <if test=" null != couponIds ">
- and co.coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
- #{couponIdItem}
- </foreach>
- </if>
- order by co.create_date_times desc
- </select>
-
- <update id="updateVerifyCouponOrder" parameterType="com.iformall.domain.po.WxCouponOrder">
- update wx_coupon_order
- set `coupon_order_status` = #{couponOrderStatus},
- `b_user_id` = #{bUserId},
- <if test=" null != bMerchantId">
- `b_merchant_id` = #{bMerchantId},
- </if>
- `update_date` = #{updateDate},
- `verify_type` = #{verifyType}
- <if test=" null != verifyRemark">
- ,`verify_remark` = #{verifyRemark}
- </if>
- <if test=" null != shippingStatus">
- ,`shipping_status` = #{shippingStatus}
- </if>
- <if test=" null != bTenantId">
- ,`b_tenant_id` = #{bTenantId}
- </if>
- where id=#{id} and `b_user_id` is null
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </update>
-
- <update id="updateVerifyCouponOrderStatus" parameterType="com.iformall.domain.po.WxCouponOrder">
- update wx_coupon_order
- set `coupon_order_status` = #{couponOrderStatus},
- `b_user_id` = #{bUserId},
- <if test=" null != bMerchantId">
- `b_merchant_id` = #{bMerchantId},
- </if>
- `update_date` = #{updateDate},
- `verify_type` = #{verifyType}
- <if test=" null != verifyRemark">
- ,`verify_remark` = #{verifyRemark}
- </if>
- <if test=" null != shippingStatus">
- ,`shipping_status` = #{shippingStatus}
- </if>
- <if test=" null != bTenantId">
- ,`b_tenant_id` = #{bTenantId}
- </if>
- where id=#{id}
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null == #{bUserId} ">
- and `b_user_id` is null
- </if>
- <if test=" null != #{bUserId} ">
- and `b_user_id` = #{bUserId}
- </if>
- </update>
-
- <update id="updateVerifyCouponOrderStatusForMicroPay" parameterType="com.iformall.domain.po.WxCouponOrder">
- update wx_coupon_order
- set `coupon_order_status` = #{couponOrderStatus},
- `b_user_id` = #{bUserId},
- <if test=" null != bMerchantId">
- `b_merchant_id` = #{bMerchantId},
- </if>
- `update_date` = #{updateDate},
- `verify_type` = #{verifyType}
- <if test=" null != verifyRemark">
- ,`verify_remark` = #{verifyRemark}
- </if>
- <if test=" null != shippingStatus">
- ,`shipping_status` = #{shippingStatus}
- </if>
- <if test=" null != bTenantId">
- ,`b_tenant_id` = #{bTenantId}
- </if>
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and id=#{id}
- </update>
-
- <update id="cancelVerifyCouponOrder" parameterType="com.iformall.domain.po.WxCouponOrder">
- update wx_coupon_order
- set `coupon_order_status` = #{couponOrderStatus},
- `b_user_id` = null,
- `b_merchant_id` = null,
- `update_date` = #{updateDate},
- `verify_type` = null,
- `b_tenant_id` = null
- where id=#{id}
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </update>
-
- <update id="updateVerifyCouponOrderSubsidy" parameterType="com.iformall.domain.po.WxCouponOrder">
- update wx_coupon_order
- set `subsidy` = #{subsidy}
- where id=#{id}
- </update>
-
-
- <select id = "findCreateDateCouponOrderCount" resultType="hashmap" parameterType="hashmap">
- select DATE_FORMAT(create_date,'%m/%d') as createTime ,count(1) as count from wx_coupon_order co
- where `tenant_id` = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="startCreateDateTimes != null">
- AND co.create_date_times >= #{startCreateDateTimes}
- </if>
- <if test="endCreateDateTimes != null">
- AND co.create_date_times <= #{endCreateDateTimes}
- </if>
- <if test="couponOrderStatus != null">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test="updateStartTime != null">
- AND co.update_date >= #{updateStartTime}
- </if>
- <if test="updateEndTime != null">
- AND co.update_date <= #{updateEndTime}
- </if>
- group by DATE_FORMAT(create_date,'%m/%d')
- </select>
-
- <select id = "findCreateDateCouponOrderUserCount" resultType="hashmap" parameterType="hashmap">
- select DATE_FORMAT(create_date,'%m/%d') as createTime ,count(DISTINCT c_user_id) as count from wx_coupon_order co
- where `tenant_id` = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="startCreateDateTimes != null">
- AND co.create_date_times >= #{startCreateDateTimes}
- </if>
- <if test="endCreateDateTimes != null">
- AND co.create_date_times <= #{endCreateDateTimes}
- </if>
- <if test="couponOrderStatus != null">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test="updateStartTime != null">
- AND co.update_date >= #{updateStartTime}
- </if>
- <if test="updateEndTime != null">
- AND co.update_date <= #{updateEndTime}
- </if>
- group by DATE_FORMAT(create_date,'%m/%d')
- </select>
-
- <select id="couponDataList" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
- SELECT createTime,couponId,sum(couponCount) couponCount,sum(couponUserCount) couponUserCount,sum(verifyCount) verifyCount,sum(verifyUserCount) verifyUserCount
- from view_coupon_data${tenantEntity.shardTableSuffix} WHERE `tenant_id` = #{tenantEntity.tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="startTime != null">
- and createTime >= DATE_FORMAT(#{startTime},'%Y-%m-%d')
- </if>
- <if test="endTime != null">
- and view_coupon_data.createTime <= DATE_FORMAT(#{endTime},'%Y-%m-%d')
- </if>
- <if test="couponType != null">
- and couponType = #{couponType}
- </if>
- <if test="couponTitle != null">
- and couponTitle like concat('%', #{couponTitle},'%')
- </if>
- GROUP BY createTime,couponId
- order by createTime desc
-
- </select>
-
- <select id="touchUsersReportList" resultType="com.iformall.domain.vo.TouchUsersReportVo" parameterType="com.iformall.domain.dto.MarkingCouponDataReportDto">
- SELECT xTime, sum(pv) pv, sum(uv) uv, sum(couponCount) couponCount, sum(userCount) userCount, sum(verifyCount) verifyCount, sum(verifyUserCount) verifyUserCount
- from view_touch_user${tenantEntity.shardTableSuffix} WHERE `tenant_id` = #{tenantEntity.tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="startTime != null">
- and xTime >= DATE_FORMAT(#{startTime},'%Y-%m-%d')
- </if>
- <if test="endTime != null">
- and xTime <= DATE_FORMAT(#{endTime},'%Y-%m-%d')
- </if>
- GROUP BY xTime
- order by xTime desc
- </select>
-
-
- <select id="queryForSceneRepotyHistoryVerified" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
- select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
- from wx_coupon_order c
- where c.coupon_order_status = 1
- <if test=" null != tenantId and '' != tenantId">
- and c.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and c.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != startTime and null != endTime">
- and c.update_date BETWEEN #{startTime} and #{endTime}
- </if>
- group by xTime
- </select>
-
- <select id="queryForSceneRepotyHistoryOrdered" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
- select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
- from wx_coupon_order c where c.`tenant_id` = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and c.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != startTime and null != endTime">
- and c.create_date BETWEEN #{startTime} and #{endTime}
- </if>
- group by xTime
- </select>
-
- <!-- <select id="queryForSceneRepotyMechantHistoryOrdered" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
- select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
- from (
- SELECT * from wx_coupon_order
- ) c left join (
- SELECT * from wx_coupon_action_log
- ) cal on cal.tenant_id = c.tenant_id
- where cal.coupon_order_id=c.id
- <if test=" null != tenantId and '' != tenantId">
- and c.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and c.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != channelType and null != channelType">
- and cal.channel_type=#{channelType}
- </if>
- <if test=" null != startTime and null != endTime">
- and c.create_date BETWEEN #{startTime} and #{endTime}
- </if>
- group by xTime
- </select> -->
-
- <select id="queryPriceTotal" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer" >
- SELECT IFNULL(SUM(coupon_price),0) from wx_coupon_order
- where `tenant_id` = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != couponOrderStatus">
- and coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != cUserId">
- and c_user_id = #{cUserId}
- </if>
- <if test=" null != couponId ">
- and coupon_id = #{couponId}
- </if>
- <if test=" null != couponType ">
- and coupon_type = #{couponType}
- </if>
- <if test=" null != startTime">
- and create_date_times >= unix_timestamp(#{startTime})*1000
- </if>
- <if test=" null != endTime">
- and create_date_times <= unix_timestamp(#{endTime})*1000
- </if>
- </select>
-
- <select id="findCount" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer">
- select COUNT(co.id) FROM wx_coupon_order co
- where co.`tenant_id` = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != couponOrderStatus">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != cUserId">
- and co.c_user_id = #{cUserId}
- </if>
- <if test=" null != couponId ">
- and co.coupon_id = #{couponId}
- </if>
- <if test=" null != couponType ">
- and co.coupon_type = #{couponType}
- </if>
-
- <if test=" null != sendMerchantId ">
- and co.send_merchant_id = #{sendMerchantId}
- </if>
-
- <if test=" 1 == couponOrderStatus">
- <if test=" null != startTime">
- and co.update_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and co.update_date <= #{endTime}
- </if>
- <if test=" 0 == timeSlot">
- and date_format(co.update_date,'%H:%m') >= '06:00'
- and date_format(co.update_date,'%H:%m') < '18:00'
- and date_format(co.update_date,'%w') in (1,2,3,4,5)
- </if>
- <if test=" 1 == timeSlot">
- and ((date_format(co.update_date,'%H:%m') >= '18:00'
- and date_format(co.update_date,'%w') in (1,2,3,4))
- or
- ((date_format(co.update_date,'%H:%m') < '06:00')
- and date_format(co.update_date,'%w') in (1,2,3,4,5)))
- </if>
- <if test=" 2 == timeSlot">
- and date_format(co.update_date,'%H:%m') >= '06:00'
- and date_format(co.update_date,'%H:%m') < '18:00'
- and date_format(co.update_date,'%w') in (0,6)
- </if>
- <if test=" 3 == timeSlot">
- and ((date_format(co.update_date,'%H:%m') >= '18:00'
- and date_format(co.update_date,'%w') in (5,6,0))
- or
- ((date_format(co.update_date,'%H:%m') < '06:00')
- and date_format(co.update_date,'%w') in (6,0)))
- </if>
- </if>
-
- <if test=" 1 != couponOrderStatus">
- <if test=" null != startTime">
- and co.create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and co.create_date <= #{endTime}
- </if>
- <if test=" 0 == timeSlot">
- and date_format(co.create_date,'%H:%m') >= '06:00'
- and date_format(co.create_date,'%H:%m') < '18:00'
- and date_format(co.create_date,'%w') in (1,2,3,4,5)
- </if>
- <if test=" 1 == timeSlot">
- and ((date_format(co.create_date,'%H:%m') >= '18:00'
- and date_format(co.create_date,'%w') in (1,2,3,4))
- or
- ((date_format(co.create_date,'%H:%m') < '06:00')
- and date_format(co.create_date,'%w') in (1,2,3,4,5)))
- </if>
- <if test=" 2 == timeSlot">
- and date_format(co.create_date,'%H:%m') >= '06:00'
- and date_format(co.create_date,'%H:%m') < '18:00'
- and date_format(co.create_date,'%w') in (0,6)
- </if>
- <if test=" 3 == timeSlot">
- and ((date_format(co.create_date,'%H:%m') >= '18:00'
- and date_format(co.create_date,'%w') in (5,6,0))
- or
- ((date_format(co.create_date,'%H:%m') < '06:00')
- and date_format(co.create_date,'%w') in (6,0)))
- </if>
- </if>
- </select>
-
- <select id="findProductCount" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer">
- select COALESCE(sum(coupon_number),0) FROM wx_coupon_order co
- where co.`tenant_id` = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != couponOrderStatus">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != cUserId">
- and co.c_user_id = #{cUserId}
- </if>
- <if test=" null != couponId ">
- and co.coupon_id = #{couponId}
- </if>
- <if test=" null != couponType ">
- and co.coupon_type = #{couponType}
- </if>
- <if test=" null != couponIds">
- and co.coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
- #{couponIdItem}
- </foreach>
- </if>
- </select>
-
- <select id="getCouponCount" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="hashmap">
- select co.coupon_id as couponId, count(1) as count FROM wx_coupon_order co
- where co.`tenant_id` = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != couponOrderStatus">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != cUserId">
- and co.c_user_id = #{cUserId}
- </if>
- <if test=" null != couponId ">
- and co.coupon_id = #{couponId}
- </if>
- <if test=" null != couponType ">
- and co.coupon_type = #{couponType}
- </if>
- <if test=" null != couponIds">
- and co.coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
- #{couponIdItem}
- </foreach>
- </if>
- <if test=" 1 == couponOrderStatus">
- <if test=" null != startTime">
- and co.update_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and co.update_date <= #{endTime}
- </if>
- <if test=" 0 == timeSlot">
- and date_format(co.update_date,'%H:%m') >= '06:00'
- and date_format(co.update_date,'%H:%m') < '18:00'
- and date_format(co.update_date,'%w') in (1,2,3,4,5)
- </if>
- <if test=" 1 == timeSlot">
- and ((date_format(co.update_date,'%H:%m') >= '18:00'
- and date_format(co.update_date,'%w') in (1,2,3,4))
- or
- ((date_format(co.update_date,'%H:%m') < '06:00')
- and date_format(co.update_date,'%w') in (1,2,3,4,5)))
- </if>
- <if test=" 2 == timeSlot">
- and date_format(co.update_date,'%H:%m') >= '06:00'
- and date_format(co.update_date,'%H:%m') < '18:00'
- and date_format(co.update_date,'%w') in (0,6)
- </if>
- <if test=" 3 == timeSlot">
- and ((date_format(co.update_date,'%H:%m') >= '18:00'
- and date_format(co.update_date,'%w') in (5,6,0))
- or
- ((date_format(co.update_date,'%H:%m') < '06:00')
- and date_format(co.update_date,'%w') in (6,0)))
- </if>
- </if>
-
- <if test=" 1 != couponOrderStatus">
- <if test=" null != startTime">
- and co.create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and co.create_date <= #{endTime}
- </if>
- <if test=" 0 == timeSlot">
- and date_format(co.create_date,'%H:%m') >= '06:00'
- and date_format(co.create_date,'%H:%m') < '18:00'
- and date_format(co.create_date,'%w') in (1,2,3,4,5)
- </if>
- <if test=" 1 == timeSlot">
- and ((date_format(co.create_date,'%H:%m') >= '18:00'
- and date_format(co.create_date,'%w') in (1,2,3,4))
- or
- ((date_format(co.create_date,'%H:%m') < '06:00')
- and date_format(co.create_date,'%w') in (1,2,3,4,5)))
- </if>
- <if test=" 2 == timeSlot">
- and date_format(co.create_date,'%H:%m') >= '06:00'
- and date_format(co.create_date,'%H:%m') < '18:00'
- and date_format(co.create_date,'%w') in (0,6)
- </if>
- <if test=" 3 == timeSlot">
- and ((date_format(co.create_date,'%H:%m') >= '18:00'
- and date_format(co.create_date,'%w') in (5,6,0))
- or
- ((date_format(co.create_date,'%H:%m') < '06:00')
- and date_format(co.create_date,'%w') in (6,0)))
- </if>
- </if>
- group by co.coupon_id
- </select>
-
- <select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" >
- SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,IFNULL(SUM(coupon_price),0) as price
- from wx_coupon_order
- where create_date_times >= unix_timestamp(#{startTime})*1000 and create_date_times < unix_timestamp(#{endTime})*1000
- and `tenant_id` = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- GROUP BY xTime
- </select>
-
- <select id="findExpiredFreeCouponOrderByValidDate" parameterType="String" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_order
- where tenant_id = #{tenantId} and expired_time >= date_sub(curdate(),interval 360 day) and expired_time < now() and coupon_price = 0 and coupon_order_status in (0, 4)
- </select>
-
- <select id="findExpiredCouponOrderByValidDate" parameterType="String" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_order
- where tenant_id = #{tenantId} and expired_time >= date_sub(curdate(),interval 360 day) and expired_time < now() and coupon_price > 0 and coupon_order_status in (0, 4)
- </select>
-
- <select id="findExpiredCouponOrderGoodsVerify" parameterType="String" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_order
- where tenant_id = #{tenantId} and coupon_type = 11
- and update_date < DATE_SUB(curdate(),interval 14 day)
- and shipping_type = 2 and shipping_status = 24 and coupon_order_status = 0
- </select>
-
- <select id="findListOfAdmin" parameterType="com.iformall.domain.vo.WxCouponOrderBVo" resultMap="BaseResultMap">
- select co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.b_merchant_id,co.b_tenant_id,co.expired_time,co.coupon_order_status,co.order_id,
- co.create_date,co.update_date,co.coupon_price, co.verify_type, co.verify_remark,co.pay_vendor,co.pay_version,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,co.send_merchant_id,co.subsidy,co.ext_param
- FROM wx_coupon_order co where co.`tenant_id` = #{tenantId}
- <if test=" null != id ">
- and co.id = #{id}
- </if>
- <if test=" null != orderId ">
- and co.order_id = #{orderId}
- </if>
- <if test=" null != cUserId and '' != cUserId">
- and co.c_user_id = #{cUserId}
- </if>
- <choose>
- <when test=" null != couponType">
- and co.coupon_type = #{couponType}
- </when>
- <otherwise>
- <!-- and co.coupon_type != 5 -->
- and co.coupon_type != 11
- <!-- and co.coupon_type != 12 -->
- <!-- and co.coupon_type != 51 -->
- and co.coupon_type < 100
- </otherwise>
- </choose>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != couponOrderStatus ">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
-
- <if test=" null != shippingType ">
- and co.`shipping_type` = #{shippingType}
- </if>
-
- <if test=" null != shippingStatus ">
- and co.`shipping_status` = #{shippingStatus}
- </if>
-
- <if test="startDate != null">
- AND co.create_date > #{startDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test="startDateTimes != null">
- AND co.create_date_times > #{startDateTimes}
- </if>
-
- <if test="endDate != null">
- AND co.create_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test="endDateTimes != null">
- AND co.create_date_times < #{endDateTimes}
- </if>
-
- <if test="verifyStartDate != null">
- AND co.update_date > #{verifyStartDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test="verifyEndDate != null">
- AND co.update_date < #{verifyEndDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test="bTenantId != null">
- AND co.b_tenant_id = #{bTenantId}
- </if>
-
- <if test=" null != couponIds">
- and co.coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
- #{couponIdItem}
- </foreach>
- </if>
-
- <if test=" null != bMerchantIdList">
- and co.b_merchant_id in
- <foreach collection="bMerchantIdList" index="index" item="bMerchantIdItem" open="(" separator="," close=")">
- #{bMerchantIdItem}
- </foreach>
- </if>
-
- <if test=" null != sortColumns">order by ${sortColumns} </if>
- <if test=" null == sortColumns">order by co.update_date desc</if>
-
- </select>
-
- <select id="findDetailOfAdmin" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.b_merchant_id,co.b_tenant_id,
- co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark, co.pay_vendor,co.pay_version,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,co.subsidy,co.ext_param
- FROM wx_coupon_order co
- where co.id = #{id} and co.tenant_id = #{tenantId}
- </select>
-
-
- <select id="findGoodsList" parameterType="com.iformall.domain.vo.WxCouponOrderBVo" resultMap="BaseResultMap">
- select
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.b_merchant_id,co.b_tenant_id,
- co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark, co.pay_vendor,co.pay_version,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,co.ext_param
- FROM wx_coupon_order co
- where co.`tenant_id` = #{tenantId}
- <choose>
- <when test=" null != couponType">
- and co.coupon_type = #{couponType}
- </when>
- <otherwise>
- <!-- and co.coupon_type != 5 -->
- and co.coupon_type != 11
- <!-- and co.coupon_type != 12 -->
- <!-- and co.coupon_type != 51 -->
- and co.coupon_type < 100
- </otherwise>
- </choose>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != couponOrderStatus ">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != shippingStatuss ">
- and co.`shipping_status` in
- <foreach collection="shippingStatuss" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
-
- <if test="startDate != null">
- AND co.create_date_times > unix_timestamp(#{startDate})*1000
- </if>
-
- <if test="endDate != null">
- AND co.create_date_times < unix_timestamp(#{endDate})*1000
- </if>
-
- <if test="verifyStartDate != null">
- AND co.update_date > #{verifyStartDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test="verifyEndDate != null">
- AND co.update_date < #{verifyEndDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test=" null != id ">
- and co.id = #{id}
- </if>
- <if test=" null != orderId ">
- and co.order_id = #{orderId}
- </if>
-
- <if test=" null != couponIds">
- and co.coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
- #{couponIdItem}
- </foreach>
- </if>
-
- order by co.update_date desc
- </select>
-
- <select id="findListOfOrderedByDate" parameterType="map" resultMap="BaseResultMap">
- select co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.b_merchant_id,co.b_tenant_id,
- co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,co.pay_version,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,co.ext_param
- from wx_coupon_order co
- where co.tenant_id = #{tenantId}
- <if test="startDateTimes != null">
- AND co.create_date_times > #{startDateTimes}
- </if>
- <if test="endDateTimes != null">
- AND co.create_date_times < #{endDateTimes}
- </if>
- <if test=" null != couponIds">
- and co.coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
- #{couponIdItem}
- </foreach>
- </if>
-
- </select>
-
- <select id="findListOfVerifiedByDate" parameterType="map" resultMap="BaseResultMap">
- select co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.b_merchant_id,co.b_tenant_id,
- co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,co.pay_version,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,co.ext_param
- from wx_coupon_order co
- where co.coupon_order_status = '1'
- and co.tenant_id = #{tenantId}
- <if test=" null != bMerchantId">
- AND co.b_merchant_id = #{bMerchantId}
- </if>
- <if test="startDate != null">
- AND co.update_date > #{startDate,jdbcType=TIMESTAMP}
- </if>
- <if test="endDate != null">
- AND co.update_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
- </select>
-
- <select id="findListOfCUserOptimize" parameterType="com.iformall.domain.vo.WxCouponOrderCVo" resultMap="BaseResultMap">
- select
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,
- co.pay_version,co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,co.ext_param
- from wx_coupon_order co
- where co.c_user_id = #{cUserId} and co.`tenant_id` = #{tenantId}
- <choose>
- <when test=" null != couponType">
- and co.coupon_type = #{couponType}
- </when>
- <otherwise>
- and co.coupon_type != 5
- and co.coupon_type != 11
- and co.coupon_type != 12
- and co.coupon_type != 51
- and co.coupon_type < 100
- </otherwise>
- </choose>
-
- <if test="ownerId != null">
- and co.owner_id = #{ownerId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="couponOrderStatus != null and 0 == couponOrderStatus">
- AND (co.coupon_order_status = #{couponOrderStatus} OR co.coupon_order_status = 100 )
- </if>
- <if test="couponOrderStatus != null and 0 != couponOrderStatus">
- AND co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != couponIds">
- and co.coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
- #{couponIdItem}
- </foreach>
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
- <select id="findDetailOfCUser" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.b_merchant_id,co.b_tenant_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,
- co.pay_version,co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,co.ext_param
- from wx_coupon_order co
- where co.id = #{id} and co.tenant_id = #{tenantId}
- </select>
-
- <select id="findCouponOrderForPos" parameterType="java.util.Map" resultMap="BaseResultMap">
- select
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.b_merchant_id,co.b_tenant_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,
- co.pay_version,co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,co.ext_param
- from wx_coupon_order co
- where co.c_user_id = #{cUserId}
- and co.coupon_order_status = #{status}
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- and co.expired_time > now()
- <if test=" null != couponIds">
- and co.coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
- #{couponIdItem}
- </foreach>
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </select>
-
- <select id="findCarListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCarCVo" resultMap="BaseResultMap">
- select
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,
- co.pay_version from wx_coupon_order co
- where co.c_user_id = #{cUserId}
- <if test="id != null">
- and co.id = #{id}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="couponOrderStatus != null and 0 == couponOrderStatus ">
- AND ( co.coupon_order_status = #{couponOrderStatus} OR co.coupon_order_status = 100 )
- </if>
- <if test="couponOrderStatus != null and 0 != couponOrderStatus ">
- AND co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != couponIds">
- and co.coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
- #{couponIdItem}
- </foreach>
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
- <select id="findCardListOfCUser" parameterType="com.iformall.domain.vo.WxCardCVo" resultMap="BaseResultMap">
- select
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date
- from wx_coupon_order co
- where co.coupon_type = 100
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test="cUserId != null">
- and co.c_user_id = #{cUserId}
- </if>
- <if test="ownerId != null">
- and co.owner_id = #{ownerId}
- </if>
- <if test="couponOrderStatus != null">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != statusS ">
- and co.coupon_order_status in
- <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
- #{sItem}
- </foreach>
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
- <select id="findCardDetailOfCUser" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.b_merchant_id,co.b_tenant_id,co.order_id,co.expired_time,co.coupon_order_status,
- co.create_date,co.update_date,co.coupon_price
- from wx_coupon_order co where co.id = #{id} and co.tenant_id = #{tenantId}
- </select>
-
- <update id="cardDefer" parameterType="map">
- update wx_coupon_order set coupon_order_status = 4,update_date = now(), expired_time= #{expireTime} where coupon_id = #{couponId} and tenant_id = #{tenantId} and coupon_order_status in (4, 5)
- </update>
-
- <select id="cardDeferCouponOrderId" parameterType="java.util.HashMap" resultType="java.lang.Long">
- select id from wx_coupon_order where coupon_id = #{couponId} and tenant_id = #{tenantId} and coupon_order_status in (4, 5)
- </select>
-
-
- <select id="findWriteOffCount" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer">
- select count(1)
- from wx_coupon_order co
- where co.`tenant_id` = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != couponType ">
- and co.`coupon_type` = #{couponType}
- </if>
- <if test=" null != couponOrderStatus ">
- and co.`coupon_order_status` = #{couponOrderStatus}
- </if>
- <if test=" null != sendMerchantId ">
- and co.`send_merchant_id` = #{sendMerchantId}
- </if>
- <if test=" null != startTime ">
- AND co.update_date >= #{startTime}
- </if>
- <if test=" null != endTime ">
- AND co.update_date <= #{endTime}
- </if>
- <if test=" null != bMerchantId">
- AND co.b_merchant_id = #{bMerchantId}
- </if>
- </select>
-
- <select id="findMerchantUserTradeList" parameterType="map" resultType="map">
- select count(co.b_merchant_id) AS consumeCountP,count(DISTINCT co.b_merchant_id) AS consumeCount,sum(co.coupon_price) AS tradeAmt, co.b_merchant_id as bMerchantId from
- wx_coupon_order co
- WHERE co.coupon_order_status = 1 and co.b_merchant_id is not null and co.b_merchant_id > 0
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="starttime != null">
- and co.create_date >= #{starttime}
- </if>
- <if test="endtime != null">
- and co.create_date <= #{endtime}
- </if>
- <if test=" null != bMerchantId">
- AND co.b_merchant_id = #{bMerchantId}
- </if>
- <if test=" null != bMerchantIdList">
- and co.b_merchant_id in
- <foreach collection="bMerchantIdList" index="index" item="bMerchantIdItem" open="(" separator="," close=")">
- #{bMerchantIdItem}
- </foreach>
- </if>
- group by co.b_merchant_id
- </select>
-
- <select id="findUserTradeList" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap">
- select co.create_date,co.coupon_id,co.c_user_id
- from wx_coupon_order co
- WHERE co.coupon_order_status=1
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="startTime != null">
- and co.create_date >= #{startTime}
- </if>
- <if test="endTime != null">
- and co.create_date <= #{endTime}
- </if>
- <if test=" null != bUserIdList">
- and co.b_user_id in
- <foreach collection="bUserIdList" index="index" item="bUserIdItem" open="(" separator="," close=")">
- #{bUserIdItem}
- </foreach>
- </if>
- <if test=" null != sortColumns">order by ${sortColumns}</if>
- <if test=" null == sortColumns">order by co.create_date desc</if>
- </select>
-
- <select id="findVerifiedUserIds" parameterType="java.util.HashMap" resultType="java.lang.Long">
- select distinct c_user_id from wx_coupon_order
- where `tenant_id` = #{tenantId}
- and coupon_order_status = 1
- and update_date >= #{verifiedStartTime}
- and update_date <= #{verifiedEndTime}
- </select>
-
- </mapper>
|