Преглед изворни кода

处理设置默认地址的问题

yujia пре 7 година
родитељ
комит
406732afb8

+ 4 - 6
src/main/java/com/uas/platform/b2c/logistics/dao/AddressDao.java

@@ -21,12 +21,11 @@ public interface AddressDao extends JpaSpecificationExecutor<Address>, JpaReposi
 	 * 根据uu号,类型 查找收货地址
 	 *
 	 * @param useruu  the useruu 个人uu
-	 * @param enuu    the enuu 企业uu
 	 * @param type    the type 类型,发货,收货
 	 * @param usetype the usetype 使用类型,1 个人,2 企业
 	 * @return list 返回查找的address列表
 	 */
-	public List<Address> findByUseruuAndEnuuAndTypeAndUsetypeOrderByNumAsc(Long useruu, Long enuu, Integer type, Short usetype);
+	public List<Address> findByUseruuAndTypeAndUsetypeOrderByNumAsc(Long useruu, Integer type, Short usetype);
 
 	/**
 	 * 根据uu号,enuu为空类型 查找收货地址
@@ -34,11 +33,10 @@ public interface AddressDao extends JpaSpecificationExecutor<Address>, JpaReposi
 	 * @param useruu       the useruu 个人uu
 	 * @param type         the type 类型 发货,收货
 	 * @param usetype      the usetype 使用类型,1 个人,2 企业
-	 * @param dissociative the dissociative 是否个人用户
 	 * @return list 返回查找的address列表
 	 */
 //	@Query("select a from Address a where a.useruu=:useruu and a.enuu is null and a.type=:type and a.usetype=:usetype")
-	public List<Address> findByUseruuAndTypeAndUsetypeAndDissociative(Long useruu, Integer type, Short usetype, Integer dissociative);
+	List<Address> findByUseruuAndTypeAndUsetype(Long useruu, Integer type, Short usetype);
 
 	/**
 	 * 根据企业uu号,类型查询平台收货地址
@@ -48,7 +46,7 @@ public interface AddressDao extends JpaSpecificationExecutor<Address>, JpaReposi
 	 * @param usertype the usertype 使用类型
 	 * @return list 返回查找的address列表
 	 */
-	public List<Address> findByEnuuAndTypeAndUsetypeOrderByNumAsc(Long enuu, Integer type, Short usertype);
+	List<Address> findByEnuuAndTypeAndUsetypeOrderByNumAsc(Long enuu, Integer type, Short usertype);
 
 	/**
 	 * 根据企业uu号默认地址,类型查询平台收货地址
@@ -59,7 +57,7 @@ public interface AddressDao extends JpaSpecificationExecutor<Address>, JpaReposi
 	 * @param usertype the usertype 使用类型
 	 * @return list 返回查找的address列表
 	 */
-	public List<Address> findByEnuuAndTypeAndNumAndUsetypeOrderByNumAsc(Long enuu, Integer type, Integer num, Short usertype);
+	List<Address> findByEnuuAndTypeAndNumAndUsetypeOrderByNumAsc(Long enuu, Integer type, Integer num, Short usertype);
 
 	/**
 	 * 2016年5月4日 下午8:11:30

+ 9 - 14
src/main/java/com/uas/platform/b2c/logistics/service/impl/AddressServiceImpl.java

@@ -2,6 +2,7 @@ package com.uas.platform.b2c.logistics.service.impl;
 
 import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.core.config.SysConf;
+import com.uas.platform.b2c.core.constant.ShortConstant;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.logistics.dao.AddressDao;
 import com.uas.platform.b2c.logistics.model.Address;
@@ -43,7 +44,7 @@ public class AddressServiceImpl implements AddressService {
 			int type = address.getType();
 			short usertype = address.getUsetype();
 			if(usertype == 1) {//个人地址信息
-				addresses = addressDao.findByUseruuAndEnuuAndTypeAndUsetypeOrderByNumAsc(address.getUseruu(), address.getEnuu(), type, (short)1);
+				addresses = addressDao.findByUseruuAndTypeAndUsetypeOrderByNumAsc(address.getUseruu(), type, (short)1);
 			}else {//企业的地址信息
 				addresses = addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(address.getEnuu(), type, (short)2);
 			}
@@ -76,8 +77,9 @@ public class AddressServiceImpl implements AddressService {
 		Long useruu = address.getUseruu();
 		int type = address.getType();
 		List<Address> addresses = null;
-		if (Type.Address_Shipping_Code.value() == address.getType()) {
-			addresses = addressDao.findByUseruuAndEnuuAndTypeAndUsetypeOrderByNumAsc(useruu, address.getEnuu(), type, (short)1);
+		if (address.getUsetype().equals(ShortConstant.YES_SHORT)) {
+			//个人账户
+			addresses = addressDao.findByUseruuAndTypeAndUsetypeOrderByNumAsc(useruu, type, (short)1);
 		} else {
 			addresses = addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(address.getEnuu(), type, (short)2);
 		}
@@ -180,18 +182,11 @@ public class AddressServiceImpl implements AddressService {
 	@Override
 	public List<Address> findShipingAdd(Long useruu, Boolean send, Long enuu) {
 		List<Address> address = new ArrayList<Address>();
-		if (send) {
-			if (enuu != null) {
-				address = addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(enuu, Type.Address_Sending_Code.value(), (short)2);
-			} else {
-				address = addressDao.findByUseruuAndTypeAndUsetypeAndDissociative(useruu, Type.Address_Sending_Code.value(), (short)2, Type.PERSONAL.value());
-			}
+		Integer type = send ? Type.Address_Sending_Code.value() :Type.Address_Shipping_Code.value();
+		if (enuu != null) {
+			address = addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(enuu, type, (short)2);
 		} else {
-			if (enuu != null) {
-				address = addressDao.findByUseruuAndEnuuAndTypeAndUsetypeOrderByNumAsc(useruu, enuu, Type.Address_Shipping_Code.value(), (short) 1);
-			} else {
-				address = addressDao.findByUseruuAndTypeAndUsetypeAndDissociative(useruu, Type.Address_Shipping_Code.value(), (short)1, Type.PERSONAL.value());
-			}
+			address = addressDao.findByUseruuAndTypeAndUsetype(useruu, type, (short)1);
 		}
 		return address;
 	}