ProductMapper.xml 80 KB

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