Browse Source

调整账户中心发票及收货地址的逻辑

yujia 7 years ago
parent
commit
903043d184

+ 8 - 16
src/main/java/com/uas/platform/b2c/fa/payment/service/impl/BankInfoServiceImpl.java

@@ -64,25 +64,16 @@ public class BankInfoServiceImpl implements BankInfoService {
 	public BankInfo save(BankInfo bankInfo, Integer type, FileUpload... fileItem) {
 		bankInfo.setOpraterUserType(type);
 		bankInfo.setCreateTime(new Date());
-		if(type == Type.BUYER.value()) {
+		type = Type.SUP.value();
+		if(SystemSession.getUser().getEnterprise() == null) {
 			if(bankInfo.getId() == null) {
-				if (SystemSession.getUser().getEnterprise() != null){
-					int num = bankInfoDao.getCountByUseruuAndStatus(SystemSession.getUser().getUserUU(), SystemSession.getUser().getEnterprise().getUu(), bankInfo.getOpraterUserType(), Status.ALLOW.value()) + 1;
-					bankInfo.setNum(num);
-				}else {
-					int num = bankInfoDao.getCountByUseruuAndStatusAndDissociative(SystemSession.getUser().getUserUU(), Type.PERSONAL.value(), bankInfo.getOpraterUserType(), Status.ALLOW.value()) + 1;
-					bankInfo.setNum(num);
-				}
+				int num = bankInfoDao.getCountByUseruuAndStatusAndDissociative(SystemSession.getUser().getUserUU(), Type.PERSONAL.value(), bankInfo.getOpraterUserType(), Status.ALLOW.value()) + 1;
+				bankInfo.setNum(num);
 			}
 			bankInfo.setUseruu(SystemSession.getUser().getUserUU());
-			bankInfo.setEnuu(SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu() : null);
-			if (bankInfo.getEnuu() == null) {
-				bankInfo.setDissociative(Type.PERSONAL.value());
-			} else {
-				bankInfo.setDissociative(Type.ENTERPRISING.value());
-			}
+			bankInfo.setDissociative(Type.PERSONAL.value());
 			bankInfo.setStatus(Status.ALLOW.value());
-		}else if(type == Type.SUP.value()) {
+		}else {
 			bankInfo.setEnuu(SystemSession.getUser().getEnterprise().getUu());
 			bankInfo.setDissociative(Type.ENTERPRISING.value());
 			if(bankInfo.getId() == null) {
@@ -198,7 +189,8 @@ public class BankInfoServiceImpl implements BankInfoService {
 		}else {
 			enuu = params[0];
 		}
-		if(operatorUserType == Type.BUYER.value()) {
+		//如果是个人用户登录
+		if(SystemSession.getUser().getEnterprise() == null) {
 			if (enuu != null) {
 				return bankInfoDao.findByUseruuAndEnuuAndOpraterUserTypeAndStatusOrderByNumAsc(SystemSession.getUser().getUserUU(), enuu, operatorUserType, status);
 			} else {

+ 4 - 4
src/main/java/com/uas/platform/b2c/fa/settlement/controller/BillController.java

@@ -103,14 +103,14 @@ public class BillController {
 	}
 
 	/**
-	 * 根据当前登录信息,获取个人当前登录企业的发票列表
+	 * 根据当前登录信息,当前登录企业的发票列表
 	 *
-	 * @return 个人当前登录企业的发票列表
+	 * @return 当前登录企业的发票列表(或个人发票)
 	 */
-	@RequestMapping(value = "/list/personal", method = RequestMethod.GET)
+	@RequestMapping(value = "/list", method = RequestMethod.GET)
 	@ApiOperation(value = "根据当前登录信息,获取个人当前登录企业的发票列表", httpMethod = "GET")
 	public List<Bill> getBills() {
-		logger.log("发票管理", "根据个人uu和企业的uu,获取发票资料信息");
+		logger.log("发票管理", "当前登录企业的发票列表");
 		return billService.getBills();
 	}
 

+ 18 - 0
src/main/java/com/uas/platform/b2c/fa/settlement/dao/BillDao.java

@@ -27,6 +27,15 @@ public interface BillDao extends JpaSpecificationExecutor<Bill>, JpaRepository<B
      */
     public List<Bill> getBillByUseruuAndEnuu(Long useruu, Long enuu);
 
+
+	/**
+	 * 根据用户UU号和企业UU号获取发票列表
+	 *
+	 * @param enuu   the enuu 企业enuu
+	 * @return the bill by useruu and enuu
+	 */
+	List<Bill> getBillByEnuu(Long enuu);
+
     /**
      * 根据个人UU号和是否个人用户获取发票列表
      *
@@ -55,6 +64,15 @@ public interface BillDao extends JpaSpecificationExecutor<Bill>, JpaRepository<B
      */
     public List<Bill> getBillByUseruuAndEnuuAndKind(Long useruu, Long enuu, Integer kind);
 
+	/**
+	 * 根据企业UU号和发票类型(增值税专用 和 增值税普通)获取发票列表
+	 *
+	 * @param enuu   the enuu 企业enuu
+	 * @param kind   the kind 发票类型
+	 * @return the bill by useruu and enuu and kind
+	 */
+	List<Bill> getBillByEnuuAndKind(Long enuu, Integer kind);
+
     /**
      * 根据个人UU号和企业UU号和发票类型(增值税专用 和 增值税普通) 和是否个人用户获取发票列表
      *

+ 2 - 2
src/main/java/com/uas/platform/b2c/fa/settlement/service/impl/BillServiceImpl.java

@@ -63,7 +63,7 @@ public class BillServiceImpl implements BillService {
 		if (bill.getId() == null) {
 			List<Bill> billList = new ArrayList<Bill>();
 			if (Type.ENTERPRISING.value() == bill.getDissociative())
-				billList = billDao.getBillByUseruuAndEnuuAndKind(useruu, enuu, bill.getKind());
+				billList = billDao.getBillByEnuuAndKind(enuu, bill.getKind());
 			if (Type.PERSONAL.value() == bill.getDissociative())
 				billList = billDao.getBillByUseruuAndEnuuAndKindAndDissociative(useruu, Type.PERSONAL.value(),bill.getKind());
 			if (billList.size() > 0) {
@@ -85,7 +85,7 @@ public class BillServiceImpl implements BillService {
 	public List<Bill> getBills() {
 		Long useruu = SystemSession.getUser().getUserUU();
 		if (SystemSession.getUser().getEnterprise() != null) {
-			return billDao.getBillByUseruuAndEnuu(useruu, SystemSession.getUser().getEnterprise().getUu());
+			return billDao.getBillByEnuu(SystemSession.getUser().getEnterprise().getUu());
 		} else {
 			return billDao.getBillByUseruuAndDissociative(useruu, Type.PERSONAL.value());
 		}

+ 2 - 11
src/main/java/com/uas/platform/b2c/logistics/controller/AddressController.java

@@ -9,7 +9,6 @@ import com.uas.platform.b2c.logistics.service.AddressService;
 import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
-import com.uas.platform.core.model.Type;
 import com.wordnik.swagger.annotations.ApiOperation;
 import com.wordnik.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -189,11 +188,7 @@ public class AddressController {
 	@ApiOperation(value = "获取企业发货地址的信息", httpMethod = "GET")
 	public Page<Address> getEnterpriseSendAddress(@ApiParam(required = true, value = "分页参数") PageParams page) {
 		logger.log("地址管理", "获取一页的企业发货地址信息");
-		PageInfo info = new PageInfo(page);
-		info.filter("enuu", SystemSession.getUser().getEnterprise().getUu());
-		info.filter("type", Type.Address_Sending_Code.value());
-		info.filter("usetype", (short)2);
-		return addressService.getEnterprise(info);
+		return addressService.getEnterpriseSendAddress(page);
 	}
 
 	/**
@@ -206,11 +201,7 @@ public class AddressController {
 	@ApiOperation(value = "获取企业收货地址信息", httpMethod = "GET")
 	public Page<Address> getEnterpriseReceiveAddress(@ApiParam(required = true, value = "分页参数") PageParams page) {
 		logger.log("地址管理", "获取一页的企业收货地址信息");
-		PageInfo info = new PageInfo(page);
-		info.filter("enuu", SystemSession.getUser().getEnterprise().getUu());
-		info.filter("type", Type.Address_Shipping_Code.value());
-		info.filter("usetype", (short)2);
-		return addressService.getEnterprise(info);
+		return addressService.getEnterpriseReceiveAddress(page);
 	}
 
 	/**

+ 21 - 4
src/main/java/com/uas/platform/b2c/logistics/service/AddressService.java

@@ -1,11 +1,11 @@
 package com.uas.platform.b2c.logistics.service;
 
-import java.util.List;
-
-import org.springframework.data.domain.Page;
-
 import com.uas.platform.b2c.logistics.model.Address;
 import com.uas.platform.core.model.PageInfo;
+import com.uas.platform.core.model.PageParams;
+import org.springframework.data.domain.Page;
+
+import java.util.List;
 
 /**
  * The interface AddressService.
@@ -97,6 +97,23 @@ public interface AddressService {
 	 */
 	public Page<Address> getEnterprise(final PageInfo info);
 
+	/**
+	 * 获取企业收货地址信息
+	 *
+	 * @param page the page 一页的参数
+	 * @return Page 返回Address的page对象
+	 */
+	Page<Address> getEnterpriseReceiveAddress(PageParams page);
+
+
+	/**
+	 * 获取企业发货地址的信息
+	 *
+	 * @param page 一页的参数
+	 * @return Page 返回Address的page对象
+	 */
+	Page<Address> getEnterpriseSendAddress(PageParams page);
+
 	/**
 	 * 2016年5月20日 下午6:38:48
 	 * 获取企业的默认账户

+ 51 - 3
src/main/java/com/uas/platform/b2c/logistics/service/impl/AddressServiceImpl.java

@@ -8,6 +8,7 @@ import com.uas.platform.b2c.logistics.model.Address;
 import com.uas.platform.b2c.logistics.service.AddressService;
 import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.model.PageInfo;
+import com.uas.platform.core.model.PageParams;
 import com.uas.platform.core.model.Type;
 import com.uas.platform.core.persistence.criteria.CriterionExpression;
 import com.uas.platform.core.persistence.criteria.SimpleExpression;
@@ -149,9 +150,16 @@ public class AddressServiceImpl implements AddressService {
 				}
 			}else {
 				address.setUseruu(user.getUserUU());
-				address.setEnuu(user.getEnterprise().getUu());
-				address.setUsetype((short)2);
-				num = addressDao.getCountByEnuuAndTypeAndUsetype(user.getEnterprise().getUu(), address.getType(), address.getUsetype());
+				if (user.getEnterprise() != null) {
+					address.setEnuu(user.getEnterprise().getUu());
+					address.setUsetype((short)2);
+					num = addressDao.getCountByEnuuAndTypeAndUsetype(user.getEnterprise().getUu(), address.getType(), address.getUsetype());
+				} else {
+					address.setDissociative(Type.PERSONAL.value());
+					address.setUsetype((short)1);
+					num =addressDao.getCountByUseruuTypeUsetypeAndDissociative(user.getUserUU(),address.getType(), address.getUsetype(), Type.PERSONAL.value());
+				}
+
 			}
 			address.setNum(num == 0 ? 1 : ++num);
 		}
@@ -237,6 +245,46 @@ public class AddressServiceImpl implements AddressService {
 		}, info);
 	}
 
+	/**
+	 * 获取企业收货地址信息
+	 *
+	 * @param page the page 一页的参数
+	 * @return Page 返回Address的page对象
+	 */
+	@Override
+	public Page<Address> getEnterpriseReceiveAddress(PageParams page) {
+		PageInfo info = new PageInfo(page);
+		info.filter("type", Type.Address_Shipping_Code.value());
+		if (SystemSession.getUser().getEnterprise() != null) {
+			info.filter("enuu", SystemSession.getUser().getEnterprise().getUu());
+			info.filter("usetype", (short)2);
+		} else {
+			info.filter("useruu", SystemSession.getUser().getUserUU());
+			info.filter("usetype", (short)1);
+		}
+		return getEnterprise(info);
+	}
+
+	/**
+	 * 获取企业发货地址的信息
+	 *
+	 * @param page 一页的参数
+	 * @return Page 返回Address的page对象
+	 */
+	@Override
+	public Page<Address> getEnterpriseSendAddress(PageParams page) {
+		PageInfo info = new PageInfo(page);
+		info.filter("type", Type.Address_Sending_Code.value());
+		if (SystemSession.getUser().getEnterprise() != null) {
+			info.filter("enuu", SystemSession.getUser().getEnterprise().getUu());
+			info.filter("usetype", (short)2);
+		} else {
+			info.filter("useruu", SystemSession.getUser().getUserUU());
+			info.filter("usetype", (short)1);
+		}
+		return getEnterprise(info);
+	}
+
 	@Override
 	public List<Address> findDefaultEnterpriseAddress(boolean bool) {
 		// boo判断查询的是收货地址还是发货地址(默认收货地址)

+ 10 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/controller/ProductController.java

@@ -420,4 +420,14 @@ public class ProductController {
 	public ResultMap updateProduct(@RequestBody String json, String attachUrl){
 		return productService.updateProduct(json, attachUrl);
 	}
+
+	/**
+	 * 根据关键字匹配器件型号,获取物料信息
+	 * @param keyword
+	 * @return
+	 */
+	@RequestMapping(value = "/keyword", method = RequestMethod.GET)
+	public List<Product> getProductsByKeyword(String keyword) {
+		return new ArrayList<>();
+	}
 }