|
@@ -1,6 +1,94 @@
|
|
|
<?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.caimei365.manager.dao.svip.CmSvipHistoryDao">
|
|
|
+ <sql id="cmCouponColumns">
|
|
|
+ a.id AS "id",
|
|
|
+ a.name AS "name",
|
|
|
+ a.couponAmount AS "couponAmount",
|
|
|
+ a.touchPrice AS "touchPrice",
|
|
|
+ a.startDate AS "startDate",
|
|
|
+ a.endDate AS "endDate",
|
|
|
+ a.status AS "status",
|
|
|
+ a.couponType AS "couponType",
|
|
|
+ a.vipFlag AS "vipFlag",
|
|
|
+ a.userId AS "userId",
|
|
|
+ a.shopId AS "shopId",
|
|
|
+ a.productType AS "productType",
|
|
|
+ a.pcBanner AS "pcBanner",
|
|
|
+ a.appletsBanner AS "appletsBanner",
|
|
|
+ a.categoryType AS "categoryType",
|
|
|
+ a.couponsMode AS "couponsMode",
|
|
|
+ a.createDate AS "createDate",
|
|
|
+ a.delFlag AS "delFlag"
|
|
|
+ </sql>
|
|
|
+ <sql id="newCmShopColumns">
|
|
|
+ a.shopID AS "shopID",
|
|
|
+ a.checkMan as "checkMan",
|
|
|
+ a.userID AS "userID",
|
|
|
+ a.name AS "name",
|
|
|
+ u.userName AS "sname",
|
|
|
+ a.logo AS "logo",
|
|
|
+ a.legalPerson AS "legalPerson",
|
|
|
+ a.businessLicense AS "businessLicense",
|
|
|
+ a.businessLicenseImage AS "businessLicenseImage",
|
|
|
+ a.taxCertificate AS "taxCertificate",
|
|
|
+ a.taxCertificateImage AS "taxCertificateImage",
|
|
|
+ a.townID AS "townID",
|
|
|
+ d.provinceID AS "provinceID",
|
|
|
+ c.cityID AS "cityID",
|
|
|
+ a.address AS "address",
|
|
|
+ a.registeredCapital AS "registeredCapital",
|
|
|
+ a.nature AS "nature",
|
|
|
+ a.turnover AS "turnover",
|
|
|
+ a.linkMan AS "linkMan",
|
|
|
+ a.contractPhone AS "contractPhone",
|
|
|
+ ifnull(u.bindMobile,a.contractMobile) AS "contractMobile",
|
|
|
+ a.contractEmail AS "contractEmail",
|
|
|
+ a.fax AS "fax",
|
|
|
+ a.zipCode AS "zipCode",
|
|
|
+ a.info AS "info",
|
|
|
+ a.productDesc AS "productDesc",
|
|
|
+ a.website,
|
|
|
+ a.wxOfficialAccount,
|
|
|
+ a.wxApplets,
|
|
|
+ a.addTime AS "addTime",
|
|
|
+ a.auditStatus AS "auditStatus",
|
|
|
+ a.auditTime AS "auditTime",
|
|
|
+ a.auditNote AS "auditNote",
|
|
|
+ a.validFlag AS "validFlag",
|
|
|
+ a.status AS "status",
|
|
|
+ a.maintenanceFee AS "maintenanceFee",
|
|
|
+ a.maintenanceDate AS "maintenanceDate",
|
|
|
+ a.businessScope AS "businessScope",
|
|
|
+ u.account AS "account",
|
|
|
+ u.registerTime AS "registerTime",
|
|
|
+ a.firstShopType AS "firstShopType",
|
|
|
+ a.secondShopType AS "secondShopType",
|
|
|
+ a.medicalPracticeLicenseImg1 AS "medicalPracticeLicenseImg1",
|
|
|
+ a.medicalPracticeLicenseImg2 AS "medicalPracticeLicenseImg2",
|
|
|
+ a.medicalPracticeLicenseImg3 AS "medicalPracticeLicenseImg3",
|
|
|
+ a.mainpro AS "mainpro",
|
|
|
+ a.bankAccount AS "bankAccount",
|
|
|
+ a.ableRebateAmount AS "ableRebateAmount",
|
|
|
+ a.rebateAmount AS "rebateAmount",
|
|
|
+ a.bankAccountName AS "bankAccountName",
|
|
|
+ a.bankName AS "bankName",
|
|
|
+ a.socialCreditCode AS "socialCreditCode",
|
|
|
+ u.email,
|
|
|
+ u.source AS "source",
|
|
|
+ a.shopType AS "shopType",
|
|
|
+ a.cardNumber AS "cardNumber",
|
|
|
+ a.chargeSupport AS "chargeSupport",
|
|
|
+ d.name AS "province",c.name AS "city",b.name AS "town"
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <sql id="newCmShopJoins">
|
|
|
+ LEFT JOIN user u ON u.userID = a.userID
|
|
|
+ LEFT JOIN town b ON b.townID=a.townID
|
|
|
+ LEFT JOIN city c ON c.cityID=b.cityID
|
|
|
+ LEFT JOIN province d ON d.provinceID=c.provinceID
|
|
|
+ </sql>
|
|
|
+
|
|
|
<select id="superFind" resultType="com.caimei365.manager.entity.caimei.svip.CmSvipHistory">
|
|
|
SELECT u.name as clubName, u.username as linkMan, u.bindMobile as mobile,
|
|
|
cs.userId,cs.beginTime,cs.endTime,cs.packageId
|
|
@@ -154,6 +242,223 @@
|
|
|
SELECT TIMESTAMPDIFF(MONTH, cs.beginTime, cs.endTime) FROM cm_svip_history cs
|
|
|
where id = #{id}
|
|
|
</select>
|
|
|
+ <select id="vipCouponGet" resultType="com.caimei365.manager.entity.caimei.svip.CmVipCoupon">
|
|
|
+ SELECT DISTINCT id, useTime, status, updateTime, delFlag
|
|
|
+ FROM cm_svip_coupon_month
|
|
|
+ WHERE id = #{id}
|
|
|
+ LIMIT 1
|
|
|
+ </select>
|
|
|
+ <select id="CmCouponGet" resultType="com.caimei365.manager.entity.caimei.svip.CmCoupon">
|
|
|
+ SELECT
|
|
|
+ <include refid="cmCouponColumns"/>
|
|
|
+ FROM cm_coupon a
|
|
|
+ WHERE a.id = #{id}
|
|
|
+ </select>
|
|
|
+ <select id="newCmShopGet" resultType="com.caimei365.manager.entity.caimei.svip.NewCmShop">
|
|
|
+ SELECT
|
|
|
+ <include refid="newCmShopColumns"/>
|
|
|
+ FROM shop a
|
|
|
+ <include refid="newCmShopJoins"/>
|
|
|
+ WHERE a.shopID = #{id}
|
|
|
+ </select>
|
|
|
+ <select id="findRedemptionCodeNum" resultType="java.lang.Integer">
|
|
|
+ SELECT COUNT(id) FROM cm_coupon_redemption_code WHERE couponId = #{couponId}
|
|
|
+ </select>
|
|
|
+ <update id="updateByDelFlag">
|
|
|
+ UPDATE cm_coupon SET delFlag = 1 WHERE id = #{couponId}
|
|
|
+ </update>
|
|
|
+ <update id="updateAssociateByDelFlag">
|
|
|
+ UPDATE cm_coupon_product SET delFlag = 1 WHERE couponId = #{couponId}
|
|
|
+ </update>
|
|
|
+ <update id="updateVipCouponMonth" parameterType="com.caimei365.manager.entity.caimei.svip.CmVipCoupon">
|
|
|
+ UPDATE cm_svip_coupon_month SET useTime=#{useTime}, updateTime=#{updateTime}, status=#{status}, delFlag=#{delFlag}
|
|
|
+ WHERE id=#{id}
|
|
|
+ </update>
|
|
|
+ <delete id="deleteByMonthId">
|
|
|
+ UPDATE cm_svip_coupon SET delFlag=1 WHERE montId = #{montId}
|
|
|
+ </delete>
|
|
|
+ <select id="findByCouponId" resultType="java.lang.Integer">
|
|
|
+ SELECT id FROM cm_coupon_product WHERE couponId = #{couponId} AND delFlag = 0
|
|
|
+ </select>
|
|
|
+ <insert id="insertCouponAssociate">
|
|
|
+ INSERT INTO `cm_coupon_product` (
|
|
|
+ `couponId`, `productId`, `pcStatus`,
|
|
|
+ `appletsStatus`,
|
|
|
+ `sort`, `addTime`, `delFlag`
|
|
|
+ )
|
|
|
+ VALUES
|
|
|
+ (
|
|
|
+ #{couponId}, #{productId}, #{pcStatus},
|
|
|
+ #{appletsStatus},
|
|
|
+ #{sort}, #{addTime}, #{delFlag}
|
|
|
+ )
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <update id="updateCouponAssociate">
|
|
|
+ UPDATE
|
|
|
+ `cm_coupon_product`
|
|
|
+ <set>
|
|
|
+ <if test="pcStatus != null and pcStatus != ''">
|
|
|
+ `pcStatus` = #{pcStatus},
|
|
|
+ </if>
|
|
|
+ <if test="appletsStatus != null and appletsStatus != ''">
|
|
|
+ `appletsStatus` = #{appletsStatus},
|
|
|
+ </if>
|
|
|
+ <if test="sort != null">
|
|
|
+ `sort` = #{sort},
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ WHERE
|
|
|
+ `id` = #{id}
|
|
|
+ </update>
|
|
|
+ <update id="logicDeleteCouponAssociate">
|
|
|
+ UPDATE cm_coupon_product SET delFlag = 1 WHERE id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <insert id="insertCoupon" parameterType="com.caimei365.manager.entity.caimei.svip.CmCoupon" keyProperty="id" useGeneratedKeys="true">
|
|
|
+ INSERT INTO cm_coupon(
|
|
|
+ name,
|
|
|
+ couponPayWay,
|
|
|
+ couponAmount,
|
|
|
+ touchPrice,
|
|
|
+ startDate,
|
|
|
+ endDate,
|
|
|
+ receivePeriod,
|
|
|
+ receiveFlag,
|
|
|
+ useTimeFlag,
|
|
|
+ usePeriod,
|
|
|
+ status,
|
|
|
+ couponType,
|
|
|
+ vipFlag,
|
|
|
+ userId,
|
|
|
+ shopId,
|
|
|
+ productType,
|
|
|
+ pcBanner,
|
|
|
+ appletsBanner,
|
|
|
+ categoryType,
|
|
|
+ couponsMode,
|
|
|
+ createDate,
|
|
|
+ moneyCouponPrice,
|
|
|
+ moneyCouponFlag,
|
|
|
+ moneyCouponType,
|
|
|
+ delFlag,
|
|
|
+ configure
|
|
|
+ ) VALUES (
|
|
|
+ #{name},
|
|
|
+ #{couponPayWay},
|
|
|
+ #{couponAmount},
|
|
|
+ #{touchPrice},
|
|
|
+ #{startDate},
|
|
|
+ #{endDate},
|
|
|
+ #{receivePeriod},
|
|
|
+ #{receiveFlag},
|
|
|
+ #{useTimeFlag},
|
|
|
+ #{usePeriod},
|
|
|
+ #{status},
|
|
|
+ #{couponType},
|
|
|
+ #{vipFlag},
|
|
|
+ #{userId},
|
|
|
+ #{shopId},
|
|
|
+ #{productType},
|
|
|
+ #{pcBanner},
|
|
|
+ #{appletsBanner},
|
|
|
+ #{categoryType},
|
|
|
+ #{couponsMode},
|
|
|
+ #{createDate},
|
|
|
+ #{moneyCouponPrice},
|
|
|
+ #{moneyCouponFlag},
|
|
|
+ #{moneyCouponType},
|
|
|
+ #{delFlag},
|
|
|
+ #{configure}
|
|
|
+ )
|
|
|
+ </insert>
|
|
|
+ <update id="updateCoupon">
|
|
|
+ UPDATE cm_coupon SET
|
|
|
+ name = #{name},
|
|
|
+ couponPayWay = #{couponPayWay},
|
|
|
+ couponAmount = #{couponAmount},
|
|
|
+ touchPrice = #{touchPrice},
|
|
|
+ startDate = #{startDate},
|
|
|
+ endDate = #{endDate},
|
|
|
+ receivePeriod = #{receivePeriod},
|
|
|
+ receiveFlag = #{receiveFlag},
|
|
|
+ useTimeFlag = #{useTimeFlag},
|
|
|
+ usePeriod = #{usePeriod},
|
|
|
+ status = #{status},
|
|
|
+ couponType = #{couponType},
|
|
|
+ vipFlag = #{vipFlag},
|
|
|
+ userId = #{userId},
|
|
|
+ shopId = #{shopId},
|
|
|
+ productType = #{productType},
|
|
|
+ pcBanner = #{pcBanner},
|
|
|
+ appletsBanner = #{appletsBanner},
|
|
|
+ categoryType = #{categoryType},
|
|
|
+ couponsMode = #{couponsMode},
|
|
|
+ moneyCouponPrice = #{moneyCouponPrice},
|
|
|
+ moneyCouponType = #{moneyCouponType},
|
|
|
+ configure = #{configure}
|
|
|
+ WHERE id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <select id="findCouponList" resultType="com.caimei365.manager.entity.caimei.svip.CmVipCoupon">
|
|
|
+ SELECT cs.id, cs.useTime, cs.status, cs.updateTime, cs.delFlag
|
|
|
+ FROM cm_svip_coupon_month cs
|
|
|
+ <where>
|
|
|
+ AND cs.delFlag = 0
|
|
|
+ <if test="startDate!=null and startDate!=''">
|
|
|
+ AND cs.useTime <![CDATA[ >= ]]> #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate!=null and endDate!=''">
|
|
|
+ AND cs.useTime <![CDATA[ <= ]]> #{endDate}
|
|
|
+ </if>
|
|
|
+ <!-- 0未生效 1已生效 2已关闭 3已失效 -->
|
|
|
+ <if test="status!=null and status!=''">
|
|
|
+ <if test='status == "0"'>
|
|
|
+ AND cs.status != '2'
|
|
|
+ AND cs.useTime <![CDATA[ > ]]> DATE_FORMAT(NOW(), '%Y-%m')
|
|
|
+ </if>
|
|
|
+ <if test='status == "1"'>
|
|
|
+ AND cs.status != '2'
|
|
|
+ AND cs.useTime <![CDATA[ = ]]> DATE_FORMAT(NOW(), '%Y-%m')
|
|
|
+ </if>
|
|
|
+ <if test='status == "2"'>
|
|
|
+ AND cs.status = '2'
|
|
|
+ </if>
|
|
|
+ <if test='status == "3"'>
|
|
|
+ AND cs.status != '2'
|
|
|
+ AND cs.useTime <![CDATA[ < ]]> DATE_FORMAT(NOW(), '%Y-%m')
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ ORDER BY cs.useTime DESC
|
|
|
+ </select>
|
|
|
+ <select id="getBindCoupons" resultType="java.lang.String">
|
|
|
+ SELECT couponId from cm_svip_coupon WHERE montId = #{montId} AND delFlag=0
|
|
|
+ </select>
|
|
|
+ <select id="getCouponListByIds" resultType="com.caimei365.manager.entity.caimei.svip.CmCoupon">
|
|
|
+ SELECT
|
|
|
+ <include refid="cmCouponColumns"/>,
|
|
|
+ u.name AS "clubName",
|
|
|
+ s.name AS "shopName"
|
|
|
+ FROM cm_coupon a
|
|
|
+ LEFT JOIN cm_coupon_club ccc ON ccc.couponId = a.id
|
|
|
+ LEFT JOIN USER u ON u.userID = a.userId
|
|
|
+ LEFT JOIN shop s ON s.shopID = a.shopId
|
|
|
+ <where>
|
|
|
+ AND a.delFlag = 0
|
|
|
+ <if test="couponType!=null and couponType!=''">
|
|
|
+ AND a.couponType = #{couponType}
|
|
|
+ </if>
|
|
|
+ <if test="bindCoupons!=null and bindCoupons.size()!=0">
|
|
|
+ AND a.id IN
|
|
|
+ <foreach collection="bindCoupons" open="(" separator="," close=")" item="couponId">
|
|
|
+ #{couponId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY a.id
|
|
|
+ ORDER BY a.createDate DESC
|
|
|
+ </select>
|
|
|
<select id="findProductList" resultType="com.caimei365.manager.entity.caimei.svip.CmSvipProduct">
|
|
|
SELECT
|
|
|
a.id AS "id",
|