Prechádzať zdrojové kódy

认证后店铺本地信息被覆盖的问题

zhaohongpeng 7 rokov pred
rodič
commit
bf6d6159fd

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

@@ -5,6 +5,8 @@ import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.common.account.model.FormEnterprise;
 import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.common.account.model.UserBaseInfo;
+import com.uas.platform.b2c.prod.store.model.EnterpriseSimple;
+import com.uas.platform.b2c.prod.store.model.StoreIn;
 import com.uas.platform.b2c.trade.support.ResultMap;
 
 import java.util.List;
@@ -81,5 +83,12 @@ public interface EnterpriseService {
 	ResultMap getEntelAndAdmintel(Long enUU);
 
 
+	/**
+	 * 企业和企业概要之间的转化;
+	 * @return 店铺信息
+	 */
+	EnterpriseSimple getNewEnterpriseSimple(Enterprise enterprise, StoreIn storeIn);
+
+
 
 }

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

@@ -116,59 +116,15 @@ public class EnterpriseServiceImpl implements EnterpriseService{
 		}
 	}
 
+
+
 	@Override
 	public Enterprise save(Enterprise enterprise) {
 		Enterprise existEnterprise = enterpriseDao.findOne(enterprise.getUu());
 		//更新店铺中的企业信息
 		List<StoreIn> storeIns = storeInDao.findByEnUU(enterprise.getUu());
 		for (StoreIn storeIn : storeIns) {
-			EnterpriseSimple newEnterprise;
-			newEnterprise = new EnterpriseSimple();
-			EnterpriseSimple enterpriseOld = storeIn.getEnterprise();
-			BeanUtils.copyProperties(enterpriseOld,newEnterprise);
-			if (enterpriseOld != null) {
-				if (enterprise.getEnName() !=null) {
-					newEnterprise.setEnName(enterprise.getEnName());
-				}
-				if (enterprise.getEnAddress() !=null) {
-					newEnterprise.setEnAddress(enterprise.getEnAddress());
-				}
-				if (enterprise.getEnFax() !=null) {
-					newEnterprise.setEnFax(enterprise.getEnFax());
-				}
-				if (enterprise.getEnTel() !=null) {
-					newEnterprise.setEnTel(enterprise.getEnTel());
-				}
-				if (enterprise.getEnType() !=null) {
-					newEnterprise.setEnType(enterprise.getEnType());
-				}
-				if (enterprise.getEnBussinessCode() !=null) {
-					newEnterprise.setEnBusinessCode(enterprise.getEnBussinessCode());
-				}
-				if (enterprise.getEnDate() !=null) {
-					newEnterprise.setEnDate(enterprise.getEnDate());
-				}
-				if (enterprise.getEnUrl() !=null) {
-					newEnterprise.setEnUrl(enterprise.getEnUrl());
-				}
-				if (enterprise.getEnLogoUrl() !=null) {
-					newEnterprise.setEnLogoUrl(enterprise.getEnLogoUrl());
-				}
-				if (enterprise.getEnEmail() !=null) {
-					newEnterprise.setEnLogoUrl(enterprise.getEnEmail());
-				}
-				if (enterprise.getEnPhone() !=null) {
-					newEnterprise.setEnLogoUrl(enterprise.getEnPhone());
-				}
-				if (enterprise.getEnWeixin() !=null) {
-					newEnterprise.setEnLogoUrl(enterprise.getEnWeixin());
-				}
-				if (enterprise.getEnQQ() !=null) {
-					newEnterprise.setEnLogoUrl(enterprise.getEnQQ());
-				}
-			} else {
-				newEnterprise = EnterpriseSimple.translateSimple(enterprise);
-			}
+			EnterpriseSimple newEnterprise = getNewEnterpriseSimple(enterprise, storeIn);
 			storeIn.setEnterprise(newEnterprise);
 			storeInDao.save(storeIn);
 		}
@@ -182,7 +138,57 @@ public class EnterpriseServiceImpl implements EnterpriseService{
 		}
 		return enterpriseDao.save(enterprise);
 	}
