Browse Source

供应商列表不再排除自己企业

dongbw 7 years ago
parent
commit
7408e5b7be

+ 18 - 31
src/main/java/com/uas/platform/b2c/trade/vendor/service/impl/VendorIntroductionServiceImpl.java

@@ -5,7 +5,6 @@ import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.common.base.dao.CommonDao;
 import com.uas.platform.b2c.common.search.rpc.service.SearchService;
 import com.uas.platform.b2c.common.search.util.SPage;
-import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.prod.commodity.dao.V_ProductPrivateDao;
 import com.uas.platform.b2c.prod.commodity.model.V_ProductPrivate;
 import com.uas.platform.b2c.prod.store.dao.StoreInDao;
@@ -94,10 +93,6 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
                 enterpriseCondition = "(en_name like '%" + keyword + "%' or en_address like '%" + keyword + "%' or en_industry like '% "
                         + keyword + "%')";
             }
-        }
-        Long enUU = 0L;
-        if (null != SystemSession.getUser() && null != SystemSession.getUser().getEnterprise()) {
-            enUU = SystemSession.getUser().getEnterprise().getUu();
         }
 		// 查询所有企业个数
 		Integer total;
@@ -106,11 +101,11 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 		if (!StringUtils.isEmpty(productCondition)) {
 			enterpriseCondition = "(en_name like '%" + keyword + "%' or en_address like '%" + keyword + "%' or en_industry like '% "
 					+ keyword + "%')";
-			total = getTotalCount(enUU, enterpriseCondition, productCondition);
-			vendorIntroductions = getEnterpriseWithProductCondition(enUU, enterpriseCondition, productCondition,  page, size);
+			total = getTotalCount(enterpriseCondition, productCondition);
+			vendorIntroductions = getEnterpriseWithProductCondition(enterpriseCondition, productCondition,  page, size);
 		} else {
-			total = getTotalCount(enUU, enterpriseCondition, productCondition);
-			vendorIntroductions = getEnterpriseWithoutProductCondition(enUU, enterpriseCondition,  page, size);
+			total = getTotalCount(enterpriseCondition, productCondition);
+			vendorIntroductions = getEnterpriseWithoutProductCondition( enterpriseCondition,  page, size);
 		}
 		return new Page<VendorIntroduction>(page, size, vendorIntroductions, total);
 	}
@@ -181,27 +176,22 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 	 */
 	@Override
 	public Integer getVendorCount() {
-		Long enUU = 0L;
-		if (null != SystemSession.getUser() && null != SystemSession.getUser().getEnterprise()) {
-			enUU = SystemSession.getUser().getEnterprise().getUu();
-		}
-		return getTotalCount(enUU, null, null);
+		return getTotalCount(null, null);
 	}
 
 	/**
 	 * 获取供应商资源信息
-	 * @param enUU 本企业UU
 	 * @param enterpriseCondition 企业搜索条件
 	 * @param productCondition 物料搜索条件
 	 * @param page 页码
 	 * @param size 尺寸
 	 * @return
 	 */
