SubmitMapper.xml 17 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.caimei365.order.mapper.SubmitMapper">
  4. <insert id="insertMainOrder" keyColumn="orderID" keyProperty="orderId"
  5. parameterType="com.caimei365.order.model.po.OrderPo" useGeneratedKeys="true">
  6. INSERT INTO cm_order (orderSeen, orderSource, orderNo, userID, clubID, organizeID, buyUserID, spID, orderTime, updateDate,
  7. delFlag,
  8. userBeans, orderType, orderSubmitType, confirmFlag, onlinePayFlag, splitFlag, payFlag,
  9. receiptStatus, payStatus, zeroCostFlag, sendOutStatus, refundType, affirmPaymentFlag,
  10. productCount, presentCount, promotionalGiftsCount, hasActProduct, promotionFullReduction,
  11. svipFullReduction, secondHandOrderFlag, invoiceFlag, freePostFlag, freight,
  12. productTotalFee,
  13. orderTotalFee, payTotalFee, payableAmount, balancePayFee, couponAmount, status,
  14. confirmTime,
  15. payTime, rebateFlag,rebateFee, clauseID, clauseName)
  16. VALUES (#{orderSeen}, #{orderSource}, #{orderNo}, #{userId}, #{clubId}, #{organizeId}, #{buyUserId}, #{spId}, #{orderTime},
  17. #{updateDate},
  18. #{delFlag},
  19. #{userBeans}, #{orderType}, #{orderSubmitType}, #{confirmFlag}, #{onlinePayFlag}, #{splitFlag},
  20. #{payFlag},
  21. #{receiptStatus}, #{payStatus}, #{zeroCostFlag}, #{sendOutStatus}, #{refundType}, #{affirmPaymentFlag},
  22. #{productCount}, #{presentCount}, #{promotionalGiftsCount}, #{hasActProduct}, #{promotionFullReduction},
  23. #{svipFullReduction},
  24. #{secondHandOrderFlag}, #{invoiceFlag}, #{postageFlag}, #{postage}, #{productTotalFee},
  25. #{orderTotalFee},
  26. #{payTotalFee}, #{payableAmount}, #{balancePayFee}, #{couponAmount}, #{status}, #{confirmTime},
  27. #{payTime}, #{rebateFlag},#{rebateFee},
  28. #{clauseId}, #{clauseName})
  29. </insert>
  30. <insert id="insertShopOrder" keyColumn="shopOrderID" keyProperty="shopOrderId"
  31. parameterType="com.caimei365.order.model.po.OrderShopPo" useGeneratedKeys="true">
  32. INSERT INTO cm_shop_order (onlinePayWays, shopOrderNo, orderID, orderNo, organizeID, isColdChina, shopID, note, userID, clubID, orderType,
  33. spID, orderPromotionsId, promotionFullReduction, svipShopReduction, brokerage,
  34. canRefundAmount, itemCount,
  35. totalAmount, productAmount, needPayAmount, shopProductAmount, shopPostFee, shopPostFlag,
  36. shopTaxFee,
  37. shouldPayShopAmount, orderTime, orderSubmitType, splitFlag, payStatus,
  38. payedShopAmount, splitCode, realPay, eachDiscount, receiptStatus)
  39. VALUES (#{onlinePayWays}, #{shopOrderNo}, #{orderId}, #{orderNo}, #{organizeId},#{isColdChina}, #{shopId}, #{note}, #{userId}, #{clubId}, #{orderType},
  40. #{spId}, #{orderPromotionsId}, #{promotionFullReduction}, #{svipShopReduction}, #{brokerage},
  41. #{canRefundAmount}, #{itemCount},
  42. #{totalAmount}, #{productAmount}, #{needPayAmount}, #{shopProductAmount}, #{shopPostFee}, #{shopPostFlag}, #{shopTaxFee},
  43. #{shouldPayShopAmount}, #{orderTime}, #{orderSubmitType}, #{splitFlag}, #{payStatus},
  44. #{payedShopAmount}, #{splitCode}, #{realPay}, #{eachDiscount}, 1)
  45. </insert>
  46. <update id="updateOrder">
  47. update cm_order
  48. set freight = #{freight}
  49. where orderId = #{orderId}
  50. </update>
  51. <insert id="insertOrderProduct" keyColumn="orderProductID" keyProperty="orderProductId"
  52. parameterType="com.caimei365.order.model.po.OrderProductPo" useGeneratedKeys="true">
  53. INSERT INTO cm_order_product (orderID, orderNo, shopOrderID, shopOrderNo, organizeProductID,organizeID, orderPromotionsId, productId, shopId,
  54. name,
  55. productImage, price, shopName, costPrice, normalPrice, ladderPriceFlag,
  56. discountPrice, discount,
  57. totalAmount, totalFee, shouldPayFee, productUnit, num, presentNum, discountFee,
  58. includedTax,
  59. invoiceType, taxRate, addedValueTax, totalAddedValueTax, supplierTaxRate,
  60. singleShouldPayTotalTax, shouldPayTotalTax,
  61. shopProductAmount, singleShopFee, shopFee, singleOtherFee, otherFee, singleCmFee,
  62. cmFee,
  63. payStatus, buyAgainFlag, notOutStore, isActProduct, productType, svipPriceFlag,
  64. svipPriceType,
  65. svipDiscount, svipReduction,skuID, organizeSkuId, cmPercent, organizePercent, shopPercent)
  66. VALUES (#{orderId}, #{orderNo}, #{shopOrderId}, #{shopOrderNo}, #{organizeProductId}, #{organizeId}, #{orderPromotionsId}, #{productId}, #{shopId},
  67. #{name},
  68. #{image}, #{price}, #{shopName}, #{costPrice}, #{normalPrice}, #{ladderPriceFlag},
  69. #{discountPrice}, #{discount},
  70. #{totalAmount}, #{totalFee}, #{shouldPayFee}, #{productUnit}, #{num}, #{presentNum}, #{discountFee},
  71. #{includedTax},
  72. #{invoiceType}, #{taxRate}, #{addedValueTax}, #{totalAddedValueTax}, #{shopTaxRate},
  73. #{singleShouldPayTotalTax}, #{shouldPayTotalTax},
  74. #{shopProductAmount}, #{singleShopFee}, #{shopFee}, #{singleOtherFee}, #{otherFee}, #{singleCmFee},
  75. #{cmFee},
  76. #{payStatus}, #{buyAgainFlag}, #{notOutStore}, #{actProduct}, #{productType}, #{svipPriceFlag},
  77. #{svipPriceType}, #{svipDiscount}, #{svipReduction},#{skuId}, #{organizeSkuId}, #{cmPercent}, #{organizePercent}, #{shopPercent})
  78. </insert>
  79. <insert id="insertOrderPromotions" keyColumn="id" keyProperty="id"
  80. parameterType="com.caimei365.order.model.vo.PromotionsVo" useGeneratedKeys="true">
  81. INSERT INTO cm_promotions_order (orderId, promotionsId, name, description, type, mode, touchPrice, reducedPrice,
  82. discount,status, beginTime, endTime)
  83. VALUES (#{orderId}, #{id}, #{name}, #{description}, #{type}, #{mode}, #{touchPrice}, #{reducedPrice}, #{discount},
  84. #{status}, #{beginTime}, #{endTime})
  85. </insert>
  86. <insert id="insertLadderPrices" keyColumn="id" keyProperty="id"
  87. parameterType="com.caimei365.order.model.vo.LadderPriceVo" useGeneratedKeys="true">
  88. INSERT INTO order_product_ladder_price (orderProductId, ladderNum, buyNum, buyPrice, createDate)
  89. VALUES (#{orderProductId}, #{ladderNum}, #{buyNum}, #{buyPrice}, #{createDate})
  90. </insert>
  91. <update id="updateShopOrderIds">
  92. UPDATE cm_order
  93. SET shopOrderIDs = #{shopOrderIds}
  94. WHERE orderID = #{orderId}
  95. </update>
  96. <insert id="insertOrderInvoice" parameterType="com.caimei365.order.model.po.InvoicePo">
  97. INSERT INTO bp_order_invoice (orderId, invoiceTitle, type, invoiceContent, invoiceTitleType, corporationTaxNum,
  98. registeredAddress, registeredPhone, bankAccountNo, openBank)
  99. VALUES (#{orderId}, #{invoiceTitle}, #{type}, #{invoiceContent}, #{headingType}, #{corporationTaxNum},
  100. #{registeredAddress}, #{registeredPhone}, #{bankAccountNo}, #{openBank})
  101. </insert>
  102. <insert id="insertOrderUserInfo" parameterType="com.caimei365.order.model.po.OrderUserInfoPo">
  103. INSERT INTO bp_order_userinfo (orderId, clubId, userId, name, shouHuoRen, mobile,
  104. townId, province, city, town, address)
  105. VALUES (#{orderId}, #{clubId}, #{userId}, #{name}, #{receiver}, #{mobile},
  106. #{townId}, #{province}, #{city}, #{town}, #{address})
  107. </insert>
  108. <insert id="insertCouponOrderRecord" parameterType="com.caimei365.order.model.po.CouponOrderRecordPo">
  109. INSERT INTO cm_coupon_order_record (orderId, clubCouponId, couponType, couponAmount, touchPrice, createDate)
  110. VALUES (#{orderId}, #{clubCouponId}, #{couponType}, #{couponAmount}, #{touchPrice}, #{createDate})
  111. </insert>
  112. <update id="updateUserMoney">
  113. UPDATE USER
  114. SET userMoney = #{userMoney},
  115. ableUserMoney = #{ableUserMoney}
  116. WHERE userID = #{userId}
  117. </update>
  118. <update id="updateOrderInvoice">
  119. UPDATE bp_order_invoice SET orderId=#{orderId},
  120. <set>
  121. <if test="invoiceTitle != null">
  122. invoiceTitle = #{invoiceTitle},
  123. </if>
  124. <if test="type != null">
  125. type = #{type,jdbcType=CHAR},
  126. </if>
  127. <if test="invoiceContent != null">
  128. invoiceContent = #{invoiceContent},
  129. </if>
  130. <if test="invoiceTitleType != null">
  131. invoiceTitleType = #{invoiceTitleType},
  132. </if>
  133. <if test="corporationTaxNum != null">
  134. corporationTaxNum = #{corporationTaxNum},
  135. </if>
  136. <if test="registeredAddress != null">
  137. registeredAddress = #{registeredAddress},
  138. </if>
  139. <if test="registeredPhone != null">
  140. registeredPhone = #{registeredPhone},
  141. </if>
  142. <if test="bankAccountNo != null">
  143. bankAccountNo = #{bankAccountNo},
  144. </if>
  145. <if test="openBank != null">
  146. openBank = #{openBank},
  147. </if>
  148. </set>
  149. WHERE id = #{id}
  150. </update>
  151. <update id="updateOnlinePayFlag">
  152. UPDATE cm_order
  153. SET onlinePayFlag = #{onlinePayFlag}
  154. WHERE orderID = #{orderId}
  155. </update>
  156. <update id="updateOnlinePayWays">
  157. UPDATE cm_shop_order
  158. SET onlinePayWays = #{onlinePayWays}
  159. WHERE orderID = #{orderId}
  160. </update>
  161. <select id="getOrganizeSkuInfo" resultType="com.caimei365.order.model.po.CmOrganizeSkuPo">
  162. SELECT
  163. skuId,
  164. productId,
  165. minBuyNumber,
  166. price,
  167. unit,
  168. stock,
  169. organizePercent,
  170. shopPercent,
  171. cmPercent
  172. FROM cm_sku
  173. where skuId = #{skuId} and organizeId = 4
  174. </select>
  175. <select id="getOrderInvoice" resultType="com.caimei365.order.model.po.InvoicePo">
  176. SELECT id,
  177. orderId,
  178. invoiceTitle,
  179. corporationTaxNum,
  180. registeredAddress,
  181. registeredPhone,
  182. bankAccountNo,
  183. openBank
  184. FROM bp_order_invoice
  185. WHERE orderId = #{orderId}
  186. </select>
  187. <select id="getOperationIdByUnionId" resultType="java.lang.Integer">
  188. SELECT `id`
  189. FROM cm_mall_operation_user
  190. WHERE unionId = #{unionId}
  191. AND userID = #{userId}
  192. AND delFlag = '0'
  193. </select>
  194. <select id="getServiceProviderUserId" resultType="java.lang.Integer">
  195. SELECT userID
  196. FROM serviceprovider
  197. WHERE serviceProviderID = #{serviceProviderId}
  198. </select>
  199. <select id="getOrderUserBoById" resultType="com.caimei365.order.model.bo.OrderParamBo">
  200. SELECT userID AS userId,
  201. clubID AS clubId,
  202. userName,
  203. bindMobile,
  204. userMoney,
  205. ableUserMoney,
  206. userBeans
  207. FROM user
  208. WHERE userID = #{userId}
  209. </select>
  210. <select id="getProductDetails" resultType="com.caimei365.order.model.po.OrderProductPo">
  211. SELECT cs.skuId AS skuId,
  212. p.productID AS productId,
  213. p.shopID AS shopId,
  214. p.`name` AS `name`,
  215. p.mainImage AS image,
  216. cs.price,
  217. cs.costPrice,
  218. IFNULL(cs.costCheckFlag, 1) AS costCheckFlag,
  219. cs.shopPercent as costProportional,
  220. p.productCategory,
  221. cs.ladderPriceFlag,
  222. p.includedTax,
  223. p.invoiceType,
  224. p.taxPoint AS taxRate,
  225. cs.unit AS productUnit,
  226. cs.normalPrice,
  227. p.supplierTaxPoint AS shopTaxRate,
  228. p.splitCode as splitCode
  229. FROM product p
  230. LEFT JOIN cm_sku cs on p.productID = cs.productId
  231. WHERE cs.skuId = #{skuId} and cs.organizeId = 0
  232. </select>
  233. <select id="getProductOrganizeDetails" resultType="com.caimei365.order.model.po.OrderProductPo">
  234. SELECT cs.skuId AS skuId,
  235. p.productID AS productId,
  236. p.shopID AS shopId,
  237. p.`name` AS `name`,
  238. p.mainImage AS image,
  239. cs.price,
  240. p.productCategory,
  241. cs.ladderPriceFlag,
  242. p.includedTax,
  243. p.invoiceType,
  244. p.taxPoint AS taxRate,
  245. cs.unit AS productUnit,
  246. p.supplierTaxPoint AS shopTaxRate,
  247. p.splitCode as splitCode
  248. FROM product p
  249. LEFT JOIN cm_sku cs ON cs.productId = p.productId
  250. WHERE cmps.id = #{skuId}
  251. </select>
  252. <select id="getClauseNameById" resultType="java.lang.String">
  253. SELECT `name`
  254. FROM bp_clause
  255. WHERE id = #{clauseId}
  256. </select>
  257. <select id="getAddressDetailById" resultType="com.caimei365.order.model.vo.AddressVo">
  258. SELECT a.addressID AS addressId,
  259. a.userID AS userId,
  260. a.shouHuoRen AS receiver,
  261. a.townID AS townId,
  262. a.address,
  263. a.mobile,
  264. a.defaultFlag,
  265. t.name AS town,
  266. c.name AS city,
  267. c.cityID AS cityId,
  268. p.name AS province,
  269. p.provinceID AS provinceId
  270. FROM address a
  271. LEFT JOIN town t ON t.townID = a.townID
  272. LEFT JOIN city c ON c.cityID = t.cityID
  273. LEFT JOIN province p ON p.provinceID = c.provinceID
  274. WHERE a.addressID = #{addressId}
  275. LIMIT 1
  276. </select>
  277. <select id="getSvipProductDetails" resultType="com.caimei365.order.model.po.SvipProductPo">
  278. select if(id is not null and csp.status = 0, 1, 0) as svipProductFlag,
  279. priceType as svipPriceType,
  280. discount as svipDiscount,
  281. discountPrice as svipDiscountPrice
  282. from cm_svip_product_sku
  283. left join cm_svip_product csp on cm_svip_product_sku.productId = csp.productId
  284. where skuId = #{skuId}
  285. and csp.status=0
  286. </select>
  287. <select id="findLowOrder" resultType="java.lang.Integer">
  288. select orderID
  289. from cm_order
  290. where status not in (6, 7)
  291. and payTotalFee <![CDATA[ < ]]> 1000
  292. and orderTime <![CDATA[ > ]]> #{orderTime}
  293. and userID = #{userId}
  294. </select>
  295. <select id="findShops" resultType="com.caimei365.order.model.po.OrderShopPo">
  296. SELECT DISTINCT
  297. s.shopID AS shopId,
  298. p.splitCode
  299. FROM shop s
  300. LEFT JOIN product p ON p.shopID = s.shopID
  301. WHERE p.productID IN
  302. <foreach collection="productIdList" open="(" separator="," close=")" item="productId">
  303. #{productId}
  304. </foreach>
  305. GROUP BY s.shopID,p.splitCode
  306. </select>
  307. <select id="findSplitResult" resultType="java.lang.Integer">
  308. SELECT COUNT(*) FROM product
  309. WHERE productId IN
  310. <foreach collection="productIdList" open="(" separator="," close=")" item="productId">
  311. #{productId}
  312. </foreach>
  313. AND (splitcode IS NULL OR splitcode ='')
  314. </select>
  315. <select id="getRechargeProductDetails" resultType="com.caimei365.order.model.po.OrderProductPo">
  316. SELECT cs.skuId AS skuId,
  317. p.productID AS productId,
  318. p.shopID AS shopId,
  319. p.`name` AS `name`,
  320. p.mainImage AS image,
  321. cs.price,
  322. cs.costPrice,
  323. IFNULL(cs.costCheckFlag, 1) AS costCheckFlag,
  324. cs.shopPercent as costProportional,
  325. p.productCategory,
  326. cs.ladderPriceFlag,
  327. p.includedTax,
  328. p.invoiceType,
  329. p.taxPoint AS taxRate,
  330. cs.unit AS productUnit,
  331. cs.normalPrice,
  332. p.supplierTaxPoint AS shopTaxRate,
  333. p.splitCode as splitCode
  334. FROM product p
  335. LEFT JOIN cm_sku cs on p.productID = cs.productId
  336. WHERE cs.productId = #{productId} and cs.organizeId = 0
  337. </select>
  338. </mapper>