SecondHandMapper.xml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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.caimei365.commodity.mapper.SecondHandMapper">
  4. <insert id="saveSencondHandProduct" parameterType="com.caimei365.commodity.model.po.ProductSecondPo" keyProperty="id" useGeneratedKeys="true">
  5. insert into cm_second_hand_detail(
  6. productID, sold, secondHandType, instrumentType, fixedYears, maturityYears, companyName, detailTalkFlag,
  7. originalPrice, contactName, contactMobile, dockingPeopleName, dockingPeopleMobile, secondProductType,
  8. townId, brandName, provinceCityDistrict, address, productQuality, productDetails, viewingNum, payStatus,
  9. payAmount, payFormData, payType, payDate, submitDate, reviewedDate, onLineDate, source, publisher
  10. ) values (
  11. #{productId}, #{sold}, #{secondHandType}, #{instrumentType}, #{fixedYears}, #{maturityYears}, #{companyName},
  12. #{detailTalkFlag}, #{originalPrice}, #{contactName}, #{contactMobile}, #{dockingPeopleName}, #{dockingPeopleMobile},
  13. #{secondProductType}, #{townId}, #{brandName}, #{provinceCityDistrict}, #{address}, #{productQuality}, #{productDetails},
  14. #{viewingNum}, #{payStatus}, #{payAmount}, #{payFormData}, #{payType}, #{payDate}, #{submitDate}, #{reviewedDate},
  15. #{onLineDate}, #{source}, #{publisher}
  16. )
  17. </insert>
  18. <insert id="insertProductImage" parameterType="com.caimei365.commodity.model.po.ProductImagePo">
  19. insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
  20. values (#{productId}, #{shopId}, #{addTime}, #{image}, #{mainFlag}, #{sortIndex})
  21. </insert>
  22. <insert id="insertProduct" keyColumn="productID" keyProperty="productId" parameterType="com.caimei365.commodity.model.po.ProductPo" useGeneratedKeys="true">
  23. insert into product (
  24. brandId, name, price, price1, stock, aliasName, normalPrice, mainImage, productCategory, preferredFlag, shopId,
  25. sellNumber, costPrice, costCheckFlag, hasSkuFlag, validFlag, ladderPriceFlag, sortIndex, featuredFlag, byFlag,
  26. step, actFlag, actStatus, freePostFlag, productType, machineType, includedTax, recommendType, invoiceType,
  27. visibility, addTime, updateTime, onlineTime, downlineTime
  28. ) values (
  29. #{brandId}, #{name}, #{price}, #{price}, #{stock}, #{aliasName}, #{normalPrice}, #{mainImage}, #{productCategory},
  30. #{preferredFlag}, #{shopId}, #{sellNumber}, #{costPrice}, #{costCheckFlag}, #{hasSkuFlag}, #{validFlag},
  31. #{ladderPriceFlag}, #{sortIndex}, #{featuredFlag}, #{byFlag}, #{step}, #{actFlag}, #{actStatus},
  32. #{freePostFlag}, #{productType}, #{machineType}, #{includedTax}, #{recommendType}, #{invoiceType},
  33. #{visibility}, #{addTime}, #{updateTime}, #{onlineTime}, #{offlineTime}
  34. )
  35. </insert>
  36. <select id="getSeconHandList" resultType="com.caimei365.commodity.model.vo.SecondListVo">
  37. select
  38. p.productID as productId,
  39. p.actStatus,
  40. p.`name` as name,
  41. p.mainImage as image,
  42. p.price1 as price,
  43. p.brandID as brandId,
  44. IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
  45. cshd.sold as "sold",
  46. cshd.detailTalkFlag as "detailTalkFlag",
  47. cshd.onLineDate as "onLineDate",
  48. cshd.viewingNum as "viewingNum",
  49. cshd.provinceCityDistrict as "provinceCityDistrict"
  50. from
  51. product p
  52. left join cm_second_hand_detail cshd on p.productID = cshd.productID
  53. left join cm_brand cb on cb.id = p.brandID
  54. where
  55. p.productCategory = 2 and p.validFlag = 2
  56. <if test="secondHandType != null and secondHandType != ''">
  57. and cshd.secondHandType = #{secondHandType}
  58. </if>
  59. <if test="instrumentType != null and instrumentType != '' and instrumentType != '0' and instrumentType != 0">
  60. and cshd.instrumentType like CONCAT('%',#{instrumentType},'%')
  61. </if>
  62. <if test="name != null and name != ''">
  63. and p.name like CONCAT('%',#{name},'%')
  64. </if>
  65. order by cshd.onLineDate desc
  66. </select>
  67. <select id="getSecondHandDetail" resultType="com.caimei365.commodity.model.vo.SecondDetailVo">
  68. select
  69. p.productID as productId,
  70. p.actStatus,
  71. p.`name` as name,
  72. p.mainImage as image,
  73. p.price1 as price,
  74. p.normalPrice,
  75. p.productType,
  76. p.stock,
  77. p.brandID as brandId,
  78. IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
  79. cb.description as "brandInfo",
  80. cshd.originalPrice,
  81. cshd.sold,
  82. cshd.detailTalkFlag,
  83. cshd.onLineDate,
  84. cshd.viewingNum,
  85. cshd.provinceCityDistrict,
  86. cshd.productDetails,
  87. cshd.productQuality,
  88. cshd.secondHandType,
  89. cshd.instrumentType,
  90. cshd.showContactFlag,
  91. cshd.contactMobile,
  92. cshd.contactName,
  93. cshd.fixedYears,
  94. cshd.maturityYears
  95. from product p
  96. left join cm_second_hand_detail cshd on p.productID = cshd.productID
  97. left join cm_brand cb on cb.id = p.brandID
  98. where p.productCategory = 2 and p.productID = #{productId}
  99. </select>
  100. <select id="getImageByProductId" resultType="java.lang.String">
  101. select image from productimage
  102. where productID = #{productId}
  103. order by mainFlag desc
  104. </select>
  105. <select id="getAddressInfo" resultType="com.caimei365.commodity.model.vo.AddressVo">
  106. select a.name as "province"
  107. ,b.name as "city"
  108. ,c.name as "town"
  109. ,c.townId as "townID"
  110. from province a
  111. right join city b on a.provinceId = b.provinceId
  112. right join town c on b.cityId = c.cityId where c.townId = #{townId}
  113. </select>
  114. <select id="getOrderPageSecondList" resultType="com.caimei365.commodity.model.vo.SecondListVo">
  115. select
  116. p.productID as productId,
  117. p.actStatus,
  118. p.`name` as name,
  119. p.mainImage as image,
  120. p.price1 as price,
  121. p.brandID as brandId,
  122. IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
  123. cshd.sold as "sold",
  124. cshd.detailTalkFlag as "detailTalkFlag",
  125. cshd.onLineDate as "onLineDate",
  126. cshd.viewingNum as "viewingNum",
  127. cshd.provinceCityDistrict as "provinceCityDistrict"
  128. from
  129. product p
  130. left join cm_second_hand_detail cshd on p.productID = cshd.productID
  131. left join cm_brand cb on cb.id = p.brandID
  132. where
  133. p.productCategory = 2 and p.validFlag = 2
  134. <if test="secondHandType != null and secondHandType != ''">
  135. and cshd.secondHandType = #{secondHandType}
  136. </if>
  137. <if test="instrumentType != null and instrumentType != ''">
  138. and cshd.instrumentType like CONCAT('%',#{instrumentType},'%')
  139. </if>
  140. <if test="searchKeyword != null and searchKeyword != ''">
  141. and p.name like CONCAT('%',#{searchKeyword},'%')
  142. </if>
  143. and cshd.sold != 1
  144. order by cshd.onLineDate desc
  145. </select>
  146. <select id="getSecondListByLimit" resultType="com.caimei365.commodity.model.vo.SecondListVo">
  147. select
  148. p.productID as productId,
  149. p.actStatus,
  150. p.`name` as name,
  151. p.mainImage as image,
  152. p.price1 as price,
  153. p.brandID as brandId,
  154. IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
  155. cshd.sold as "sold",
  156. cshd.detailTalkFlag as "detailTalkFlag",
  157. cshd.onLineDate as "onLineDate",
  158. cshd.viewingNum as "viewingNum",
  159. cshd.provinceCityDistrict as "provinceCityDistrict"
  160. from
  161. product p
  162. left join cm_second_hand_detail cshd on p.productID = cshd.productID
  163. left join cm_brand cb on cb.id = p.brandID
  164. where p.productCategory = 2 and p.validFlag = 2
  165. <if test="secondHandType != null and secondHandType != ''">
  166. and cshd.secondHandType = #{secondHandType}
  167. </if>
  168. order by cshd.onLineDate desc
  169. limit 10
  170. </select>
  171. <select id="getBrandList" resultType="com.caimei365.commodity.model.vo.BrandVo">
  172. select id, name
  173. from cm_brand
  174. where status = '1' and delFlag = '0' and description is not null and description != '' and id not in (161)
  175. order by sort
  176. </select>
  177. </mapper>