ProductNewMapper.xml 33 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.preferredFlag AS "preferredFlag",
  21. a.shopID AS "shopID",
  22. a.name AS "name",
  23. a.searchKey AS "searchKey",
  24. a.combinationID AS "combinationID",
  25. a.productRemarks AS "productRemarks",
  26. a.priceFlag AS "priceFlag",
  27. a.beautyActFlag AS "beautyActFlag",
  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.beforeValidFlag AS "beforeValidFlag",
  35. copi.validFlag AS "validFlag",
  36. a.favoriteTimes AS "favoriteTimes",
  37. a.commentScore AS "commentScore",
  38. a.commentTimes AS "commentTimes",
  39. -- a.selfRecommendFlag AS "selfRecommendFlag",
  40. -- a.sysRecommendFlag AS "sysRecommendFlag",
  41. a.sortIndex AS "sortIndex",
  42. a.featuredFlag AS "featuredFlag",
  43. a.featuredSortIndex AS "featuredSortIndex",
  44. a.productCode AS "productCode",
  45. -- a.synToERPFlag AS "synToERPFlag",
  46. a.allAreaFlag AS "allAreaFlag",
  47. a.provinceIDs AS "provinceIDs",
  48. a.serviceNumber AS "serviceNumber",
  49. a.packageCount AS "packageCount",
  50. a.byFlag AS "byFlag",
  51. a.normalProductFlag AS "normalProductFlag",
  52. -- a.wholeSaleProductFlag AS "wholeSaleProductFlag",
  53. -- a.promotionProductFlag AS "promotionProductFlag",
  54. -- a.groupBuyProductFlag AS "groupBuyProductFlag",
  55. a.step AS "step",
  56. a.actStatus AS "actStatus",
  57. a.actFlag AS "actFlag",
  58. a.actType AS "actType",
  59. a.onlineTime AS "onlineTime",
  60. a.downlineTime AS "downlineTime",
  61. a.freePostFlag AS "freePostFlag",
  62. -- a.precisehKey AS "precisehKey",
  63. s.name AS "shopName",
  64. a.actSort AS "actSort",
  65. a.recommendType AS "recommendType",
  66. a.aliasName as "aliasName",
  67. a.visibility as "visibility",
  68. a.commodityDetailsFlag as "commodityDetailsFlag",
  69. a.productType as "productType",
  70. a.qualificationImg as "qualificationImg",
  71. a.includedTax as "includedTax",
  72. a.invoiceType as "invoiceType",
  73. a.taxPoint as "taxPoint",
  74. a.supplierTaxPoint as "supplierTaxPoint",
  75. a.tags as "tags",
  76. a.machineType as "machineType",
  77. a.commodityType as "commodityType",
  78. a.trainingMethod as "trainingMethod",
  79. a.trainingType as "trainingType",
  80. a.trainingFee as "trainingFee",
  81. a.splitCode as "splitCode",
  82. a.productDescribe as "productDescribe",
  83. cshd.secondHandType as "secondHandType",
  84. cshd.instrumentType as "instrumentType",
  85. cshd.sold as "sold",
  86. cshd.payStatus as "payStatus",
  87. cshd.contactName as "contactName",
  88. cshd.originalPrice as "originalPrice",
  89. cshd.submitDate AS "submitDate",
  90. cshd.reviewedDate AS "reviewedDate",
  91. cshd.onLineDate AS "onLineDate",
  92. cshd.brandName AS "otherBrandName",
  93. cshd.publisher AS "publisher",
  94. cshd.source AS "source",
  95. cshd.dockingPeopleName AS "dockingPeopleName",
  96. cb.name as "brandName",
  97. if(csp.id is not null,1,0) as "svipFlag",
  98. cshd.companyName as "companyName",
  99. cshd.publishIdentity as "publishIdentity",
  100. a.qualificationNo,
  101. a.productName,
  102. a.qualificationTime,
  103. a.qualificationLink,
  104. a.returnGoodsStutas,
  105. a.labelIds
  106. </sql>
  107. <sql id="productJoins">
  108. left join cm_organize_product_info copi on copi.productId = a.productID
  109. LEFT JOIN shop s ON s.shopID = a.shopID
  110. LEFT JOIN cm_second_hand_detail cshd ON cshd.productID = a.productID
  111. LEFT JOIN cm_brand cb ON a.brandID = cb.id
  112. LEFT JOIN cm_svip_product csp on a.productID = csp.productId
  113. </sql>
  114. <sql id="ActivityJoins">
  115. LEFT JOIN shop s on s.shopID = a.shopID
  116. INNER JOIN tinytype AS b ON a.`tinyTypeID` = b.`tinyTypeID`
  117. INNER JOIN smalltype AS c ON b.`smallTypeID` = c.`smallTypeID`
  118. INNER JOIN bigtype AS d ON c.`bigTypeID` = d.`bigTypeID`
  119. </sql>
  120. <select id="get" resultType="Product">
  121. SELECT
  122. <include refid="productColumns"/>
  123. FROM product a
  124. <include refid="productJoins"/>
  125. WHERE a.productID = #{id} and copi.organizeId=(SELECT SUBSTRING_INDEX(groundMall, ',', 1)FROM product WHERE productID=#{id})
  126. </select>
  127. <select id="getProductParams" resultType="com.caimei.modules.product.entity.ProductParameters">
  128. select *
  129. from cm_product_related_parameters
  130. where productId = #{productId}
  131. and delFlag = 0
  132. LIMIT 50
  133. </select>
  134. <select id="findList" resultType="Product">
  135. SELECT
  136. <include refid="productColumns"/>
  137. FROM product a
  138. <include refid="productJoins"/>
  139. <where>
  140. a.groundMall like CONCAT('%', copi.organizeId, '%')
  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 copi.validFlag = '1'
  165. </if>
  166. <if test="validFlag == 2">
  167. AND copi.validFlag = '2'
  168. </if>
  169. <if test="validFlag == 3">
  170. AND copi.validFlag = '3'
  171. </if>
  172. <if test="validFlag == 8">
  173. AND copi.validFlag = '8'
  174. </if>
  175. <if test="validFlag == null and validFlag == ''">
  176. AND copi.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 copi.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. group by a.productID
  267. <choose>
  268. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  269. ORDER BY ${page.orderBy}
  270. </when>
  271. <otherwise>
  272. order by a.productID desc
  273. </otherwise>
  274. </choose>
  275. </select>
  276. <select id="findAllList" resultType="Product">
  277. SELECT
  278. <include refid="productColumns"/>
  279. FROM product a
  280. <include refid="productJoins"/>
  281. <where>
  282. a.productCategory = 1 and a.groundMall like CONCAT('%', copi.organizeId, '%')
  283. <if test="productCategory != null and productCategory != ''">
  284. AND a.productCategory = #{productCategory}
  285. </if>
  286. </where>
  287. group by a.productID
  288. <choose>
  289. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  290. ORDER BY ${page.orderBy}
  291. </when>
  292. <otherwise>
  293. </otherwise>
  294. </choose>
  295. </select>
  296. <select id="getImageList" resultType="com.caimei.po.ProductImage">
  297. select *
  298. from productimage
  299. where productID = #{productId}
  300. ORDER BY mainFlag DESC, sortIndex is null, sortIndex ASC
  301. </select>
  302. <select id="getImageById" resultType="com.caimei.po.ProductImage">
  303. select *
  304. from productimage
  305. where productImageID = #{productImageID}
  306. </select>
  307. <select id="getValidFlagByProductId" resultType="java.lang.String">
  308. select copi.validFlag
  309. from product p
  310. left join cm_organize_product_info copi on copi.productId = p.productID and copi.organizeId = 0
  311. where p.productID = #{productID}
  312. </select>
  313. <select id="getBeforeValidFlagByProductId" resultType="java.lang.String">
  314. select beforeValidFlag
  315. from product
  316. where productID = #{productID}
  317. </select>
  318. <insert id="insert" parameterType="Product" keyProperty="id" useGeneratedKeys="true">
  319. INSERT INTO product(productID,
  320. brandID,
  321. tinyTypeID,
  322. productCategory,
  323. -- selfTypeID,
  324. shopID,
  325. name,
  326. searchKey,
  327. priceFlag,
  328. beautyActFlag,
  329. hasSkuFlag,
  330. mainImage,
  331. propertiesInfo,
  332. addTime,
  333. updateTime,
  334. sellNumber,
  335. -- weekSellNumber,
  336. -- beforeValidFlag,
  337. validFlag,
  338. favoriteTimes,
  339. commentScore,
  340. commentTimes,
  341. -- selfRecommendFlag,
  342. -- sysRecommendFlag,
  343. sortIndex,
  344. featuredFlag,
  345. featuredSortIndex,
  346. productCode,
  347. -- synToERPFlag,
  348. allAreaFlag,
  349. provinceIDs,
  350. serviceNumber,
  351. packageCount,
  352. byFlag,
  353. normalProductFlag,
  354. -- wholeSaleProductFlag,
  355. -- promotionProductFlag,
  356. -- groupBuyProductFlag,
  357. step,
  358. actFlag,
  359. actType,
  360. onlineTime,
  361. downlineTime,
  362. freePostFlag,
  363. -- precisehKey,
  364. returnGoodsStutas)
  365. VALUES (#{id},
  366. #{brandID},
  367. #{tinyTypeID},
  368. #{productCategory},
  369. -- #{selfTypeID},
  370. #{shopID},
  371. #{name},
  372. #{searchKey},
  373. #{priceFlag},
  374. #{beautyActFlag},
  375. #{hasSkuFlag},
  376. #{mainImage},
  377. #{propertiesInfo},
  378. #{addTime},
  379. #{updateTime},
  380. #{sellNumber},
  381. -- #{weekSellNumber},
  382. -- #{beforeValidFlag},
  383. #{validFlag},
  384. #{favoriteTimes},
  385. #{commentScore},
  386. #{commentTimes},
  387. -- #{selfRecommendFlag},
  388. -- #{sysRecommendFlag},
  389. #{sortIndex},
  390. #{featuredFlag},
  391. #{featuredSortIndex},
  392. #{productCode},
  393. -- #{synToERPFlag},
  394. #{allAreaFlag},
  395. #{provinceIDs},
  396. #{serviceNumber},
  397. #{packageCount},
  398. #{byFlag},
  399. #{normalProductFlag},
  400. -- #{wholeSaleProductFlag},
  401. -- #{promotionProductFlag},
  402. -- #{groupBuyProductFlag},
  403. #{step},
  404. #{actFlag},
  405. #{actType},
  406. #{onlineTime},
  407. #{downlineTime},
  408. #{freePostFlag},
  409. -- #{precisehKey},
  410. #{returnGoodsStutas})
  411. </insert>
  412. <update id="update">
  413. UPDATE product
  414. SET productID = #{id},
  415. brandID = #{brandID},
  416. tinyTypeID = #{tinyTypeID},
  417. productCategory = #{productCategory},
  418. -- selfTypeID = #{selfTypeID},
  419. shopID = #{shopID},
  420. name = #{name},
  421. searchKey = #{searchKey},
  422. priceFlag = #{priceFlag},
  423. beautyActFlag = #{beautyActFlag},
  424. hasSkuFlag = #{hasSkuFlag},
  425. mainImage = #{mainImage},
  426. propertiesInfo = #{propertiesInfo},
  427. addTime = #{addTime},
  428. updateTime = #{updateTime},
  429. sellNumber = #{sellNumber},
  430. -- weekSellNumber = #{weekSellNumber},
  431. -- beforeValidFlag = #{beforeValidFlag},
  432. validFlag = #{validFlag},
  433. favoriteTimes = #{favoriteTimes},
  434. commentScore = #{commentScore},
  435. commentTimes = #{commentTimes},
  436. -- selfRecommendFlag = #{selfRecommendFlag},
  437. -- sysRecommendFlag = #{sysRecommendFlag},
  438. sortIndex = #{sortIndex},
  439. featuredFlag = #{featuredFlag},
  440. featuredSortIndex = #{featuredSortIndex},
  441. productCode = #{productCode},
  442. -- synToERPFlag = #{synToERPFlag},
  443. allAreaFlag = #{allAreaFlag},
  444. provinceIDs = #{provinceIDs},
  445. serviceNumber = #{serviceNumber},
  446. packageCount = #{packageCount},
  447. byFlag = #{byFlag},
  448. normalProductFlag = #{normalProductFlag},
  449. -- wholeSaleProductFlag = #{wholeSaleProductFlag},
  450. -- promotionProductFlag = #{promotionProductFlag},
  451. -- groupBuyProductFlag = #{groupBuyProductFlag},
  452. step = #{step},
  453. actFlag = #{actFlag},
  454. actType = #{actType},
  455. onlineTime = #{onlineTime},
  456. downlineTime = #{downlineTime},
  457. freePostFlag = #{freePostFlag},
  458. -- precisehKey = #{precisehKey},
  459. actSort = #{actSort},
  460. productType = #{productType},
  461. qualificationImg = #{qualificationImg},
  462. includedTax = #{includedTax},
  463. invoiceType = #{invoiceType},
  464. taxPoint = #{taxPoint},
  465. supplierTaxPoint = #{supplierTaxPoint}
  466. WHERE productID = #{id}
  467. </update>
  468. <insert id="insertProductImage" parameterType="com.caimei.po.ProductImage">
  469. insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
  470. values (#{productID}, #{shopID}, #{addTime}, #{image}, #{mainFlag}, #{sortIndex});
  471. </insert>
  472. <select id="newFloorId" resultType="java.lang.Integer">
  473. select id
  474. from new_page_floor
  475. where floorType = 1
  476. limit 1
  477. </select>
  478. <update id="updateByPrimaryKeySelective" parameterType="com.caimei.modules.product.entity.Product">
  479. update product
  480. <set>
  481. <if test="floorId != null and floorId != ''">
  482. floorId=#{floorId},
  483. </if>
  484. <if test="newvalidFlag != null and newvalidFlag != '' ">
  485. newvalidFlag=#{newvalidFlag},
  486. </if>
  487. <if test="brandID != null and brandID != ''">
  488. brandID = #{brandID},
  489. </if>
  490. <if test="bigTypeID != null and bigTypeID !=''">
  491. bigTypeID = #{bigTypeID},
  492. smallTypeID = #{smallTypeID},
  493. tinyTypeID = #{tinyTypeID},
  494. </if>
  495. <if test="preferredFlag != null and preferredFlag !=''">
  496. preferredFlag = #{preferredFlag},
  497. </if>
  498. <!-- <if test="selfTypeID != null and selfTypeID !=''">-->
  499. <!-- selfTypeID = #{selfTypeID},-->
  500. <!-- </if>-->
  501. <if test="shopID != null and shopID !=''">
  502. shopID = #{shopID},
  503. </if>
  504. <if test="name != null and name !=''">
  505. `name` = #{name},
  506. </if>
  507. <if test="aliasName != null and aliasName !=''">
  508. aliasName = #{aliasName},
  509. </if>
  510. <if test="searchKey != null and searchKey !=''">
  511. searchKey = #{searchKey},
  512. </if>
  513. <if test="productRemarks != null and productRemarks !=''">
  514. productRemarks = #{productRemarks},
  515. </if>
  516. <if test="combinationID != null and combinationID !=''">
  517. combinationID = #{combinationID},
  518. </if>
  519. <if test="normalPrice != null and normalPrice !=''">
  520. normalPrice = #{normalPrice},
  521. </if>
  522. <if test="price != null and price !=''">
  523. price = #{price},
  524. </if>
  525. <if test="priceFlag != null and priceFlag !=''">
  526. priceFlag = #{priceFlag},
  527. </if>
  528. <if test="beautyActFlag != null and beautyActFlag !=''">
  529. beautyActFlag = #{beautyActFlag},
  530. </if>
  531. <if test="ladderPriceFlag != null and ladderPriceFlag !=''">
  532. ladderPriceFlag = #{ladderPriceFlag},
  533. </if>
  534. <if test="stock != null and stock !=''">
  535. stock = #{stock},
  536. </if>
  537. <if test="hasSkuFlag != null and hasSkuFlag !=''">
  538. hasSkuFlag = #{hasSkuFlag},
  539. </if>
  540. <if test="mainImage != null and mainImage !=''">
  541. mainImage = #{mainImage},
  542. </if>
  543. <if test="propertiesInfo != null and propertiesInfo !=''">
  544. propertiesInfo = #{propertiesInfo},
  545. </if>
  546. <if test="addTime != null and addTime !=''">
  547. addTime = #{addTime},
  548. </if>
  549. <if test="updateTime != null and updateTime !=''">
  550. updateTime = #{updateTime},
  551. </if>
  552. <if test="sellNumber != null and sellNumber !=''">
  553. sellNumber = #{sellNumber},
  554. </if>
  555. <!-- <if test="weekSellNumber != null and weekSellNumber !=''">-->
  556. <!-- weekSellNumber = #{weekSellNumber},-->
  557. <!-- </if>-->
  558. <!-- <if test="beforeValidFlag != null and beforeValidFlag !=''">-->
  559. <!-- beforeValidFlag = #{beforeValidFlag},-->
  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} LIMIT 1;
  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>