BaseMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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.order.mapper.BaseMapper">
  4. <select id="getShopNameById" resultType="java.lang.String">
  5. SELECT `name`
  6. FROM shop
  7. WHERE shopID = #{shopId}
  8. LIMIT 1
  9. </select>
  10. <select id="getClubNameById" resultType="java.lang.String">
  11. SELECT `name`
  12. FROM club
  13. WHERE clubID = #{clubId}
  14. LIMIT 1
  15. </select>
  16. <insert id="insertUserInvoiceByUserId" parameterType="com.caimei365.order.model.vo.InvoiceVo">
  17. INSERT INTO cm_user_invoiceinfo (userId, invoiceTitle, corporationTaxNum, registeredAddress, registeredPhone,
  18. bankAccountNo, openBank)
  19. VALUES (#{userId}, #{invoiceTitle}, #{corporationTaxNum}, #{registeredAddress}, #{registeredPhone},
  20. #{bankAccountNo}, #{openBank})
  21. </insert>
  22. <insert id="insertPurchasePrice" keyColumn="id" keyProperty="id"
  23. parameterType="com.caimei365.order.model.po.PurchasePricePo" useGeneratedKeys="true">
  24. INSERT INTO repeat_purchase_price (userId, clubId, orderId, productId, shopId, shopName,
  25. taxRate, currentPrice, createTime, updateTime, delFlag)
  26. VALUES (#{userId}, #{clubId}, #{orderId}, #{productId}, #{shopId}, #{shopName},
  27. #{taxRate}, #{currentPrice}, #{createTime}, #{updateTime}, #{delFlag})
  28. </insert>
  29. <insert id="insertPurchaseHistory" keyColumn="id" keyProperty="id"
  30. parameterType="com.caimei365.order.model.po.PurchaseHistoryPo" useGeneratedKeys="true">
  31. INSERT INTO repeat_purchase_price_history (userId, clubId, orderId, productId, price, currentCostPrice,
  32. createTime, delFlag)
  33. VALUES (#{userId}, #{clubId}, #{orderId}, #{productId}, #{price}, #{currentCostPrice}, #{createTime},
  34. #{delFlag})
  35. </insert>
  36. <update id="updateUserInvoiceByUserId" parameterType="com.caimei365.order.model.vo.InvoiceVo">
  37. UPDATE cm_user_invoiceinfo
  38. SET invoiceTitle = #{invoiceTitle},
  39. corporationTaxNum = #{corporationTaxNum},
  40. registeredAddress = #{registeredAddress},
  41. registeredPhone = #{registeredPhone},
  42. bankAccountNo = #{bankAccountNo},
  43. openBank = #{openBank}
  44. WHERE userId = #{userId}
  45. </update>
  46. <update id="updatePurchasePrice">
  47. UPDATE repeat_purchase_price
  48. SET currentPrice = #{currentPrice},
  49. taxRate = #{taxRate},
  50. updateTime = #{updateTime}
  51. WHERE id = #{id}
  52. </update>
  53. <select id="getUserIdByClubId" resultType="java.lang.Integer">
  54. select userID
  55. from user
  56. where clubID = #{clubId}
  57. LIMIT 1
  58. </select>
  59. <select id="getIdentityByUserId" resultType="java.lang.Integer">
  60. select ifnull(userIdentity,0)
  61. from user
  62. where userID = #{userId}
  63. LIMIT 1
  64. </select>
  65. <select id="getUserNameByUserId" resultType="java.lang.String">
  66. select userName
  67. from user
  68. where userID = #{userId}
  69. LIMIT 1
  70. </select>
  71. <select id="getLadderPriceList" resultType="com.caimei365.order.model.vo.LadderPriceVo">
  72. select id,
  73. productId,
  74. ladderNum,
  75. buyNum,
  76. buyPrice
  77. from product_ladder_price
  78. where productId = #{productId}
  79. and userType = 3
  80. and delFlag = 0
  81. order by ladderNum asc
  82. </select>
  83. <select id="getRepurchasePrice" resultType="java.lang.Double">
  84. select r.currentPrice,p.productType
  85. from repeat_purchase_price r
  86. left join product p on p.productID = r.productId
  87. where r.productId = #{productId}
  88. and r.userId = #{userId}
  89. and ((p.costCheckFlag = 1 and r.currentPrice <![CDATA[ >= ]]> p.costPrice) or p.costCheckFlag = 2)
  90. and p.price <![CDATA[ >= ]]> r.currentPrice
  91. and r.delFlag = 0
  92. </select>
  93. <select id="getPromotionByShopId" resultType="com.caimei365.order.model.vo.PromotionsVo">
  94. SELECT pr.id,
  95. pr.name,
  96. pr.description,
  97. pr.type,
  98. pr.mode,
  99. pr.touchPrice,
  100. pr.reducedPrice,
  101. pr.beginTime,
  102. pr.endTime,
  103. pr.status,
  104. prp.productId,
  105. prp.supplierId AS shopId,
  106. pr.seen,
  107. pr.discount
  108. FROM cm_promotions pr
  109. LEFT JOIN cm_promotions_product prp ON pr.id = prp.promotionsId
  110. WHERE prp.supplierId = #{shopId}
  111. and pr.delFlag = 0
  112. and pr.type = 3
  113. AND (pr.status = 1 OR (pr.status = 2 AND (NOW() BETWEEN pr.beginTime AND pr.endTime)))
  114. ORDER BY pr.type DESC
  115. LIMIT 1
  116. </select>
  117. <select id="getPromotionByProductId" resultType="com.caimei365.order.model.vo.PromotionsVo">
  118. SELECT pr.id,
  119. pr.name,
  120. pr.description,
  121. pr.type,
  122. pr.mode,
  123. pr.touchPrice,
  124. pr.reducedPrice,
  125. pr.beginTime,
  126. pr.endTime,
  127. pr.status,
  128. prp.productId,
  129. prp.supplierId AS shopId,
  130. pr.discount,
  131. pr.seen
  132. FROM cm_promotions pr
  133. LEFT JOIN cm_promotions_product prp ON pr.id = prp.promotionsId
  134. WHERE prp.productId = #{productId}
  135. and pr.delFlag = 0
  136. and pr.type in (1, 2)
  137. AND (pr.status = 1 OR (pr.status = 2 AND (NOW() BETWEEN pr.beginTime AND pr.endTime)))
  138. ORDER BY pr.type DESC
  139. LIMIT 1
  140. </select>
  141. <select id="getPromotionGifts" resultType="com.caimei365.order.model.vo.CartItemVo">
  142. SELECT cpg.id AS id,
  143. p.productID AS productId,
  144. p.shopID AS shopId,
  145. p.`name` AS `name`,
  146. p.mainImage AS image,
  147. cpg.number AS number,
  148. 0 AS price,
  149. 2 as productType,
  150. p.price AS originalPrice,
  151. p.unit AS unit,
  152. p.stock AS stock,
  153. p.validFlag AS validFlag,
  154. p.productType
  155. FROM cm_promotions_gift cpg
  156. LEFT JOIN product p ON cpg.productId = p.productID
  157. WHERE cpg.promotionsId = #{promotionsId}
  158. ORDER BY cpg.id DESC
  159. </select>
  160. <select id="getShopByProductId" resultType="com.caimei365.order.model.vo.CartShopVo">
  161. SELECT s.shopID AS shopId,
  162. s.name AS shopName,
  163. s.logo AS shopLogo,
  164. p.productType
  165. FROM shop s
  166. LEFT JOIN product p ON p.shopID = s.shopID
  167. WHERE p.productId = #{productId}
  168. LIMIT 1
  169. </select>
  170. <select id="getUserInvoice" resultType="com.caimei365.order.model.vo.InvoiceVo">
  171. SELECT id,
  172. userId,
  173. invoiceTitle,
  174. corporationTaxNum,
  175. registeredAddress,
  176. registeredPhone,
  177. bankAccountNo,
  178. openBank
  179. FROM cm_user_invoiceinfo
  180. WHERE userId = #{userId}
  181. LIMIT 1
  182. </select>
  183. <select id="getUserMoney" resultType="java.lang.Double">
  184. SELECT IFNULL(userMoney, 0)
  185. FROM user
  186. WHERE userID = #{userId}
  187. </select>
  188. <select id="getAbleUserMoney" resultType="java.lang.Double">
  189. SELECT IFNULL(ableUserMoney, 0)
  190. FROM user
  191. WHERE userID = #{userId}
  192. </select>
  193. <select id="getUserBeans" resultType="java.lang.Integer">
  194. SELECT IFNULL(userBeans, 0)
  195. FROM user
  196. WHERE userID = #{userId}
  197. </select>
  198. <select id="getPostageFlagList" resultType="com.caimei365.order.model.vo.ProductPostageVo">
  199. SELECT
  200. productID AS productId,
  201. freePostFlag AS postageFlag,
  202. commodityType,
  203. productType
  204. FROM product
  205. WHERE validFlag='2' AND productID in
  206. <foreach collection="productIds" open="(" separator="," close=")" item="productId">
  207. #{productId}
  208. </foreach>
  209. </select>
  210. <select id="countUserOrder" resultType="java.lang.Integer">
  211. SELECT COUNT(*)
  212. FROM cm_order
  213. WHERE userID = #{userId}
  214. AND delFlag = 0
  215. AND STATUS != 6
  216. </select>
  217. <select id="getProvinceIdAndCityId" resultType="com.caimei365.order.model.vo.AddressVo">
  218. SELECT provinceID AS provinceId, cityID AS cityId
  219. FROM city
  220. WHERE cityID = (SELECT cityID from town where townID = #{townId})
  221. </select>
  222. <select id="getTownIdByAddressId" resultType="java.lang.Integer">
  223. SELECT townID
  224. FROM address
  225. WHERE addressID = #{addressId}
  226. </select>
  227. <select id="getPurchasePricePo" resultType="com.caimei365.order.model.po.PurchasePricePo">
  228. SELECT id,
  229. userId,
  230. clubId,
  231. orderId,
  232. productId,
  233. shopId,
  234. shopName,
  235. taxRate,
  236. currentPrice,
  237. createTime
  238. FROM repeat_purchase_price
  239. WHERE userId = #{userId}
  240. AND productId = #{productId}
  241. AND delFlag = '0'
  242. </select>
  243. <select id="getBindMobileByUserId" resultType="java.lang.String">
  244. SELECT bindMobile
  245. FROM user
  246. WHERE userID = #{userId}
  247. </select>
  248. <select id="getShopIdByproductId" resultType="java.lang.Integer">
  249. SELECT shopID,productType
  250. FROM product
  251. WHERE productID = #{productId}
  252. </select>
  253. <select id="getClauseList" resultType="com.caimei365.order.model.vo.ClauseVo">
  254. SELECT id,
  255. name,
  256. content,
  257. clauseType,
  258. enabledStatus
  259. FROM bp_clause
  260. </select>
  261. <insert id="insertDiscernReceipt" keyColumn="id" keyProperty="id"
  262. parameterType="com.caimei365.order.model.po.DiscernReceiptPo" useGeneratedKeys="true">
  263. INSERT INTO cm_discern_receipt (payWay, payType, receiptType, receiptStatus, receiptAmount, confirmType,
  264. receiptDate, confirmDate, reviewDate, updateDate, delFlag, rePayFlag, formData)
  265. VALUES (#{payWay}, #{payType}, #{receiptType}, #{receiptStatus}, #{receiptAmount}, #{confirmType},
  266. #{receiptDate}, #{confirmDate}, #{reviewDate}, #{updateDate}, #{delFlag}, #{rePayFlag}, #{formData})
  267. </insert>
  268. <insert id="insertOrderReceiptRelation" keyColumn="id" keyProperty="id"
  269. parameterType="com.caimei365.order.model.po.OrderReceiptRelationPo" useGeneratedKeys="true">
  270. INSERT INTO cm_receipt_order_relation (relationType, receiptId, associationType, associateAmount, orderId, couponRecordId, vipRecordId, authVipRecordId, delFlag,
  271. mbOrderId, orderRequestNo, splitStatus, productId)
  272. VALUES (#{relationType}, #{receiptId}, #{associationType}, #{associateAmount}, #{orderId}, #{couponRecordId}, #{vipRecordId}, #{authVipRecordId}, #{delFlag},
  273. #{mbOrderId}, #{orderRequestNo}, #{splitStatus}, #{productId})
  274. </insert>
  275. <insert id="insertBeansHistory" parameterType="com.caimei365.order.model.po.UserBeansHistoryPo">
  276. INSERT INTO user_beans_history (userId, type, beansType, orderId, num, pushStatus, addTime, delFlag)
  277. VALUES (#{userId}, #{type}, #{beansType}, #{orderId}, #{num}, #{pushStatus}, #{addTime}, #{delFlag})
  278. </insert>
  279. <update id="updateUserBeans">
  280. UPDATE USER
  281. SET userBeans = #{userBeans}
  282. WHERE userID = #{userId}
  283. </update>
  284. <update id="updateUserClubStatus">
  285. UPDATE user
  286. SET clubStatus = #{clubStatus}
  287. WHERE userID = #{userId}
  288. </update>
  289. <update id="updateClubStatus">
  290. UPDATE club
  291. SET status = #{clubStatus}
  292. WHERE userID = #{userId}
  293. </update>
  294. <update id="updateUserMoney">
  295. UPDATE USER
  296. SET userMoney = #{userMoney},
  297. ableUserMoney = #{ableUserMoney}
  298. WHERE userID = #{userId}
  299. </update>
  300. <insert id="insertBalanceRecord" parameterType="com.caimei365.order.model.po.BalanceRecordPo">
  301. INSERT INTO cm_user_balance_record (userId, type, balanceType, addDate, amount, orderId, receiptId, remark, delFlag)
  302. VALUES (#{userId}, #{type}, #{balanceType}, #{addDate}, #{amount}, #{orderId}, #{receiptId}, #{remark}, #{delFlag})
  303. </insert>
  304. <select id="getSvipUserIdByUserId" resultType="java.lang.Integer">
  305. select userId
  306. from cm_svip_user
  307. where userId = #{userId}
  308. and delFlag = '0'
  309. and now() <![CDATA[ < ]]> endTime
  310. </select>
  311. <select id="getSvipUserIdByClubId" resultType="java.lang.Integer">
  312. select svu.userId
  313. from cm_svip_user svu
  314. left join club c on svu.userId = c.userID
  315. where c.clubID = #{clubId}
  316. and delFlag = '0'
  317. and now() <![CDATA[ < ]]> endTime;
  318. </select>
  319. <select id="getClubStatus" resultType="java.lang.Integer">
  320. select clubStatus
  321. from user
  322. where userID = #{userId}
  323. </select>
  324. <select id="getClubConfirmTime" resultType="java.util.Date">
  325. SELECT confirmTime
  326. FROM club_confirm_record
  327. WHERE userId = #{userId}
  328. ORDER BY confirmTime DESC
  329. LIMIT 1
  330. </select>
  331. <select id="findLowOrder" resultType="com.caimei365.order.model.po.UserBeansHistoryPo">
  332. select id, userId, type, beansType, orderId, num, addTime
  333. from user_beans_history
  334. where orderId = #{orderId}
  335. and delFlag = 0
  336. and type = 2
  337. and num = 500
  338. </select>
  339. <select id="findBeans" resultType="java.lang.Integer">
  340. select userBeans from user where userID=#{userId}
  341. </select>
  342. <select id="getonlineMoney" resultType="java.lang.Double">
  343. select onlineMoney FROM USER WHERE userId = #{userId}
  344. </select>
  345. <select id="getAuthUser" resultType="com.caimei365.order.model.vo.AuthUserVo">
  346. select authUserId,name,mobile
  347. from cm_brand_auth_user
  348. where authUserId = #{userId}
  349. LIMIT 1
  350. </select>
  351. </mapper>