SecondHandMapper.xml 9.6 KB

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