QwContactWayMapper.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. package com.fs.qw.mapper;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.fs.qw.domain.QwContactWay;
  4. import com.fs.qw.param.QwStatisticsParam;
  5. import com.fs.qw.vo.QwWayStatisticsListVO;
  6. import org.apache.ibatis.annotations.Param;
  7. import org.apache.ibatis.annotations.Select;
  8. import org.apache.ibatis.annotations.Update;
  9. import org.springframework.stereotype.Repository;
  10. import java.util.List;
  11. import java.util.Map;
  12. /**
  13. * 企微活码Mapper接口
  14. *
  15. * @author fs
  16. * @date 2024-07-05
  17. */
  18. @SuppressWarnings("ALL")
  19. @Repository
  20. public interface QwContactWayMapper
  21. {
  22. /**
  23. * 查询企微活码
  24. *
  25. * @param id 企微活码主键
  26. * @return 企微活码
  27. */
  28. public QwContactWay selectQwContactWayById(Long id);
  29. /**
  30. * 查询企微活码列表
  31. *
  32. * @param qwContactWay 企微活码
  33. * @return 企微活码集合
  34. */
  35. public List<QwContactWay> selectQwContactWayList(QwContactWay qwContactWay);
  36. /**
  37. * 新增企微活码
  38. *
  39. * @param qwContactWay 企微活码
  40. * @return 结果
  41. */
  42. public int insertQwContactWay(QwContactWay qwContactWay);
  43. /**
  44. * 修改企微活码
  45. *
  46. * @param qwContactWay 企微活码
  47. * @return 结果
  48. */
  49. public int updateQwContactWay(QwContactWay qwContactWay);
  50. /**
  51. * 删除企微活码
  52. *
  53. * @param id 企微活码主键
  54. * @return 结果
  55. */
  56. public int deleteQwContactWayById(Long id);
  57. /**
  58. * 批量删除企微活码
  59. *
  60. * @param ids 需要删除的数据主键集合
  61. * @return 结果
  62. */
  63. public int deleteQwContactWayByIds(Long[] ids);
  64. @Select("select * from qw_contact_way where config_id=#{configId} and corp_id=#{corpId} limit 1")
  65. QwContactWay selectQwContactWayByConfigIdAndCompanyId(@Param("configId") String configId,@Param("corpId") String corpId);
  66. @Select("select * from qw_contact_way where user_type=2")
  67. List<QwContactWay> selectQwContactWayByUserTime();
  68. @Select({"<script> " +
  69. "select u.nick_name,ROUND(AVG(DATEDIFF(o.create_time, cu.create_time))) AS customerCycle,count(1) customerOkNum from fs_store_order o left join crm_customer cu ON o.customer_id = cu.customer_id LEFT JOIN company_user u on u.user_id=o.company_user_id WHERE is_first=1 " +
  70. " " +
  71. "<if test = 'maps.type != null and maps.type ==1 '> " +
  72. "and TO_DAYS(cu.create_time) = TO_DAYS(NOW()) " +
  73. "</if>" +
  74. "<if test = 'maps.type != null and maps.type ==2 '> " +
  75. "and TO_DAYS(NOW()) - TO_DAYS(cu.create_time) &lt;= 1 " +
  76. "</if>" +
  77. "<if test = 'maps.type != null and maps.type ==3 '> " +
  78. "and YEARWEEK(DATE_FORMAT(cu.create_time,'%Y-%m-%d')) = YEARWEEK(NOW()) " +
  79. "</if>" +
  80. "<if test = 'maps.type != null and maps.type ==4 '> " +
  81. "and YEARWEEK(DATE_FORMAT(cu.create_time,'%Y-%m-%d')) = YEARWEEK(NOW())-1 " +
  82. "</if>" +
  83. "<if test = 'maps.type != null and maps.type ==5 '> " +
  84. "and DATE_FORMAT(cu.create_time,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m') " +
  85. "</if>" +
  86. "<if test = 'maps.type != null and maps.type ==6 '> " +
  87. "and PERIOD_DIFF(DATE_FORMAT(NOW(),'%Y%m'),DATE_FORMAT(cu.create_time,'%Y%m')) = 1 " +
  88. "</if>" +
  89. "<if test = 'maps.type != null and maps.type ==7 '> " +
  90. "and QUARTER(cu.create_time) = QUARTER(NOW()) " +
  91. "</if>" +
  92. "<if test = 'maps.type != null and maps.type ==8 '> " +
  93. "and QUARTER(cu.create_time) = QUARTER(DATE_SUB(NOW(),INTERVAL 1 QUARTER)) " +
  94. "</if>" +
  95. "<if test = 'maps.type != null and maps.type ==9 '> " +
  96. "and YEAR(cu.create_time)=YEAR(NOW()) " +
  97. "</if>" +
  98. "<if test = 'maps.type != null and maps.type ==10 '> " +
  99. "and YEAR(cu.create_time) = YEAR(DATE_SUB(NOW(),INTERVAL 1 YEAR))" +
  100. "</if>" +
  101. "<if test = 'maps.startTime != null and maps.startTime != \"\" '> " +
  102. "AND date_format(cu.create_time,'%y%m%d') &gt;= date_format(#{maps.startTime},'%y%m%d')"+
  103. "</if>" +
  104. "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
  105. "AND date_format(cu.create_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d')"+
  106. "</if>" +
  107. "and cu.create_user_id IN " +
  108. "<foreach item='item' index='index' collection='maps.users' open='(' separator=',' close=')'> #{item} </foreach>"+
  109. " group by o.company_user_id "+
  110. "</script>"})
  111. List<QwWayStatisticsListVO> QwWayStatisticsListVO(@Param("maps")QwStatisticsParam param);
  112. List<JSONObject> selectQwWayStatisticsCounts(Map<String, Object> map);
  113. @Update("UPDATE qw_contact_way SET add_num = add_num + 1,num=num + 1 where id=#{id};")
  114. void addContactWayNum(Long id);
  115. @Update("UPDATE qw_information SET add_num = add_num + 1,num=num + 1 where id=#{informationId};")
  116. void addInformationNum(Long informationId);
  117. }