Browse Source

个人 物料bug修复4

wangdy 8 years ago
parent
commit
341942abdb

+ 4 - 4
src/main/java/com/uas/platform/b2c/common/account/controller/EnterpriseController.java

@@ -214,13 +214,13 @@ public class EnterpriseController {
 			if (!CollectionUtils.isEmpty(applyUserSpacePage.getContent())) {
 				List<ApplyUserSpace> applyUserSpaceList = applyUserSpacePage.getContent();
 				for (ApplyUserSpace applyUserSpace : applyUserSpaceList) {
-					Enterprise e = enterpriseService.findByEnBussinessCode(applyUserSpace.getBusinessCode());
+					List<Enterprise> e = enterpriseService.findByEnBussinessCode(applyUserSpace.getBusinessCode());
 					User admin = null;
-					if (null != e && null != e.getEnAdminuu()) {
-						admin = userService.findUserByUserUU(e.getEnAdminuu());
+					if (!CollectionUtils.isEmpty(e) && e.get(0).getEnAdminuu() != null) {
+						admin = userService.findUserByUserUU(e.get(0).getEnAdminuu());
 					}
 					Map<String,Object> map = new HashMap<>();
-					map.put("enName", e.getEnName());
+					map.put("enName", CollectionUtils.isEmpty(e) ? "" : e.get(0).getEnName());
 					map.put("date",applyUserSpace.getSubmitDate());
 					map.put("adminName",admin == null ? null : admin.getUserName());
 					map.put("status",applyUserSpace.getStatus());

+ 1 - 1
src/main/java/com/uas/platform/b2c/common/account/dao/EnterpriseDao.java

@@ -25,5 +25,5 @@ public interface EnterpriseDao extends JpaSpecificationExecutor<Enterprise>, Jpa
 	 * @param bussinessCode
 	 * @return
 	 */
-	public Enterprise findByEnBussinessCode(String bussinessCode);
+	public List<Enterprise> findByEnBussinessCode(String bussinessCode);
 }

+ 1 - 1
src/main/java/com/uas/platform/b2c/common/account/service/EnterpriseService.java

@@ -44,7 +44,7 @@ public interface EnterpriseService {
 	 * @param bussinessCode
 	 * @return
 	 */
-	Enterprise findByEnBussinessCode(String bussinessCode);
+	List<Enterprise> findByEnBussinessCode(String bussinessCode);
 
 	/**
 	 * 个人用户注册企业信息

+ 1 - 1
src/main/java/com/uas/platform/b2c/common/account/service/impl/EnterpriseServiceImpl.java

@@ -57,7 +57,7 @@ public class EnterpriseServiceImpl implements EnterpriseService{
 	}
 
 	@Override
-	public Enterprise findByEnBussinessCode(String bussinessCode) {
+	public List<Enterprise> findByEnBussinessCode(String bussinessCode) {
 		return enterpriseDao.findByEnBussinessCode(bussinessCode);
 	}
 

+ 19 - 18
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -1042,28 +1042,13 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 
 		List<ReleaseProductByBatch> releaseProductByBatchList =
 				releaseProductByBatchDao.findByRelbatchid(batch);
+		List<Long> productIds = null;
 		if (!CollectionUtils.isEmpty(releaseProductByBatchList)) {
 			List<com.uas.ps.entity.Product> products = convertProduct(releaseProductByBatchList,false);
 			// TODO 什么接口
 			String result = restTemplate.postForEntity(productServiceIp + "/product/update", products, String.class).getBody();
-			List<Long> productIds = JSON.parseArray(result, Long.class);
-			// 默认为b2c Enable开启
-			List<ProductPrivate> productPrivates = new ArrayList<>();
-			for (Long prId : productIds) {
-				ProductPrivate productPrivate = productPrivateDao.findByPrId(prId);
-				if (null == productPrivate) {
-					productPrivate = new ProductPrivate();
-					productPrivate.setPrId(prId);
-				}
-				productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
-				// 统计现在有多少在售信息
-                int batchCount = goodsDao.findCountByProductid(prId);
-                productPrivate.setBatchCount(batchCount);
-                productPrivates.add(productPrivate);
-			}
-			productPrivateDao.save(productPrivates);
+			productIds = JSON.parseArray(result, Long.class);
 		}
-
 		Enterprise enterprise = SystemSession.getUser().getEnterprise();
 		final Object[] obj = new Object[]{enterprise.getUu(), enterprise.getEnName(), batch};
 		String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @enName = '%s'; set @batch = '%s'; call RELEASE_TO_GOODS_V2(@enuu, @enName, @batch, @out); select @out";
@@ -1081,7 +1066,23 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 				return "0";
 			}
 		});
-
+		if (null != productIds) {
+			// 默认为b2c Enable开启
+			List<ProductPrivate> productPrivates = new ArrayList<>();
+			for (Long prId : productIds) {
+				ProductPrivate productPrivate = productPrivateDao.findByPrId(prId);
+				if (null == productPrivate) {
+					productPrivate = new ProductPrivate();
+					productPrivate.setPrId(prId);
+				}
+				productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
+				// 统计现在有多少在售信息
+				int batchCount = goodsDao.findCountByProductid(prId);
+				productPrivate.setBatchCount(batchCount);
+				productPrivates.add(productPrivate);
+			}
+			productPrivateDao.save(productPrivates);
+		}
 
 //		Enterprise enterprise = SystemSession.getUser().getEnterprise();
 //		final Object[] obj = new Object[]{enterprise.getUu(), enterprise.getEnName(), batch};