OrderItemMapper.xml 5.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.yami.shop.dao.OrderItemMapper">
  4. <resultMap id="BaseResultMap" type="com.yami.shop.bean.model.OrderItem">
  5. <!--
  6. WARNING - @mbg.generated
  7. -->
  8. <id column="order_item_id" jdbcType="BIGINT" property="orderItemId"/>
  9. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  10. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  11. <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
  12. <result column="sku_id" jdbcType="BIGINT" property="skuId"/>
  13. <result column="prod_count" jdbcType="INTEGER" property="prodCount"/>
  14. <result column="gain_score" jdbcType="INTEGER" property="gainScore"/>
  15. <result column="use_score" jdbcType="INTEGER" property="useScore"/>
  16. <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
  17. <result column="pic" jdbcType="VARCHAR" property="pic"/>
  18. <result column="price" jdbcType="DECIMAL" property="price"/>
  19. <result column="user_id" jdbcType="VARCHAR" property="userId"/>
  20. <result column="product_total_amount" jdbcType="DECIMAL" property="productTotalAmount"/>
  21. <result column="subsidy_amount" jdbcType="DECIMAL" property="subsidyAmount"/>
  22. <result column="rec_time" jdbcType="TIMESTAMP" property="recTime"/>
  23. <result column="comm_sts" jdbcType="INTEGER" property="commSts"/>
  24. <result column="actual_total" jdbcType="DECIMAL" property="actualTotal"/>
  25. <result column="basket_date" property="basketDate"/>
  26. <result column="distribution_card_no" property="distributionCardNo"/>
  27. <result column="share_reduce" jdbcType="DECIMAL" property="shareReduce"/>
  28. <result column="dvy_type" jdbcType="INTEGER" property="dvyType"/>
  29. </resultMap>
  30. <select id="listByOrderNumber" resultType="com.yami.shop.bean.model.OrderItem">
  31. select sku.spec,toi.*, tor.return_money_sts, tor.refund_sn from tz_order_item toi
  32. left JOIN tz_order_refund tor ON tor.`order_item_id` = toi.`order_item_id` AND tor.`return_money_sts` not in (6,7, -1)
  33. LEFT JOIN tz_sku sku on toi.sku_id=sku.sku_id
  34. where toi.order_number = #{orderNumber}
  35. </select>
  36. <update id="updateByDeliveries">
  37. <foreach collection="orderItems" item="orderItem" separator=";">
  38. UPDATE tz_order_item oi set status=#{orderItem.prodCount} - #{orderItem.changeNum}, dvy_type = #{orderItem.dvyType} WHERE order_item_id = #{orderItem.orderItemId}
  39. </foreach>
  40. </update>
  41. <select id="getListByOrderNumber" resultType="com.yami.shop.bean.model.OrderItem">
  42. SELECT r.return_money_sts,sku.spec,oi.* FROM tz_order_item oi
  43. JOIN tz_order o ON o.order_number = oi.order_number AND o.order_number = #{orderNumber}
  44. LEFT JOIN tz_order_refund r ON r.order_item_id = oi.order_item_id
  45. LEFT JOIN tz_sku sku on oi.sku_id=sku.sku_id
  46. WHERE r.return_money_sts != 5 OR r.return_money_sts IS NULL
  47. </select>
  48. <select id="getRefundTypeByOrderItem2" resultType="com.yami.shop.bean.model.OrderItem">
  49. SELECT a.product_count,b.*,(a.product_count * b.price) goods_total FROM tz_order_refund_sku a
  50. LEFT JOIN tz_order_item b on a.order_item_id=b.order_item_id
  51. where a.order_refund_id=#{refundId}
  52. </select>
  53. <!--<select id="listByOrderNumber" resultType="com.yami.shop.bean.model.OrderItem">-->
  54. <!--SELECT toi.*, tor.return_money_sts, tor.refund_sn-->
  55. <!--FROM tz_order_item toi-->
  56. <!--LEFT JOIN tz_order_refund tor ON tor.`order_item_id` = toi.`order_item_id` AND tor.return_money_sts NOT IN (6,7, -1)-->
  57. <!--WHERE tor.order_item_id <![CDATA[ <> ]]> 0 AND toi.order_number = #{orderNumber}-->
  58. <!--UNION-->
  59. <!--SELECT toi.*, tor.return_money_sts, tor.refund_sn FROM tz_order_item toi ,tz_order_refund tor, tz_order tzor-->
  60. <!--WHERE tor.order_item_id = 0 AND tor.order_id = tzor.order_id AND tzor.`order_number`=toi.`order_number` AND tor.return_money_sts NOT IN (6,7, -1)-->
  61. <!--AND toi.`order_number` = #{orderNumber}-->
  62. <!--</select>-->
  63. <select id="refundIngCount" resultType="integer">
  64. SELECT IFNULL(SUM(product_count), 0) c
  65. FROM `tz_order_refund_sku` a
  66. LEFT JOIN tz_order_refund b on a.order_refund_id = b.refund_id
  67. WHERE a.order_item_id = #{orderItemId}
  68. and b.return_money_sts not in(30,40,70);
  69. </select>
  70. <select id="refundSuccessCount" resultType="integer">
  71. SELECT IFNULL(SUM(product_count), 0) c
  72. FROM `tz_order_refund_sku` a
  73. LEFT JOIN tz_order_refund b on a.order_refund_id = b.refund_id
  74. WHERE a.order_item_id = #{orderItemId}
  75. and b.return_money_sts =70;
  76. </select>
  77. <select id="refundCount" resultType="integer">
  78. SELECT IFNULL(SUM(product_count), 0) c
  79. FROM `tz_order_refund_sku` a
  80. LEFT JOIN tz_order_refund b on a.order_refund_id = b.refund_id
  81. WHERE a.order_item_id = #{orderItemId}
  82. and b.return_money_sts !=40
  83. </select>
  84. </mapper>