-
+	@Override
+	public EnterpriseSimple getNewEnterpriseSimple(Enterprise enterprise, StoreIn storeIn) {
+		EnterpriseSimple newEnterprise;
+		newEnterprise = new EnterpriseSimple();
+		EnterpriseSimple enterpriseOld = storeIn.getEnterprise();
+		BeanUtils.copyProperties(enterpriseOld,newEnterprise);
+		if (enterpriseOld != null) {
+            if (enterprise.getEnName() !=null) {
+                newEnterprise.setEnName(enterprise.getEnName());
+            }
+            if (enterprise.getEnAddress() !=null) {
+                newEnterprise.setEnAddress(enterprise.getEnAddress());
+            }
+            if (enterprise.getEnFax() !=null) {
+                newEnterprise.setEnFax(enterprise.getEnFax());
+            }
+            if (enterprise.getEnTel() !=null) {
+                newEnterprise.setEnTel(enterprise.getEnTel());
+            }
+            if (enterprise.getEnType() !=null) {
+                newEnterprise.setEnType(enterprise.getEnType());
+            }
+            if (enterprise.getEnBussinessCode() !=null) {
+                newEnterprise.setEnBusinessCode(enterprise.getEnBussinessCode());
+            }
+            if (enterprise.getEnDate() !=null) {
+                newEnterprise.setEnDate(enterprise.getEnDate());
+            }
+            if (enterprise.getEnUrl() !=null) {
+                newEnterprise.setEnUrl(enterprise.getEnUrl());
+            }
+            if (enterprise.getEnLogoUrl() !=null) {
+                newEnterprise.setEnLogoUrl(enterprise.getEnLogoUrl());
+            }
+            if (enterprise.getEnEmail() !=null) {
+                newEnterprise.setEnLogoUrl(enterprise.getEnEmail());
+            }
+            if (enterprise.getEnPhone() !=null) {
+                newEnterprise.setEnLogoUrl(enterprise.getEnPhone());
+            }
+            if (enterprise.getEnWeixin() !=null) {
+                newEnterprise.setEnLogoUrl(enterprise.getEnWeixin());
+            }
+            if (enterprise.getEnQQ() !=null) {
+                newEnterprise.setEnLogoUrl(enterprise.getEnQQ());
+            }
+        } else {
+            newEnterprise = EnterpriseSimple.translateSimple(enterprise);
+        }
+		return newEnterprise;
+	}
 
 
 	private void postToAccountCenter(Enterprise enterprise) throws Exception {

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

@@ -31,6 +31,9 @@ public class EnterpriseServiceImpl implements EnterpriseService {
 	@Autowired
 	private EnterpriseDao enterpriseDao;
 
+    @Autowired
+	private com.uas.platform.b2c.common.account.service.EnterpriseService enterpriseService;
+
 	@Autowired
     private UserDao userDao;
     @Autowired
@@ -101,9 +104,11 @@ public class EnterpriseServiceImpl implements EnterpriseService {
             try {
                 List<StoreIn> storeIns = storeInDao.findByEnUU(enterprise.getUu());
                 if (storeIns != null && storeIns.size() > 0) {
-                    storeIns.get(0).setEnterprise(EnterpriseSimple.translateSimple(enterprise));
-                    storeIns.get(0).setStoreName(enterprise.getEnName());
-                    storeInDao.save(storeIns.get(0));
+                    StoreIn storeIn = storeIns.get(0);
+                    EnterpriseSimple newEnterpriseSimple = enterpriseService.getNewEnterpriseSimple(enterprise, storeIn);
+                    storeIn.setEnterprise(newEnterpriseSimple);
+                    storeIn.setStoreName(enterprise.getEnName());
+                    storeInDao.save(storeIn);
                 }
             } catch (Exception e) {
                 e.printStackTrace();
@@ -177,4 +182,6 @@ public class EnterpriseServiceImpl implements EnterpriseService {
 
 
 
+
+
 }