AppMapper.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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.gree.mall.miniapp.commonmapper.AppMapper">
  4. <select id="findCommonFileById" resultType="com.gree.mall.miniapp.plus.entity.CommonFile">
  5. SELECT * FROM common_file
  6. WHERE
  7. id IN
  8. <foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
  9. #{item}
  10. </foreach>
  11. </select>
  12. <select id="queryShoppingCartList" resultType="com.gree.mall.miniapp.bean.order.ShoppingCartList">
  13. SELECT
  14. a.*,
  15. b.price,
  16. c.goods_name,
  17. b.spec_value,
  18. b.org_price,
  19. b.price * num AS 'totalPrice', e.img_url 'goodsImg',
  20. IFNULL(d.stock_qty, 0) AS stock_qty
  21. FROM shopping_cart a
  22. JOIN goods_spec b ON a.goods_spec_id = b.goods_spec_id
  23. JOIN goods c ON c.goods_id = a.goods_id
  24. LEFT JOIN goods_material_storage d ON b.goods_code = d.goods_material_id AND a.storage_id = d.storage_id
  25. LEFT JOIN goods_detail e on c.goods_id = e.goods_id
  26. WHERE a.user_id = #{userId}
  27. <if test="storageId != null and storageId != ''">
  28. AND a.storage_id = #{storageId}
  29. </if>
  30. </select>
  31. <select id="orderStatusCount" resultType="com.gree.mall.miniapp.bean.order.OrderStatusBean">
  32. select sum(if(order_status = 'NOPAY', 1, 0)) noPay,
  33. sum(if(order_status in ('YFH','DFH'), 1, 0)) yfh,
  34. sum(if(order_status = 'DFH', 1, 0)) dfh,
  35. sum(if(order_status in ('REFUND'), 1, 0)) sh,
  36. sum(if(order_status = 'OVER' and comment_goods=0, 1, 0)) ywc
  37. from order_info
  38. where user_id = #{userId}
  39. </select>
  40. <select id="queryNewGoods" resultType="com.gree.mall.miniapp.bean.goods.GoodsNewBean">
  41. select
  42. a.*,
  43. c.img_url
  44. <if test="objId != null and objId != ''">
  45. ,b.obj_id
  46. </if>
  47. from goods a
  48. LEFT JOIN goods_detail c ON a.goods_id = c.goods_id
  49. <if test="objId != null and objId != ''">
  50. join goods_news_category_goods b on a.goods_id = b.goods_id
  51. </if>
  52. where
  53. a.company_wechat_id = #{companyWechatId} and a.del=0 and a.status=1
  54. <if test="objId != null and objId != ''">
  55. and b.obj_id = #{objId}
  56. </if>
  57. <if test="type != null and type != ''">
  58. and b.type = #{type}
  59. </if>
  60. <if test="sort != null and sort==0">
  61. order by a.sort_num
  62. </if>
  63. <if test="sort != null and sort==1">
  64. order by a.sold_num desc
  65. </if>
  66. <if test="sort != null and sort==2">
  67. order by goods_price asc
  68. </if>
  69. <if test="sort != null and sort==3">
  70. order by goods_price desc
  71. </if>
  72. <if test="sort != null and sort==4">
  73. order by a.create_time desc
  74. </if>
  75. </select>
  76. <select id="findStorageByLocate" resultType="com.gree.mall.miniapp.bean.StorageBean">
  77. SELECT
  78. storage_id,
  79. company_wechat_id,
  80. company_name,
  81. storage_name,
  82. storage_address,
  83. storage_mobile,
  84. type,
  85. status,
  86. is_default,
  87. lng,
  88. lat,
  89. -- 使用哈弗辛公式计算球面距离(单位:公里)
  90. ROUND(6371 * 2 * ASIN(
  91. SQRT(
  92. POW(SIN((RADIANS(23.09) - RADIANS(CAST(lat AS DECIMAL(10,6)))) / 2), 2) +
  93. COS(RADIANS(23.09)) * COS(RADIANS(CAST(lat AS DECIMAL(10,6)))) *
  94. POW(SIN((RADIANS(113.32) - RADIANS(CAST(lng AS DECIMAL(10,6)))) / 2), 2)
  95. )
  96. ), 2) AS distance
  97. FROM storage
  98. WHERE del = 0
  99. AND status = 1
  100. AND lng IS NOT NULL
  101. AND lat IS NOT NULL
  102. AND lng != ''
  103. AND lat != ''
  104. <if test="companyWechatId != null and companyWechatId !=''">
  105. AND company_wechat_id = #{companyWechatId}
  106. </if>
  107. ORDER BY distance ASC
  108. </select>
  109. <select id="queryTrainingList" resultType="com.gree.mall.miniapp.bean.message.TrainingVO">
  110. SELECT
  111. a.id,
  112. a.company_wechat_id,
  113. a.company_name,
  114. b.name,
  115. b.remark,
  116. b.file_type,
  117. b.url
  118. FROM training a
  119. LEFT JOIN common_file b ON a.obj_id = b.id
  120. WHERE
  121. a.company_wechat_id IN ('0', CONCAT(#{companyWechatId}))
  122. AND a.del = 0
  123. ORDER BY a.create_time DESC
  124. </select>
  125. </mapper>