ProductNewMapper.xml 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  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.ProductNewDao">
  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.newvalidFlag,
  10. ifnull(a.newProductType,2) as newProductType,
  11. ifnull(a.announType,1) as announType,
  12. a.productID AS "id",
  13. a.productID AS "productID",
  14. a.groundMall AS "groundMall",
  15. a.brandID AS "brandID",
  16. ifnull(a.bigTypeID,0) AS "bigTypeID",
  17. ifnull(a.smallTypeID,0) AS "smallTypeID",
  18. ifnull(a.tinyTypeID,0) AS "tinyTypeID",
  19. a.productCategory AS "productCategory",
  20. a.selfTypeID AS "selfTypeID",
  21. a.preferredFlag AS "preferredFlag",
  22. a.shopID AS "shopID",
  23. a.name AS "name",
  24. a.searchKey AS "searchKey",
  25. a.combinationID AS "combinationID",
  26. a.productRemarks AS "productRemarks",
  27. a.priceFlag AS "priceFlag",
  28. a.beautyActFlag AS "beautyActFlag",
  29. a.hasSkuFlag AS "hasSkuFlag",
  30. a.mainImage AS "mainImage",
  31. a.propertiesInfo AS "propertiesInfo",
  32. a.addTime AS "addTime",
  33. a.updateTime AS "updateTime",
  34. a.sellNumber AS "sellNumber",
  35. a.weekSellNumber AS "weekSellNumber",
  36. a.beforeValidFlag AS "beforeValidFlag",
  37. a.validFlag AS "validFlag",
  38. a.favoriteTimes AS "favoriteTimes",
  39. a.commentScore AS "commentScore",
  40. a.commentTimes AS "commentTimes",
  41. a.selfRecommendFlag AS "selfRecommendFlag",
  42. a.sysRecommendFlag AS "sysRecommendFlag",
  43. a.sortIndex AS "sortIndex",
  44. a.featuredFlag AS "featuredFlag",
  45. a.featuredSortIndex AS "featuredSortIndex",
  46. a.productCode AS "productCode",
  47. a.synToERPFlag AS "synToERPFlag",
  48. a.allAreaFlag AS "allAreaFlag",
  49. a.provinceIDs AS "provinceIDs",
  50. a.serviceNumber AS "serviceNumber",
  51. a.packageCount AS "packageCount",
  52. a.byFlag AS "byFlag",
  53. a.normalProductFlag AS "normalProductFlag",
  54. a.wholeSaleProductFlag AS "wholeSaleProductFlag",
  55. a.promotionProductFlag AS "promotionProductFlag",
  56. a.groupBuyProductFlag AS "groupBuyProductFlag",
  57. a.step AS "step",
  58. a.actStatus AS "actStatus",
  59. a.actFlag AS "actFlag",
  60. a.actType AS "actType",
  61. a.onlineTime AS "onlineTime",
  62. a.downlineTime AS "downlineTime",
  63. a.freePostFlag AS "freePostFlag",
  64. a.precisehKey AS "precisehKey",
  65. s.name AS "shopName",
  66. a.actSort AS "actSort",
  67. a.recommendType AS "recommendType",
  68. a.aliasName as "aliasName",
  69. a.visibility as "visibility",
  70. a.commodityDetailsFlag as "commodityDetailsFlag",
  71. a.productType as "productType",
  72. a.qualificationImg as "qualificationImg",
  73. a.includedTax as "includedTax",
  74. a.invoiceType as "invoiceType",
  75. a.taxPoint as "taxPoint",
  76. a.supplierTaxPoint as "supplierTaxPoint",
  77. a.tags as "tags",
  78. a.machineType as "machineType",
  79. a.commodityType as "commodityType",
  80. a.trainingMethod as "trainingMethod",
  81. a.trainingType as "trainingType",
  82. a.trainingFee as "trainingFee",
  83. a.splitCode as "splitCode",
  84. a.productDescribe as "productDescribe",
  85. cshd.secondHandType as "secondHandType",
  86. cshd.instrumentType as "instrumentType",
  87. cshd.sold as "sold",
  88. cshd.payStatus as "payStatus",
  89. cshd.contactName as "contactName",
  90. cshd.originalPrice as "originalPrice",
  91. cshd.submitDate AS "submitDate",
  92. cshd.reviewedDate AS "reviewedDate",
  93. cshd.onLineDate AS "onLineDate",
  94. cshd.brandName AS "otherBrandName",
  95. cshd.publisher AS "publisher",
  96. cshd.source AS "source",
  97. cshd.dockingPeopleName AS "dockingPeopleName",
  98. cb.name as "brandName",
  99. if(csp.id is not null,1,0) as "svipFlag",
  100. cshd.companyName as "companyName",
  101. cshd.publishIdentity as "publishIdentity",
  102. a.qualificationNo,
  103. a.productName,
  104. a.qualificationTime,
  105. a.qualificationLink,
  106. a.returnGoodsStutas,
  107. a.labelIds
  108. </sql>
  109. <sql id="productJoins">
  110. LEFT JOIN shop s ON s.shopID = a.shopID
  111. LEFT JOIN cm_second_hand_detail cshd ON cshd.productID = a.productID
  112. LEFT JOIN cm_brand cb ON a.brandID = cb.id
  113. LEFT JOIN cm_svip_product csp on a.productID = csp.productId
  114. </sql>
  115. <sql id="ActivityJoins">
  116. LEFT JOIN shop s on s.shopID = a.shopID
  117. INNER JOIN tinytype AS b ON a.`tinyTypeID` = b.`tinyTypeID`
  118. INNER JOIN smalltype AS c ON b.`smallTypeID` = c.`smallTypeID`
  119. INNER JOIN bigtype AS d ON c.`bigTypeID` = d.`bigTypeID`
  120. </sql>
  121. <select id="get" resultType="Product">
  122. SELECT
  123. <include refid="productColumns"/>
  124. FROM product a
  125. <include refid="productJoins"/>
  126. WHERE a.productID = #{id}
  127. </select>
  128. <select id="getProductParams" resultType="com.caimei.modules.product.entity.ProductParameters">
  129. select *
  130. from cm_product_related_parameters
  131. where productId = #{productId}
  132. and delFlag = 0
  133. LIMIT 50
  134. </select>
  135. <select id="findList" resultType="Product">
  136. SELECT
  137. <include refid="productColumns"/>
  138. FROM product a
  139. <include refid="productJoins"/>
  140. <where>
  141. <if test="id !=null and id !=''">
  142. AND a.productID=#{id}
  143. </if>
  144. <if test="commodityType != null and commodityType != ''">
  145. AND a.commodityType=#{commodityType}
  146. </if>
  147. <if test="bigTypeID != null and bigTypeID != 0">
  148. AND a.bigTypeID = #{bigTypeID}
  149. </if>
  150. <if test="smallTypeID != null and smallTypeID != 0">
  151. AND a.smallTypeID = #{smallTypeID}
  152. </if>
  153. <if test="tinyTypeID != null and tinyTypeID != 0">
  154. AND a.tinyTypeID = #{tinyTypeID}
  155. </if>
  156. <if test="groundMall != null and groundMall != ''">
  157. AND a.groundMall like concat('%',#{groundMall},'%')
  158. </if>
  159. <if test="productCategory != null and productCategory != ''">
  160. AND a.productCategory = #{productCategory}
  161. <if test="productCategory == 2">
  162. # 1待审核 2已上架 3已下架 8 审核不通过
  163. <if test="validFlag == 1">
  164. AND a.validFlag = '1'
  165. </if>
  166. <if test="validFlag == 2">
  167. AND a.validFlag = '2'
  168. </if>
  169. <if test="validFlag == 3">
  170. AND a.validFlag = '3'
  171. </if>
  172. <if test="validFlag == 8">
  173. AND a.validFlag = '8'
  174. </if>
  175. <if test="validFlag == null and validFlag == ''">
  176. AND a.validFlag != '0'
  177. </if>
  178. </if>
  179. </if>
  180. <if test="brandID != null and brandID != ''">
  181. AND a.brandID = #{brandID}
  182. </if>
  183. <if test="shopID != null and shopID != ''">
  184. AND a.shopID = #{shopID}
  185. </if>
  186. <if test="productType != null and productType !=''">
  187. AND a.productType = #{productType}
  188. </if>
  189. <if test="preferredFlag != null and preferredFlag != ''and preferredFlag != 0">
  190. <if test="preferredFlag/100>=1">
  191. AND a.preferredFlag in (100,101,110,111)
  192. </if>
  193. <if test="(preferredFlag%100)/10>=1">
  194. AND a.preferredFlag in (10,11,110,111)
  195. </if>
  196. <if test="preferredFlag%10>=1">
  197. AND a.preferredFlag in (1,11,101,111)
  198. </if>
  199. </if>
  200. <if test="name != null and name != ''">
  201. AND a.name LIKE
  202. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  203. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  204. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  205. </if>
  206. <if test="shopName != null and shopName != ''">
  207. AND s.name LIKE
  208. <if test="dbName == 'oracle'">'%'||#{shopName}||'%'</if>
  209. <if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
  210. <if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
  211. </if>
  212. <if test="validFlagString !=null and validFlagString !=''">
  213. AND a.validFlag in
  214. <foreach collection="validFlagString" separator="," item="valid" open="(" close=")">
  215. #{valid}
  216. </foreach>
  217. </if>
  218. <if test="actFlag !=null and actFlag !=''">
  219. AND a.actFlag=#{actFlag}
  220. </if>
  221. <if test="actType !=null and actType !=''">
  222. AND a.actType=#{actType}
  223. </if>
  224. <if test="secondHandType !=null and secondHandType !=''">
  225. AND cshd.secondHandType=#{secondHandType}
  226. </if>
  227. <if test="instrumentType !=null and instrumentType !=''">
  228. AND cshd.instrumentType like concat('%',#{instrumentType},'%')
  229. </if>
  230. <if test="sold != null and sold != ''">
  231. AND cshd.sold=#{sold}
  232. </if>
  233. <if test="source != null and source != ''">
  234. AND cshd.source=#{source}
  235. </if>
  236. <if test="publishIdentity != null and publishIdentity !=''">
  237. AND cshd.publishIdentity = #{publishIdentity}
  238. </if>
  239. <if test="announType !=null and announType!= '' and productCategory == 2">
  240. AND a.announType=#{announType}
  241. </if>
  242. <if test="newvalidFlag !=null and newvalidFlag!= ''">
  243. AND a.newvalidFlag=#{newvalidFlag}
  244. </if>
  245. <if test="newProductType !=null and productCategory == 1">
  246. AND a.newProductType=#{newProductType}
  247. </if>
  248. <if test="contactName !=null and contactName !=''">
  249. AND (cshd.contactName LIKE concat('%',#{contactName},'%') or cshd.companyName LIKE
  250. concat('%',#{contactName},'%'))
  251. </if>
  252. <if test="isRelevance != null and isRelevance != ''">
  253. <if test="isRelevance == 1">
  254. AND a.labelIds IS NOT NULL
  255. </if>
  256. <if test="isRelevance == 2">
  257. AND a.labelIds IS NULL
  258. </if>
  259. </if>
  260. <if test="sqlMap !=null and sqlMap !=''">
  261. ${sqlMap.dsf}
  262. </if>
  263. AND a.shopID not in (SELECT s.`value` FROM `sys_dict` s WHERE s.type='heheShopID')
  264. AND a.productID NOT IN (6060, 6061, 6062, 6063, 6064,6065, 6066, 6067, 6068, 6069)
  265. </where>
  266. <choose>
  267. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  268. ORDER BY ${page.orderBy}
  269. </when>
  270. <otherwise>
  271. order by a.productID desc
  272. </otherwise>
  273. </choose>
  274. </select>
  275. <select id="findAllList" resultType="Product">
  276. SELECT
  277. <include refid="productColumns"/>
  278. FROM product a
  279. <include refid="productJoins"/>
  280. <where>
  281. a.productCategory = 1
  282. <if test="productCategory != null and productCategory != ''">
  283. AND a.productCategory = #{productCategory}
  284. </if>
  285. </where>
  286. <choose>
  287. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  288. ORDER BY ${page.orderBy}
  289. </when>
  290. <otherwise>
  291. </otherwise>
  292. </choose>
  293. </select>
  294. <select id="getImageList" resultType="com.caimei.po.ProductImage">
  295. select *
  296. from productimage
  297. where productID = #{productId}
  298. ORDER BY mainFlag DESC, sortIndex is null, sortIndex ASC
  299. </select>
  300. <select id="getImageById" resultType="com.caimei.po.ProductImage">
  301. select *
  302. from productimage
  303. where productImageID = #{productImageID}
  304. </select>
  305. <select id="getValidFlagByProductId" resultType="java.lang.String">
  306. select validFlag
  307. from product
  308. where productID = #{productID}
  309. </select>
  310. <select id="getBeforeValidFlagByProductId" resultType="java.lang.String">
  311. select beforeValidFlag
  312. from product
  313. where productID = #{productID}
  314. </select>
  315. <insert id="insert" parameterType="Product" keyProperty="id" useGeneratedKeys="true">
  316. INSERT INTO product(productID,
  317. brandID,
  318. tinyTypeID,
  319. productCategory,
  320. selfTypeID,
  321. shopID,
  322. name,
  323. searchKey,
  324. priceFlag,
  325. beautyActFlag,
  326. hasSkuFlag,
  327. mainImage,
  328. propertiesInfo,
  329. addTime,
  330. updateTime,
  331. sellNumber,
  332. weekSellNumber,
  333. beforeValidFlag,
  334. validFlag,
  335. favoriteTimes,
  336. commentScore,
  337. commentTimes,
  338. selfRecommendFlag,
  339. sysRecommendFlag,
  340. sortIndex,
  341. featuredFlag,
  342. featuredSortIndex,
  343. productCode,
  344. synToERPFlag,
  345. allAreaFlag,
  346. provinceIDs,
  347. serviceNumber,
  348. packageCount,
  349. byFlag,
  350. normalProductFlag,
  351. wholeSaleProductFlag,
  352. promotionProductFlag,
  353. groupBuyProductFlag,
  354. step,
  355. actFlag,
  356. actType,
  357. onlineTime,
  358. downlineTime,
  359. freePostFlag,
  360. precisehKey,
  361. returnGoodsStutas)
  362. VALUES (#{id},
  363. #{brandID},
  364. #{tinyTypeID},
  365. #{productCategory},
  366. #{selfTypeID},
  367. #{shopID},
  368. #{name},
  369. #{searchKey},
  370. #{priceFlag},
  371. #{beautyActFlag},
  372. #{hasSkuFlag},
  373. #{mainImage},
  374. #{propertiesInfo},
  375. #{addTime},
  376. #{updateTime},
  377. #{sellNumber},
  378. #{weekSellNumber},
  379. #{beforeValidFlag},
  380. #{validFlag},
  381. #{favoriteTimes},
  382. #{commentScore},
  383. #{commentTimes},
  384. #{selfRecommendFlag},
  385. #{sysRecommendFlag},
  386. #{sortIndex},
  387. #{featuredFlag},
  388. #{featuredSortIndex},
  389. #{productCode},
  390. #{synToERPFlag},
  391. #{allAreaFlag},
  392. #{provinceIDs},
  393. #{serviceNumber},
  394. #{packageCount},
  395. #{byFlag},
  396. #{normalProductFlag},
  397. #{wholeSaleProductFlag},
  398. #{promotionProductFlag},
  399. #{groupBuyProductFlag},
  400. #{step},
  401. #{actFlag},
  402. #{actType},
  403. #{onlineTime},
  404. #{downlineTime},
  405. #{freePostFlag},
  406. #{precisehKey},
  407. #{returnGoodsStutas})
  408. </insert>
  409. <update id="update">
  410. UPDATE product
  411. SET productID = #{id},
  412. brandID = #{brandID},
  413. tinyTypeID = #{tinyTypeID},
  414. productCategory = #{productCategory},
  415. selfTypeID = #{selfTypeID},
  416. shopID = #{shopID},
  417. name = #{name},
  418. searchKey = #{searchKey},
  419. priceFlag = #{priceFlag},
  420. beautyActFlag = #{beautyActFlag},
  421. hasSkuFlag = #{hasSkuFlag},
  422. mainImage = #{mainImage},
  423. propertiesInfo = #{propertiesInfo},
  424. addTime = #{addTime},
  425. updateTime = #{updateTime},
  426. sellNumber = #{sellNumber},
  427. weekSellNumber = #{weekSellNumber},
  428. beforeValidFlag = #{beforeValidFlag},
  429. validFlag = #{validFlag},
  430. favoriteTimes = #{favoriteTimes},
  431. commentScore = #{commentScore},
  432. commentTimes = #{commentTimes},
  433. selfRecommendFlag = #{selfRecommendFlag},
  434. sysRecommendFlag = #{sysRecommendFlag},
  435. sortIndex = #{sortIndex},
  436. featuredFlag = #{featuredFlag},
  437. featuredSortIndex = #{featuredSortIndex},
  438. productCode = #{productCode},
  439. synToERPFlag = #{synToERPFlag},
  440. allAreaFlag = #{allAreaFlag},
  441. provinceIDs = #{provinceIDs},
  442. serviceNumber = #{serviceNumber},
  443. packageCount = #{packageCount},
  444. byFlag = #{byFlag},
  445. normalProductFlag = #{normalProductFlag},
  446. wholeSaleProductFlag = #{wholeSaleProductFlag},
  447. promotionProductFlag = #{promotionProductFlag},
  448. groupBuyProductFlag = #{groupBuyProductFlag},
  449. step = #{step},
  450. actFlag = #{actFlag},
  451. actType = #{actType},
  452. onlineTime = #{onlineTime},
  453. downlineTime = #{downlineTime},
  454. freePostFlag = #{freePostFlag},
  455. precisehKey = #{precisehKey},
  456. actSort = #{actSort},
  457. productType = #{productType},
  458. qualificationImg = #{qualificationImg},
  459. includedTax = #{includedTax},
  460. invoiceType = #{invoiceType},
  461. taxPoint = #{taxPoint},
  462. supplierTaxPoint = #{supplierTaxPoint}
  463. WHERE productID = #{id}
  464. </update>
  465. <insert id="insertProductImage" parameterType="com.caimei.po.ProductImage">
  466. insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
  467. values (#{productID}, #{shopID}, #{addTime}, #{image}, #{mainFlag}, #{sortIndex});
  468. </insert>
  469. <select id="newFloorId" resultType="java.lang.Integer">
  470. select id
  471. from new_page_floor
  472. where floorType = 1
  473. limit 1
  474. </select>
  475. <update id="updateByPrimaryKeySelective" parameterType="com.caimei.modules.product.entity.Product">
  476. update product
  477. <set>
  478. <if test="floorId != null and floorId != ''">
  479. floorId=#{floorId},
  480. </if>
  481. <if test="newvalidFlag != null and newvalidFlag != '' ">
  482. newvalidFlag=#{newvalidFlag},
  483. </if>
  484. <if test="brandID != null and brandID != ''">
  485. brandID = #{brandID},
  486. </if>
  487. <if test="bigTypeID != null and bigTypeID !=''">
  488. bigTypeID = #{bigTypeID},
  489. smallTypeID = #{smallTypeID},
  490. tinyTypeID = #{tinyTypeID},
  491. </if>
  492. <if test="preferredFlag != null and preferredFlag !=''">
  493. preferredFlag = #{preferredFlag},
  494. </if>
  495. <if test="selfTypeID != null and selfTypeID !=''">
  496. selfTypeID = #{selfTypeID},
  497. </if>
  498. <if test="shopID != null and shopID !=''">
  499. shopID = #{shopID},
  500. </if>
  501. <if test="name != null and name !=''">
  502. `name` = #{name},
  503. </if>
  504. <if test="aliasName != null and aliasName !=''">
  505. aliasName = #{aliasName},
  506. </if>
  507. <if test="searchKey != null and searchKey !=''">
  508. searchKey = #{searchKey},
  509. </if>
  510. <if test="productRemarks != null and productRemarks !=''">
  511. productRemarks = #{productRemarks},
  512. </if>
  513. <if test="combinationID != null and combinationID !=''">
  514. combinationID = #{combinationID},
  515. </if>
  516. <if test="normalPrice != null and normalPrice !=''">
  517. normalPrice = #{normalPrice},
  518. </if>
  519. <if test="price != null and price !=''">
  520. price = #{price},
  521. </if>
  522. <if test="priceFlag != null and priceFlag !=''">
  523. priceFlag = #{priceFlag},
  524. </if>
  525. <if test="beautyActFlag != null and beautyActFlag !=''">
  526. beautyActFlag = #{beautyActFlag},
  527. </if>
  528. <if test="ladderPriceFlag != null and ladderPriceFlag !=''">
  529. ladderPriceFlag = #{ladderPriceFlag},
  530. </if>
  531. <if test="stock != null and stock !=''">
  532. stock = #{stock},
  533. </if>
  534. <if test="hasSkuFlag != null and hasSkuFlag !=''">
  535. hasSkuFlag = #{hasSkuFlag},
  536. </if>
  537. <if test="mainImage != null and mainImage !=''">
  538. mainImage = #{mainImage},
  539. </if>
  540. <if test="propertiesInfo != null and propertiesInfo !=''">
  541. propertiesInfo = #{propertiesInfo},
  542. </if>
  543. <if test="addTime != null and addTime !=''">
  544. addTime = #{addTime},
  545. </if>
  546. <if test="updateTime != null and updateTime !=''">
  547. updateTime = #{updateTime},
  548. </if>
  549. <if test="sellNumber != null and sellNumber !=''">
  550. sellNumber = #{sellNumber},
  551. </if>
  552. <if test="weekSellNumber != null and weekSellNumber !=''">
  553. weekSellNumber = #{weekSellNumber},
  554. </if>
  555. <if test="beforeValidFlag != null and beforeValidFlag !=''">
  556. beforeValidFlag = #{beforeValidFlag},
  557. </if>
  558. <if test="validFlag != null and validFlag !=''">
  559. validFlag = #{validFlag},
  560. </if>
  561. <if test="favoriteTimes != null and favoriteTimes !=''">
  562. favoriteTimes = #{favoriteTimes},
  563. </if>
  564. <if test="commentScore != null and commentScore !=''">
  565. commentScore = #{commentScore},
  566. </if>
  567. <if test="commentTimes != null and commentTimes !=''">
  568. commentTimes = #{commentTimes},
  569. </if>
  570. <if test="selfRecommendFlag != null and selfRecommendFlag !=''">
  571. selfRecommendFlag = #{selfRecommendFlag},
  572. </if>
  573. <if test="sysRecommendFlag != null and sysRecommendFlag !=''">
  574. sysRecommendFlag = #{sysRecommendFlag},
  575. </if>
  576. <if test="sortIndex != null and sortIndex != ''">
  577. sortIndex = #{sortIndex},
  578. </if>
  579. <if test="featuredFlag != null and featuredFlag !=''">
  580. featuredFlag = #{featuredFlag},
  581. </if>
  582. <if test="featuredSortIndex != null and featuredSortIndex !=''">
  583. featuredSortIndex = #{featuredSortIndex},
  584. </if>
  585. <if test="productCode != null and productCode !=''">
  586. productCode = #{productCode},
  587. </if>
  588. <if test="unit != null and unit !=''">
  589. unit = #{unit},
  590. </if>
  591. <if test="synToERPFlag != null and synToERPFlag !=''">
  592. synToERPFlag = #{synToERPFlag},
  593. </if>
  594. <if test="allAreaFlag != null and allAreaFlag !=''">
  595. allAreaFlag = #{allAreaFlag},
  596. </if>
  597. <if test="provinceIDs != null and provinceIDs !=''">
  598. provinceIDs = #{provinceIDs},
  599. </if>
  600. <if test="serviceNumber != null and serviceNumber !=''">
  601. serviceNumber = #{serviceNumber},
  602. </if>
  603. <if test="maxBuyNumber != null and maxBuyNumber !=''">
  604. maxBuyNumber = #{maxBuyNumber},
  605. </if>
  606. <if test="minBuyNumber != null and minBuyNumber !=''">
  607. minBuyNumber = #{minBuyNumber},
  608. </if>
  609. <if test="packageCount != null and packageCount !=''">
  610. packageCount = #{packageCount},
  611. </if>
  612. <if test="byFlag != null and byFlag !=''">
  613. byFlag = #{byFlag},
  614. </if>
  615. <if test="normalProductFlag != null and normalProductFlag !=''">
  616. normalProductFlag = #{normalProductFlag},
  617. </if>
  618. <if test="wholeSaleProductFlag != null and wholeSaleProductFlag !=''">
  619. wholeSaleProductFlag = #{wholeSaleProductFlag},
  620. </if>
  621. <if test="promotionProductFlag != null and promotionProductFlag !=''">
  622. promotionProductFlag = #{promotionProductFlag},
  623. </if>
  624. <if test="groupBuyProductFlag != null and groupBuyProductFlag !=''">
  625. groupBuyProductFlag = #{groupBuyProductFlag},
  626. </if>
  627. <if test="step != null and step !=''">
  628. step = #{step},
  629. </if>
  630. <if test="actFlag != null and actFlag !=''">
  631. actFlag = #{actFlag},
  632. </if>
  633. <if test="actSort != null and actSort !=''">
  634. actSort = #{actSort},
  635. </if>
  636. <if test="actType != null and actType !=''">
  637. actType = #{actType},
  638. </if>
  639. <if test="onlineTime != null and onlineTime !=''">
  640. onlineTime = #{onlineTime},
  641. </if>
  642. <if test="downlineTime != null and downlineTime !=''">
  643. downlineTime = #{downlineTime},
  644. </if>
  645. <if test="freePostFlag != null and freePostFlag !=''">
  646. freePostFlag = #{freePostFlag},
  647. </if>
  648. <if test="costPrice != null and costPrice != ''">
  649. costPrice = #{costPrice},
  650. </if>
  651. <if test="shopPercent != null and shopPercent !=''">
  652. shopPercent = #{shopPercent},
  653. </if>
  654. <if test="costCheckFlag != null and costCheckFlag !=''">
  655. costCheckFlag = #{costCheckFlag},
  656. </if>
  657. <if test="precisehKey != null and precisehKey !=''">
  658. precisehKey = #{precisehKey},
  659. </if>
  660. <if test="visibility != null and visibility !=''">
  661. visibility = #{visibility},
  662. </if>
  663. <if test="endTimeStr != null and endTimeStr !=''">
  664. endTimeStr = #{endTimeStr},
  665. </if>
  666. <if test="tags != null and tags !=''">
  667. tags = #{tags},
  668. </if>
  669. <if test="recommendType != null and recommendType !=''">
  670. recommendType = #{recommendType},
  671. </if>
  672. <if test="machineType != null and machineType !=''">
  673. machineType = #{machineType},
  674. </if>
  675. <if test="commodityType != null and commodityType != ''">
  676. commodityType = #{commodityType},
  677. </if>
  678. <if test="showTime!= '' and showTime!=null">
  679. showTime=#{showTime},
  680. </if>
  681. <if test="newshowTime !=null">
  682. newshowTime=#{newshowTime},
  683. </if>
  684. <if test="newvalidFlag == 1">
  685. showFlag=1
  686. </if>
  687. <if test="newvalidFlag == 2">
  688. showFlag=4
  689. </if>
  690. </set>
  691. where productID = #{productID}
  692. </update>
  693. <update id="updateImageSort">
  694. update productimage
  695. set sortIndex = #{sortIndex}
  696. where productImageID = #{productImageID}
  697. </update>
  698. <update id="cancelImageMainFlag">
  699. update productimage
  700. set mainFlag = 0
  701. where productID = #{productID}
  702. and mainFlag = 1
  703. </update>
  704. <update id="setImageMainFlag">
  705. update productimage
  706. set mainFlag = 1
  707. where productImageID = #{productImageID}
  708. </update>
  709. <update id="setProductImage">
  710. UPDATE product
  711. SET mainImage = #{mainImage}
  712. WHERE productID = #{productID}
  713. </update>
  714. <delete id="deleteImage">
  715. DELETE
  716. FROM productimage
  717. WHERE productImageID = #{productImageID}
  718. </delete>
  719. <delete id="mulDeleteImage">
  720. DELETE FROM productimage
  721. WHERE productImageID IN
  722. <foreach collection="idList" item="productImageID" index="index" open="(" separator="," close=")">
  723. #{productImageID}
  724. </foreach>
  725. </delete>
  726. <delete id="deleteParameters">
  727. DELETE
  728. FROM cm_product_related_parameters
  729. WHERE productId = #{productId}
  730. </delete>
  731. <delete id="deleteImageByProductId">
  732. DELETE
  733. FROM productimage
  734. WHERE productID = #{productID}
  735. </delete>
  736. <insert id="insertParameters" parameterType="com.caimei.modules.product.entity.ProductParameters">
  737. insert into cm_product_related_parameters
  738. (productId,
  739. paramsName,
  740. paramsContent,
  741. delFlag)
  742. values (#{productId},
  743. #{paramsName},
  744. #{paramsContent},
  745. #{delFlag})
  746. </insert>
  747. <insert id="insertStatusRecord">
  748. INSERT INTO `product_status_record` (`productId`,
  749. `modifyUserId`,
  750. `validFlag`,
  751. `remarks`,
  752. `addTime`)
  753. VALUES (#{productId},
  754. #{modifyUserId},
  755. #{validFlag},
  756. #{remarks},
  757. #{addTime})
  758. </insert>
  759. <insert id="addProductData">
  760. update product
  761. set taxPoint = #{taxPoint},
  762. supplierTaxPoint = #{supplierTaxPoint}
  763. where productID = #{productId}
  764. </insert>
  765. <select id="findAllStatusRemarks" resultType="com.caimei.modules.product.entity.ProductStatusRecord">
  766. SELECT id,
  767. `productId`,
  768. `modifyUserId`,
  769. `validFlag`,
  770. `remarks`,
  771. `addTime`
  772. FROM `product_status_record`
  773. WHERE productId = #{productId}
  774. ORDER BY addTime DESC
  775. </select>
  776. <select id="findSplitCode" resultType="com.caimei.modules.user.entity.SplitCode">
  777. select shopId, commercialCode as splitCode, codeDetail as codeRemark
  778. from cm_shop_splitcode
  779. where shopId = #{shopID}
  780. </select>
  781. <select id="findSplitCodeByProduct" resultType="java.lang.String">
  782. select splitCode
  783. from product
  784. where productID = #{productID}
  785. </select>
  786. <select id="getShopIdByName" resultType="java.lang.Integer">
  787. select shopID
  788. from shop
  789. where name like concat('%', #{shopName}, '%')
  790. order by shopID desc
  791. limit 1
  792. </select>
  793. <select id="findSecondSplitCode" resultType="com.caimei.modules.user.entity.SplitCode">
  794. select css.shopId, css.commercialCode as splitCode, css.codeDetail as codeRemark
  795. from cm_shop_splitcode css
  796. left join product p on p.shopID = css.shopId
  797. where p.productID = #{id}
  798. </select>
  799. <select id="validIList" resultType="com.caimei.modules.product.entity.Product">
  800. select p.*, s.contractMobile as mobile, s.userID as userId, s.name as shopName
  801. from product p
  802. left join shop s on p.shopID = s.shopId
  803. where p.productID = #{productID}
  804. </select>
  805. </mapper>