ProductMapper.xml 58 KB

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