ProductMapper.xml 53 KB

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