|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502 |
- <?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.WxCouponMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCoupon">
- <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="make_merchant_id" jdbcType="BIGINT" property="makeMerchantId"/>
- <result column="brand" jdbcType="BIGINT" property="brand"/>
- <result column="type" jdbcType="INTEGER" property="type"/>
- <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
- <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
- <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
- <result column="title" jdbcType="VARCHAR" property="title"/>
- <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
- <result column="item_group" jdbcType="VARCHAR" property="itemGroup"/>
- <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
- <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule"/>
- <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
- <result column="send_type" jdbcType="INTEGER" property="sendType"/>
- <result column="valid_type" jdbcType="INTEGER" property="validType"/>
- <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
- <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
- <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
- <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
- <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
- <result column="price" jdbcType="INTEGER" property="price"/>
- <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
- <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
- <result column="unit" jdbcType="INTEGER" property="unit"/>
- <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
- <result column="inventory" jdbcType="INTEGER" property="inventory"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="business" jdbcType="INTEGER" property="business"/>
- <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
- <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
- <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
- <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
- <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
- <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
- <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
- <result column="credit_price" jdbcType="INTEGER" property="creditPrice"/>
- <result column="credit_refund" jdbcType="INTEGER" property="creditRefund"/>
- <result column="is_del" property="isDel"/>
- <result column="put_apply_status" property="putApplyStatus"/>
- <result column="stock_apply_status" property="stockApplyStatus"/>
- <result column="cancle_apply_status" property="cancleApplyStatus"/>
- <result column="conditions" jdbcType="VARCHAR" property="conditions"/>
- <result column="approval_type" property="approvalType"/>
- <result column="password_support" property="passwordSupport"/>
- <result column="content_type" property="contentType"/>
- <result column="html" property="html"/>
- <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
- <result column="merchant_type" jdbcType="INTEGER" property="merchantType"/>
- <result column="product_type" jdbcType="INTEGER" property="productType"/>
- <result column="category_id" jdbcType="INTEGER" property="categoryId"/>
- <result column="goods_id" jdbcType="VARCHAR" property="goodsId"/>
-
- <result column="spu_id" jdbcType="VARCHAR" property="spuId"/>
- <result column="poi_status" jdbcType="INTEGER" property="poiStatus"/>
- <result column="status_desc" jdbcType="VARCHAR" property="statusDesc"/>
- <result column="last_status" jdbcType="INTEGER" property="lastStatus"/>
- <result column="last_status_desc" jdbcType="VARCHAR" property="lastStatusDesc"/>
- </resultMap>
- <resultMap id="statisMap" type="com.iformall.domain.vo.WxCouponStatisVo">
- <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="make_merchant_id" jdbcType="BIGINT" property="makeMerchantId"/>
- <result column="brand" jdbcType="BIGINT" property="brand"/>
- <result column="type" jdbcType="INTEGER" property="type"/>
- <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
- <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
- <result column="title" jdbcType="VARCHAR" property="title"/>
- <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
- <result column="item_group" jdbcType="VARCHAR" property="itemGroup"/>
- <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
- <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule"/>
- <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
- <result column="send_type" jdbcType="INTEGER" property="sendType"/>
- <result column="valid_type" jdbcType="INTEGER" property="validType"/>
- <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
- <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
- <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
- <result column="price" jdbcType="INTEGER" property="price"/>
- <result column="unit" jdbcType="INTEGER" property="unit"/>
- <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
- <result column="inventory" jdbcType="INTEGER" property="inventory"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="business" jdbcType="INTEGER" property="business"/>
- <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
- <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
- <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
- <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
- <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
- <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
- <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
-
- <result column="sale_count" property="saleCount"/>
- <result column="transfer_count" property="transferCount"/>
- <result column="sale_amount" property="saleAmount"/>
- <result column="sum_payment" property="sumPayment"/>
- <result column="press_count" property="pressSendCount"/>
- <result column="press_succ_count" property="pressSuccCount"/>
- <result column="join_count" property="pressJoinCount"/>
- <result column="sum_subsidy" property="sumSubsidy"/>
- <result column="payment_rate" property="paymentRate"/>
- <result column="change_rate" property="changeRate"/>
- <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
- <result column="merchant_type" jdbcType="INTEGER" property="merchantType"/>
- </resultMap>
-
- <sql id="allColumns">
- c.`id`,c.`tenant_id`,c.`parent_tenant_id`,c.`make_merchant_id`,c.`brand`,c.`type`,c.`cover_img`,c.`cover_picture`,c.`detail_picture`,
- c.`title`,c.`sub_title`,c.`item_group`,c.`sale_price`,c.`freight_price`,c.`use_price`,c.`use_limit_rule`,c.`use_limit_quantity`,c.`send_type`,
- c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.pick_start_date,c.pick_end_date,c.`valid_days`,c.`detail`,c.`price`,c.tail_price,c.orig_price,c.`unit`,c.`remain_inventory`,c.`inventory`,
- c.`remark`,c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`,c.`support_transfer`,c.`subsidy_num`,c.`subsidy_type`,
- c.`press_limit_num`, c.`press_limit_hours`, c.`auto_refund`,c.`credit_price`,c.`credit_refund`,c.`put_apply_status`,c.`stock_apply_status`,c.`cancle_apply_status`,
- c.`conditions`,c.approval_type,c.content_type,c.source_type,c.merchant_type,c.password_support,c.gift_list,c.product_type,c.category_id,c.goods_id
- </sql>
-
- <sql id="statusColumns">
- `id`,`remain_inventory`,`status`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and `id` = #{id}
- </if>
-
- <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 != makeMerchantId ">
- and `make_merchant_id` = #{makeMerchantId}
- </if>
-
- <if test=" null != brand ">
- and `brand` = #{brand}
- </if>
-
- <if test=" null != type ">
- and `type` = #{type}
- </if>
-
- <if test=" null != coverImg ">
- and `cover_img` like concat('%', #{coverImg},'%')
- </if>
-
- <if test=" null != title and ''!=title">
- and `title` like concat('%', #{title},'%')
- </if>
-
- <if test=" null != subTitle ">
- and `sub_title` like concat('%', #{subTitle},'%')
- </if>
-
- <if test=" null != salePrice ">
- and `sale_price` = #{salePrice}
- </if>
-
- <if test=" null != usePrice ">
- and `use_price` = #{usePrice}
- </if>
-
- <if test=" null != useLimitRule ">
- and `use_limit_rule` = #{useLimitRule}
- </if>
-
- <if test=" null != useLimitQuantity ">
- and `use_limit_quantity` = #{useLimitQuantity}
- </if>
-
- <if test=" null != sendType ">
- and `send_type` = #{sendType}
- </if>
-
- <if test=" null != validType ">
- and `valid_type` = #{validType}
- </if>
-
- <if test=" null != validStartDate ">
- and `valid_start_date` = #{validStartDate}
- </if>
-
- <if test=" null != validEndDate ">
- and `valid_end_date` = #{validEndDate}
- </if>
-
- <if test=" null != validDays ">
- and `valid_days` = #{validDays}
- </if>
-
- <if test=" null != detail ">
- and `detail` like concat('%', #{detail},'%')
- </if>
-
- <if test=" null != price ">
- and `price` = #{price}
- </if>
-
- <if test=" null != unit ">
- and `unit` = #{unit}
- </if>
-
- <if test=" null != remainInventory ">
- and `remain_inventory` = #{remainInventory}
- </if>
-
- <if test=" null != inventory ">
- and `inventory` = #{inventory}
- </if>
-
- <if test=" null != remark ">
- and `remark` like concat('%', #{remark},'%')
- </if>
-
- <if test=" null != status">
- and `status` = #{status}
- </if>
-
- <if test=" null != startdate and null!=enddate">
- and `create_date` between #{startdate} and #{enddate}
- </if>
-
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
- </if>
-
- <if test=" null != business ">
- and `business` = #{business}
- </if>
-
- <if test=" null != subBusiness ">
- and `sub_business` = #{subBusiness}
- </if>
-
- <if test=" null != supportTransfer ">
- and `support_transfer` = #{supportTransfer}
- </if>
-
- <if test=" null != subsidyType ">
- and `subsidy_type` = #{subsidyType}
- </if>
-
- <if test=" null != subsidyNum ">
- and `subsidy_num` = #{subsidyNum}
- </if>
-
- <if test=" null != pressLimitNum ">
- and `press_limit_num` = #{pressLimitNum}
- </if>
-
- <if test=" null != pressLimitHours ">
- and `press_limit_hours` = #{pressLimitHours}
- </if>
-
- <if test=" null != autoRefund ">
- and `auto_refund` = #{autoRefund}
- </if>
-
- <if test=" null != creditPrice ">
- and `credit_price` = #{creditPrice}
- </if>
- <if test=" null != userCredit ">
- and `credit_price` <= #{userCredit}
- </if>
-
- <if test=" null != creditRefund ">
- and `credit_refund` = #{creditRefund}
- </if>
-
- <if test=" 1 == filterCanPut ">
- and `credit_refund` = #{creditRefund}
- </if>
-
- <if test=" null != contentType ">
- and `content_type` = #{contentType}
- </if>
-
- <if test=" null != putApplyStatus and putApplyStatus == 2">
- and `put_apply_status` = #{putApplyStatus}
- </if>
- <if test=" null != putApplyStatus and putApplyStatus == -1">
- and `put_apply_status` != 2
- </if>
-
- <if test=" null != stockApplyStatus ">
- and `stock_apply_status` = #{stockApplyStatus}
- </if>
-
- <if test=" null != cancleApplyStatus ">
- and `cancle_apply_status` = #{cancleApplyStatus}
- </if>
-
- <if test=" null != sourceType ">
- and `source_type` = #{sourceType}
- </if>
-
- <if test=" null != merchantType ">
- and `merchant_type` = #{merchantType}
- </if>
-
- <if test=" null != giftList">
- and JSON_CONTAINS(gift_list,json_array(#{giftList}))
- </if>
-
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
-
- <if test=" null != notinTypes ">
- and type not in
- <foreach collection="notinTypes" index="index" item="ntypeItem" open="(" separator="," close=")">
- #{ntypeItem}
- </foreach>
- </if>
-
- <if test=" null != types ">
- and type in
- <foreach collection="types" index="index" item="typeItem" open="(" separator="," close=")">
- #{typeItem}
- </foreach>
- </if>
-
- <if test=" null != sortColumns">order by ${sortColumns}</if>
- </sql>
-
-
- <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select <include refid="allColumns"/> ,c.html from wx_coupon c where id = #{id} and tenant_id = #{tenantId}
- </select>
-
- <resultMap id="AttrsResultMap" type="com.iformall.domain.po.WxCoupon">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="product_type" jdbcType="INTEGER" property="productType"/>
- <result column="category_id" jdbcType="INTEGER" property="categoryId"/>
- <result column="product_attrs" jdbcType="VARCHAR" property="productAttrs"/>
- <result column="sku_attrs" jdbcType="VARCHAR" property="skuAttrs"/>
- </resultMap>
-
- <select id="getAttrsById" parameterType="java.util.HashMap" resultMap="AttrsResultMap">
- select id,product_type,category_id,product_attrs,sku_attrs
- from wx_coupon where id = #{id} and tenant_id = #{tenantId}
- </select>
-
- <select id="getPriceAndStock" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select c.id,c.sale_price,c.price,c.remain_inventory,c.inventory,c.credit_price from wx_coupon c where id = #{id} and tenant_id = #{tenantId}
- </select>
-
- <select id="batchGetPriceAndStock" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select c.id,c.sale_price,c.price,c.remain_inventory,c.inventory,c.credit_price from wx_coupon c where tenant_id = #{tenantId}
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </select>
-
- <select id="findTenantSimpleList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
- select id,title,sale_price,use_price,price,tail_price,orig_price,auto_refund,business,subsidy_type,source_type,merchant_type,type,unit,cover_img,
- sub_title,item_group,valid_type,valid_start_date,valid_end_date,pick_start_date,pick_end_date
- from wx_coupon c where c.`tenant_id` = #{tenantId}
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != types ">
- and type in
- <foreach collection="types" index="index" item="typeItem" open="(" separator="," close=")">
- #{typeItem}
- </foreach>
- </if>
- </select>
-
- <select id="findSimpleDetail" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
- select c.id,c.type,c.cover_img,c.title,c.sub_title,c.item_group,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.detail,c.remark,c.valid_type,c.valid_start_date,
- c.valid_end_date,c.pick_start_date,c.pick_end_date,c.auto_refund,c.business,c.subsidy_type,c.source_type,c.merchant_type,c.content_type,c.gift_list,c.support_transfer,c.subsidy_num
- from wx_coupon c where c.id = #{id} and c.`tenant_id` = #{tenantId}
- </select>
-
- <select id="findCouponCVoDetail" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
- select c.id,c.type,c.cover_img,c.cover_picture,c.detail_picture,c.title,c.sub_title,c.item_group,c.sale_price,c.use_price,
- c.use_limit_rule,c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,
- c.valid_days,c.detail,c.price,c.tail_price,c.orig_price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,
- c.create_date,c.update_date,c.business,c.sub_business,c.support_transfer,c.press_limit_num, c.auto_refund,c.credit_price,c.conditions,c.content_type
- from wx_coupon c where c.id = #{id} and c.`tenant_id` = #{tenantId}
- </select>
-
-
-
- <select id="findSimpleDetailList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
- select c.id,c.type,c.cover_img,c.title,c.sub_title,c.item_group,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.detail,c.remark,c.valid_type,c.valid_start_date,
- c.valid_end_date,c.pick_start_date,c.pick_end_date,c.auto_refund,c.business,c.subsidy_type,c.source_type,c.merchant_type,c.content_type
- from wx_coupon c
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="findIdList" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
- select id
- from wx_coupon c
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="findSendCouponIds" parameterType="java.util.HashMap" resultType="Long">
- select id
- from wx_coupon where `tenant_id` = #{tenantId}
- and ((valid_type=1
- <choose>
- <when test="expired == 0">
- and <![CDATA[ valid_end_date >= now() ]]>
- </when>
- <when test="expired == 1">
- and <![CDATA[ valid_end_date < now() ]]>
- </when>
- <otherwise>
- </otherwise>
- </choose>
- )
- <choose>
- <when test="expired == 0">
- or <![CDATA[ valid_type = 2 ]]>
- </when>
- <when test="expired == 1">
- </when>
- <otherwise>
- or <![CDATA[ valid_type = 2 ]]>
- </otherwise>
- </choose>
- )
- </select>
-
- <select id="findSendCouponList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
- select
- c.id,c.remain_inventory, c.use_limit_rule,c.use_limit_quantity, c.inventory, c.valid_start_date, c.valid_end_date,c.valid_type,c.valid_days
- from wx_coupon c where c.`tenant_id` = #{tenantId}
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </select>
-
- <delete id="deleteById" parameterType="java.util.HashMap">
- update wx_coupon set is_del = 1 where id = #{id} and tenant_id = #{tenantId}
- </delete>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_coupon c
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <update id="updateStockAndValidDate" parameterType="com.iformall.domain.po.WxCoupon">
- update wx_coupon
- SET
- `remain_inventory` = #{remainInventory}, `inventory` = #{inventory},
- `valid_type` = #{validType}, `valid_end_date` = #{validEndDate}, `valid_days` = #{validDays}
- 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} and `remain_inventory` = #{orgRemainInventory} and `inventory` = #{orgInventory}
- </update>
-
-
- <sql id="dynamicWhereConditionsForCoupon">
-
- <if test=" null != id ">
- and c.`id` = #{id}
- </if>
-
- <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 != type ">
- and c.`type` = #{type}
- </if>
-
- <if test=" null != coverImg ">
- and c.`cover_img` like concat('%', #{coverImg},'%')
- </if>
-
- <if test=" null != title and ''!=title">
- and c.`title` like concat('%', #{title},'%')
- </if>
-
- <if test=" null != subTitle ">
- and c.`sub_title` like concat('%', #{subTitle},'%')
- </if>
-
- <if test=" null != salePrice ">
- and c.`sale_price` = #{salePrice}
- </if>
-
- <if test=" null != usePrice ">
- and c.`use_price` = #{usePrice}
- </if>
-
- <if test=" null != useLimitRule ">
- and c.`use_limit_rule` = #{useLimitRule}
- </if>
-
- <if test=" null != useLimitQuantity ">
- and c.`use_limit_quantity` = #{useLimitQuantity}
- </if>
-
- <if test=" null != sendType ">
- and c.`send_type` = #{sendType}
- </if>
-
- <if test=" null != validType ">
- and c.`valid_type` = #{validType}
- </if>
-
- <if test=" null != validStartDate ">
- and c.`valid_start_date` = #{validStartDate}
- </if>
-
- <if test=" null != validEndDate ">
- and c.`valid_end_date` = #{validEndDate}
- </if>
-
- <if test=" null != validDays ">
- and c.`valid_days` = #{validDays}
- </if>
-
- <if test=" null != detail ">
- and c.`detail` like concat('%', #{detail},'%')
- </if>
-
- <if test=" null != price ">
- and c.`price` = #{price}
- </if>
-
- <if test=" null != unit ">
- and c.`unit` = #{unit}
- </if>
-
- <if test=" null != remainInventory ">
- and c.`remain_inventory` = #{remainInventory}
- </if>
-
- <if test=" null != inventory ">
- and c.`inventory` = #{inventory}
- </if>
-
- <if test=" null != remark ">
- and c.`remark` like concat('%', #{remark},'%')
- </if>
-
- <if test=" null != status">
- and c.`status` = #{status}
- </if>
-
- <if test=" null != startdate and null!=enddate">
- and c.`create_date` between #{startdate} and #{enddate}
- </if>
-
- <if test=" null != updateDate ">
- and c.`update_date` = #{updateDate}
- </if>
-
- <if test=" null != business ">
- and c.`business` = #{business}
- </if>
-
- <if test=" null != subBusiness ">
- and c.`sub_business` = #{subBusiness}
- </if>
-
- <if test=" null != supportTransfer ">
- and c.`support_transfer` = #{supportTransfer}
- </if>
-
- <if test=" null != subsidyType ">
- and c.`subsidy_type` = #{subsidyType}
- </if>
-
- <if test=" null != subsidyNum ">
- and c.`subsidy_num` = #{subsidyNum}
- </if>
-
- <if test=" null != pressLimitNum ">
- and c.`press_limit_num` = #{pressLimitNum}
- </if>
-
- <if test=" null != pressLimitHours ">
- and c.`press_limit_hours` = #{pressLimitHours}
- </if>
-
- <if test=" null != autoRefund ">
- and c.`auto_refund` = #{autoRefund}
- </if>
-
- <if test=" null != contentType ">
- and c.`content_type` = #{contentType}
- </if>
-
- <if test=" null != putApplyStatus and putApplyStatus == 2">
- and c.`put_apply_status` = #{putApplyStatus}
- </if>
- <if test=" null != putApplyStatus and putApplyStatus == -1">
- and c.`put_apply_status` != 2
- </if>
-
- <if test=" null != stockApplyStatus ">
- and c.`stock_apply_status` = #{stockApplyStatus}
- </if>
-
- <if test=" null != cancleApplyStatus ">
- and c.`cancle_apply_status` = #{cancleApplyStatus}
- </if>
-
- <if test=" null != sourceType ">
- and c.`source_type` = #{sourceType}
- </if>
-
- <if test=" null != merchantType ">
- and c.`merchant_type` = #{merchantType}
- </if>
-
- <if test=" null != giftList">
- and JSON_CONTAINS(c.gift_list,json_array(#{giftList}))
- </if>
-
- <if test=" null != targetAd ">
- and 0 = (select count(*) from wx_coupon_channel cc
- where c.`id` = cc.coupon_id
- and cc.status = 0
- and cc.target_ad = #{targetAd})
- </if>
-
- <if test=" null != ids ">
- and c.id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
-
- <if test=" null != types ">
- and c.type in
- <foreach collection="types" index="index" item="typesItem" open="(" separator="," close=")">
- #{typesItem}
- </foreach>
- </if>
-
- <if test=" null != sendTypes ">
- and c.send_type in
- <foreach collection="sendTypes" index="index" item="typesItem" open="(" separator="," close=")">
- #{typesItem}
- </foreach>
- </if>
-
- </sql>
-
- <select id="findCouponList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- <if test="plat != null and plat == 3">
- ,poi.spu_id,poi.status poi_status,poi.status_desc,poi.last_status,poi.last_status_desc
- </if>
- from wx_coupon c
- <if test="plat != null and plat == 3">
- left join tt_coupon_channel_poi poi on poi.id = c.id
- </if>
- where c.is_del = 0
- <if test="plat != null and plat == 3">
- <if test=" null != spuId and '' != spuId">
- and poi.`spu_id` = #{spuId}
- </if>
-
- <if test=" null != poiStatus">
- and poi.`status` = #{poiStatus}
- </if>
-
- <if test=" null != lastStatus">
- and poi.`last_status` = #{lastStatus}
- </if>
- </if>
- <include refid="dynamicWhereConditionsForCoupon"/>
- <if test=" null != sortColumns">order by ${sortColumns}</if>
-
- <if test="null != limitStart and null != limitEnd">
- limit #{limitStart},#{limitEnd}
- </if>
- </select>
-
- <select id="findCouponListCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Integer">
- select
- count(c.id)
- from wx_coupon c
- <if test="plat != null and plat == 3">
- left join tt_coupon_channel_poi poi on poi.id = c.id
- </if>
- where c.is_del = 0
- <if test="plat != null and plat == 3">
- <if test=" null != spuId and '' != spuId">
- and poi.`spu_id` = #{spuId}
- </if>
-
- <if test=" null != poiStatus">
- and poi.`status` = #{poiStatus}
- </if>
-
- <if test=" null != lastStatus">
- and poi.`last_status` = #{lastStatus}
- </if>
- </if>
- <include refid="dynamicWhereConditionsForCoupon"/>
- </select>
-
- <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo">
- <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="type" jdbcType="INTEGER" property="type"/>
- <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
- <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
- <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
- <result column="title" jdbcType="VARCHAR" property="title"/>
- <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
- <result column="item_group" jdbcType="VARCHAR" property="itemGroup"/>
- <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
- <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule"/>
- <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
- <result column="send_type" jdbcType="INTEGER" property="sendType"/>
- <result column="valid_type" jdbcType="INTEGER" property="validType"/>
- <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
- <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
- <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
- <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
- <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
- <result column="price" jdbcType="INTEGER" property="price"/>
- <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
- <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
- <result column="unit" jdbcType="INTEGER" property="unit"/>
- <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
- <result column="inventory" jdbcType="INTEGER" property="inventory"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="business" jdbcType="INTEGER" property="business"/>
- <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
- <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
- <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
- <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
- <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
- <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
- <result column="conditions" jdbcType="VARCHAR" property="conditions"/>
- <result column="content_type" jdbcType="INTEGER" property="contentType"/>
- <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
- <result column="merchant_type" jdbcType="INTEGER" property="merchantType"/>
-
- <result column="gift_list" jdbcType="VARCHAR" property="giftList"></result>
-
- <result column="product_type" jdbcType="INTEGER" property="productType"/>
- <result column="category_id" jdbcType="INTEGER" property="categoryId"/>
-
- </resultMap>
-
- <resultMap id="WxCouponCVoMapL" type="com.iformall.domain.vo.WxCouponCVo">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="type" jdbcType="INTEGER" property="type"/>
- <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
- <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
- <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
- <result column="title" jdbcType="VARCHAR" property="title"/>
- <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
- <result column="item_group" jdbcType="VARCHAR" property="itemGroup"/>
- <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
- <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule"/>
- <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
- <result column="send_type" jdbcType="INTEGER" property="sendType"/>
- <result column="valid_type" jdbcType="INTEGER" property="validType"/>
- <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
- <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
- <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
- <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
- <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
- <result column="price" jdbcType="INTEGER" property="price"/>
- <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
- <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
- <result column="unit" jdbcType="INTEGER" property="unit"/>
- <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
- <result column="inventory" jdbcType="INTEGER" property="inventory"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="business" jdbcType="INTEGER" property="business"/>
- <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
- <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
- <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
- <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
- <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
- <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
- <result column="conditions" jdbcType="VARCHAR" property="conditions"/>
- <result column="content_type" jdbcType="INTEGER" property="contentType"/>
- <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
- <result column="merchant_type" jdbcType="INTEGER" property="merchantType"/>
- </resultMap>
-
- <select id="findVoDetail" parameterType="java.util.HashMap" resultMap="WxCouponCVoMap">
- select
- <include refid="allColumns"/>
- from wx_coupon c
- where id = #{id} and tenant_id =#{tenantId}
- </select>
-
- <select id="findVoStatusDetail" parameterType="java.util.HashMap" resultMap="WxCouponCVoMapL">
- select id, remain_inventory, status
- from wx_coupon
- where id = #{id} and tenant_id =#{tenantId}
- </select>
-
- <update id="reduceInventory">
- update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory - #{number} >= 0
- </update>
-
- <update id="backInventory">
- update wx_coupon SET remain_inventory = remain_inventory + #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory + #{number} <= inventory
- </update>
-
- <update id="offExpiriedCouponByValidDate" parameterType="String">
- update wx_coupon SET status = 1, update_date = now()
- where status = 0 and tenant_id =#{tenantId} and valid_type = 1 and valid_end_date < now()
- </update>
-
- <update id="offExpiriedCouponByMerchantStatus" parameterType="HashMap">
- update wx_coupon c
- SET c.status = 1, c.update_date = now()
- where c.status = 0 and c.tenant_id =#{tenantId}
- <!-- type=12 礼包卷没有门店 -->
- and c.type != 12
- <if test=" null != validIds ">
- and c.id not in
- <foreach collection="validIds" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </update>
-
- <select id="getValidMerchantProductIds" resultType="Long">
- select cm.product_id from wx_coupon_merchant cm, wx_merchant m
- where m.id = cm.merchant_id
- and cm.status = 0
- and m.status = 1
- </select>
-
- <select id="findSaleMoneyByDate"
- resultType="com.iformall.domain.vo.WxCouponStatisVo">
- select DATE_FORMAT(ci.create_date,'%Y-%m-%d') xtime,sum(round(ci.sale_amount/100,2)) xcount from wx_card_info ci
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) c on c.id = ci.coupon_id
- where c.type = 100
- and ci.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- group by xtime
- </select>
-
- <select id="findPaymentByDate"
- resultType="com.iformall.domain.vo.WxCouponStatisVo">
- select DATE_FORMAT(wcs.create_date,'%Y-%m-%d') xtime,sum(round(wcs.real_payment/100,2)) xcount from wx_card_info ci
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) c on c.id = ci.coupon_id
- left join wx_card_spend wcs on wcs.card_id = ci.id
- where c.type = 100
- and wcs.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- group by xtime
- </select>
-
- <select id="findSaleCardCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
- select count(co.id)
- from wx_card_info ci
- left join wx_coupon c on c.id = ci.coupon_id
- left join wx_coupon_order co on co.id = ci.id
- where c.type = 100
- and co.create_date between #{startdate} and #{enddate}
- </select>
-
- <select id="findTranCardCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
- select count(distinct wcs.coupon_order_id) from wx_card_info ci
- left join wx_coupon c on c.id = ci.coupon_id
- left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
- where c.type = 100 and wcs.create_date between #{startdate} and #{enddate}
- </select>
-
- <select id="findSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
- select sum(round(sc.subsidy/100,2)) from wx_card_info ci
- left join wx_coupon c on c.id = ci.coupon_id
- left join wx_merchant_subsidy sc on sc.coupon_order_id = ci.id
- where c.type = 100 and sc.create_date between #{startdate} and #{enddate}
- </select>
-
- <select id="findCountData" resultMap="statisMap">
- select c.*,
- IFNULL(round((select sum(wcs.real_payment) from wx_card_info ci
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc on wc.id = ci.coupon_id
- left join wx_card_spend wcs on wcs.card_id = ci.id
- where wc.id = c.id)/(select sum(ci.sale_amount) from wx_card_info ci
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc on wc.id = ci.coupon_id
- where wc.id = c.id)*100,2),0) payment_rate,
-
- (select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wco on wc.id = wco.coupon_id
- where wc.id = c.id) as sale_count,
-
- (select count(distinct wcs.coupon_order_id) from wx_card_info ci
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc on wc.id = ci.coupon_id
- left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
- where wc.id = c.id) as transfer_count,
-
- (select sum(ci.sale_amount) from wx_card_info ci
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc on wc.id = ci.coupon_id
- where wc.id = c.id) as sale_amount,
-
- (select sum(wcs.real_payment) from wx_card_info ci
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc on wc.id = ci.coupon_id
- left join wx_card_spend wcs on wcs.card_id = ci.id
- where wc.id = c.id) as sum_payment,
-
- (select sum(sc.subsidy) from wx_card_info ci
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc on wc.id = ci.coupon_id
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_merchant_subsidy${tenantEntity.shardTableSuffix}
- </foreach>) sc on sc.coupon_order_id = ci.id
- where wc.id = c.id) as sum_subsidy
-
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) c where c.type = 100
- <if test="wxCoupon.title != null and wxCoupon.title !=''">
- and c.title like concat('%', #{wxCoupon.title},'%')
- </if>
- <if test="wxCoupon.id != null">
- and c.id = #{wxCoupon.id}
- </if>
- <if test=" null != wxCoupon.sortColumns">order by ${wxCoupon.sortColumns}</if>
- <if test=" null == wxCoupon.sortColumns">order by c.status asc,c.create_date desc</if>
-
- </select>
-
- <select id="findCouponData" resultMap="statisMap">
- select c.*,
- IFNULL(round((select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wco where wco.coupon_id = wc.id and
- wco.coupon_order_status = 1 and wc.id = c.id)/(select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wco where wco.coupon_id
- = c.id)*100,2),0) payment_rate,
- (select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wco where wco.coupon_id = c.id) as sale_count,
- (select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wco where wco.coupon_id = wc.id and
- wco.coupon_order_status = 1 and wc.id = c.id) as sum_payment,
- (select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wco where wco.coupon_id = wc.id and
- wco.coupon_order_status = 3 and wc.id = c.id) as backpay_count,
- (select sum(sc.subsidy) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wo on wo.coupon_id = wc.id
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_merchant_subsidy${tenantEntity.shardTableSuffix}
- </foreach>) sc on sc.coupon_order_id = wo.id
- where wc.id = c.id) as sum_subsidy
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) c where c.type not in(8,9,100)
- <if test=" 1 == wxCoupon.type ">
- and c.sale_price > 0
- </if>
- <if test=" 2 == wxCoupon.type ">
- and c.sale_price = 0
- </if>
- <if test="wxCoupon.title != null and wxCoupon.title != ''">
- and c.title like concat('%', #{wxCoupon.title},'%')
- </if>
- <if test="wxCoupon.id != null">
- and c.id = #{wxCoupon.id}
- </if>
- <if test=" null != wxCoupon.sortColumns">order by ${wxCoupon.sortColumns}</if>
- <if test=" null == wxCoupon.sortColumns">order by c.status asc,c.create_date desc</if>
- </select>
-
- <select id="findPressData" resultMap="statisMap">
- select c.id,c.tenant_id, c.`cover_img`,c.`title`,c.`sale_price`,c.`freight_price`,c.`price`,
- ifnull(op.press_count,0) as press_count,
- ifnull(o.press_succ_count,0) as press_succ_count,
- ifnull(op2.join_count,0) as join_count,
- ifnull(round(o.press_succ_count/op.press_count*100,2),0) as change_rate,
- ifnull(round(cop.xCount/op.press_count*100,2),0) as payment_rate
- FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) c
- left join (SELECT count(id) as press_count, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
- </foreach>) wx_order_press WHERE `first` = 1
- <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
- and `tenant_id` = #{wxCoupon.tenantId}
- </if>
- <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
- and `parent_tenant_id` = #{wxCoupon.parentTenantId}
- </if>
- group by coupon_id) op on op.coupon_id = c.id
- left join (SELECT count(id) as press_succ_count, product_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order${tenantEntity.shardTableSuffix}
- </foreach>) wx_order WHERE order_status = 1
- <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
- and `tenant_id` = #{wxCoupon.tenantId}
- </if>
- <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
- and `parent_tenant_id` = #{wxCoupon.parentTenantId}
- </if>
- group by product_id) o on o.product_id = c.id
- left join (SELECT count(id) as join_count, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
- </foreach>) wx_order_press WHERE 1=1
- <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
- and `tenant_id` = #{wxCoupon.tenantId}
- </if>
- <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
- and `parent_tenant_id` = #{wxCoupon.parentTenantId}
- </if>
- group by coupon_id) op2 on op2.coupon_id = c.id
- left join (SELECT count(id) as xCount, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wx_coupon_order WHERE coupon_order_status = 1
- <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
- and `tenant_id` = #{wxCoupon.tenantId}
- </if>
- <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
- and `parent_tenant_id` = #{wxCoupon.parentTenantId}
- </if>
- group by coupon_id) cop on cop.coupon_id = c.id
- where c.type = 8
-
- <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
- and c.`tenant_id` = #{wxCoupon.tenantId}
- </if>
- <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
- and c.`parent_tenant_id` = #{wxCoupon.parentTenantId}
- </if>
- <if test="wxCoupon.id != null">
- and c.id = #{wxCoupon.id}
- </if>
- <if test="wxCoupon.title != null and wxCoupon.title != ''">
- and c.title like concat('%', #{wxCoupon.title},'%')
- </if>
- <if test=" null != wxCoupon.startdate and null!=wxCoupon.enddate">
- and c.`create_date` between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- </if>
-
- <if test=" null != wxCoupon.sortColumns">order by ${wxCoupon.sortColumns}</if>
- <if test=" null == wxCoupon.sortColumns">order by c.status asc,c.create_date desc</if>
- </select>
-
- <select id="findCouponOrderCount"
- resultType="com.iformall.domain.vo.WxCouponStatisVo">
- select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) c
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wco on c.id = wco.coupon_id
- where c.type not in(8,9,100)
- and wco.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- group by xtime
- </select>
-
-
- <select id="findCouponPaymentCount"
- resultType="com.iformall.domain.vo.WxCouponStatisVo">
- select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) c,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wco
- where c.type not in(8,9,100)
- and wco.coupon_id = c.id and wco.coupon_order_status = 1
- and wco.update_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- group by xtime
- </select>
-
- <select id="priceCouponSaleCount"
- resultType="com.iformall.domain.vo.WxCouponStatisVo">
- select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) c,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wco
- where c.type not in(8,9,100)
- and wco.coupon_id = c.id and wco.coupon_price > 0
- and wco.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- group by xtime
- </select>
-
- <select id="priceCouponPaymentCount"
- resultType="com.iformall.domain.vo.WxCouponStatisVo">
- select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) c,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wco
- where c.type not in(8,9,100)
- and wco.coupon_id = c.id and wco.coupon_order_status = 1 and wco.coupon_price > 0
- and wco.update_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- group by xtime
- </select>
-
- <select id="findSumPriceSaleMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
- select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
- where wco.coupon_id = c.id and wco.coupon_price > 0
- and wco.create_date between #{startdate} and #{enddate}
- </select>
-
- <select id="findSumPricePayMent" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
- select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
- where wco.coupon_id = c.id and wco.coupon_price > 0 and wco.coupon_order_status = 1
- and wco.update_date between #{startdate} and #{enddate}
- </select>
-
- <select id="findSumSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
- select sum(round(sc.subsidy/100,2)) from wx_coupon c
- left join wx_coupon_order wo on wo.coupon_id = c.id
- left join wx_merchant_subsidy sc on sc.coupon_order_id = wo.id
- where c.type not in(8,9,100) and wo.coupon_order_status = 1
- and sc.create_date between #{startdate} and #{enddate}
- </select>
-
-
- <!--砍价-->
- <select id="pressSendHistory"
- resultType="com.iformall.domain.vo.WxCouponStatisVo">
- select DATE_FORMAT(wop.create_date,'%Y-%m-%d') xtime,count(wop.id) xcount from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order${tenantEntity.shardTableSuffix}
- </foreach>) wo on wo.product_id = wc.id
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
- </foreach>) wop on wop.order_id = wo.id
- where wc.type = 8 and wop.first = 1 and
- wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- group by xtime
- </select>
- <select id="pressSuccHistory"
- resultType="com.iformall.domain.vo.WxCouponStatisVo">
- select DATE_FORMAT(wo.create_date,'%Y-%m-%d') xtime,count(wo.id) xcount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order${tenantEntity.shardTableSuffix}
- </foreach>) wo on wo.product_id = wc.id
- where wc.type = 8 and wo.order_status = 1
- and wo.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- group by xtime
- </select>
- <select id="pressPaymentHistory"
- resultType="com.iformall.domain.vo.WxCouponStatisVo">
- select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wco on wco.coupon_id = wc.id
- where wc.type = 8 and wco.coupon_order_status = 1
- and wco.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- group by xtime
- </select>
- <select id="pressSuccRate" resultType="java.lang.String">
- select
- round(
- (select count(wo.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order${tenantEntity.shardTableSuffix}
- </foreach>) wo on wo.product_id = wc.id
- where wo.order_status = 1 and wc.type = 8
- and wo.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- )
- /
- (select count(wop.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order${tenantEntity.shardTableSuffix}
- </foreach>) wo on wo.product_id = wc.id
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
- </foreach>) wop on wop.order_id = wo.id
- where wop.first = 1 and wc.type = 8
- and wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- )
- * 100
- ,2)
- </select>
- <select id="sumJoin" resultType="Long">
- select count(wop.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) wc
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order${tenantEntity.shardTableSuffix}
- </foreach>) wo on wo.product_id = wc.id
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
- </foreach>) wop on wop.order_id = wo.id
- where wc.type = 8
- and wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- </select>
-
- <select id="priceCouponCancelCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
- select count(c.id) from wx_coupon c
- left join wx_coupon_order wco on c.id = wco.coupon_id
- where c.type not in(8,9,100)
- and wco.create_date between #{startdate} and #{enddate}
- and wco.coupon_order_status = 3
- </select>
-
- <select id="findSaleCardCountHistory"
- resultType="com.iformall.domain.vo.WxCouponStatisVo">
- select DATE_FORMAT(co.create_date,'%Y-%m-%d') xtime,count(co.id) xcount
- from wx_card_info ci
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) c on c.id = ci.coupon_id
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) co on co.id = ci.id
- where c.type = 100
- and co.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
- group by xtime
- </select>
-
- <select id="findCouponByTopic" parameterType="com.iformall.domain.po.WxTopic"
- resultType="com.iformall.domain.po.WxCoupon">
- select ct.id as id,wc.id as couponId,
- wc.tenant_id,wc.parent_tenant_id,wc.`type`,wc.`cover_img`,wc.`cover_picture`,wc.`detail_picture`,wc.`title`,wc.`sub_title`,wc.`item_group`,wc.`sale_price`,wc.`freight_price`,wc.`use_price`,wc.`use_limit_rule`,wc.`use_limit_quantity`,wc.`send_type`,
- wc.`valid_type`,wc.`valid_start_date`,wc.`valid_end_date`,wc.pick_start_date,wc.pick_end_date,wc.`valid_days`,wc.`detail`,wc.`price`,wc.tail_price,wc.orig_price,wc.`unit`,wc.`remain_inventory`,wc.`inventory`,
- wc.`remark`,wc.`status`,wc.`create_date`,wc.`update_date`,wc.`business`,wc.`sub_business`,wc.`support_transfer`,wc.`subsidy_num`,wc.`subsidy_type`,
- wc.`press_limit_num`, wc.`press_limit_hours`, wc.`auto_refund`,wc.`credit_price`,wc.`credit_refund`,wc.`conditions`,
- wc.title as couponName,wc.`cover_img` as couponPic,wc.`cover_picture` as couponPicture,wc.`detail_picture` as detailPicture,wc.id as couponId
- from wx_coupon_channel ct
- left join wx_coupon wc on wc.id = ct.coupon_id
- where ct.`sub_target_id` = #{id} and ct.status = 0
- </select>
-
- <select id="findCouponModel" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
- select
- max(case type when 9 then model_id else 0 end) couponModelId,
- max(case type when 10 then model_id else 0 end) cardModelId,
- max(case type when 11 then model_id else 0 end) groupModelId,
- max(case type when 12 then model_id else 0 end) pressModelId
- from wx_flow_config
- where type in(9,10,11,12)
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </select>
-
- <update id="updateValidEndDate" parameterType="com.iformall.domain.po.WxCoupon">
- update wx_coupon set valid_end_date = #{validEndDate} , update_date = #{updateDate} where id = #{id}
- </update>
-
- <select id="newfindCList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
- select id,remain_inventory,inventory,cover_img,title,sub_title,item_group,sale_price,use_price,price,tail_price,
- orig_price,unit,use_limit_rule,use_limit_quantity,send_type,support_transfer,press_limit_num,auto_refund,
- conditions,valid_type,valid_start_date,valid_end_date,pick_start_date,pick_end_date,valid_days,credit_price,
- content_type,source_type,merchant_type
- from wx_coupon where `tenant_id` = #{tenantId}
- <if test=" null != id ">
- and `id` = #{id}
- </if>
- <if test=" null != business ">
- and `business` = #{business}
- </if>
- <if test=" null != subBusiness ">
- and `sub_business` = #{subBusiness}
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </select>
-
- <select id="findIdsListHasConditons" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
- select c.id
- from wx_coupon c
- where c.`tenant_id` = #{tenantId} and c.conditions is not null
- /*and JSON_EXTRACT(c.conditions, '$.type') = 1*/
- <if test=" null != parentTenantId and '' != parentTenantId">
- and c.`parent_tenant_id` = #{parentTenantId}
- </if>
- </select>
-
-
- <resultMap id="TtCouponVoResultMap" type="com.iformall.domain.vo.TtCouponVo">
- <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="type" jdbcType="INTEGER" property="type"/>
- <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
- <result column="title" jdbcType="VARCHAR" property="title"/>
- <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
- <result column="send_type" jdbcType="INTEGER" property="sendType"/>
- <result column="valid_type" jdbcType="INTEGER" property="validType"/>
- <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
- <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
- <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
- <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
- <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
- <result column="price" jdbcType="INTEGER" property="price"/>
- <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
- <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
- <result column="unit" jdbcType="INTEGER" property="unit"/>
- <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
- <result column="inventory" jdbcType="INTEGER" property="inventory"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="business" jdbcType="INTEGER" property="business"/>
- <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
- <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
- <result column="credit_price" jdbcType="INTEGER" property="creditPrice"/>
- <result column="credit_refund" jdbcType="INTEGER" property="creditRefund"/>
- <result column="content_type" property="contentType"/>
- <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
- <result column="merchant_type" jdbcType="INTEGER" property="merchantType"/>
- <result column="product_type" jdbcType="INTEGER" property="productType"/>
- <result column="category_id" jdbcType="INTEGER" property="categoryId"/>
-
- <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
- <result column="spu_id" jdbcType="VARCHAR" property="spuId"/>
- <result column="poi_status" jdbcType="INTEGER" property="poiStatus"/>
- <result column="status_desc" jdbcType="VARCHAR" property="statusDesc"/>
- <result column="last_status" jdbcType="INTEGER" property="lastStatus"/>
- <result column="last_status_desc" jdbcType="VARCHAR" property="lastStatusDesc"/>
- </resultMap>
-
-
- <select id="ttCouponList" parameterType="com.iformall.domain.vo.TtCouponVo" resultMap="TtCouponVoResultMap">
- select c.`id`,c.`tenant_id`,c.`parent_tenant_id`,c.`type`,c.`cover_img`,
- c.`title`,c.`sub_title`,c.`sale_price`,c.`freight_price`,c.`send_type`,
- c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.pick_start_date,c.pick_end_date,
- c.`valid_days`,c.`price`,c.tail_price,c.orig_price,c.`unit`,c.`remain_inventory`,c.`inventory`,
- c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`,
- c.`auto_refund`,c.`credit_price`,c.`credit_refund`,
- c.content_type,c.source_type,c.merchant_type,c.product_type,c.category_id,
- poi.coupon_channel_id,poi.spu_id,poi.status poi_status,poi.status_desc,poi.last_status,poi.last_status_desc
- from wx_coupon c
- left join tt_coupon_channel_poi poi on poi.id = c.id
- where c.`type` = #{type}
-
- <if test=" null != id ">
- and c.`id` = #{id}
- </if>
-
- <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 != title and ''!=title">
- and c.`title` like concat('%', #{title},'%')
- </if>
-
- <if test=" null != sendType ">
- and c.`send_type` = #{sendType}
- </if>
-
- <if test=" null != status">
- and c.`status` = #{status}
- </if>
-
- <if test=" null != startdate and null!=enddate">
- and c.`create_date` between #{startdate} and #{enddate}
- </if>
-
- <if test=" null != sourceType ">
- and c.`source_type` = #{sourceType}
- </if>
-
- <if test=" null != merchantType ">
- and c.`merchant_type` = #{merchantType}
- </if>
-
- <if test=" null != couponChannelId ">
- and poi.`coupon_channel_id` = #{couponChannelId}
- </if>
-
- <if test=" null != spuId and '' != spuId">
- and poi.`spu_id` = #{spuId}
- </if>
-
- <if test=" null != poiStatus">
- and poi.`status` = #{poiStatus}
- </if>
-
- <if test=" null != lastStatus">
- and poi.`last_status` = #{lastStatus}
- </if>
-
- <if test=" null != sortColumns">order by ${sortColumns}</if>
- </select>
-
-
- <select id="findCategoryIdById" parameterType="java.util.HashMap" resultType="Integer">
- select category_id
- from wx_coupon
- where id = #{id}
- and tenant_id = #{tenantId}
- </select>
-
- <update id="setMakeMerchantId" parameterType="com.iformall.domain.po.WxCoupon" >
- update wx_coupon set make_merchant_id = #{makeMerchantId} where id = #{id} and tenant_id = #{tenantId}
- </update>
-
- </mapper>
|