ProductNewMapper.xml 33 KB

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