-	private List<VendorIntroduction> getEnterpriseWithProductCondition(Long enUU, String enterpriseCondition, String productCondition, int page, int size) {
+	private List<VendorIntroduction> getEnterpriseWithProductCondition(String enterpriseCondition, String productCondition, int page, int size) {
 		StringBuilder enterpriseSql = new StringBuilder();
 		// 查询所有符合条件的enUU的语句,按待售物料数量排序
-		String enUUSql = getEnUUGroupByEnUUOrderByCount(enUU, " 1 = 1 ", productCondition);
-		String noProductenUUSql = getEnUUGroupByEnUUOrderByCount(enUU, enterpriseCondition, null);
+		String enUUSql = getEnUUGroupByEnUUOrderByCount(" 1 = 1 ", productCondition);
+		String noProductenUUSql = getEnUUGroupByEnUUOrderByCount(enterpriseCondition, null);
 		// 获取企业sql
 		enterpriseSql.append("select en.en_uu enUU, en.en_name enName, en.en_shortname enShortname, st.st_logo_url storeLogoUrl, en.en_logurl enLogoUrl, en.en_address enAddress, en.en_tel enTel, " +
 				" en.en_email enEmail, en.en_corporation enCorporation, en.en_businesscode enBusinesscode, en.en_industry enIndustry, en.en_Businessscope enBusinessScope " +
@@ -219,21 +209,20 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 
 	/**
 	 * 获取供应商资源信息
-	 * @param enUU 本企业UU
 	 * @param enterpriseCondition 企业搜索条件
 	 * @param page 页码
 	 * @param size 尺寸
 	 * @return
 	 */
-	private List<VendorIntroduction> getEnterpriseWithoutProductCondition(Long enUU, String enterpriseCondition, int page, int size) {
+	private List<VendorIntroduction> getEnterpriseWithoutProductCondition(String enterpriseCondition, int page, int size) {
 		StringBuilder enterpriseSql = new StringBuilder();
 		// 获取企业sql
 		enterpriseSql.append("select en.en_uu enUU, en.en_name enName, en.en_shortname enShortname, st.st_logo_url storeLogoUrl, en.en_logurl enLogoUrl, en.en_address enAddress, en.en_tel enTel, " +
 				"en.en_email enEmail, en.en_corporation enCorporation, en.en_businesscode enBusinesscode, en.en_industry enIndustry, en.en_Businessscope enBusinessScope " +
 				",st.st_enuu,st.st_status from sec$enterprises en left join store$info st on st.st_enuu = en.en_uu where en_name not like '%测试%' and en_name not like '%test%' " +
 				"and (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' or en_area like '%香港%') and " +
-				" (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]')) and en_uu <> ")
-				.append(enUU).append(" and ").append(enterpriseCondition);
+				" (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]'))")
+				.append(" and ").append(enterpriseCondition);
 		// rownum 控制
 		String rownumSql = ") s order by isStore desc,enUU asc limit " + (page - 1) * size + "," + size ;
 		// 查询企业是否开店语句
@@ -244,25 +233,24 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 
 	/**
 	 * 获取所有符合条件企业数量
-	 * @param enUU  本企业UU
 	 * @param enterpriseCondition 企业过滤条件
 	 * @param productCondition 物料过滤条件
 	 * @return
 	 */
-	private Integer getTotalCount(Long enUU, String enterpriseCondition, String productCondition) {
+	private Integer getTotalCount(String enterpriseCondition, String productCondition) {
 		StringBuilder enCountSql = new StringBuilder();
 		enCountSql.append("select count(1) from (select distinct(en_uu) from (select en_uu from sec$enterprises where en_name not like '%测试%' " +
 				" and en_name not like '%test%' and (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' " +
 				" or en_area like '%香港%')and (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or " +
-				" en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]') ) and ");
+				" en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]') )");
 		if (StringUtils.isEmpty(productCondition) && !StringUtils.isEmpty(enterpriseCondition)) {
-			enCountSql.append(enterpriseCondition).append(" and ");
+			enCountSql.append(" and ").append(enterpriseCondition);
 		}
-		enCountSql.append(" en_uu <> ").append(enUU).append(") e ");
+		enCountSql.append(") e ");
 		if (!StringUtils.isEmpty(productCondition)) {
 			enCountSql.append("right join ( select pr_enuu from products where ").append(productCondition).append(") p on pr_enuu = en_uu");
 			enCountSql.append(" union select en_uu from sec$enterprises where en_name not like '%测试%'  and en_name not like '%test%' and (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%'  or en_area like '%香港%')and (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or  en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]') and ")
-					.append(enterpriseCondition).append(" and en_uu <> ").append(enUU).append(")");
+					.append(enterpriseCondition).append(")");
 		}
 		enCountSql.append(")a");
 		return commonDao.queryForObject(enCountSql.toString(), Integer.class);
@@ -270,18 +258,17 @@ public class VendorIntroductionServiceImpl implements VendorIntroductionService
 
 	/**
 	 * 拼接所有待售物料所属企业UU,按enUU分组,按物料数量倒序
-	 * @param enUU 当前企业UU
 	 * @param enterpriseCondition 企业过滤条件
 	 * @param productCondition 物料匹配条件
 	 * @return
 	 */
-	private String getEnUUGroupByEnUUOrderByCount(Long enUU, String enterpriseCondition, String productCondition) {
+	private String getEnUUGroupByEnUUOrderByCount(String enterpriseCondition, String productCondition) {
 		StringBuilder enUUSql = new StringBuilder();
 		// 含名称、企业执照号、地址、邮箱、电话、行业、经营范围搜索
 		enUUSql.append("select distinct(en_uu) from (select en_uu from sec$enterprises where en_name not like '%测试%' " +
 				" and en_name not like '%test%' and (length(en_businesscode) > 12 or en_name like '%香港%' or en_name like '%HONG KONG%' " +
 				" or en_area like '%香港%')and (en_name not REGEXP '^[0-9]*$' and (en_name like '%ltd%' or en_name like '%limited%' or " +
-				" en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]')) and ").append(enterpriseCondition).append(" and en_uu <> ").append(enUU)
+				" en_name like '%tcl%' or en_name not regexp '[\\u4e00-\\u9fa5_a-zA-Z0-9]')) and ").append(enterpriseCondition)
 				.append(") e");
 		if (!StringUtils.isEmpty(productCondition)) {
 			enUUSql.append(" inner join ( select pr_enuu from products where ").append(productCondition).append(") p on pr_enuu = en_uu ");