ProductMapper.xml 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897
  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.caimei.modules.product.dao.ProductDao">
  4. <resultMap id="productModelResultMap" type="com.caimei.modules.product.entity.Product">
  5. <id property="id" column="id"/>
  6. <result property="name" column="name"/>
  7. </resultMap>
  8. <sql id="productColumns">
  9. a.productID AS "id",
  10. a.productID AS "productID",
  11. a.brandID AS "brandID",
  12. a.bigTypeID AS "bigTypeID",
  13. ifnull(a.smallTypeID,-1) AS "smallTypeID",
  14. ifnull(a.tinyTypeID,-1) AS "tinyTypeID",
  15. a.selfTypeID AS "selfTypeID",
  16. a.preferredFlag AS "preferredFlag",
  17. a.shopID AS "shopID",
  18. a.name AS "name",
  19. a.searchKey AS "searchKey",
  20. a.combinationID AS "combinationID",
  21. a.productRemarks AS "productRemarks",
  22. a.normalPrice AS "normalPrice",
  23. a.price AS "price",
  24. a.priceFlag AS "priceFlag",
  25. a.beautyActFlag AS "beautyActFlag",
  26. a.ladderPriceFlag AS "ladderPriceFlag",
  27. a.stock AS "stock",
  28. a.hasSkuFlag AS "hasSkuFlag",
  29. a.mainImage AS "mainImage",
  30. a.propertiesInfo AS "propertiesInfo",
  31. a.addTime AS "addTime",
  32. a.updateTime AS "updateTime",
  33. a.sellNumber AS "sellNumber",
  34. a.weekSellNumber AS "weekSellNumber",
  35. a.beforeValidFlag AS "beforeValidFlag",
  36. a.validFlag AS "validFlag",
  37. a.favoriteTimes AS "favoriteTimes",
  38. a.commentScore AS "commentScore",
  39. a.commentTimes AS "commentTimes",
  40. a.selfRecommendFlag AS "selfRecommendFlag",
  41. a.sysRecommendFlag AS "sysRecommendFlag",
  42. a.sortIndex AS "sortIndex",
  43. a.featuredFlag AS "featuredFlag",
  44. a.featuredSortIndex AS "featuredSortIndex",
  45. a.productCode AS "productCode",
  46. a.unit AS "unit",
  47. a.synToERPFlag AS "synToERPFlag",
  48. a.allAreaFlag AS "allAreaFlag",
  49. a.provinceIDs AS "provinceIDs",
  50. a.serviceNumber AS "serviceNumber",
  51. a.maxBuyNumber AS "maxBuyNumber",
  52. a.minBuyNumber AS "minBuyNumber",
  53. a.packageCount AS "packageCount",
  54. a.byFlag AS "byFlag",
  55. a.normalProductFlag AS "normalProductFlag",
  56. a.wholeSaleProductFlag AS "wholeSaleProductFlag",
  57. a.promotionProductFlag AS "promotionProductFlag",
  58. a.groupBuyProductFlag AS "groupBuyProductFlag",
  59. a.step AS "step",
  60. a.actStatus AS "actStatus",
  61. a.actFlag AS "actFlag",
  62. a.actType AS "actType",
  63. a.onlineTime AS "onlineTime",
  64. a.downlineTime AS "downlineTime",
  65. a.freePostFlag AS "freePostFlag",
  66. a.costPrice AS "costPrice",
  67. a.costProportional AS "costProportional",
  68. a.costCheckFlag AS "costCheckFlag",
  69. a.precisehKey AS "precisehKey",
  70. s.name AS "shopName",
  71. a.actSort AS "actSort",
  72. a.recommendType AS "recommendType",
  73. a.aliasName as "aliasName",
  74. a.visibility as "visibility",
  75. a.productType as "productType",
  76. a.qualificationImg as "qualificationImg",
  77. a.includedTax as "includedTax",
  78. a.invoiceType as "invoiceType",
  79. a.taxPoint as "taxPoint",
  80. a.tags as "tags",
  81. a.machineType as "machineType",
  82. a.trainingMethod as "trainingMethod",
  83. a.trainingType as "trainingType",
  84. a.trainingFee as "trainingFee",
  85. a.commodityType as "commodityType",
  86. a.splitCode
  87. </sql>
  88. <sql id="productJoins">
  89. LEFT JOIN shop s on s.shopID = a.shopID
  90. left join product p on a.productID = p.productId
  91. </sql>
  92. <sql id="ActivityJoins">
  93. LEFT JOIN shop s on s.shopID = a.shopID
  94. </sql>
  95. <update id="saveSort">
  96. UPDATE cm_search_recommend_product SET
  97. sort = #{sort}
  98. WHERE id = #{id}
  99. </update>
  100. <select id="findLadderPriceByNum" resultType="Integer">
  101. select IFNULL(buyNum,1)
  102. FROM product_ladder_price
  103. WHERE userType = 3 and ladderNum = 1 and delFlag = 0 and productID = #{productID}
  104. </select>
  105. <select id="get" resultType="Product">
  106. SELECT
  107. <include refid="productColumns"/>
  108. FROM product a
  109. <include refid="productJoins"/>
  110. WHERE a.productID = #{id}
  111. </select>
  112. <select id="getAllExistsProductList" resultType="Integer">
  113. SELECT
  114. a.productID
  115. FROM cm_mall_organize_products a
  116. WHERE a.delFlag = 0 and a.organizeID = #{organizeID}
  117. </select>
  118. <select id="findRecommendPage" resultType="Product">
  119. SELECT
  120. <include refid="productColumns"/>
  121. FROM product a
  122. <include refid="productJoins"/>
  123. <where>
  124. <if test="productID !=null and productID !=''">
  125. AND a.productID=#{productID}
  126. </if>
  127. <if test="tinyTypeID != null and tinyTypeID != ''">
  128. AND a.tinyTypeID = #{tinyTypeID}
  129. </if>
  130. <if test="shopID != null and shopID != ''">
  131. AND a.shopID = #{shopID}
  132. </if>
  133. <if test="name != null and name != ''">
  134. AND a.name LIKE
  135. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  136. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  137. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  138. </if>
  139. <if test="shopName != null and shopName != ''">
  140. AND s.name LIKE
  141. <if test="dbName == 'oracle'">'%'||#{shopName}||'%'</if>
  142. <if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
  143. <if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
  144. </if>
  145. <if test="validFlag !=null and validFlag !=''">
  146. AND a.validFlag=#{validFlag}
  147. </if>
  148. <if test="actFlag !=null and actFlag !=''">
  149. AND a.actFlag=#{actFlag}
  150. </if>
  151. <if test="speCommisionFlag !=null and speCommisionFlag !=''">
  152. AND a.speCommisionFlag=#{speCommisionFlag}
  153. </if>
  154. <if test="displayOnCRMFlag !=null and displayOnCRMFlag !=''">
  155. AND a.displayOnCRMFlag=#{displayOnCRMFlag}
  156. </if>
  157. <if test="crmBigTypeId !=null and crmBigTypeId !=''">
  158. AND a.crmBigTypeId=#{crmBigTypeId}
  159. </if>
  160. <if test="crmSmallTypeId !=null and crmSmallTypeId !=''">
  161. AND a.crmSmallTypeId=#{crmSmallTypeId}
  162. </if>
  163. <if test="sqlMap !=null and sqlMap !=''">
  164. ${sqlMap.dsf}
  165. </if>
  166. <choose>
  167. <when test="actType != null and actType != ''">
  168. AND a.actType = #{actType}
  169. </when>
  170. <otherwise>
  171. AND a.actType != 3
  172. </otherwise>
  173. </choose>
  174. AND a.validFlag != 0
  175. AND a.shopID not in (SELECT s.`value` FROM `sys_dict` s WHERE s.type='heheShopID')
  176. and a.productCategory = 1
  177. </where>
  178. <choose>
  179. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  180. ORDER BY ${page.orderBy}
  181. </when>
  182. <otherwise>
  183. order by case WHEN a.validFlag = 1 then 0 else 1 END asc,a.productID desc
  184. </otherwise>
  185. </choose>
  186. </select>
  187. <!--小程序商品获取采美2已上架 3已下架 9已冻结的商品-->
  188. <select id="findListBuyMall" resultType="Product">
  189. SELECT
  190. <include refid="productColumns"/>
  191. FROM product a
  192. <include refid="productJoins"/>
  193. <where>
  194. <if test="productID !=null and productID !=''">
  195. AND a.productID=#{productID}
  196. </if>
  197. <if test="name != null and name != ''">
  198. AND a.name LIKE
  199. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  200. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  201. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  202. </if>
  203. <if test="shopName != null and shopName != ''">
  204. AND s.name LIKE
  205. <if test="dbName == 'oracle'">'%'||#{shopName}||'%'</if>
  206. <if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
  207. <if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
  208. </if>
  209. AND a.validFlag in (2,3,9)
  210. and a.productCategory = 1
  211. </where>
  212. <choose>
  213. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  214. ORDER BY ${page.orderBy}
  215. </when>
  216. <otherwise>
  217. order by a.productID desc
  218. </otherwise>
  219. </choose>
  220. </select>
  221. <select id="findList" resultType="Product">
  222. SELECT
  223. <include refid="productColumns"/>
  224. FROM product a
  225. <include refid="productJoins"/>
  226. <where>
  227. <if test="id !=null and id !=''">
  228. AND a.productID=#{id}
  229. </if>
  230. <if test="tinyTypeID != null and tinyTypeID != ''">
  231. AND a.tinyTypeID = #{tinyTypeID}
  232. </if>
  233. <if test="shopID != null and shopID != ''">
  234. AND a.shopID = #{shopID}
  235. </if>
  236. <if test="preferredFlag != null and preferredFlag != ''and preferredFlag != 0">
  237. <if test="preferredFlag/100>=1">
  238. AND a.preferredFlag in (100,101,110,111)
  239. </if>
  240. <if test="(preferredFlag%100)/10>=1">
  241. AND a.preferredFlag in (10,11,110,111)
  242. </if>
  243. <if test="preferredFlag%10>=1">
  244. AND a.preferredFlag in (1,11,101,111)
  245. </if>
  246. </if>
  247. <if test="name != null and name != ''">
  248. AND a.name LIKE
  249. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  250. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  251. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  252. </if>
  253. <if test="shopName != null and shopName != ''">
  254. AND s.name LIKE
  255. <if test="dbName == 'oracle'">'%'||#{shopName}||'%'</if>
  256. <if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
  257. <if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
  258. </if>
  259. <if test="validFlag !=null and validFlag !=''">
  260. AND a.validFlag=#{validFlag}
  261. </if>
  262. <if test="actFlag !=null and actFlag !=''">
  263. AND a.actFlag=#{actFlag}
  264. </if>
  265. <if test="actType !=null and actType !=''">
  266. AND a.actType=#{actType}
  267. </if>
  268. <if test="speCommisionFlag !=null and speCommisionFlag !=''">
  269. AND a.speCommisionFlag=#{speCommisionFlag}
  270. </if>
  271. <if test="displayOnCRMFlag !=null and displayOnCRMFlag !=''">
  272. AND a.displayOnCRMFlag=#{displayOnCRMFlag}
  273. </if>
  274. <if test="crmBigTypeId !=null and crmBigTypeId !=''">
  275. AND a.crmBigTypeId=#{crmBigTypeId}
  276. </if>
  277. <if test="crmSmallTypeId !=null and crmSmallTypeId !=''">
  278. AND a.crmSmallTypeId=#{crmSmallTypeId}
  279. </if>
  280. <if test="sqlMap !=null and sqlMap !=''">
  281. ${sqlMap.dsf}
  282. </if>
  283. AND a.validFlag != 0
  284. AND a.shopID not in (SELECT s.`value` FROM `sys_dict` s WHERE s.type='heheShopID')
  285. and a.productCategory = 1
  286. </where>
  287. <choose>
  288. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  289. ORDER BY ${page.orderBy}
  290. </when>
  291. <otherwise>
  292. order by case WHEN a.validFlag = 1 then 0 else 1 END asc,a.productID desc
  293. </otherwise>
  294. </choose>
  295. </select>
  296. <select id="findAllList" resultType="Product">
  297. SELECT
  298. <include refid="productColumns"/>
  299. FROM product a
  300. <include refid="productJoins"/>
  301. <where>
  302. a.productCategory = 1
  303. </where>
  304. <choose>
  305. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  306. ORDER BY ${page.orderBy}
  307. </when>
  308. <otherwise>
  309. </otherwise>
  310. </choose>
  311. </select>
  312. <insert id="insert" parameterType="Product" keyProperty="productID" keyColumn="productID" useGeneratedKeys="true">
  313. INSERT INTO product(
  314. brandID,
  315. bigTypeID,
  316. smallTypeID,
  317. tinyTypeID,
  318. selfTypeID,
  319. shopID,
  320. aliasName,
  321. name,
  322. searchKey,
  323. normalPrice,
  324. price,
  325. priceFlag,
  326. beautyActFlag,
  327. ladderPriceFlag,
  328. stock,
  329. hasSkuFlag,
  330. mainImage,
  331. propertiesInfo,
  332. addTime,
  333. updateTime,
  334. weekSellNumber,
  335. beforeValidFlag,
  336. validFlag,
  337. favoriteTimes,
  338. commentScore,
  339. commentTimes,
  340. selfRecommendFlag,
  341. sysRecommendFlag,
  342. sortIndex,
  343. featuredFlag,
  344. featuredSortIndex,
  345. productCode,
  346. unit,
  347. synToERPFlag,
  348. allAreaFlag,
  349. provinceIDs,
  350. serviceNumber,
  351. maxBuyNumber,
  352. minBuyNumber,
  353. packageCount,
  354. byFlag,
  355. normalProductFlag,
  356. wholeSaleProductFlag,
  357. promotionProductFlag,
  358. groupBuyProductFlag,
  359. step,
  360. actFlag,
  361. actType,
  362. actSort,
  363. onlineTime,
  364. downlineTime,
  365. freePostFlag,
  366. costPrice,
  367. costProportional,
  368. costCheckFlag,
  369. precisehKey,
  370. visibility,
  371. productType,
  372. qualificationImg,
  373. invoiceType,
  374. taxPoint,
  375. supplierTaxPoint,
  376. tags,
  377. recommendType,
  378. machineType,
  379. includedTax,
  380. commodityType,
  381. trainingMethod,
  382. trainingType,
  383. trainingFee,
  384. productDescribe,
  385. splitCode,
  386. productDetail
  387. ) VALUES (
  388. #{brandID},
  389. #{bigTypeID},
  390. #{smallTypeID},
  391. #{tinyTypeID},
  392. #{selfTypeID},
  393. #{shopID},
  394. #{aliasName},
  395. #{name},
  396. #{searchKey},
  397. #{normalPrice},
  398. #{price},
  399. #{priceFlag},
  400. #{beautyActFlag},
  401. #{ladderPriceFlag},
  402. #{stock},
  403. #{hasSkuFlag},
  404. #{mainImage},
  405. #{propertiesInfo},
  406. #{addTime},
  407. #{updateTime},
  408. #{weekSellNumber},
  409. #{beforeValidFlag},
  410. #{validFlag},
  411. #{favoriteTimes},
  412. #{commentScore},
  413. #{commentTimes},
  414. #{selfRecommendFlag},
  415. #{sysRecommendFlag},
  416. #{sortIndex},
  417. #{featuredFlag},
  418. #{featuredSortIndex},
  419. #{productCode},
  420. #{unit},
  421. #{synToERPFlag},
  422. #{allAreaFlag},
  423. #{provinceIDs},
  424. #{serviceNumber},
  425. #{maxBuyNumber},
  426. #{minBuyNumber},
  427. #{packageCount},
  428. #{byFlag},
  429. #{normalProductFlag},
  430. #{wholeSaleProductFlag},
  431. #{promotionProductFlag},
  432. #{groupBuyProductFlag},
  433. #{step},
  434. #{actFlag},
  435. #{actType},
  436. #{actSort},
  437. #{onlineTime},
  438. #{downlineTime},
  439. #{freePostFlag},
  440. #{costPrice},
  441. #{costProportional},
  442. #{costCheckFlag},
  443. #{precisehKey},
  444. #{visibility},
  445. #{productType},
  446. #{qualificationImg},
  447. #{invoiceType},
  448. #{sqlTaxPoint},
  449. #{sqlSupplierTaxPoint},
  450. #{tags},
  451. #{recommendType},
  452. #{machineType},
  453. #{includedTax},
  454. #{commodityType},
  455. #{trainingMethod},
  456. #{trainingType},
  457. #{trainingFee},
  458. #{productDescribe},
  459. #{splitCode},
  460. #{productDetail}
  461. )
  462. </insert>
  463. <update id="update">
  464. UPDATE product SET
  465. productID = #{id},
  466. brandID = #{brandID},
  467. tinyTypeID = #{tinyTypeID},
  468. selfTypeID = #{selfTypeID},
  469. shopID = #{shopID},
  470. name = #{name},
  471. searchKey = #{searchKey},
  472. normalPrice = #{normalPrice},
  473. price = #{price},
  474. priceFlag = #{priceFlag},
  475. beautyActFlag = #{beautyActFlag},
  476. ladderPriceFlag = #{ladderPriceFlag},
  477. stock = #{stock},
  478. hasSkuFlag = #{hasSkuFlag},
  479. mainImage = #{mainImage},
  480. propertiesInfo = #{propertiesInfo},
  481. addTime = #{addTime},
  482. updateTime = #{updateTime},
  483. sellNumber = #{sellNumber},
  484. weekSellNumber = #{weekSellNumber},
  485. beforeValidFlag = #{beforeValidFlag},
  486. validFlag = #{validFlag},
  487. favoriteTimes = #{favoriteTimes},
  488. commentScore = #{commentScore},
  489. commentTimes = #{commentTimes},
  490. selfRecommendFlag = #{selfRecommendFlag},
  491. sysRecommendFlag = #{sysRecommendFlag},
  492. sortIndex = #{sortIndex},
  493. featuredFlag = #{featuredFlag},
  494. featuredSortIndex = #{featuredSortIndex},
  495. productCode = #{productCode},
  496. unit = #{unit},
  497. synToERPFlag = #{synToERPFlag},
  498. allAreaFlag = #{allAreaFlag},
  499. provinceIDs = #{provinceIDs},
  500. serviceNumber = #{serviceNumber},
  501. maxBuyNumber = #{maxBuyNumber},
  502. minBuyNumber = #{minBuyNumber},
  503. packageCount = #{packageCount},
  504. byFlag = #{byFlag},
  505. normalProductFlag = #{normalProductFlag},
  506. wholeSaleProductFlag = #{wholeSaleProductFlag},
  507. promotionProductFlag = #{promotionProductFlag},
  508. groupBuyProductFlag = #{groupBuyProductFlag},
  509. step = #{step},
  510. actFlag = #{actFlag},
  511. actType = #{actType},
  512. onlineTime = #{onlineTime},
  513. downlineTime = #{downlineTime},
  514. freePostFlag = #{freePostFlag},
  515. costPrice = #{costPrice},
  516. costProportional = #{costProportional},
  517. costCheckFlag = #{costCheckFlag},
  518. precisehKey = #{precisehKey},
  519. actSort = #{actSort}
  520. WHERE productID = #{id}
  521. </update>
  522. <update id="updateActive">
  523. UPDATE product
  524. <set>
  525. <if test="actFlag != null and actFlag != ''">
  526. actFlag = #{actFlag},
  527. </if>
  528. <if test="actType != null and actType != ''">
  529. actType = #{actType},
  530. </if>
  531. <if test="actSort != null and actSort != ''">
  532. actSort = #{actSort},
  533. </if>
  534. <if test="actCreateTime != null and actCreateTime != ''">
  535. actCreateTime = #{actCreateTime},
  536. </if>
  537. </set>
  538. WHERE productID = #{productID}
  539. </update>
  540. <update id="updatePreferred">
  541. UPDATE product SET preferredFlag = #{preferredFlag}
  542. WHERE productID = #{productID}
  543. </update>
  544. <delete id="delete">
  545. DELETE FROM product
  546. WHERE id = #{id}
  547. </delete>
  548. <update id="deleteProduct">
  549. UPDATE cm_search_recommend_product
  550. SET delFlag = #{DateTime}
  551. WHERE id = #{id}
  552. </update>
  553. <select id="getAllActType" resultType="com.caimei.po.ActType">
  554. SELECT
  555. *
  556. FROM acttype
  557. where validFlag = 1
  558. </select>
  559. <select id="getSupplierProductList" resultType="com.caimei.modules.product.entity.Product">
  560. SELECT
  561. *
  562. FROM
  563. product
  564. <where>
  565. <if test="name != null and name != ''">
  566. AND name LIKE concat('%',#{name},'%')
  567. </if>
  568. AND shopID = #{shopID}
  569. AND (validFlag = 1 or validFlag = 2 or validFlag = 3 or validFlag = 9)
  570. </where>
  571. ORDER BY addTime desc
  572. </select>
  573. <select id="getGiftProductInfo" parameterType="com.caimei.modules.product.entity.GiftProduct" resultType="com.caimei.modules.product.entity.GiftProduct">
  574. SELECT
  575. g.id as "id",
  576. g.fullGiftProductId as "fullGiftProductId",
  577. g.giftProductId as "giftProductId",
  578. g.actType as "actType",
  579. g.giftProductNum as "giftProductNum",
  580. p.name as "productName"
  581. FROM
  582. gift_product g
  583. left join product p on p.productID = g.giftProductId
  584. <where>
  585. g.fullGiftProductId = #{fullGiftProductId}
  586. AND g.actType = #{actType}
  587. <if test="giftProductId != null and giftProductId != ''">
  588. AND g.giftProductId = #{giftProductId}
  589. </if>
  590. <if test="delFlag != null and delFlag != ''">
  591. AND g.delFlag = #{delFlag}
  592. </if>
  593. and p.productCategory = 1
  594. </where>
  595. </select>
  596. <select id="getProductSku" resultType="com.caimei.modules.product.entity.Sku">
  597. SELECT
  598. *
  599. FROM
  600. sku
  601. <where>
  602. productID = #{productId}
  603. AND validFlag = 1
  604. </where>
  605. </select>
  606. <select id="findProductBigTypeByProductID" parameterType="java.lang.Integer" resultType="java.lang.String">
  607. SELECT
  608. tb.name
  609. FROM
  610. bigType AS tb
  611. INNER JOIN smallType AS ts
  612. ON tb.bigTypeID = ts.bigTypeID
  613. INNER JOIN tinyType AS tt
  614. ON ts.smallTypeID = tt.smallTypeID
  615. INNER JOIN product AS tp
  616. ON tt.tinyTypeID = tp.tinyTypeID
  617. <where>
  618. tp.productID = #{productId}
  619. and tp.productCategory = 1
  620. </where>
  621. </select>
  622. <update id="updateGiftProudct" parameterType="com.caimei.modules.product.entity.GiftProduct">
  623. update gift_product
  624. <set >
  625. <if test="fullGiftProductId != null and !=''" >
  626. fullGiftProductId = #{fullGiftProductId},
  627. </if>
  628. <if test="giftProductId != null and !=''" >
  629. giftProductId = #{giftProductId},
  630. </if>
  631. <if test="productName != null and !=''" >
  632. productName = #{productName},
  633. </if>
  634. <if test="actType != null and !=''" >
  635. actType = #{actType},
  636. </if>
  637. <if test="giftProductNum != null and !=''" >
  638. giftProductNum = #{giftProductNum},
  639. </if>
  640. <if test="createBy != null and !=''" >
  641. createBy = #{createBy.id},
  642. </if>
  643. <if test="createDate != null and !=''" >
  644. createDate = #{createDate},
  645. </if>
  646. <if test="updateBy != null and !=''" >
  647. updateBy = #{updateBy.id},
  648. </if>
  649. <if test="updateDate != null and !=''" >
  650. updateDate = #{updateDate},
  651. </if>
  652. <if test="delFlag != null and !=''" >
  653. delFlag = #{delFlag},
  654. </if>
  655. </set>
  656. where id = #{id}
  657. </update>
  658. <insert id="insertGiftProudct" parameterType="com.caimei.modules.product.entity.GiftProduct" keyProperty="id" useGeneratedKeys="true">
  659. INSERT INTO gift_product(
  660. fullGiftProductId,
  661. giftProductId,
  662. productName,
  663. actType,
  664. giftProductNum,
  665. createBy,
  666. createDate,
  667. updateBy,
  668. updateDate,
  669. delFlag
  670. ) VALUES (
  671. #{fullGiftProductId},
  672. #{giftProductId},
  673. #{productName},
  674. #{actType},
  675. #{giftProductNum},
  676. #{createBy.id},
  677. #{createDate},
  678. #{updateBy.id},
  679. #{updateDate},
  680. #{delFlag}
  681. )
  682. </insert>
  683. <insert id="insertProductPriceRecord" parameterType="com.caimei.modules.product.entity.ProductPriceRecord" keyProperty="productPriceRecordID" useGeneratedKeys="true">
  684. INSERT INTO productpricerecord(
  685. `productID`,
  686. `shopID`,
  687. `highestUserLevelPrice`,
  688. `lowestUserLevelPrice`,
  689. `lowestUserLevelID`,
  690. `price0`,
  691. `price1`,
  692. `updateTime`
  693. )
  694. VALUES
  695. (
  696. #{productID},
  697. #{shopID},
  698. #{highestUserLevelPrice},
  699. #{lowestUserLevelPrice},
  700. #{lowestUserLevelID},
  701. #{price0},
  702. #{price1},
  703. #{updateTime}
  704. )
  705. </insert>
  706. <!-- <update id="updateCRMFlag">-->
  707. <!-- UPDATE product a SET a.displayOnCRMFlag = #{param1}-->
  708. <!-- WHERE a.productID IN-->
  709. <!-- <foreach collection="param2" item="id" index="index" open="(" separator="," close=")" >-->
  710. <!-- #{id}-->
  711. <!-- </foreach>-->
  712. <!-- </update>-->
  713. <update id="deleteActive">
  714. UPDATE product a SET a.actFlag = 0
  715. WHERE a.productID = #{id}
  716. </update>
  717. <update id="updatePostFlag">
  718. UPDATE product a SET a.freePostFlag = #{param1}
  719. WHERE a.productID IN
  720. <foreach collection="param2" item="id" index="index" open="(" separator="," close=")" >
  721. #{id}
  722. </foreach>
  723. </update>
  724. <select id="getBigTypeList" resultType="com.caimei.modules.product.entity.ProductBigType">
  725. select * from bigtype
  726. <where>
  727. validFlag = 1
  728. <if test="bigTypeID != null and bigTypeID != ''">
  729. AND bigTypeID = #{bigTypeID}
  730. </if>
  731. </where>
  732. </select>
  733. <select id="getSmallTypeList" resultType="com.caimei.modules.product.entity.ProductSmallType">
  734. select * from smalltype
  735. <where>
  736. validFlag = 1
  737. <if test="bigTypeID != null and bigTypeID != ''">
  738. AND bigTypeID = #{bigTypeID}
  739. </if>
  740. <if test="smallTypeID != null and smallTypeID != ''">
  741. AND smallTypeID = #{smallTypeID}
  742. </if>
  743. </where>
  744. </select>
  745. <select id="getTinyTypeList" resultType="com.caimei.modules.product.entity.ProducTinyType">
  746. select * from tinytype
  747. <where>
  748. validFlag = 1
  749. <if test="smallTypeID != null and smallTypeID != ''">
  750. AND smallTypeID = #{smallTypeID}
  751. </if>
  752. <if test="smallTypeID != null and smallTypeID != ''">
  753. AND smallTypeID = #{smallTypeID}
  754. </if>
  755. </where>
  756. </select>
  757. <select id="getProductTypeNameAndID" resultType="map">
  758. select
  759. b.name AS bigTypeName,
  760. b.bigTypeID AS bigTypeID,
  761. s.name AS smallTypeName,
  762. s.smallTypeID AS smallTypeID,
  763. t.name AS tinyTypeName,
  764. t.tinyTypeID AS tinyTypeID
  765. from tinytype AS t
  766. join smalltype AS s on t.smallTypeID = s.smallTypeID
  767. JOIN bigtype AS b on b.bigTypeID = s.bigTypeID
  768. where t.tinyTypeID = #{tinyTypeID}
  769. </select>
  770. <delete id="deleteCustomClassification">
  771. delete from product_custom_classification
  772. where productID = #{productID}
  773. </delete>
  774. <insert id="insertCustomClassification" parameterType="com.caimei.modules.product.entity.ProductCustomClassification" keyProperty="userId" useGeneratedKeys="true">
  775. INSERT INTO product_custom_classification(
  776. productID,
  777. bigTypeID,
  778. smallTypeID,
  779. tinyTypeID,
  780. createDate,
  781. updateDate
  782. ) VALUES (
  783. #{productID},
  784. #{bigTypeID},
  785. #{smallTypeID},
  786. #{tinyTypeID},
  787. #{createDate},
  788. #{updateDate}
  789. )
  790. </insert>
  791. <insert id="insertAddProduct">
  792. INSERT INTO cm_search_recommend_product(
  793. productID,
  794. tinyTypeID,
  795. sort,
  796. delFlag
  797. ) VALUES (
  798. #{productID},
  799. #{tinyTypeID},
  800. 0,
  801. 0
  802. )
  803. </insert>
  804. <insert id="insertLadderPrice">
  805. insert into product_ladder_price (productId, userType, ladderNum,
  806. buyNum, buyPrice, createBy, createDate, delFlag)
  807. values (#{productId}, 3, #{ladderNum},
  808. #{buyNum}, #{buyPrice}, #{createBy},
  809. #{createDate},'0')
  810. </insert>
  811. <insert id="insertProduct" keyColumn="productID" keyProperty="productID" parameterType="com.caimei.modules.product.entity.Product" useGeneratedKeys="true">
  812. INSERT INTO `product` (
  813. `brandID`,
  814. `tinyTypeID`,
  815. <if test="productCategory != null and productCategory != '' ">
  816. `productCategory`,
  817. </if>
  818. `preferredFlag`,
  819. `selfTypeID`,
  820. `shopID`,
  821. `name`,
  822. `aliasName`,
  823. `searchKey`,
  824. `productRemarks`,
  825. `normalPrice`,
  826. `price`,
  827. `priceFlag`,
  828. `beautyActFlag`,
  829. `ladderPriceFlag`,
  830. `stock`,
  831. `hasSkuFlag`,
  832. `mainImage`,
  833. `propertiesInfo`,
  834. `addTime`,
  835. `updateTime`,
  836. `weekSellNumber`,
  837. `beforeValidFlag`,
  838. `validFlag`,
  839. `favoriteTimes`,
  840. `commentScore`,
  841. `commentTimes`,
  842. `selfRecommendFlag`,
  843. `sysRecommendFlag`,
  844. `sortIndex`,
  845. `featuredFlag`,
  846. `featuredSortIndex`,
  847. `productCode`,
  848. `unit`,
  849. `synToERPFlag`,
  850. `allAreaFlag`,
  851. `provinceIDs`,
  852. `serviceNumber`,
  853. `maxBuyNumber`,
  854. `minBuyNumber`,
  855. `packageCount`,
  856. `byFlag`,
  857. `normalProductFlag`,
  858. `wholeSaleProductFlag`,
  859. `promotionProductFlag`,
  860. `groupBuyProductFlag`,
  861. `step`,
  862. `actFlag`,
  863. `actStatus`,
  864. `actSort`,
  865. `actType`,
  866. `visibility`,
  867. `onlineTime`,
  868. `downlineTime`,
  869. `freePostFlag`,
  870. `costPrice`,
  871. `costProportional`,
  872. `costCheckFlag`,
  873. `precisehKey`,
  874. `tags`,
  875. `productType`,
  876. `machineType`,
  877. `qualificationImg`,
  878. `includedTax`,
  879. `taxPoint`,
  880. `invoiceType`,
  881. `recommendType`,
  882. `combinationID`,
  883. `combinationSort`
  884. )
  885. VALUES
  886. (
  887. #{brandID},
  888. #{tinyTypeID},
  889. <if test="productCategory != null and productCategory != '' ">
  890. #{productCategory},
  891. </if>
  892. #{preferredFlag},
  893. #{selfTypeID},
  894. #{shopID},
  895. #{name},
  896. #{aliasName},
  897. #{searchKey},
  898. #{productRemarks},
  899. #{normalPrice},
  900. #{price},
  901. #{priceFlag},
  902. #{beautyActFlag},
  903. #{ladderPriceFlag},
  904. #{stock},
  905. #{hasSkuFlag},
  906. #{mainImage},
  907. #{propertiesInfo},
  908. #{addTime},
  909. #{updateTime},
  910. #{weekSellNumber},
  911. #{beforeValidFlag},
  912. #{validFlag},
  913. #{favoriteTimes},
  914. #{commentScore},
  915. #{commentTimes},
  916. #{selfRecommendFlag},
  917. #{sysRecommendFlag},
  918. #{sortIndex},
  919. #{featuredFlag},
  920. #{featuredSortIndex},
  921. #{productCode},
  922. #{unit},
  923. #{synToERPFlag},
  924. #{allAreaFlag},
  925. #{provinceIDs},
  926. #{serviceNumber},
  927. #{maxBuyNumber},
  928. #{minBuyNumber},
  929. #{packageCount},
  930. #{byFlag},
  931. #{normalProductFlag},
  932. #{wholeSaleProductFlag},
  933. #{promotionProductFlag},
  934. #{groupBuyProductFlag},
  935. #{step},
  936. #{actFlag},
  937. #{actStatus},
  938. #{actSort},
  939. #{actType},
  940. #{visibility},
  941. #{onlineTime},
  942. #{downlineTime},
  943. #{freePostFlag},
  944. #{costPrice},
  945. #{costProportional},
  946. #{costCheckFlag},
  947. #{precisehKey},
  948. #{tags},
  949. #{productType},
  950. #{machineType},
  951. #{qualificationImg},
  952. #{includedTax},
  953. #{taxPoint},
  954. #{invoiceType},
  955. #{recommendType},
  956. #{combinationID},
  957. #{combinationSort}
  958. )
  959. </insert>
  960. <insert id="insertProductDetailInfo">
  961. insert into productdetailinfo
  962. <trim prefix="(" suffix=")" suffixOverrides=",">
  963. <if test="productID != null">
  964. `productID`,
  965. </if>
  966. <if test="detailInfo != null and detailInfo != ''">
  967. `detailInfo`,
  968. </if>
  969. <if test="serviceInfo != null and serviceInfo != ''">
  970. `serviceInfo`,
  971. </if>
  972. <if test="orderInfo != null and orderInfo != ''">
  973. `orderInfo`,
  974. </if>
  975. </trim>
  976. <trim prefix="values (" suffix=")" suffixOverrides=",">
  977. <if test="productID != null">
  978. #{productID},
  979. </if>
  980. <if test="detailInfo != null and detailInfo != ''">
  981. #{detailInfo},
  982. </if>
  983. <if test="serviceInfo != null and serviceInfo != ''">
  984. #{serviceInfo},
  985. </if>
  986. <if test="orderInfo != null and orderInfo != ''">
  987. #{orderInfo},
  988. </if>
  989. </trim>
  990. </insert>
  991. <select id="getrecommendProductList" resultType="product">
  992. select
  993. a.*,
  994. csrp.sort AS sort,
  995. csrp.id AS recommendProductId,
  996. b.name AS brandName,
  997. s.name AS shopName
  998. FROM
  999. cm_search_recommend_product csrp
  1000. LEFT JOIN product a on a.productID = csrp.productID
  1001. LEFT JOIN shop s on s.shopID = a.shopID
  1002. left join cm_brand b on b.id = a.brandID
  1003. WHERE
  1004. csrp.tinyTypeId = #{tinyTypeID}
  1005. <if test="name != null and name != ''">
  1006. AND a.name like concat('%', #{name} ,'%')
  1007. </if>
  1008. <if test="validFlag !=null and validFlag !=''">
  1009. AND a.validFlag=#{validFlag}
  1010. </if>
  1011. <if test="shopName != null and shopName != ''">
  1012. AND s.name like concat('%', #{shopName} ,'%')
  1013. </if>
  1014. <if test="brandName != null and brandName != ''">
  1015. AND b.name like concat('%', #{brandName} ,'%')
  1016. </if>
  1017. and a.productCategory = 1
  1018. AND a.validFlag != 0
  1019. AND csrp.delFlag =0
  1020. ORDER BY csrp.sort DESC
  1021. </select>
  1022. <select id="relatedProductList" resultType="product">
  1023. select
  1024. <include refid="productColumns"/>,
  1025. b.name AS brandName,
  1026. (case when a.tinyTypeID = #{tinyTypeID} then '1' else '0' end) AS defaultType
  1027. FROM product a
  1028. <include refid="productJoins"/>
  1029. left join brand b on b.brandID = a.brandID
  1030. WHERE (a.productID
  1031. IN (select productID from product_custom_classification where tinyTypeID = #{tinyTypeID})
  1032. OR a.tinyTypeID = #{tinyTypeID})
  1033. <if test="name != null and name != ''">
  1034. AND a.name like concat('%', #{name} ,'%')
  1035. </if>
  1036. <if test="validFlag !=null and validFlag !=''">
  1037. AND a.validFlag=#{validFlag}
  1038. </if>
  1039. <if test="shopName != null and shopName != ''">
  1040. AND s.name like concat('%', #{shopName} ,'%')
  1041. </if>
  1042. <if test="brandName != null and brandName != ''">
  1043. AND b.name like concat('%', #{brandName} ,'%')
  1044. </if>
  1045. AND a.validFlag != 0
  1046. and a.productCategory = 1
  1047. </select>
  1048. <delete id="deleteProductCustomClassification">
  1049. delete from product_custom_classification
  1050. where productID = #{productID} and tinyTypeID = #{tinyTypeID}
  1051. </delete>
  1052. <delete id="deleteLadderPriceByProductId">
  1053. DELETE FROM product_ladder_price where productId = #{productID}
  1054. </delete>
  1055. <delete id="deleteLadderPriceById">
  1056. DELETE FROM product_ladder_price where id = #{id}
  1057. </delete>
  1058. <select id="toAddProductCustomClassificationList" resultType="product">
  1059. select
  1060. <include refid="productColumns"/>,
  1061. b.name AS brandName
  1062. FROM product a
  1063. <include refid="productJoins"/>
  1064. left join cm_brand b on b.id = a.brandID
  1065. WHERE a.tinyTypeID != #{tinyTypeID}
  1066. and not exists
  1067. (select pcc.id from product_custom_classification pcc where pcc.productID = a.productID and pcc.tinyTypeID = #{tinyTypeID})
  1068. and a.validFlag = '2'
  1069. and (select count(id) from product_custom_classification pcc where pcc.productID = a.productID) <![CDATA[ < ]]> 5
  1070. <if test="name != null and name != ''">
  1071. and a.name like concat('%', #{name} ,'%')
  1072. </if>
  1073. <if test="shopName != null and shopName != ''">
  1074. AND s.name like concat('%', #{shopName} ,'%')
  1075. </if>
  1076. <if test="brandName != null and brandName != ''">
  1077. AND b.name like concat('%', #{brandName} ,'%')
  1078. </if>
  1079. </select>
  1080. <select id="toAddProductList" resultType="product">
  1081. select
  1082. a.*,
  1083. b.name AS brandName,
  1084. s.name AS shopName
  1085. FROM product a
  1086. LEFT JOIN shop s on s.shopID = a.shopID
  1087. left join cm_brand b on b.id = a.brandID
  1088. WHERE
  1089. NOT EXISTS (select * from cm_search_recommend_product csrp where csrp.productID = a.productID and csrp.tinyTypeID = #{tinyTypeID} AND csrp.delFlag = 0)
  1090. and a.validFlag = '2'
  1091. <if test="name != null and name != ''">
  1092. and a.name like concat('%', #{name} ,'%')
  1093. </if>
  1094. <if test="shopName != null and shopName != ''">
  1095. AND s.name like concat('%', #{shopName} ,'%')
  1096. </if>
  1097. <if test="brandName != null and brandName != ''">
  1098. AND b.name like concat('%', #{brandName} ,'%')
  1099. </if>
  1100. and a.productCategory = 1
  1101. </select>
  1102. <select id="getProductTypes" resultType="com.caimei.modules.product.entity.ProductCustomClassification">
  1103. select *
  1104. from product_custom_classification where productID = #{productID}
  1105. </select>
  1106. <select id="findRecommendActivityListPage" resultType="Product">
  1107. SELECT
  1108. <include refid="productColumns"/>
  1109. FROM product a
  1110. <include refid="ActivityJoins"/>
  1111. <where>
  1112. <if test="id !=null and id !=''">
  1113. AND a.productID=#{id}
  1114. </if>
  1115. <if test="tinyTypeID != null and tinyTypeID != ''">
  1116. AND a.tinyTypeID = #{tinyTypeID}
  1117. </if>
  1118. <if test="smallTypeID != null and smallTypeID != ''">
  1119. AND a.smallTypeID = #{smallTypeID}
  1120. </if>
  1121. <if test="bigTypeID != null and bigTypeID != ''">
  1122. AND a.bigTypeID = #{bigTypeID}
  1123. </if>
  1124. <if test="shopID != null and shopID != ''">
  1125. AND a.shopID = #{shopID}
  1126. </if>
  1127. <if test="name != null and name != ''">
  1128. AND a.name LIKE
  1129. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  1130. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  1131. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  1132. </if>
  1133. <if test="shopName != null and shopName != ''">
  1134. AND s.name LIKE
  1135. <if test="dbName == 'oracle'">'%'||#{shopName}||'%'</if>
  1136. <if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
  1137. <if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
  1138. </if>
  1139. <if test="actFlag !=null and actFlag !=''">
  1140. AND a.actFlag=#{actFlag}
  1141. </if>
  1142. <if test="sqlMap !=null and sqlMap !=''">
  1143. ${sqlMap.dsf}
  1144. </if>
  1145. AND a.validFlag = 2
  1146. AND (a.actType != 3 or a.`actType` IS NULL or (a.actType = 3 and STR_TO_DATE(a.endTime,'%Y-%m-%d %H:%i') <![CDATA[ < ]]> STR_TO_DATE(SYSDATE(),'%Y-%m-%d %H:%i')))
  1147. AND a.shopID not in (SELECT s.`value` FROM `sys_dict` s WHERE s.type='heheShopID')
  1148. and a.productCategory = 1
  1149. </where>
  1150. <choose>
  1151. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  1152. ORDER BY ${page.orderBy}
  1153. </when>
  1154. <otherwise>
  1155. order by case WHEN a.validFlag = 1 then 0 else 1 END asc,a.productID desc
  1156. </otherwise>
  1157. </choose>
  1158. </select>
  1159. <select id="findGroupActivityListPage" resultType="Product">
  1160. SELECT
  1161. <include refid="productColumns"/>
  1162. FROM product a
  1163. <include refid="ActivityJoins"/>
  1164. <where>
  1165. <if test="id !=null and id !=''">
  1166. AND a.productID=#{id}
  1167. </if>
  1168. <if test="tinyTypeID != null and tinyTypeID != ''">
  1169. AND a.tinyTypeID = #{tinyTypeID}
  1170. </if>
  1171. <if test="smallTypeID != null and smallTypeID != ''">
  1172. AND a.smallTypeID = #{smallTypeID}
  1173. </if>
  1174. <if test="bigTypeID != null and bigTypeID != ''">
  1175. AND a.bigTypeID = #{bigTypeID}
  1176. </if>
  1177. <if test="shopID != null and shopID != ''">
  1178. AND a.shopID = #{shopID}
  1179. </if>
  1180. <if test="name != null and name != ''">
  1181. AND a.name LIKE
  1182. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  1183. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  1184. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  1185. </if>
  1186. <if test="shopName != null and shopName != ''">
  1187. AND s.name LIKE
  1188. <if test="dbName == 'oracle'">'%'||#{shopName}||'%'</if>
  1189. <if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
  1190. <if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
  1191. </if>
  1192. <if test="actFlag !=null and actFlag !=''">
  1193. AND a.actFlag=#{actFlag}
  1194. </if>
  1195. <if test="actStatus != null and actStatus != '' and actStatus == 1">
  1196. AND STR_TO_DATE(SYSDATE(),'%Y-%m-%d %H:%i') <![CDATA[ < ]]> STR_TO_DATE(a.beginTime,'%Y-%m-%d %H:%i')
  1197. </if>
  1198. <if test="actStatus != null and actStatus != '' and actStatus == 2">
  1199. AND STR_TO_DATE(SYSDATE(),'%Y-%m-%d %H:%i') <![CDATA[ > ]]> STR_TO_DATE(a.beginTime,'%Y-%m-%d %H:%i')
  1200. AND STR_TO_DATE(SYSDATE(),'%Y-%m-%d %H:%i') <![CDATA[ < ]]> STR_TO_DATE(a.endTime,'%Y-%m-%d %H:%i')
  1201. </if>
  1202. <if test="sqlMap !=null and sqlMap !=''">
  1203. ${sqlMap.dsf}
  1204. </if>
  1205. AND a.validFlag = 2
  1206. AND ((a.actType != 1 AND a.actType != 2 OR a.`actType` IS NULL) or a.actFlag = 0)
  1207. AND a.shopID not in (SELECT s.`value` FROM `sys_dict` s WHERE s.type='heheShopID')
  1208. and a.productCategory = 1
  1209. </where>
  1210. <choose>
  1211. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  1212. ORDER BY ${page.orderBy}
  1213. </when>
  1214. <otherwise>
  1215. order by case WHEN a.validFlag = 1 then 0 else 1 END asc,a.productID desc
  1216. </otherwise>
  1217. </choose>
  1218. </select>
  1219. <select id="findBigTypeList" resultType="com.caimei.modules.product.entity.ProductBigType">
  1220. SELECT
  1221. *
  1222. FROM bigtype a
  1223. <where>
  1224. <if test="bigTypeID != null and bigTypeID != ''">
  1225. AND a.bigTypeID = #{bigTypeID}
  1226. </if>
  1227. <if test="name != null and name != ''">
  1228. AND a.name LIKE
  1229. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  1230. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  1231. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  1232. </if>
  1233. </where>
  1234. </select>
  1235. <select id="findSmallTypeList" resultType="com.caimei.modules.product.entity.ProductSmallType">
  1236. SELECT
  1237. *
  1238. FROM smalltype a
  1239. <where>
  1240. <if test="smallTypeID != null and smallTypeID != ''">
  1241. AND a.smallTypeID = #{smallTypeID}
  1242. </if>
  1243. <if test="bigTypeID != null and bigTypeID != ''">
  1244. AND a.bigTypeID = #{bigTypeID}
  1245. </if>
  1246. <if test="name != null and name != ''">
  1247. AND a.name LIKE
  1248. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  1249. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  1250. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  1251. </if>
  1252. </where>
  1253. </select>
  1254. <select id="findTinyTypeList" resultType="com.caimei.modules.product.entity.ProducTinyType">
  1255. SELECT
  1256. *
  1257. FROM tinytype a
  1258. <where>
  1259. <if test="tinyTypeID != null and tinyTypeID != ''">
  1260. AND a.tinyTypeID = #{tinyTypeID}
  1261. </if>
  1262. <if test="smallTypeID != null and smallTypeID != ''">
  1263. AND a.smallTypeID = #{smallTypeID}
  1264. </if>
  1265. <if test="name != null and name != ''">
  1266. AND a.name LIKE
  1267. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  1268. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  1269. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  1270. </if>
  1271. </where>
  1272. </select>
  1273. <select id="findProductRecommendList" resultType="com.caimei.modules.product.entity.CmProductRecommend">
  1274. select
  1275. cpr.id AS id,
  1276. cpr.productID AS productID,
  1277. cpr.recommendProductID AS recommendProductID,
  1278. cpr.sort AS sort,
  1279. pro.name AS productName,
  1280. pro.unit AS unit,
  1281. pro.mainImage AS img,
  1282. cpr.shopName AS shopName
  1283. from cm_product_recommend cpr
  1284. join product pro on cpr.recommendProductID = pro.productID
  1285. where cpr.productID = #{productID}
  1286. order by cpr.sort desc
  1287. </select>
  1288. <select id="findProductRecommendCount" resultType="int">
  1289. select
  1290. count(1)
  1291. from cm_product_recommend cpr
  1292. where cpr.productID = #{productID}
  1293. </select>
  1294. <select id="findProductList" resultType="com.caimei.modules.product.entity.CmProductRecommend">
  1295. select
  1296. a.productID AS productID,
  1297. a.name AS productName,
  1298. a.unit AS unit,
  1299. a.mainImage AS img,
  1300. s.name AS shopName
  1301. from product a
  1302. <include refid="ActivityJoins"/>
  1303. <where>
  1304. <choose>
  1305. <when test="commodityType != null and commodityType != ''">
  1306. AND a.commodityType = #{commodityType}
  1307. </when>
  1308. <when test="bigTypeID != null and bigTypeID != ''">
  1309. AND a.bigTypeID = #{bigTypeID}
  1310. </when>
  1311. <when test="smallTypeID != null and smallTypeID != ''">
  1312. AND a.smallTypeID = #{smallTypeID}
  1313. </when>
  1314. <when test="tinyTypeID != null and tinyTypeID != ''">
  1315. AND a.tinyTypeID = #{tinyTypeID}
  1316. </when>
  1317. </choose>
  1318. <if test="productName != null and productName != ''">
  1319. and a.name like concat('%', #{productName} ,'%')
  1320. </if>
  1321. <if test="shopName != null and shopName != ''">
  1322. and s.name like concat('%', #{shopName} ,'%')
  1323. </if>
  1324. and a.productCategory = 1
  1325. </where>
  1326. <!-- limit 0, 10-->
  1327. </select>
  1328. <update id="updateRecommendType">
  1329. UPDATE product SET
  1330. recommendType = #{recommendType}
  1331. WHERE productID = #{productID}
  1332. </update>
  1333. <update id="updateBrnadId">
  1334. UPDATE product
  1335. set brandID = #{brandID}
  1336. WHERE productID = #{productID}
  1337. </update>
  1338. <update id="updateProductByBrandId">
  1339. UPDATE product
  1340. set brandID = null
  1341. WHERE brandID = #{brandId}
  1342. </update>
  1343. <select id="getProductIdByBrandId" resultType="java.lang.Integer">
  1344. SELECT productID FROM product WHERE brandID = #{brandId}
  1345. </select>
  1346. <update id="updateTinyType">
  1347. UPDATE product
  1348. set tinyTypeID = #{tinyTypeID}
  1349. WHERE productID = #{productID}
  1350. </update>
  1351. <update id="updateByPrimaryKeySelective" parameterType="com.caimei.modules.product.entity.Product">
  1352. update product
  1353. <set>
  1354. <if test="productDescribe != null and productDescribe != ''">
  1355. productDescribe = #{productDescribe},
  1356. </if>
  1357. <if test="productDetail != null and productDetail != ''">
  1358. productDetail = #{productDetail},
  1359. </if>
  1360. <if test="brandID != null and brandID != ''">
  1361. brandID = #{brandID},
  1362. </if>
  1363. <if test="bigTypeID != null and bigTypeID !=''">
  1364. bigTypeID = #{bigTypeID},
  1365. smallTypeID = #{smallTypeID},
  1366. tinyTypeID = #{tinyTypeID},
  1367. </if>
  1368. <if test="preferredFlag != null and preferredFlag !=''">
  1369. preferredFlag = #{preferredFlag},
  1370. </if>
  1371. <if test="shopID != null and shopID !=''">
  1372. shopID = #{shopID},
  1373. </if>
  1374. <if test="name != null and name !=''">
  1375. `name` = #{name},
  1376. </if>
  1377. <if test="aliasName != null and aliasName !=''">
  1378. aliasName = #{aliasName},
  1379. </if>
  1380. <if test="searchKey != null and searchKey !=''">
  1381. searchKey = #{searchKey},
  1382. </if>
  1383. <if test="productRemarks != null and productRemarks !=''">
  1384. productRemarks = #{productRemarks},
  1385. </if>
  1386. <if test="combinationID != null and combinationID !=''">
  1387. combinationID = #{combinationID},
  1388. </if>
  1389. <if test="normalPrice != null and normalPrice !=''">
  1390. normalPrice = #{normalPrice},
  1391. </if>
  1392. <if test="price != null and price !=''">
  1393. price = #{price},
  1394. </if>
  1395. <if test="priceFlag != null and priceFlag !=''">
  1396. priceFlag = #{priceFlag},
  1397. </if>
  1398. <if test="beautyActFlag != null and beautyActFlag !=''">
  1399. beautyActFlag = #{beautyActFlag},
  1400. </if>
  1401. <if test="ladderPriceFlag != null and ladderPriceFlag !=''">
  1402. ladderPriceFlag = #{ladderPriceFlag},
  1403. </if>
  1404. <if test="stock != null and stock !=''">
  1405. stock = #{stock},
  1406. </if>
  1407. <if test="hasSkuFlag != null and hasSkuFlag !=''">
  1408. hasSkuFlag = #{hasSkuFlag},
  1409. </if>
  1410. <if test="mainImage != null and mainImage !=''">
  1411. mainImage = #{mainImage},
  1412. </if>
  1413. <if test="propertiesInfo != null and propertiesInfo !=''">
  1414. propertiesInfo = #{propertiesInfo},
  1415. </if>
  1416. <if test="addTime != null and addTime !=''">
  1417. addTime = #{addTime},
  1418. </if>
  1419. <if test="updateTime != null and updateTime !=''">
  1420. updateTime = #{updateTime},
  1421. </if>
  1422. <if test="weekSellNumber != null and weekSellNumber !=''">
  1423. weekSellNumber = #{weekSellNumber},
  1424. </if>
  1425. <if test="beforeValidFlag != null and beforeValidFlag !=''">
  1426. beforeValidFlag = #{beforeValidFlag},
  1427. </if>
  1428. <if test="validFlag != null and validFlag !=''">
  1429. validFlag = #{validFlag},
  1430. </if>
  1431. <if test="favoriteTimes != null and favoriteTimes !=''">
  1432. favoriteTimes = #{favoriteTimes},
  1433. </if>
  1434. <if test="commentScore != null and commentScore !=''">
  1435. commentScore = #{commentScore},
  1436. </if>
  1437. <if test="commentTimes != null and commentTimes !=''">
  1438. commentTimes = #{commentTimes},
  1439. </if>
  1440. <if test="selfRecommendFlag != null and selfRecommendFlag !=''">
  1441. selfRecommendFlag = #{selfRecommendFlag},
  1442. </if>
  1443. <if test="sysRecommendFlag != null and sysRecommendFlag !=''">
  1444. sysRecommendFlag = #{sysRecommendFlag},
  1445. </if>
  1446. <if test="sortIndex != null and sortIndex != ''">
  1447. sortIndex = #{sortIndex},
  1448. </if>
  1449. <if test="featuredFlag != null and featuredFlag !=''">
  1450. featuredFlag = #{featuredFlag},
  1451. </if>
  1452. <if test="featuredSortIndex != null and featuredSortIndex !=''">
  1453. featuredSortIndex = #{featuredSortIndex},
  1454. </if>
  1455. <if test="productCode != null and productCode !=''">
  1456. productCode = #{productCode},
  1457. </if>
  1458. <if test="unit != null and unit !=''">
  1459. unit = #{unit},
  1460. </if>
  1461. <if test="synToERPFlag != null and synToERPFlag !=''">
  1462. synToERPFlag = #{synToERPFlag},
  1463. </if>
  1464. <if test="allAreaFlag != null and allAreaFlag !=''">
  1465. allAreaFlag = #{allAreaFlag},
  1466. </if>
  1467. <if test="provinceIDs != null and provinceIDs !=''">
  1468. provinceIDs = #{provinceIDs},
  1469. </if>
  1470. <if test="serviceNumber != null and serviceNumber !=''">
  1471. serviceNumber = #{serviceNumber},
  1472. </if>
  1473. <if test="maxBuyNumber != null and maxBuyNumber !=''">
  1474. maxBuyNumber = #{maxBuyNumber},
  1475. </if>
  1476. <if test="minBuyNumber != null and minBuyNumber !=''">
  1477. minBuyNumber = #{minBuyNumber},
  1478. </if>
  1479. <if test="packageCount != null and packageCount !=''">
  1480. packageCount = #{packageCount},
  1481. </if>
  1482. <if test="byFlag != null and byFlag !=''">
  1483. byFlag = #{byFlag},
  1484. </if>
  1485. <if test="normalProductFlag != null and normalProductFlag !=''">
  1486. normalProductFlag = #{normalProductFlag},
  1487. </if>
  1488. <if test="wholeSaleProductFlag != null and wholeSaleProductFlag !=''">
  1489. wholeSaleProductFlag = #{wholeSaleProductFlag},
  1490. </if>
  1491. <if test="promotionProductFlag != null and promotionProductFlag !=''">
  1492. promotionProductFlag = #{promotionProductFlag},
  1493. </if>
  1494. <if test="groupBuyProductFlag != null and groupBuyProductFlag !=''">
  1495. groupBuyProductFlag = #{groupBuyProductFlag},
  1496. </if>
  1497. <if test="step != null and step !=''">
  1498. step = #{step},
  1499. </if>
  1500. <if test="actFlag != null and actFlag !=''">
  1501. actFlag = #{actFlag},
  1502. </if>
  1503. <if test="actSort != null and actSort !=''">
  1504. actSort = #{actSort},
  1505. </if>
  1506. <if test="actType != null and actType !=''">
  1507. actType = #{actType},
  1508. </if>
  1509. <if test="onlineTime != null and onlineTime !=''">
  1510. onlineTime = #{onlineTime},
  1511. </if>
  1512. <if test="downlineTime != null and downlineTime !=''">
  1513. downlineTime = #{downlineTime},
  1514. </if>
  1515. <if test="freePostFlag != null and freePostFlag !=''">
  1516. freePostFlag = #{freePostFlag},
  1517. </if>
  1518. <if test="costPrice != null and costPrice != ''">
  1519. costPrice = #{costPrice},
  1520. </if>
  1521. <if test="costProportional != null and costProportional !=''">
  1522. costProportional = #{costProportional},
  1523. </if>
  1524. <if test="costCheckFlag != null and costCheckFlag !=''">
  1525. costCheckFlag = #{costCheckFlag},
  1526. </if>
  1527. <if test="precisehKey != null and precisehKey !=''">
  1528. precisehKey = #{precisehKey},
  1529. </if>
  1530. <if test="visibility != null and visibility !=''">
  1531. visibility = #{visibility},
  1532. </if>
  1533. <if test="productType != null and productType !=''">
  1534. productType = #{productType},
  1535. </if>
  1536. <if test="qualificationImg != null and qualificationImg !=''">
  1537. qualificationImg = #{qualificationImg},
  1538. </if>
  1539. <if test="qualificationImg != null and qualificationImg !=''">
  1540. qualificationImg = #{qualificationImg},
  1541. </if>
  1542. <if test="invoiceType != null and invoiceType !=''">
  1543. invoiceType = #{invoiceType},
  1544. </if>
  1545. <if test="taxPoint != null and taxPoint !=''">
  1546. taxPoint = #{taxPoint},
  1547. </if>
  1548. <if test="supplierTaxPoint != null and supplierTaxPoint !=''">
  1549. supplierTaxPoint = #{supplierTaxPoint},
  1550. </if>
  1551. <if test="endTimeStr != null and endTimeStr !=''">
  1552. endTimeStr = #{endTimeStr},
  1553. </if>
  1554. <if test="tags != null and tags !=''">
  1555. tags = #{tags},
  1556. </if>
  1557. <if test="recommendType != null and recommendType !=''">
  1558. recommendType = #{recommendType},
  1559. </if>
  1560. <if test="machineType != null and machineType !=''">
  1561. machineType = #{machineType},
  1562. </if>
  1563. <if test="includedTax != null and includedTax !=''">
  1564. includedTax = #{includedTax},
  1565. </if>
  1566. <if test="invoiceType != null and invoiceType !=''">
  1567. invoiceType = #{invoiceType},
  1568. </if>
  1569. <if test="commodityType != null and commodityType != ''">
  1570. commodityType = #{commodityType},
  1571. </if>
  1572. <if test="trainingMethod != null">
  1573. trainingMethod = #{trainingMethod},
  1574. </if>
  1575. <if test="trainingType != null">
  1576. trainingType = #{trainingType},
  1577. </if>
  1578. <if test="trainingFee != null">
  1579. trainingFee = #{trainingFee},
  1580. </if>
  1581. splitCode = #{splitCode}
  1582. </set>
  1583. where productID = #{productID}
  1584. </update>
  1585. <update id="updateproductDetailInfo" parameterType="com.caimei.modules.product.entity.ProductDetailInfo">
  1586. update productdetailinfo
  1587. <set>
  1588. <if test="propValueAlias != null and propValueAlias != ''">
  1589. propValueAlias = #{propValueAlias},
  1590. </if>
  1591. <if test="propValueImages != null and propValueImages !=''">
  1592. propValueImages = #{propValueImages},
  1593. </if>
  1594. <if test="detailInfo != null">
  1595. detailInfo = #{detailInfo},
  1596. </if>
  1597. <if test="commonDetailInfo != null">
  1598. commonDetailInfo = #{commonDetailInfo},
  1599. </if>
  1600. <if test="detailInfoTxt != null">
  1601. detailInfoTxt = #{detailInfoTxt},
  1602. </if>
  1603. <if test="seoTitle != null and seoTitle !=''">
  1604. seoTitle = #{seoTitle},
  1605. </if>
  1606. <if test="seoKeyword != null and seoKeyword !=''">
  1607. seoKeyword = #{seoKeyword},
  1608. </if>
  1609. <if test="seoDes != null and seoDes !=''">
  1610. seoDes = #{seoDes},
  1611. </if>
  1612. <if test="serviceInfo != null ">
  1613. serviceInfo = #{serviceInfo},
  1614. </if>
  1615. <if test="orderInfo != null ">
  1616. orderInfo = #{orderInfo},
  1617. </if>
  1618. </set>
  1619. where productID = #{productID}
  1620. </update>
  1621. <update id="updateLadderPrice">
  1622. update product_ladder_price
  1623. set productId = #{productId},
  1624. ladderNum = #{ladderNum},
  1625. buyNum = #{buyNum},
  1626. buyPrice = #{buyPrice},
  1627. updateBy = #{updateBy},
  1628. updateDate = #{updateDate},
  1629. delFlag = #{delFlag}
  1630. where id = #{id}
  1631. </update>
  1632. <update id="updateMainImage">
  1633. update product
  1634. set mainImage =#{mainImage}
  1635. where productID=#{productID}
  1636. </update>
  1637. <select id="getProductByTypeName" resultType="com.caimei.modules.brand.entity.BrandAndProductType">
  1638. select
  1639. b.name AS "bigTypeName",b.bigTypeID,s.`name` AS "smallTypeName",s.smalltypeID,t.name AS "tinyTypeName" ,t.tinytypeID
  1640. from tinytype t LEFT JOIN smalltype s on t.smallTypeID = s.smallTypeID LEFT JOIN bigtype b ON b.bigTypeID = s.bigTypeID
  1641. where b.`name` = #{name} AND s.`name` = #{name1} AND t.name = #{name2}
  1642. </select>
  1643. <select id="findRecommendBySys" resultType="com.caimei.modules.product.entity.CmProductRecommend">
  1644. select
  1645. p.productID AS recommendProductID,
  1646. p.name AS productName,
  1647. p.unit AS unit,
  1648. p.mainImage AS img,
  1649. s.name AS shopName
  1650. from product p
  1651. left join shop s on s.shopID = p.shopID
  1652. where p.tinyTypeID = #{tinyTypeID} and p.productCategory = 1
  1653. order by p.sellNumber
  1654. desc limit 0, 7
  1655. </select>
  1656. <select id="getSecondHandRecommend" resultType="CmSecondHandRecommendVo">
  1657. select p.productID AS id,
  1658. 1 AS type,
  1659. p.name AS name,
  1660. p.unit AS unit,
  1661. p.mainImage AS img,
  1662. s.name AS shopName,
  1663. p.productCategory as "productCategory"
  1664. from product p
  1665. left join shop s on s.shopID = p.shopID
  1666. where p.productID = #{productID}
  1667. AND p.validFlag = '2'
  1668. </select>
  1669. <select id="querySecondHandRecommend" resultType="CmSecondHandRecommendVo">
  1670. select
  1671. p.productID AS id,
  1672. 1 AS type,
  1673. p.name AS name,
  1674. p.unit AS unit,
  1675. p.mainImage AS img,
  1676. s.name AS shopName,
  1677. p.productCategory as "productCategory"
  1678. from product p
  1679. left join shop s on s.shopID = p.shopID
  1680. <where>
  1681. <if test="productID != null and productID != ''">
  1682. p.productID = #{productID}
  1683. </if>
  1684. <if test="productName != null and productName != ''">
  1685. and p.name like concat('%', #{productName} ,'%')
  1686. </if>
  1687. AND p.validFlag = '2'
  1688. and p.productCategory = #{queryProductType}
  1689. </where>
  1690. limit 0, 10
  1691. </select>
  1692. <select id="queryProductDetailInfo" resultType="com.caimei.modules.product.entity.ProductDetailInfo">
  1693. SELECT * FROM
  1694. productdetailinfo
  1695. where productID = #{productID}
  1696. </select>
  1697. <select id="findProductLadderPrice" resultType="com.caimei.po.ProductLadderPrice">
  1698. SELECT *
  1699. FROM product_ladder_price
  1700. WHERE
  1701. productId = #{productId}
  1702. AND userType = #{userType}
  1703. AND buyNum is NOT null
  1704. AND buyPrice is NOT null
  1705. AND delFlag = 0
  1706. ORDER BY ladderNum ASC
  1707. </select>
  1708. <select id="findActList" resultType="com.caimei.modules.product.entity.Product">
  1709. SELECT
  1710. <include refid="productColumns"/>
  1711. FROM product a
  1712. <include refid="productJoins"/>
  1713. <where>
  1714. <if test="id !=null and id !=''">
  1715. AND a.productID=#{id}
  1716. </if>
  1717. <if test="shopID != null and shopID != ''">
  1718. AND a.shopID = #{shopID}
  1719. </if>
  1720. <if test="name != null and name != ''">
  1721. AND a.name LIKE
  1722. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  1723. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  1724. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  1725. </if>
  1726. <if test="shopName != null and shopName != ''">
  1727. AND s.name LIKE
  1728. <if test="dbName == 'oracle'">'%'||#{shopName}||'%'</if>
  1729. <if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
  1730. <if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
  1731. </if>
  1732. <if test="validFlag !=null and validFlag !=''">
  1733. AND a.validFlag=#{validFlag}
  1734. </if>
  1735. <if test="actFlag !=null and actFlag !=''">
  1736. AND a.actFlag=#{actFlag}
  1737. </if>
  1738. <if test="actType !=null and actType !=''">
  1739. AND a.actType=#{actType}
  1740. </if>
  1741. AND a.actStatus = 1
  1742. and a.productCategory = 1
  1743. </where>
  1744. <choose>
  1745. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  1746. ORDER BY ${page.orderBy}
  1747. </when>
  1748. <otherwise>
  1749. order by case WHEN a.validFlag = 1 then 0 else 1 END asc,a.productID desc
  1750. </otherwise>
  1751. </choose>
  1752. </select>
  1753. <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
  1754. select p.productID,p.mainImage,p.name,s.name as shopName from product p left join shop s on p.shopID = s.shopID
  1755. <where>
  1756. (p.actFlag=0 or p.actType is null) and p.validFlag = 2 and p.productCategory = 1
  1757. <if test="productIds != null and productIds != '' ">
  1758. and p.productID != #{productIds}
  1759. </if>
  1760. <if test="productID != null and productID != ''">
  1761. and p.productID = #{productID}
  1762. </if>
  1763. <if test="name != null and name != ''">
  1764. and p.name like concat('%',#{name},'%')
  1765. </if>
  1766. <if test="shopName != null and shopName != ''">
  1767. and s.name like concat('%',#{shopName},'%')
  1768. </if>
  1769. </where>
  1770. order by productID asc
  1771. </select>
  1772. <select id="findProductImage" resultType="com.caimei.modules.product.entity.Product">
  1773. SELECT
  1774. <include refid="productColumns"/>
  1775. FROM product a
  1776. <include refid="productJoins"/>
  1777. <where>
  1778. <if test="productID !=null">
  1779. AND a.productID=#{productID}
  1780. </if>
  1781. <if test="shopID != null and shopID != ''">
  1782. AND a.shopID = #{shopID}
  1783. </if>
  1784. <if test="name != null and name != ''">
  1785. AND a.name LIKE concat('%',#{name},'%')
  1786. </if>
  1787. <if test="shopName != null and shopName != ''">
  1788. AND s.name LIKE concat('%',#{shopName},'%')
  1789. </if>
  1790. <if test="validFlag !=null and validFlag !=''">
  1791. AND a.validFlag=#{validFlag}
  1792. </if>
  1793. <if test="productCategory !=null and productCategory !=''">
  1794. AND a.productCategory=#{productCategory}
  1795. </if>
  1796. <if test="ids != null and ids.size() > 0">
  1797. AND a.productID NOT IN
  1798. <foreach collection="ids" close=")" separator="," open="(" item="id">
  1799. #{id}
  1800. </foreach>
  1801. </if>
  1802. </where>
  1803. <choose>
  1804. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  1805. ORDER BY ${page.orderBy}
  1806. </when>
  1807. <otherwise>
  1808. order by a.productID asc
  1809. </otherwise>
  1810. </choose>
  1811. </select>
  1812. <select id="findProductDetail" resultType="java.lang.String">
  1813. select productDetail from product where productID = #{productID}
  1814. </select>
  1815. <select id="findProductDescribe" resultType="java.lang.String">
  1816. select productDescribe from product where productID = #{productID}
  1817. </select>
  1818. <select id="findSepcialShopList" resultType="com.caimei.po.Shop">
  1819. select name,shopId from shop where shopType=2
  1820. </select>
  1821. <select id="getSplitCodeByProductId" resultType="java.lang.String">
  1822. select splitCode from product where productID = #{productID}
  1823. </select>
  1824. </mapper>