YhShopMapper.xml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.cyksj.mapper.shop.YhShopMapper">
  4. <select id="selectSoldMaxGoods" resultType="java.lang.String">
  5. select title
  6. from goods_don
  7. where id = (select od.goods_id
  8. from (select id from yh_shop where user_id = #{userId} limit 1) s
  9. inner join order_don od
  10. on od.yhs_id = s.id and od.status not in ('close', 'noPayment', 'refund')
  11. group by od.goods_id
  12. order by max(od.money) desc limit 1)
  13. </select>
  14. <select id="getApplyDetailByUserId" resultType="com.cyksj.model.views.YhShopDistributeView">
  15. select ifnull(sum(da.money), 0) as gotMoney, u.yhs_money as availableMoney
  16. from (select id, yhs_money from user where id = #{userId} limit 1) u
  17. left join yh_shop_distribute_money_apply da on da.user_id = u.id and verify_status = 'success'
  18. group by u.id, u.yhs_money
  19. </select>
  20. <select id="selectYhShopDetail" resultType="java.util.Map">
  21. select count(distinct ys.user_id) as numOfYhShop,
  22. count(distinct us.user_id) as numOfRegisterYhShopUser
  23. from (select user_id from `yh_shop` ys where
  24. verify_status = 'success'
  25. <if test="startDate != null">
  26. and created_time >= #{startDate}
  27. </if>
  28. <if test="endDate != null">
  29. and created_time &lt; #{endDate}
  30. </if>) ys left join yh_shop_user_distribute_shared us on us.shop_user_id = ys.user_id
  31. </select>
  32. <select id="selectYhShopTakeMoney" resultType="java.math.BigDecimal">
  33. select ifnull(sum(money),0) from `yh_shop_distribute_waiting_send_points` where send_status in
  34. ('waiting','success')
  35. <if test="startDate != null">
  36. and created_time >= #{startDate}
  37. </if>
  38. <if test="endDate != null">
  39. and created_time &lt; #{endDate}
  40. </if>
  41. </select>
  42. <select id="selectYhShopApplyMoney" resultType="java.util.Map">
  43. select ifnull(sum(if(verify_status = 'success',money,0)),0)s,
  44. ifnull(sum(if(verify_status = 'verifying',money,0)),0)vf
  45. from yh_shop_distribute_money_apply where verify_status in ('verifying','success')
  46. <if test="startDate != null">
  47. and created_time >= #{startDate}
  48. </if>
  49. <if test="endDate != null">
  50. and created_time &lt; #{endDate}
  51. </if>
  52. </select>
  53. <select id="selectRelationBusiness" resultType="com.cyksj.model.entity.YhShopDistributeMoneyApply">
  54. select ys.business_id, cu.nickname as businessName
  55. from (select * from yh_shop where user_id = #{userId} limit 1) ys
  56. left join cms_user cu on cu.id = ys.business_id
  57. </select>
  58. <select id="getYhShopSkuSysStatusDownInfo" resultType="com.cyksj.model.dto.YhShopSkuDownInfo">
  59. select any_value(g.title) as title, group_concat(distinct sku.spec_val SEPARATOR '') as specVal
  60. from (select goods_id, sku_id
  61. from yh_shop_sku_sys_take_down_record
  62. where user_id = #{userId}
  63. and deleted is true) s
  64. inner join goods_don_sku sku on sku.id = s.sku_id
  65. inner join goods_don g on g.id = s.goods_id
  66. group by g.id
  67. </select>
  68. </mapper>