81b96e90aaa893fadcf06265f08697a84723b15d.svn-base 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package com.chinacreator.process.dao;
  2. import com.chinacreator.process.bean.OrderBean;
  3. import com.chinacreator.process.bean.VipBlackBean;
  4. import com.chinacreator.process.util.DataSource;
  5. import com.frameworkset.common.poolman.SQLExecutor;
  6. import org.apache.commons.lang.math.NumberUtils;
  7. import org.springframework.stereotype.Component;
  8. import java.sql.SQLException;
  9. import java.util.List;
  10. @Component
  11. public class BlackDao {
  12. public String getActiveType(VipBlackBean bean) throws SQLException {
  13. String sql = "select ACTIVETYPE from TB_ACTIVITY_CONFIG where cpid=#[cpid] and spid= #[spid] and province in (#[province],'0') and ROWNUM=1";
  14. return SQLExecutor.queryFieldBeanWithDBName(DataSource.NET3G, sql,bean);
  15. }
  16. /**
  17. * 统计十小时内各省份会员三户
  18. */
  19. public List<VipBlackBean> getAllOrderCount(String cpid,String spid) throws SQLException {
  20. String sql = "select DISTINCT province,count(*) count,cpid,spid from net3g.TD_ORDER_RELATIONS where cpid=? and spid=? and ORDERTIME BETWEEN (sysdate -interval '10' hour ) and sysdate group by PROVINCE,cpid,spid having count(*) >=50";
  21. return SQLExecutor.queryList( VipBlackBean.class, sql,cpid,spid);
  22. }
  23. /**
  24. * 根据产品统计十小时内省份套餐订购记录
  25. */
  26. public VipBlackBean getOrderCountBy(String cpid,String spid,String province) throws SQLException {
  27. String sql = "SELECT A.PROVINCE province,B.PACAKGE limit,count(1) count,A.spid,A.cpid FROM NET3G.TD_ORDER_RELATIONS A LEFT JOIN NET3G.TB_ECB_LOG_TEMP B " +
  28. "ON A.USERID=B.USERID AND A.SPID=B.SPID AND B.RESULTCODE='0' AND TO_CHAR(A.ORDERTIME,'YYYY-MM')=TO_CHAR(B.INSERTTIME,'YYYY-MM') " +
  29. "WHERE A.CPID=? and A.SPID=? and PROVINCE=? and FILEPATH is not null AND A.ORDERTIME BETWEEN (sysdate -interval '10' hour ) and sysdate and PACAKGE is not null " +
  30. "group by A.PROVINCE, B.PACAKGE,A.spid,A.cpid order by count desc";
  31. List<VipBlackBean> beans=SQLExecutor.queryList(VipBlackBean.class, sql,cpid,spid,province);
  32. if(beans.size()>0){
  33. return beans.get(0);
  34. }else {
  35. return null;
  36. }
  37. }
  38. /**
  39. * 是否在订购黑名单
  40. * @param cpid
  41. * @param spid
  42. * @param province
  43. * @return
  44. * @throws SQLException
  45. */
  46. public boolean isOrderBlackUser(String cpid, String spid,String province,String limit) throws SQLException {
  47. String sql = "select count(*) from TB_ECB_CONFIG where status=0 and cpid=? and spid=? and province=? and limit like concat(concat('%',?),'%')";
  48. return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql, cpid, spid,province,limit), 0) > 0;
  49. }
  50. /**
  51. * 加入订购黑名单
  52. * @param bean
  53. * @throws SQLException
  54. */
  55. public void insertOrderBlack(VipBlackBean bean) throws SQLException{
  56. String sql = "merge into TB_ECB_CONFIG a using (select #[cpid] cpid, #[spid] spid, #[province] province from dual) b " +
  57. "on(a.cpid=b.cpid and a.spid=b.spid and a.province=b.province) " +
  58. "when matched then update set LIMIT=concat(concat(concat(LIMIT,'||*'),#[limit]),'*') " +
  59. "when not matched then insert(CPID, SPID, INSERTTIME, STATUS, PROVINCE, LIMIT, AREA) " +
  60. " VALUES (#[cpid], #[spid], sysdate, '0', #[province], concat(concat('*',#[limit]),'*'), '0') ";
  61. SQLExecutor.insertBean(DataSource.NET3G, sql, bean);
  62. }
  63. /**
  64. * 是否在领取黑名单
  65. * @param cpid
  66. * @param spid
  67. * @param province
  68. * @return
  69. * @throws SQLException
  70. */
  71. public boolean isVipBlackUser(String cpid, String spid,String province,String limit) throws SQLException {
  72. String sql = "select count(*) from TB_JOINECB_CONFIG where status=0 and cpid=? and spid=? and province=? and limit like concat(concat('%',?),'%')";
  73. return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql, cpid, spid,province,limit), 0) > 0;
  74. }
  75. /**
  76. * 加入领取黑名单
  77. * @param bean
  78. * @throws SQLException
  79. */
  80. public void insertVipBlack(VipBlackBean bean) throws SQLException{
  81. String sql = "merge into TB_JOINECB_CONFIG a using (select #[cpid] cpid, #[spid] spid, #[province] province from dual) b " +
  82. "on(a.cpid=b.cpid and a.spid=b.spid and a.province=b.province) " +
  83. "when matched then update set LIMIT=concat(concat(concat(LIMIT,'||*'),#[limit]),'*')" +
  84. "when not matched then insert(CPID, SPID, INSERTTIME, STATUS, PROVINCE, LIMIT, AREA,ACTIVETYPE,BRANDLIMIT) " +
  85. " VALUES (#[cpid], #[spid], sysdate, '0', #[province], concat(concat('*',#[limit]),'*'), '0',#[activetype],NULL) ";
  86. SQLExecutor.insertBean(DataSource.NET3G, sql, bean);
  87. }
  88. /**
  89. * 是否在白名单
  90. * @param cpid
  91. * @param spid
  92. * @param province
  93. * @return
  94. * @throws SQLException
  95. */
  96. public boolean isOrderWhiteUser(String cpid, String spid,String province,String limit) throws SQLException {
  97. String sql = "select count(*) from TB_ECBWHITE_CONFIG where status=0 and cpid=? and spid=? and province in (?,'0') and limit like concat(concat('%',?),'%')";
  98. return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql, cpid, spid,province,limit), 0) > 0;
  99. }
  100. }