ProductMapper.xml 59 KB

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