ProductMapper.xml 76 KB

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