SecondHandMapper.xml 12 KB

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