SecondHandMapper.xml 11 KB

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