SecondHandMapper.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. <select id="getSeconHandList" resultType="com.caimei365.commodity.model.vo.SecondListVo">
  38. select
  39. p.productID as productId,
  40. p.actStatus,
  41. p.`name` as name,
  42. p.mainImage as image,
  43. p.price1 as price,
  44. p.brandID as brandId,
  45. IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
  46. cshd.sold as "sold",
  47. cshd.detailTalkFlag as "detailTalkFlag",
  48. cshd.onLineDate as "onLineDate",
  49. cshd.viewingNum as "viewingNum",
  50. cshd.provinceCityDistrict as "provinceCityDistrict"
  51. from
  52. product p
  53. left join cm_second_hand_detail cshd on p.productID = cshd.productID
  54. left join cm_brand cb on cb.id = p.brandID
  55. where
  56. p.productCategory = 2 and p.validFlag = 2
  57. <if test="secondHandType != null and secondHandType != ''">
  58. and cshd.secondHandType = #{secondHandType}
  59. </if>
  60. <if test="instrumentType != null and instrumentType != '' and instrumentType != '0' and instrumentType != 0">
  61. and cshd.instrumentType like CONCAT('%',#{instrumentType},'%')
  62. </if>
  63. <if test="name != null and name != ''">
  64. and p.name like CONCAT('%',#{name},'%')
  65. </if>
  66. <if test="userIdentity == null or userIdentity == 0">
  67. AND p.visibility = 3
  68. </if>
  69. <if test="userIdentity == 4">
  70. AND p.visibility IN (2,3)
  71. </if>
  72. order by cshd.onLineDate desc
  73. </select>
  74. <select id="getSecondHandDetail" resultType="com.caimei365.commodity.model.vo.SecondDetailVo">
  75. select
  76. p.productID as productId,
  77. p.actStatus,
  78. p.`name` as name,
  79. p.mainImage as image,
  80. p.price1 as price,
  81. p.normalPrice,
  82. p.productType,
  83. p.stock,
  84. p.brandID as brandId,
  85. p.visibility as visibility,
  86. IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
  87. cb.description as "brandInfo",
  88. cshd.originalPrice,
  89. cshd.sold,
  90. cshd.detailTalkFlag,
  91. cshd.onLineDate,
  92. cshd.viewingNum,
  93. cshd.provinceCityDistrict,
  94. cshd.productDetails,
  95. cshd.productQuality,
  96. cshd.secondHandType,
  97. cshd.instrumentType,
  98. cshd.showContactFlag,
  99. cshd.contactMobile,
  100. cshd.contactName,
  101. cshd.fixedYears,
  102. cshd.maturityYears
  103. from product p
  104. left join cm_second_hand_detail cshd on p.productID = cshd.productID
  105. left join cm_brand cb on cb.id = p.brandID
  106. where p.productCategory = 2 and p.productID = #{productId}
  107. </select>
  108. <select id="getImageByProductId" resultType="java.lang.String">
  109. select image from productimage
  110. where productID = #{productId}
  111. order by mainFlag desc
  112. </select>
  113. <select id="getAddressInfo" resultType="com.caimei365.commodity.model.vo.AddressVo">
  114. select a.name as "province"
  115. ,b.name as "city"
  116. ,c.name as "town"
  117. ,c.townId as "townID"
  118. from province a
  119. right join city b on a.provinceId = b.provinceId
  120. right join town c on b.cityId = c.cityId where c.townId = #{townId}
  121. </select>
  122. <select id="getOrderPageSecondList" resultType="com.caimei365.commodity.model.vo.SecondListVo">
  123. select
  124. p.productID as productId,
  125. p.actStatus,
  126. p.`name` as name,
  127. p.mainImage as image,
  128. p.price1 as price,
  129. p.brandID as brandId,
  130. IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
  131. cshd.sold as "sold",
  132. cshd.detailTalkFlag as "detailTalkFlag",
  133. cshd.onLineDate as "onLineDate",
  134. cshd.viewingNum as "viewingNum",
  135. cshd.provinceCityDistrict as "provinceCityDistrict"
  136. from
  137. product p
  138. left join cm_second_hand_detail cshd on p.productID = cshd.productID
  139. left join cm_brand cb on cb.id = p.brandID
  140. where
  141. p.productCategory = 2 and p.validFlag = 2
  142. <if test="secondHandType != null and secondHandType != ''">
  143. and cshd.secondHandType = #{secondHandType}
  144. </if>
  145. <if test="instrumentType != null and instrumentType != ''">
  146. and cshd.instrumentType like CONCAT('%',#{instrumentType},'%')
  147. </if>
  148. <if test="searchKeyword != null and searchKeyword != ''">
  149. and p.name like CONCAT('%',#{searchKeyword},'%')
  150. </if>
  151. and cshd.sold != 1
  152. order by cshd.onLineDate desc
  153. </select>
  154. <select id="getSecondListByLimit" resultType="com.caimei365.commodity.model.vo.SecondListVo">
  155. select
  156. p.productID as productId,
  157. p.actStatus,
  158. p.`name` as name,
  159. p.mainImage as image,
  160. p.price1 as price,
  161. p.brandID as brandId,
  162. IF(p.brandID != 161,cb.name ,cshd.brandName) as "brandName",
  163. cshd.sold as "sold",
  164. cshd.detailTalkFlag as "detailTalkFlag",
  165. cshd.onLineDate as "onLineDate",
  166. cshd.viewingNum as "viewingNum",
  167. cshd.provinceCityDistrict as "provinceCityDistrict"
  168. from
  169. product p
  170. left join cm_second_hand_detail cshd on p.productID = cshd.productID
  171. left join cm_brand cb on cb.id = p.brandID
  172. where p.productCategory = 2 and p.validFlag = 2
  173. <if test="secondHandType != null and secondHandType != ''">
  174. and cshd.secondHandType = #{secondHandType}
  175. </if>
  176. order by cshd.onLineDate desc
  177. limit 10
  178. </select>
  179. <select id="getBrandList" resultType="com.caimei365.commodity.model.vo.BrandVo">
  180. select id, name
  181. from cm_brand
  182. where status = '1' and delFlag = '0' and description is not null and description != '' and id not in (161)
  183. order by sort
  184. </select>
  185. </mapper>