CmSecondHandDetailMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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. (SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) 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 cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
  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. group by p.productID
  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. <if test="productID != null and productID != ''">
  77. AND a.productID = #{productID}
  78. </if>
  79. </where>
  80. group by p.productID
  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. </where>
  97. group by p.productID
  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. group by p.productID
  119. </select>
  120. <select id="findFlieTypes" resultType="java.lang.Integer">
  121. select fileType
  122. from cm_second_file_type
  123. where productId = #{productID}
  124. </select>
  125. <select id="findShopId" resultType="java.lang.Integer">
  126. select shopId
  127. from product
  128. where productID = #{productId}
  129. </select>
  130. <insert id="insert" parameterType="CmSecondHandDetail" keyProperty="id" useGeneratedKeys="true">
  131. INSERT INTO cm_second_hand_detail(publishIdentity,
  132. authenticationBackImage,
  133. licenseImage,
  134. productID,
  135. sold,
  136. secondHandType,
  137. instrumentType,
  138. fixedYears,
  139. maturityYears,
  140. companyName,
  141. detailTalkFlag,
  142. originalPrice,
  143. contactName,
  144. contactMobile,
  145. dockingPeopleName,
  146. dockingPeopleMobile,
  147. secondProductType,
  148. provinceCityDistrict,
  149. townId,
  150. address,
  151. productQuality,
  152. productDetails,
  153. viewingNum,
  154. brandName,
  155. payAmount,
  156. payFormData,
  157. payType,
  158. payDate,
  159. submitDate,
  160. reviewedDate,
  161. onLineDate,
  162. source,
  163. showContactFlag,
  164. publisher,
  165. authenticationImage,
  166. fileName,
  167. ossName,
  168. commitmentImage)
  169. VALUES (#{publishIdentity},
  170. #{authenticationBackImage},
  171. #{licenseImage},
  172. #{productID},
  173. #{sold},
  174. #{secondHandType},
  175. #{instrumentType},
  176. #{fixedYears},
  177. #{maturityYears},
  178. #{companyName},
  179. #{detailTalkFlag},
  180. #{originalPrice},
  181. #{contactName},
  182. #{contactMobile},
  183. #{dockingPeopleName},
  184. #{dockingPeopleMobile},
  185. #{secondProductType},
  186. #{provinceCityDistrict},
  187. #{townId},
  188. #{address},
  189. #{productQuality},
  190. #{productDetails},
  191. #{viewingNum},
  192. #{brandName},
  193. #{payAmount},
  194. #{payFormData},
  195. #{payType},
  196. #{payDate},
  197. #{submitDate},
  198. #{reviewedDate},
  199. #{onLineDate},
  200. #{source},
  201. #{showContactFlag},
  202. #{publisher},
  203. #{authenticationImage},
  204. #{fileName},
  205. #{ossName},
  206. #{commitmentImage})
  207. </insert>
  208. <insert id="insertFileType">
  209. insert into cm_second_file_type
  210. (secondid, productid, filetype)
  211. values (#{secondId}, #{productId}, #{fileType})
  212. </insert>
  213. <insert id="insertShop" keyColumn="shopID" keyProperty="shopID" useGeneratedKeys="true">
  214. insert into shop (name, linkMan, contractMobile, cardNumber, accountType, banOfDeposit, accountName, addTime,
  215. status, shopType)
  216. values (#{name}, #{linkMan}, #{contractMobile}, #{cardNumber}, #{accountType}, #{banOfDeposit}, #{accountName},
  217. now(), 90, #{shopType})
  218. </insert>
  219. <select id="selectContactDockingPeople" resultType="CmSecondHandDetail">
  220. select contactName, dockingPeopleName
  221. from cm_second_hand_detail
  222. where productID IN (
  223. SELECT p.productID
  224. FROM product AS p
  225. LEFT JOIN cm_order_product cop ON p.productID = cop.productID
  226. WHERE cop.shopOrderNo = #{shopOrderNo}
  227. )
  228. </select>
  229. <update id="update">
  230. UPDATE cm_second_hand_detail
  231. SET productID = #{productID},
  232. sold = #{sold},
  233. secondHandType = #{secondHandType},
  234. instrumentType = #{instrumentType},
  235. fixedYears = #{fixedYears},
  236. maturityYears = #{maturityYears},
  237. companyName = #{companyName},
  238. detailTalkFlag = #{detailTalkFlag},
  239. originalPrice = #{originalPrice},
  240. contactName = #{contactName},
  241. contactMobile = #{contactMobile},
  242. dockingPeopleName = #{dockingPeopleName},
  243. dockingPeopleMobile = #{dockingPeopleMobile},
  244. secondProductType = #{secondProductType},
  245. provinceCityDistrict = #{provinceCityDistrict},
  246. townId = #{townId},
  247. address = #{address},
  248. productQuality = #{productQuality},
  249. productDetails = #{productDetails},
  250. viewingNum = #{viewingNum},
  251. brandName = #{brandName},
  252. payAmount = #{payAmount},
  253. payFormData = #{payFormData},
  254. payType = #{payType},
  255. payDate = #{payDate},
  256. submitDate = #{submitDate},
  257. reviewedDate = #{reviewedDate},
  258. onLineDate = #{onLineDate},
  259. source = #{source},
  260. showContactFlag = #{showContactFlag},
  261. publisher = #{publisher},
  262. authenticationImage = #{authenticationImage},
  263. fileName = #{fileName},
  264. ossName = #{ossName},
  265. commitmentImage = #{commitmentImage},
  266. publishIdentity = #{publishIdentity}
  267. WHERE productID = #{productID}
  268. </update>
  269. <update id="updateRevieweInfo">
  270. UPDATE cm_second_hand_detail
  271. SET reviewedDate = #{reviewedDate},
  272. onLineDate = #{onLineDate}
  273. WHERE productID = #{productID}
  274. </update>
  275. <update id="updateOnLineDate">
  276. UPDATE cm_second_hand_detail
  277. SET onLineDate = #{date}
  278. WHERE productID = #{productID}
  279. </update>
  280. <update id="updatSecondHnadproductSold">
  281. UPDATE cm_second_hand_detail
  282. SET sold = 1
  283. where productID = #{productID}
  284. </update>
  285. <delete id="delete">
  286. DELETE
  287. FROM cm_second_hand_detail
  288. WHERE productID = #{productID}
  289. </delete>
  290. <delete id="deleteFileType">
  291. delete
  292. from cm_second_file_type
  293. where productId = #{productId}
  294. </delete>
  295. <update id="updatSecondHnadBySold">
  296. UPDATE cm_second_hand_detail
  297. SET sold = 0
  298. WHERE productID = #{productID}
  299. </update>
  300. <update id="updateShop">
  301. update shop
  302. set name=#{name},
  303. linkMan=#{linkMan},
  304. contractMobile=#{contractMobile},
  305. cardNumber=#{cardNumber},
  306. accountType=#{accountType},
  307. banOfDeposit=#{banOfDeposit},
  308. accountName=#{accountName}
  309. where shopID = #{shopID}
  310. </update>
  311. <update id="updateShopType">
  312. update shop
  313. set shopType=3
  314. where shopID = (select shopID from product where productID = #{productID})
  315. </update>
  316. </mapper>