CmSecondHandDetailMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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.caimei.modules.product.dao.CmSecondHandDetailDao">
  4. <sql id="cmSecondHandDetailColumns">
  5. a.id AS "id",
  6. a.productID AS "productID",
  7. a.sold AS "sold",
  8. a.secondHandType AS "secondHandType",
  9. a.instrumentType AS "instrumentType",
  10. a.fixedYears AS "fixedYears",
  11. a.maturityYears AS "maturityYears",
  12. a.companyName AS "companyName",
  13. a.detailTalkFlag AS "detailTalkFlag",
  14. a.originalPrice AS "originalPrice",
  15. a.contactName AS "contactName",
  16. a.contactMobile AS "contactMobile",
  17. a.dockingPeopleName AS "dockingPeopleName",
  18. a.dockingPeopleMobile AS "dockingPeopleMobile",
  19. a.secondProductType AS "secondProductType",
  20. a.provinceCityDistrict AS "provinceCityDistrict",
  21. a.townId as "townId",
  22. a.address AS "address",
  23. a.productQuality AS "productQuality",
  24. a.productDetails AS "productDetails",
  25. a.viewingNum AS "viewingNum",
  26. a.brandName AS "brandName",
  27. a.payAmount AS "payAmount",
  28. a.payFormData AS "payFormData",
  29. a.payType AS "payType",
  30. a.payDate AS "payDate",
  31. a.submitDate AS "submitDate",
  32. a.reviewedDate AS "reviewedDate",
  33. a.onLineDate AS "onLineDate",
  34. a.source AS "source",
  35. a.showContactFlag AS "showContactFlag",
  36. a.publisher AS "publisher",
  37. a.authenticationImage AS "authenticationImage",
  38. a.fileName AS "fileName",
  39. a.ossName AS "ossName",
  40. a.commitmentImage AS "commitmentImage",
  41. copi.validFlag AS "validFlag",
  42. p.productCategory AS "productCategory",
  43. p.name AS "name",
  44. cs.normalPrice AS "normalPrice",
  45. cs.price AS "price",
  46. cs.stock AS "stock",
  47. p.brandID AS "brandID",
  48. cs.costPrice as "costPrice",
  49. cs.costCheckFlag AS "costCheckFlag",
  50. cs.shopPercent AS "shopPercent",
  51. cs.organizeId AS "organizeId",
  52. p.visibility AS "visibility",
  53. p.splitCode AS "splitCode"
  54. </sql>
  55. <sql id="cmSecondHandDetailJoins">
  56. left join product p on p.productID = a.productID
  57. left join cm_sku cs on p.productId=cs.productId and p.groundMall like CONCAT('%', cs.organizeId, '%')
  58. </sql>
  59. <select id="get" resultType="CmSecondHandDetail">
  60. SELECT
  61. <include refid="cmSecondHandDetailColumns"/>
  62. ,cs.organizeId
  63. FROM cm_second_hand_detail a
  64. <include refid="cmSecondHandDetailJoins"/>
  65. left join cm_organize_product_info copi on copi.productId = a.productID
  66. WHERE a.productID = #{id}
  67. and a.groundMall like CONCAT('%', copi.organizeId, '%')
  68. </select>
  69. <select id="findList" resultType="CmSecondHandDetail">
  70. SELECT
  71. <include refid="cmSecondHandDetailColumns"/>
  72. FROM cm_second_hand_detail a
  73. <include refid="cmSecondHandDetailJoins"/>
  74. left join cm_organize_product_info copi on copi.productId = a.productID
  75. <where>
  76. a.groundMall like CONCAT('%', copi.organizeId, '%')
  77. <if test="productID != null and productID != ''">
  78. AND a.productID = #{productID}
  79. </if>
  80. </where>
  81. <choose>
  82. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  83. ORDER BY ${page.orderBy}
  84. </when>
  85. <otherwise>
  86. </otherwise>
  87. </choose>
  88. </select>
  89. <select id="findAllList" resultType="CmSecondHandDetail">
  90. SELECT
  91. <include refid="cmSecondHandDetailColumns"/>
  92. FROM cm_second_hand_detail a
  93. <include refid="cmSecondHandDetailJoins"/>
  94. left join cm_organize_product_info copi on copi.productId = p.productID
  95. <where>
  96. p.groundMall like CONCAT('%', copi.organizeId, '%')
  97. </where>
  98. <choose>
  99. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  100. ORDER BY ${page.orderBy}
  101. </when>
  102. <otherwise>
  103. </otherwise>
  104. </choose>
  105. </select>
  106. <select id="findValue" resultType="com.caimei.modules.product.entity.CmSecondHandDetail">
  107. select cshd.publishIdentity,
  108. cshd.authenticationBackImage,
  109. cshd.licenseImage,
  110. s.cardNumber,
  111. s.accountType,
  112. s.banOfDeposit,
  113. s.accountName
  114. from cm_second_hand_detail cshd
  115. left join product p on cshd.productId = p.productId
  116. left join shop s on s.shopID = p.shopID
  117. where p.productID = #{productID}
  118. </select>
  119. <select id="findFlieTypes" resultType="java.lang.Integer">
  120. select fileType
  121. from cm_second_file_type
  122. where productId = #{productID}
  123. </select>
  124. <select id="findShopId" resultType="java.lang.Integer">
  125. select shopId
  126. from product
  127. where productID = #{productId}
  128. </select>
  129. <insert id="insert" parameterType="CmSecondHandDetail" keyProperty="id" useGeneratedKeys="true">
  130. INSERT INTO cm_second_hand_detail(publishIdentity,
  131. authenticationBackImage,
  132. licenseImage,
  133. productID,
  134. sold,
  135. secondHandType,
  136. instrumentType,
  137. fixedYears,
  138. maturityYears,
  139. companyName,
  140. detailTalkFlag,
  141. originalPrice,
  142. contactName,
  143. contactMobile,
  144. dockingPeopleName,
  145. dockingPeopleMobile,
  146. secondProductType,
  147. provinceCityDistrict,
  148. townId,
  149. address,
  150. productQuality,
  151. productDetails,
  152. viewingNum,
  153. brandName,
  154. payAmount,
  155. payFormData,
  156. payType,
  157. payDate,
  158. submitDate,
  159. reviewedDate,
  160. onLineDate,
  161. source,
  162. showContactFlag,
  163. publisher,
  164. authenticationImage,
  165. fileName,
  166. ossName,
  167. commitmentImage)
  168. VALUES (#{publishIdentity},
  169. #{authenticationBackImage},
  170. #{licenseImage},
  171. #{productID},
  172. #{sold},
  173. #{secondHandType},
  174. #{instrumentType},
  175. #{fixedYears},
  176. #{maturityYears},
  177. #{companyName},
  178. #{detailTalkFlag},
  179. #{originalPrice},
  180. #{contactName},
  181. #{contactMobile},
  182. #{dockingPeopleName},
  183. #{dockingPeopleMobile},
  184. #{secondProductType},
  185. #{provinceCityDistrict},
  186. #{townId},
  187. #{address},
  188. #{productQuality},
  189. #{productDetails},
  190. #{viewingNum},
  191. #{brandName},
  192. #{payAmount},
  193. #{payFormData},
  194. #{payType},
  195. #{payDate},
  196. #{submitDate},
  197. #{reviewedDate},
  198. #{onLineDate},
  199. #{source},
  200. #{showContactFlag},
  201. #{publisher},
  202. #{authenticationImage},
  203. #{fileName},
  204. #{ossName},
  205. #{commitmentImage})
  206. </insert>
  207. <insert id="insertFileType">
  208. insert into cm_second_file_type
  209. (secondid, productid, filetype)
  210. values (#{secondId}, #{productId}, #{fileType})
  211. </insert>
  212. <insert id="insertShop" keyColumn="shopID" keyProperty="shopID" useGeneratedKeys="true">
  213. insert into shop (name, linkMan, contractMobile, cardNumber, accountType, banOfDeposit, accountName, addTime,
  214. status, shopType)
  215. values (#{name}, #{linkMan}, #{contractMobile}, #{cardNumber}, #{accountType}, #{banOfDeposit}, #{accountName},
  216. now(), 90, #{shopType})
  217. </insert>
  218. <select id="selectContactDockingPeople" resultType="CmSecondHandDetail">
  219. select contactName, dockingPeopleName
  220. from cm_second_hand_detail
  221. where productID IN (
  222. SELECT p.productID
  223. FROM product AS p
  224. LEFT JOIN cm_order_product cop ON p.productID = cop.productID
  225. WHERE cop.shopOrderNo = #{shopOrderNo}
  226. )
  227. </select>
  228. <update id="update">
  229. UPDATE cm_second_hand_detail
  230. SET productID = #{productID},
  231. sold = #{sold},
  232. secondHandType = #{secondHandType},
  233. instrumentType = #{instrumentType},
  234. fixedYears = #{fixedYears},
  235. maturityYears = #{maturityYears},
  236. companyName = #{companyName},
  237. detailTalkFlag = #{detailTalkFlag},
  238. originalPrice = #{originalPrice},
  239. contactName = #{contactName},
  240. contactMobile = #{contactMobile},
  241. dockingPeopleName = #{dockingPeopleName},
  242. dockingPeopleMobile = #{dockingPeopleMobile},
  243. secondProductType = #{secondProductType},
  244. provinceCityDistrict = #{provinceCityDistrict},
  245. townId = #{townId},
  246. address = #{address},
  247. productQuality = #{productQuality},
  248. productDetails = #{productDetails},
  249. viewingNum = #{viewingNum},
  250. brandName = #{brandName},
  251. payAmount = #{payAmount},
  252. payFormData = #{payFormData},
  253. payType = #{payType},
  254. payDate = #{payDate},
  255. submitDate = #{submitDate},
  256. reviewedDate = #{reviewedDate},
  257. onLineDate = #{onLineDate},
  258. source = #{source},
  259. showContactFlag = #{showContactFlag},
  260. publisher = #{publisher},
  261. authenticationImage = #{authenticationImage},
  262. fileName = #{fileName},
  263. ossName = #{ossName},
  264. commitmentImage = #{commitmentImage},
  265. publishIdentity = #{publishIdentity}
  266. WHERE productID = #{productID}
  267. </update>
  268. <update id="updateRevieweInfo">
  269. UPDATE cm_second_hand_detail
  270. SET reviewedDate = #{reviewedDate},
  271. onLineDate = #{onLineDate}
  272. WHERE productID = #{productID}
  273. </update>
  274. <update id="updateOnLineDate">
  275. UPDATE cm_second_hand_detail
  276. SET onLineDate = #{date}
  277. WHERE productID = #{productID}
  278. </update>
  279. <update id="updatSecondHnadproductSold">
  280. UPDATE cm_second_hand_detail
  281. SET sold = 1
  282. where productID = #{productID}
  283. </update>
  284. <delete id="delete">
  285. DELETE
  286. FROM cm_second_hand_detail
  287. WHERE productID = #{productID}
  288. </delete>
  289. <delete id="deleteFileType">
  290. delete
  291. from cm_second_file_type
  292. where productId = #{productId}
  293. </delete>
  294. <update id="updatSecondHnadBySold">
  295. UPDATE cm_second_hand_detail
  296. SET sold = 0
  297. WHERE productID = #{productID}
  298. </update>
  299. <update id="updateShop">
  300. update shop
  301. set name=#{name},
  302. linkMan=#{linkMan},
  303. contractMobile=#{contractMobile},
  304. cardNumber=#{cardNumber},
  305. accountType=#{accountType},
  306. banOfDeposit=#{banOfDeposit},
  307. accountName=#{accountName}
  308. where shopID = #{shopID}
  309. </update>
  310. <update id="updateShopType">
  311. update shop
  312. set shopType=3
  313. where shopID = (select shopID from product where productID = #{productID})
  314. </update>
  315. </mapper>