NewOrderProductMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.caimei.modules.order.dao.NewOrderProductDao">
  6. <sql id="orderProductColumns">
  7. a.`orderProductID` AS `orderProductID`,
  8. a.`orderNo` AS `orderNo`,
  9. a.`orderID` AS `orderID`,
  10. a.`shopOrderID` AS `shopOrderID`,
  11. a.`shopOrderNo` AS `shopOrderNo`,
  12. a.`shopID` AS `shopID`,
  13. a.`productID` AS `productID`,
  14. a.`num` AS `num`,
  15. a.`presentNum` AS `presentNum`,
  16. a.`outStoreType` AS `outStoreType`,
  17. a.`skuID` AS `skuID`,
  18. a.`props` AS `props`,
  19. a.`propName` AS `propName`,
  20. a.`productNo` AS `productNo`,
  21. a.`price` AS `price`,
  22. a.`normalPrice` AS `normalPrice`,
  23. a.`price0` AS `price0`,
  24. a.`price1` AS `price1`,
  25. a.`totalAmount` AS `totalAmount`,
  26. a.`totalFee` AS `totalFee`,
  27. a.`shouldPayFee` AS `shouldPayFee`,
  28. a.`discount` AS `discount`,
  29. a.`discountPrice` AS `discountPrice`,
  30. a.`taxRate` AS `taxRate`,
  31. a.`addedValueTax` AS `addedValueTax`,
  32. a.`totalAddedValueTax` AS `totalAddedValueTax`,
  33. IFNULL(a.`shouldPayTotalTax` ,0) AS `shouldPayTotalTax`,
  34. a.`shopFee` AS `shopFee`,
  35. a.`otherFee` AS `otherFee`,
  36. a.`cmFee` AS `cmFee`,
  37. a.`singleShopFee` AS `singleShopFee`,
  38. a.`singleOtherFee` AS `singleOtherFee`,
  39. a.`singleCmFee` AS `singleCmFee`,
  40. a.`status` AS `status`,
  41. a.`commentFlag` AS `commentFlag`,
  42. a.`totalBeans` AS `totalBeans`,
  43. a.`useBalanceAmount` AS `useBalanceAmount`,
  44. a.`useBeanAmount` AS `useBeanAmount`,
  45. a.`notOutStore` AS `notOutStore`,
  46. a.`cmbeanPrice` AS `cmbeanPrice`,
  47. a.`isActProduct` AS `isActProduct`,
  48. a.`isGiftProduct` AS `isGiftProduct`,
  49. a.`productActInfo` AS `productActInfo`,
  50. a.`buyAgainFlag` AS `buyAgainFlag`,
  51. a.`confirmProductFlag` AS `confirmProductFlag`,
  52. a.`payStatus` AS `payStatus`,
  53. a.`name` AS `name`,
  54. p.`unit` AS `unit`,
  55. a.`actType` AS `actType`,
  56. a.`actPreferential` AS `actPreferential`,
  57. a.`preferential` AS `preferential`,
  58. (select mainImage from product p where p.productID = a.productID) AS image,
  59. a.`discountFee` AS `discountFee`,
  60. (select cso.status from cm_shop_order cso where cso.shopOrderID = a.shopOrderID) AS status,
  61. a.`productUnit` AS `productUnit`,
  62. a.`productImage` AS `productImage`,
  63. a.`shopName` AS `shopName`,
  64. p.costProportional AS costProportional,
  65. p.stock AS stock,
  66. p.costCheckFlag AS costCheckFlag,
  67. p.costPrice AS costPrice,
  68. a.costPrice as newCostPrice,
  69. p.aliasName AS aliasName,
  70. a.singleShouldPayTotalTax AS singleShouldPayTotalTax
  71. </sql>
  72. <sql id="orderProductJoins">
  73. LEFT JOIN product p ON p.productID = a.productID
  74. </sql>
  75. <select id="get" resultType="com.caimei.modules.order.entity.NewOrderProduct">
  76. SELECT
  77. <include refid="orderProductColumns"/>
  78. FROM cm_order_product a
  79. <include refid="orderProductJoins"/>
  80. WHERE a.orderProductID = #{orderProductID}
  81. </select>
  82. <select id="findListByShopOrderID" resultType="com.caimei.modules.order.entity.NewOrderProduct">
  83. SELECT
  84. <include refid="orderProductColumns"/>
  85. FROM cm_order_product a
  86. <include refid="orderProductJoins"/>
  87. WHERE a.shopOrderID = #{shopOrderID}
  88. </select>
  89. <select id="getReturningNum" resultType="Integer">
  90. SELECT
  91. IFNULL(sum(a.actualReturnedNum+a.actualCancelNum),0)
  92. FROM cm_returned_purchase_product a
  93. right join cm_returned_purchase b on a.returnedID = b.id
  94. WHERE a.orderProductID = #{orderProductID}
  95. and b.status = 1
  96. and b.delFlag = 0
  97. </select>
  98. <select id="getReturnedNum" resultType="Integer">
  99. SELECT
  100. IFNULL(sum(a.actualReturnedNum+a.actualCancelNum),0)
  101. FROM cm_returned_purchase_product a
  102. right join cm_returned_purchase b on a.returnedID = b.id
  103. WHERE a.orderProductID = #{orderProductID}
  104. and b.status = 2
  105. and b.delFlag = 0
  106. </select>
  107. <select id="getReceivedNum" resultType="Integer">
  108. SELECT
  109. IFNULL(sum(a.num),0)
  110. FROM cm_logistics_record a
  111. right join cm_logistics_batch b on a.logisticsBatchID = b.id
  112. WHERE a.orderProductID = #{orderProductID}
  113. and b.status = 1
  114. </select>
  115. </mapper>