SubmitMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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" parameterType="com.caimei365.order.model.po.OrderPo" useGeneratedKeys="true">
  5. INSERT INTO cm_order (orderSource, orderNo, userID, clubID, buyUserID, spID, orderTime, updateDate, delFlag,
  6. userBeans, orderType, orderSubmitType, confirmFlag, onlinePayFlag, splitFlag, payFlag,
  7. receiptStatus, payStatus, zeroCostFlag, sendOutStatus, refundType, affirmPaymentFlag,
  8. productCount, presentCount, promotionalGiftsCount, hasActProduct, promotionFullReduction,
  9. secondHandOrderFlag, invoiceFlag, freePostFlag, freight, productTotalFee, orderTotalFee,
  10. payTotalFee, payableAmount, balancePayFee, couponAmount, status, confirmTime, payTime, rebateFlag,
  11. clauseID, clauseName)
  12. VALUES (#{orderSource},#{orderNo},#{userId},#{clubId},#{buyUserId},#{spId},#{orderTime},#{updateDate},#{delFlag},
  13. #{userBeans},#{orderType},#{orderSubmitType},#{confirmFlag},#{onlinePayFlag},#{splitFlag},#{payFlag},
  14. #{receiptStatus},#{payStatus},#{zeroCostFlag},#{sendOutStatus},#{refundType},#{affirmPaymentFlag},
  15. #{productCount},#{presentCount},#{promotionalGiftsCount},#{hasActProduct},#{promotionFullReduction},
  16. #{secondHandOrderFlag},#{invoiceFlag},#{postageFlag},#{postage},#{productTotalFee},#{orderTotalFee},
  17. #{payTotalFee},#{payableAmount},#{balancePayFee},#{couponAmount},#{status},#{confirmTime},#{payTime},#{rebateFlag},
  18. #{clauseId},#{clauseName})
  19. </insert>
  20. <insert id="insertShopOrder" keyColumn="shopOrderID" keyProperty="shopOrderId" parameterType="com.caimei365.order.model.po.OrderShopPo" useGeneratedKeys="true">
  21. INSERT INTO cm_shop_order (shopOrderNo, orderID, orderNo, shopID, note, userID, clubID,
  22. spID, orderPromotionsId, promotionFullReduction, brokerage, canRefundAmount, itemCount,
  23. totalAmount, productAmount, needPayAmount, shopProductAmount, shopPostFee, shopTaxFee,
  24. shouldPayShopAmount, orderTime, orderSubmitType, splitFlag, payStatus, payedShopAmount)
  25. VALUES (#{shopOrderNo},#{orderId},#{orderNo},#{shopId}, #{note},#{userId},#{clubId},
  26. #{spId},#{orderPromotionsId},#{promotionFullReduction},#{brokerage},#{canRefundAmount},#{itemCount},
  27. #{totalAmount},#{productAmount},#{needPayAmount},#{shopProductAmount},#{shopPostFee},#{shopTaxFee},
  28. #{shouldPayShopAmount},#{orderTime},#{orderSubmitType},#{splitFlag},#{payStatus},#{payedShopAmount})
  29. </insert>
  30. <insert id="insertOrderProduct" keyColumn="orderProductID" keyProperty="orderProductId" parameterType="com.caimei365.order.model.po.OrderProductPo" useGeneratedKeys="true">
  31. INSERT INTO cm_order_product (orderID, orderNo, shopOrderID, shopOrderNo, orderPromotionsId, productId, shopId, name,
  32. productImage, price, price1, shopName, costPrice, normalPrice, ladderPriceFlag, discountPrice, discount,
  33. totalAmount, totalFee, shouldPayFee, productUnit, num, presentNum, discountFee, includedTax,
  34. invoiceType, taxRate, addedValueTax, totalAddedValueTax, singleShouldPayTotalTax, shouldPayTotalTax,
  35. shopProductAmount, singleShopFee, shopFee, singleOtherFee, otherFee, singleCmFee, cmFee,
  36. payStatus, buyAgainFlag, notOutStore, isActProduct, productType)
  37. VALUES (#{orderId},#{orderNo},#{shopOrderId},#{shopOrderNo},#{orderPromotionsId},#{productId},#{shopId},#{name},
  38. #{image},#{price},#{price},#{shopName},#{costPrice},#{normalPrice},#{ladderPriceFlag},#{discountPrice},#{discount},
  39. #{totalAmount},#{totalFee},#{shouldPayFee},#{productUnit},#{num},#{presentNum},#{discountFee},#{includedTax},
  40. #{invoiceType},#{taxRate},#{addedValueTax},#{totalAddedValueTax},#{singleShouldPayTotalTax},#{shouldPayTotalTax},
  41. #{shopProductAmount},#{singleShopFee},#{shopFee},#{singleOtherFee},#{otherFee},#{singleCmFee},#{cmFee},
  42. #{payStatus},#{buyAgainFlag},#{notOutStore},#{actProduct},#{productType})
  43. </insert>
  44. <insert id="insertOrderPromotions" keyColumn="id" keyProperty="id" parameterType="com.caimei365.order.model.vo.PromotionsVo" useGeneratedKeys="true">
  45. INSERT INTO cm_promotions_order (orderId, promotionsId, name, description, type, mode, touchPrice, reducedPrice, status, beginTime, endTime)
  46. VALUES (#{orderId},#{id},#{name},#{description},#{type},#{mode},#{touchPrice},#{reducedPrice},#{status},#{beginTime},#{endTime})
  47. </insert>
  48. <insert id="insertLadderPrices" keyColumn="id" keyProperty="id" parameterType="com.caimei365.order.model.vo.LadderPriceVo" useGeneratedKeys="true">
  49. INSERT INTO order_product_ladder_price (orderProductId, ladderNum, buyNum, buyPrice, createDate)
  50. VALUES (#{orderProductId},#{ladderNum},#{buyNum},#{buyPrice},#{createDate})
  51. </insert>
  52. <update id="updateShopOrderIds">
  53. UPDATE cm_order SET shopOrderIDs = #{shopOrderIds}
  54. WHERE orderID = #{orderId}
  55. </update>
  56. <insert id="insertOrderInvoice" parameterType="com.caimei365.order.model.po.InvoicePo">
  57. INSERT INTO bp_order_invoice (orderId, invoiceTitle, type, invoiceContent, invoiceTitleType, corporationTaxNum, registeredAddress, registeredPhone, bankAccountNo, openBank)
  58. VALUES (#{orderId}, #{invoiceTitle}, #{type},#{invoiceContent},#{invoiceTitleType},#{corporationTaxNum}, #{registeredAddress}, #{registeredPhone}, #{bankAccountNo}, #{openBank})
  59. </insert>
  60. <insert id="insertOrderUserInfo" parameterType="com.caimei365.order.model.po.OrderUserInfoPo">
  61. INSERT INTO bp_order_userinfo (orderId, clubId, userId, name, shouHuoRen, mobile,
  62. townId, province, city, town, address)
  63. VALUES (#{orderId}, #{clubId}, #{userId}, #{name}, #{receiver}, #{mobile},
  64. #{townId}, #{province}, #{city}, #{town}, #{address})
  65. </insert>
  66. <insert id="insertCouponOrderRecord" parameterType="com.caimei365.order.model.po.CouponOrderRecordPo">
  67. INSERT INTO cm_coupon_order_record (orderId, clubCouponId, couponType, couponAmount, touchPrice, createDate)
  68. VALUES (#{orderId}, #{clubCouponId}, #{couponType}, #{couponAmount}, #{touchPrice}, #{createDate})
  69. </insert>
  70. <update id="updateUserMoney">
  71. UPDATE USER SET userMoney = #{userMoney}, ableUserMoney = #{ableUserMoney}
  72. WHERE userID = #{userId}
  73. </update>
  74. <update id="updateOrderInvoice">
  75. UPDATE bp_order_invoice SET orderId=#{orderId},
  76. <set>
  77. <if test="invoiceTitle != null">
  78. invoiceTitle = #{invoiceTitle},
  79. </if>
  80. <if test="type != null">
  81. type = #{type,jdbcType=CHAR},
  82. </if>
  83. <if test="invoiceContent != null">
  84. invoiceContent = #{invoiceContent},
  85. </if>
  86. <if test="invoiceTitleType != null">
  87. invoiceTitleType = #{invoiceTitleType},
  88. </if>
  89. <if test="corporationTaxNum != null">
  90. corporationTaxNum = #{corporationTaxNum},
  91. </if>
  92. <if test="registeredAddress != null">
  93. registeredAddress = #{registeredAddress},
  94. </if>
  95. <if test="registeredPhone != null">
  96. registeredPhone = #{registeredPhone},
  97. </if>
  98. <if test="bankAccountNo != null">
  99. bankAccountNo = #{bankAccountNo},
  100. </if>
  101. <if test="openBank != null">
  102. openBank = #{openBank},
  103. </if>
  104. </set>
  105. WHERE id = #{id}
  106. </update>
  107. <select id="getOrderInvoice" resultType="com.caimei365.order.model.po.InvoicePo">
  108. SELECT id, orderId, invoiceTitle, corporationTaxNum, registeredAddress, registeredPhone, bankAccountNo, openBank
  109. FROM bp_order_invoice WHERE orderId = #{orderId}
  110. </select>
  111. <select id="getOperationIdByUnionId" resultType="java.lang.Integer">
  112. SELECT `id` FROM cm_mall_operation_user
  113. WHERE unionId = #{unionId} AND userID = #{userId} AND delFlag = '0'
  114. </select>
  115. <select id="getServiceProviderUserId" resultType="java.lang.Integer">
  116. SELECT userID FROM serviceprovider WHERE serviceProviderID = #{serviceProviderId}
  117. </select>
  118. <select id="getOrderUserBoById" resultType="com.caimei365.order.model.bo.OrderParamBo">
  119. SELECT
  120. userID AS userId,
  121. clubID AS clubId,
  122. userName,
  123. bindMobile,
  124. userMoney,
  125. ableUserMoney,
  126. userBeans
  127. FROM user
  128. WHERE userID = #{userId}
  129. </select>
  130. <select id="getProductDetails" resultType="com.caimei365.order.model.po.OrderProductPo">
  131. SELECT
  132. p.productID AS productId,
  133. p.shopID AS shopId,
  134. p.`name` AS `name`,
  135. p.mainImage AS image,
  136. p.price1 AS price,
  137. p.costPrice,
  138. p.costCheckFlag,
  139. p.costProportional,
  140. p.productCategory,
  141. p.ladderPriceFlag,
  142. p.includedTax,
  143. p.invoiceType,
  144. p.taxPoint AS taxRate,
  145. p.unit AS productUnit,
  146. p.normalPrice,
  147. p.supplierTaxPoint AS shopTaxRate
  148. FROM product p
  149. WHERE p.productId = #{productId}
  150. </select>
  151. <select id="getClauseNameById" resultType="java.lang.String">
  152. SELECT `name` FROM bp_clause WHERE id = #{clauseId}
  153. </select>
  154. <select id="getAddressDetailById" resultType="com.caimei365.order.model.vo.AddressVo">
  155. SELECT
  156. a.addressID AS addressId,
  157. a.userID AS userId,
  158. a.shouHuoRen AS receiver,
  159. a.townID AS townId,
  160. a.address,
  161. a.mobile,
  162. a.defaultFlag,
  163. t.name AS town,
  164. c.name AS city,
  165. c.cityID AS cityId,
  166. p.name AS province,
  167. p.provinceID AS provinceId
  168. FROM address a
  169. LEFT JOIN town t ON t.townID = a.townID
  170. LEFT JOIN city c ON c.cityID = t.cityID
  171. LEFT JOIN province p ON p.provinceID = c.provinceID
  172. WHERE a.addressID = #{addressId}
  173. LIMIT 1
  174. </select>
  175. </mapper>