CmSvipHistoryDao.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.caimei365.manager.dao.svip.CmSvipHistoryDao">
  4. <sql id="cmCouponColumns">
  5. a.id AS "id",
  6. a.name AS "name",
  7. a.couponAmount AS "couponAmount",
  8. a.touchPrice AS "touchPrice",
  9. a.startDate AS "startDate",
  10. a.endDate AS "endDate",
  11. a.status AS "status",
  12. a.couponType AS "couponType",
  13. a.vipFlag AS "vipFlag",
  14. a.userId AS "userId",
  15. a.shopId AS "shopId",
  16. a.productType AS "productType",
  17. a.pcBanner AS "pcBanner",
  18. a.appletsBanner AS "appletsBanner",
  19. a.categoryType AS "categoryType",
  20. a.couponsMode AS "couponsMode",
  21. a.createDate AS "createDate",
  22. a.delFlag AS "delFlag"
  23. </sql>
  24. <sql id="newCmShopColumns">
  25. a.shopID AS "shopID",
  26. a.checkMan as "checkMan",
  27. a.userID AS "userID",
  28. a.name AS "name",
  29. u.userName AS "sname",
  30. a.logo AS "logo",
  31. a.legalPerson AS "legalPerson",
  32. a.businessLicense AS "businessLicense",
  33. a.businessLicenseImage AS "businessLicenseImage",
  34. a.taxCertificate AS "taxCertificate",
  35. a.taxCertificateImage AS "taxCertificateImage",
  36. a.townID AS "townID",
  37. d.provinceID AS "provinceID",
  38. c.cityID AS "cityID",
  39. a.address AS "address",
  40. a.registeredCapital AS "registeredCapital",
  41. a.nature AS "nature",
  42. a.turnover AS "turnover",
  43. a.linkMan AS "linkMan",
  44. a.contractPhone AS "contractPhone",
  45. ifnull(u.bindMobile,a.contractMobile) AS "contractMobile",
  46. a.contractEmail AS "contractEmail",
  47. a.fax AS "fax",
  48. a.zipCode AS "zipCode",
  49. a.info AS "info",
  50. a.productDesc AS "productDesc",
  51. a.website,
  52. a.wxOfficialAccount,
  53. a.wxApplets,
  54. a.addTime AS "addTime",
  55. a.auditStatus AS "auditStatus",
  56. a.auditTime AS "auditTime",
  57. a.auditNote AS "auditNote",
  58. a.validFlag AS "validFlag",
  59. a.status AS "status",
  60. a.maintenanceFee AS "maintenanceFee",
  61. a.maintenanceDate AS "maintenanceDate",
  62. a.businessScope AS "businessScope",
  63. u.account AS "account",
  64. u.registerTime AS "registerTime",
  65. a.firstShopType AS "firstShopType",
  66. a.secondShopType AS "secondShopType",
  67. a.medicalPracticeLicenseImg1 AS "medicalPracticeLicenseImg1",
  68. a.medicalPracticeLicenseImg2 AS "medicalPracticeLicenseImg2",
  69. a.medicalPracticeLicenseImg3 AS "medicalPracticeLicenseImg3",
  70. a.mainpro AS "mainpro",
  71. a.bankAccount AS "bankAccount",
  72. a.ableRebateAmount AS "ableRebateAmount",
  73. a.rebateAmount AS "rebateAmount",
  74. a.bankAccountName AS "bankAccountName",
  75. a.bankName AS "bankName",
  76. a.socialCreditCode AS "socialCreditCode",
  77. u.email,
  78. u.source AS "source",
  79. a.shopType AS "shopType",
  80. a.cardNumber AS "cardNumber",
  81. a.chargeSupport AS "chargeSupport",
  82. d.name AS "province",c.name AS "city",b.name AS "town"
  83. </sql>
  84. <sql id="productColumns">
  85. a.productID AS "id",
  86. a.productID AS "productId",
  87. a.brandID AS "brandID",
  88. a.bigTypeID AS "bigTypeID",
  89. ifnull(a.smallTypeID,-1) AS "smallTypeID",
  90. ifnull(a.tinyTypeID,-1) AS "tinyTypeID",
  91. a.selfTypeID AS "selfTypeID",
  92. a.preferredFlag AS "preferredFlag",
  93. a.shopID AS "shopId",
  94. a.name AS "name",
  95. a.searchKey AS "searchKey",
  96. a.combinationID AS "combinationID",
  97. a.productRemarks AS "productRemarks",
  98. a.priceFlag AS "priceFlag",
  99. a.beautyActFlag AS "beautyActFlag",
  100. a.hasSkuFlag AS "hasSkuFlag",
  101. a.mainImage AS "mainImage",
  102. a.propertiesInfo AS "propertiesInfo",
  103. a.addTime AS "addTime",
  104. a.updateTime AS "updateTime",
  105. a.sellNumber AS "sellNumber",
  106. a.weekSellNumber AS "weekSellNumber",
  107. a.beforeValidFlag AS "beforeValidFlag",
  108. a.validFlag AS "validFlag",
  109. a.favoriteTimes AS "favoriteTimes",
  110. a.commentScore AS "commentScore",
  111. a.commentTimes AS "commentTimes",
  112. a.selfRecommendFlag AS "selfRecommendFlag",
  113. a.sysRecommendFlag AS "sysRecommendFlag",
  114. a.sortIndex AS "sortIndex",
  115. a.featuredFlag AS "featuredFlag",
  116. a.featuredSortIndex AS "featuredSortIndex",
  117. a.productCode AS "productCode",
  118. a.synToERPFlag AS "synToERPFlag",
  119. a.allAreaFlag AS "allAreaFlag",
  120. a.provinceIDs AS "provinceIDs",
  121. a.serviceNumber AS "serviceNumber",
  122. a.packageCount AS "packageCount",
  123. a.byFlag AS "byFlag",
  124. a.normalProductFlag AS "normalProductFlag",
  125. a.wholeSaleProductFlag AS "wholeSaleProductFlag",
  126. a.promotionProductFlag AS "promotionProductFlag",
  127. a.groupBuyProductFlag AS "groupBuyProductFlag",
  128. a.step AS "step",
  129. a.actStatus AS "actStatus",
  130. a.actFlag AS "actFlag",
  131. a.actType AS "actType",
  132. a.onlineTime AS "onlineTime",
  133. a.downlineTime AS "downlineTime",
  134. a.freePostFlag AS "freePostFlag",
  135. a.precisehKey AS "precisehKey",
  136. s.name AS "shopName",
  137. a.actSort AS "actSort",
  138. a.recommendType AS "recommendType",
  139. a.aliasName as "aliasName",
  140. a.visibility as "visibility",
  141. # a.commodityDetailsFlag as "commodityDetailsFlag",
  142. a.productType as "productType",
  143. a.qualificationImg as "qualificationImg",
  144. a.includedTax as "includedTax",
  145. a.invoiceType as "invoiceType",
  146. a.taxPoint as "taxPoint",
  147. a.tags as "tags",
  148. a.machineType as "machineType",
  149. a.trainingMethod as "trainingMethod",
  150. a.trainingType as "trainingType",
  151. a.trainingFee as "trainingFee",
  152. a.commodityType as "commodityType",
  153. a.splitCode,
  154. a.announType,
  155. ifnull(a.newvalidFlag,0),
  156. ifnull(a.newProductType,2),
  157. a.showFlag,
  158. a.showTime,
  159. a.newshowTime,
  160. a.recommend,
  161. a.qualificationNo,
  162. a.productName,
  163. a.qualificationTime,
  164. a.qualificationLink,
  165. a.labelIds
  166. </sql>
  167. <sql id="newCmShopJoins">
  168. LEFT JOIN user u ON u.userID = a.userID
  169. LEFT JOIN town b ON b.townID=a.townID
  170. LEFT JOIN city c ON c.cityID=b.cityID
  171. LEFT JOIN province d ON d.provinceID=c.provinceID
  172. </sql>
  173. <select id="superFind" resultType="com.caimei365.manager.entity.caimei.svip.CmSvipHistory">
  174. SELECT u.name as clubName, u.username as linkMan, u.bindMobile as mobile,
  175. cs.userId,cs.beginTime,cs.endTime,cs.packageId
  176. FROM cm_svip_history cs
  177. LEFT JOIN club cb ON cs.userId = cb.userId
  178. LEFT JOIN cm_svip_user cu ON cs.userId = cu.userId
  179. left join user u on cs.userId = u.userID
  180. left join cm_svip_package cp on cp.id = cs.packageId
  181. <where>
  182. AND cs.payStatus = '1'
  183. <if test="clubName != null and clubName != ''">
  184. and u.name like concat('%',#{clubName},'%')
  185. </if>
  186. <if test="linkMan != null and linkMan != ''">
  187. and u.username like concat('%',#{linkMan},'%')
  188. </if>
  189. <if test="mobile != null and mobile != ''">
  190. and u.bindMobile LIKE concat('%',#{mobile},'%')
  191. </if>
  192. <if test="startPayTime !=null and startPayTime != '' and endPayTime !=null and endPayTime!=''">
  193. and (cs.payTime between #{startPayTime} and #{endPayTime})
  194. </if>
  195. <if test="startEndTime !=null and startEndTime!='' and endEndTime!=null and endEndTime!=''">
  196. and (cu.endTime between #{startEndTime} and #{endEndTime})
  197. </if>
  198. <if test="packageId !=null and packageId != '' and packageId != 0">
  199. and cp.duration = #{packageId}
  200. </if>
  201. <if test="packageId == 0">
  202. and cs.packageId = 0
  203. </if>
  204. <if test='status == "1"'>
  205. and cu.endTime > NOW()
  206. </if>
  207. <if test='status == "2"'>
  208. and now() > cu.endTime
  209. </if>
  210. </where>
  211. group by cs.userId
  212. order by cs.payTime DESC
  213. </select>
  214. <select id="findEndTime" resultType="com.caimei365.manager.entity.caimei.svip.CmSvipHistory">
  215. select beginTime, endTime, updateTime
  216. from cm_svip_user
  217. where userId = #{userId}
  218. and endTime > now()
  219. </select>
  220. <select id="findUserList" resultType="com.caimei365.manager.entity.caimei.CmUser">
  221. SELECT
  222. clubID as clubId,
  223. userID as userId,
  224. name,
  225. sname AS shortName,
  226. linkMan,
  227. contractMobile as contractMobile
  228. FROM
  229. club
  230. WHERE
  231. status IN (1, 90)
  232. <if test="clubId != null and clubId != ''">
  233. AND clubId = #{clubId}
  234. </if>
  235. <if test="name != null and name != ''">
  236. AND name LIKE CONCAT('%',#{name},'%')
  237. </if>
  238. <if test="shortName != null and shortName != ''">
  239. AND sname LIKE CONCAT('%',#{shortName},'%')
  240. </if>
  241. ORDER BY clubId ASC
  242. </select>
  243. <select id="findVipUser" resultType="com.caimei365.manager.entity.caimei.svip.CmSvipHistory">
  244. select beginTime, endTime, updateTime, userId
  245. from cm_svip_user
  246. where userId = #{userId}
  247. and delflag = 0
  248. </select>
  249. <insert id="addMessageCenter">
  250. INSERT INTO message_center (shopID, clubID, userType, messageType, content, time, accountType, couponType,
  251. couponFee, couponMessageType, orderID, orderMessageType, shopMessType, productID)
  252. VALUES (#{shopId}, #{clubId}, #{userType}, #{messageType}, #{content}, #{time}, #{accountType}, #{couponType},
  253. #{couponFee}, #{couponMessageType}, #{orderId}, #{orderMessageType}, #{shopMessType}, #{productId})
  254. </insert>
  255. <insert id="insertHistory">
  256. insert into cm_svip_history(userId, packageId, beginTime, endTime, payStatus, payWay, price, userBeans, payTime)
  257. values (#{userId}, 0, #{beginTime}, #{endTime}, 1, #{payWay}, 0, 0, #{payTime})
  258. </insert>
  259. <update id="updateVip">
  260. UPDATE cm_svip_user
  261. SET
  262. <if test="beginTime != null">
  263. beginTime = #{beginTime},
  264. </if>
  265. endTime = #{endTime},
  266. updateTime = now()
  267. WHERE userId = #{userId}
  268. </update>
  269. <insert id="giveVip">
  270. insert into cm_svip_user (userId, beginTime, endTime, delFlag, updateTime)
  271. values (#{userId}, #{beginTime}, #{endTime}, 0, #{beginTime})
  272. </insert>
  273. <select id="findHistory" resultType="com.caimei365.manager.entity.caimei.svip.CmSvipHistory">
  274. select
  275. cs.id,
  276. cs.userId,
  277. cs.packageId,
  278. u.name as clubName,
  279. u.userName as linkMan,
  280. u.bindMobile as mobile,
  281. cs.beginTime,
  282. cs.price,
  283. cs.payWay,
  284. cs.payType,
  285. cs.userBeans,
  286. cs.payTime,
  287. cs.endTime
  288. from cm_svip_history cs
  289. LEFT JOIN club cb ON cs.userId = cb.userId
  290. left join user u on cs.userId = u.userID
  291. left join cm_svip_package cp on cp.id = cs.packageId
  292. where cs.userId = #{userId}
  293. AND cs.payStatus = '1'
  294. <if test="startPayTime != null and startPayTime != '' and endPayTime != null and endPayTime != ''">
  295. and (cs.payTime between #{startPayTime} and #{endPayTime})
  296. </if>
  297. <if test="startEndTime != null and startEndTime != '' and endEndTime != null and endEndTime != ''">
  298. and (cs.endTime between #{startEndTime} and #{endEndTime})
  299. </if>
  300. <if test="packageId != null and packageId != 0">
  301. and cp.duration = #{packageId}
  302. </if>
  303. <if test="packageId == 0">
  304. and cs.packageId = 0
  305. </if>
  306. <if test='status == "1"'>
  307. and (NOW() between cs.beginTime and cs.endTime)
  308. </if>
  309. <if test='status == "2"'>
  310. and NOW() > cs.endTime
  311. </if>
  312. <if test='status == "3"'>
  313. and cs.beginTime > NOW()
  314. </if>
  315. order by cs.payTime desc
  316. </select>
  317. <select id="findDuration" resultType="java.lang.Integer">
  318. select duration
  319. from cm_svip_package
  320. where id = #{packageId}
  321. </select>
  322. <select id="findMonth" resultType="java.lang.String">
  323. SELECT TIMESTAMPDIFF(MONTH, cs.beginTime, cs.endTime) FROM cm_svip_history cs
  324. where id = #{id}
  325. </select>
  326. <select id="vipCouponGet" resultType="com.caimei365.manager.entity.caimei.svip.CmVipCoupon">
  327. SELECT DISTINCT id, useTime, status, updateTime, delFlag
  328. FROM cm_svip_coupon_month
  329. WHERE id = #{id}
  330. LIMIT 1
  331. </select>
  332. <select id="CmCouponGet" resultType="com.caimei365.manager.entity.caimei.svip.CmCoupon">
  333. SELECT
  334. <include refid="cmCouponColumns"/>
  335. FROM cm_coupon a
  336. WHERE a.id = #{id}
  337. </select>
  338. <select id="newCmShopGet" resultType="com.caimei365.manager.entity.caimei.svip.NewCmShop">
  339. SELECT
  340. <include refid="newCmShopColumns"/>
  341. FROM shop a
  342. <include refid="newCmShopJoins"/>
  343. WHERE a.shopID = #{id}
  344. </select>
  345. <select id="findRedemptionCodeNum" resultType="java.lang.Integer">
  346. SELECT COUNT(id) FROM cm_coupon_redemption_code WHERE couponId = #{couponId}
  347. </select>
  348. <update id="updateByDelFlag">
  349. UPDATE cm_coupon SET delFlag = 1 WHERE id = #{couponId}
  350. </update>
  351. <update id="updateAssociateByDelFlag">
  352. UPDATE cm_coupon_product SET delFlag = 1 WHERE couponId = #{couponId}
  353. </update>
  354. <update id="updateVipCouponMonth" parameterType="com.caimei365.manager.entity.caimei.svip.CmVipCoupon">
  355. UPDATE cm_svip_coupon_month SET useTime=#{useTime}, updateTime=#{updateTime}, status=#{status}, delFlag=#{delFlag}
  356. WHERE id=#{id}
  357. </update>
  358. <delete id="deleteByMonthId">
  359. UPDATE cm_svip_coupon SET delFlag=1 WHERE montId = #{montId}
  360. </delete>
  361. <select id="findByCouponId" resultType="java.lang.Integer">
  362. SELECT id FROM cm_coupon_product WHERE couponId = #{couponId} AND delFlag = 0
  363. </select>
  364. <insert id="insertCouponAssociate">
  365. INSERT INTO `cm_coupon_product` (
  366. `couponId`, `productId`, `pcStatus`,
  367. `appletsStatus`,
  368. `sort`, `addTime`, `delFlag`
  369. )
  370. VALUES
  371. (
  372. #{couponId}, #{productId}, #{pcStatus},
  373. #{appletsStatus},
  374. #{sort}, #{addTime}, #{delFlag}
  375. )
  376. </insert>
  377. <update id="updateCouponAssociate">
  378. UPDATE
  379. `cm_coupon_product`
  380. <set>
  381. <if test="pcStatus != null and pcStatus != ''">
  382. `pcStatus` = #{pcStatus},
  383. </if>
  384. <if test="appletsStatus != null and appletsStatus != ''">
  385. `appletsStatus` = #{appletsStatus},
  386. </if>
  387. <if test="sort != null">
  388. `sort` = #{sort},
  389. </if>
  390. </set>
  391. WHERE
  392. `id` = #{id}
  393. </update>
  394. <update id="logicDeleteCouponAssociate">
  395. UPDATE cm_coupon_product SET delFlag = 1 WHERE id = #{id}
  396. </update>
  397. <insert id="insertCoupon" parameterType="com.caimei365.manager.entity.caimei.svip.CmCoupon" keyProperty="id" useGeneratedKeys="true">
  398. INSERT INTO cm_coupon(
  399. name,
  400. couponPayWay,
  401. couponAmount,
  402. touchPrice,
  403. startDate,
  404. endDate,
  405. receivePeriod,
  406. receiveFlag,
  407. useTimeFlag,
  408. usePeriod,
  409. status,
  410. couponType,
  411. vipFlag,
  412. userId,
  413. shopId,
  414. productType,
  415. pcBanner,
  416. appletsBanner,
  417. categoryType,
  418. couponsMode,
  419. createDate,
  420. moneyCouponPrice,
  421. moneyCouponFlag,
  422. moneyCouponType,
  423. delFlag,
  424. configure
  425. ) VALUES (
  426. #{name},
  427. #{couponPayWay},
  428. #{couponAmount},
  429. #{touchPrice},
  430. #{startDate},
  431. #{endDate},
  432. #{receivePeriod},
  433. #{receiveFlag},
  434. #{useTimeFlag},
  435. #{usePeriod},
  436. #{status},
  437. #{couponType},
  438. #{vipFlag},
  439. #{userId},
  440. #{shopId},
  441. #{productType},
  442. #{pcBanner},
  443. #{appletsBanner},
  444. #{categoryType},
  445. #{couponsMode},
  446. #{createDate},
  447. #{moneyCouponPrice},
  448. #{moneyCouponFlag},
  449. #{moneyCouponType},
  450. #{delFlag},
  451. #{configure}
  452. )
  453. </insert>
  454. <update id="updateCoupon">
  455. UPDATE cm_coupon SET
  456. name = #{name},
  457. couponPayWay = #{couponPayWay},
  458. couponAmount = #{couponAmount},
  459. touchPrice = #{touchPrice},
  460. startDate = #{startDate},
  461. endDate = #{endDate},
  462. receivePeriod = #{receivePeriod},
  463. receiveFlag = #{receiveFlag},
  464. useTimeFlag = #{useTimeFlag},
  465. usePeriod = #{usePeriod},
  466. status = #{status},
  467. couponType = #{couponType},
  468. vipFlag = #{vipFlag},
  469. userId = #{userId},
  470. shopId = #{shopId},
  471. productType = #{productType},
  472. pcBanner = #{pcBanner},
  473. appletsBanner = #{appletsBanner},
  474. categoryType = #{categoryType},
  475. couponsMode = #{couponsMode},
  476. moneyCouponPrice = #{moneyCouponPrice},
  477. moneyCouponType = #{moneyCouponType},
  478. configure = #{configure}
  479. WHERE id = #{id}
  480. </update>
  481. <select id="findCouponList" resultType="com.caimei365.manager.entity.caimei.svip.CmVipCoupon">
  482. SELECT cs.id, cs.useTime, cs.status, cs.updateTime, cs.delFlag
  483. FROM cm_svip_coupon_month cs
  484. <where>
  485. AND cs.delFlag = 0
  486. <if test="startDate!=null and startDate!=''">
  487. AND cs.useTime <![CDATA[ >= ]]> #{startDate}
  488. </if>
  489. <if test="endDate!=null and endDate!=''">
  490. AND cs.useTime <![CDATA[ <= ]]> #{endDate}
  491. </if>
  492. <!-- 0未生效 1已生效 2已关闭 3已失效 -->
  493. <if test="status!=null and status!=''">
  494. <if test='status == "0"'>
  495. AND cs.status != '2'
  496. AND cs.useTime <![CDATA[ > ]]> DATE_FORMAT(NOW(), '%Y-%m')
  497. </if>
  498. <if test='status == "1"'>
  499. AND cs.status != '2'
  500. AND cs.useTime <![CDATA[ = ]]> DATE_FORMAT(NOW(), '%Y-%m')
  501. </if>
  502. <if test='status == "2"'>
  503. AND cs.status = '2'
  504. </if>
  505. <if test='status == "3"'>
  506. AND cs.status != '2'
  507. AND cs.useTime <![CDATA[ < ]]> DATE_FORMAT(NOW(), '%Y-%m')
  508. </if>
  509. </if>
  510. </where>
  511. ORDER BY cs.useTime DESC
  512. </select>
  513. <select id="getBindCoupons" resultType="java.lang.String">
  514. SELECT couponId from cm_svip_coupon WHERE montId = #{montId} AND delFlag=0
  515. </select>
  516. <select id="getCouponListByIds" resultType="com.caimei365.manager.entity.caimei.svip.CmCoupon">
  517. SELECT
  518. <include refid="cmCouponColumns"/>,
  519. u.name AS "clubName",
  520. s.name AS "shopName"
  521. FROM cm_coupon a
  522. LEFT JOIN cm_coupon_club ccc ON ccc.couponId = a.id
  523. LEFT JOIN USER u ON u.userID = a.userId
  524. LEFT JOIN shop s ON s.shopID = a.shopId
  525. <where>
  526. AND a.delFlag = 0
  527. <if test="couponType!=null and couponType!=''">
  528. AND a.couponType = #{couponType}
  529. </if>
  530. <if test="bindCoupons!=null and bindCoupons.size()!=0">
  531. AND a.id IN
  532. <foreach collection="bindCoupons" open="(" separator="," close=")" item="couponId">
  533. #{couponId}
  534. </foreach>
  535. </if>
  536. </where>
  537. GROUP BY a.id
  538. ORDER BY a.createDate DESC
  539. </select>
  540. <select id="findShopList" resultType="com.caimei365.manager.entity.caimei.svip.NewCmShop">
  541. SELECT
  542. s.shopId,
  543. s.userId,
  544. IFNULL(s.name, u.name) AS name,
  545. IFNULL(s.sname, u.realName) AS sname,
  546. IFNULL(s.contractMobile, u.bindMobile) AS contractMobile,
  547. IFNULL(s.linkMan, u.userName) AS linkMan
  548. FROM
  549. shop s
  550. LEFT JOIN USER u ON u.`shopID` = s.`shopID`
  551. WHERE
  552. s.status = 90
  553. <if test="shopId != null">
  554. AND s.shopID = #{shopId}
  555. </if>
  556. <if test="name != null and name != ''">
  557. AND (s.name LIKE CONCAT('%',#{name},'%') OR u.name LIKE CONCAT('%',#{name},'%'))
  558. </if>
  559. <if test="sname != null and sname != ''">
  560. AND (s.sname LIKE CONCAT('%',#{sname},'%') OR u.realName LIKE CONCAT('%',#{sname},'%'))
  561. </if>
  562. ORDER BY
  563. s.shopID
  564. </select>
  565. <select id="findProductImage" resultType="com.caimei365.manager.entity.caimei.product.Product">
  566. SELECT
  567. <include refid="productColumns"/>
  568. FROM product a
  569. LEFT JOIN shop s on s.shopID = a.shopID
  570. left join product p on a.productID = p.productId
  571. <where>
  572. <if test="productId !=null">
  573. AND a.productID=#{productId}
  574. </if>
  575. <if test="shopId != null and shopId != ''">
  576. AND a.shopID = #{shopId}
  577. </if>
  578. <if test="name != null and name != ''">
  579. AND a.name LIKE concat('%',#{name},'%')
  580. </if>
  581. <if test="shopName != null and shopName != ''">
  582. AND s.name LIKE concat('%',#{shopName},'%')
  583. </if>
  584. <if test="validFlag !=null and validFlag !=''">
  585. AND a.validFlag=#{validFlag}
  586. </if>
  587. <if test="productCategory !=null and productCategory !=''">
  588. AND a.productCategory=#{productCategory}
  589. </if>
  590. <if test="ids != null and ids.size() > 0">
  591. AND a.productID NOT IN
  592. <foreach collection="ids" close=")" separator="," open="(" item="id">
  593. #{id}
  594. </foreach>
  595. </if>
  596. </where>
  597. <choose>
  598. <otherwise>
  599. order by a.productID asc
  600. </otherwise>
  601. </choose>
  602. </select>
  603. <select id="findProductList" resultType="com.caimei365.manager.entity.caimei.svip.CmSvipProduct">
  604. SELECT
  605. a.id AS "id",
  606. a.productId AS "productId",
  607. a.sort AS "sort",
  608. a.addTime AS "addTime",
  609. a.status as "status",
  610. p.mainImage as "productImage",
  611. p.name as "productName",
  612. s.name as "shopName",
  613. p.includedTax,
  614. p.invoiceType,
  615. p.taxPoint,
  616. p.supplierTaxPoint
  617. FROM cm_svip_product a
  618. left join product p on a.productId = p.productID
  619. left join shop s on s.shopID = p.shopID
  620. <where>
  621. <if test="productId != null and productId != ''">
  622. AND a.productId = #{productId}
  623. </if>
  624. <if test="productName != null and productId != ''">
  625. AND p.name like concat('%',#{productName},'%')
  626. </if>
  627. <if test="shopName != null and productId != ''">
  628. AND s.name like concat('%',#{shopName},'%')
  629. </if>
  630. <if test="status !=null and status == 0">
  631. and a.status=0
  632. </if>
  633. <if test="status !=null and status !='' and status == 1">
  634. and a.status=1
  635. </if>
  636. </where>
  637. order by -sort desc,addTime desc
  638. </select>
  639. <select id="findSku" resultType="com.caimei365.manager.entity.caimei.svip.CmSku">
  640. select price, costPrice, costCheckFlag, costProportional, normalPrice
  641. from cm_sku
  642. where productId = #{productId}
  643. order by price asc
  644. limit 1
  645. </select>
  646. <select id="findSvipSku" resultType="com.caimei365.manager.entity.caimei.svip.CmSku">
  647. select ifnull(discountPrice, 0) as "discountPrice",
  648. ifnull(discount, 0) as "discount",
  649. ifnull(priceType, 0) as "priceType"
  650. from cm_svip_product_sku csps
  651. left join cm_sku cs on cs.productId = csps.productId
  652. where csps.productId = #{productId}
  653. order by cs.price asc
  654. limit 1
  655. </select>
  656. <select id="findPackage" resultType="com.caimei365.manager.entity.caimei.svip.CmSvipPackage">
  657. select price, duration, proportion
  658. from cm_svip_package
  659. </select>
  660. <update id="updatePrice">
  661. update cm_svip_package
  662. set
  663. <if test="price != null">
  664. price = #{price},
  665. </if>
  666. <if test="proportion != null">
  667. proportion = #{proportion}
  668. </if>
  669. where duration = #{duration}
  670. </update>
  671. </mapper>