ProductMapper.xml 74 KB

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