Просмотр исходного кода

调整发票及地址的逻辑

yuj 7 лет назад
Родитель
Сommit
c11a2cbd2c

+ 1 - 1
src/main/java/com/uas/platform/b2c/fa/settlement/service/impl/BillSubmitServiceImpl.java

@@ -188,7 +188,7 @@ public class BillSubmitServiceImpl implements BillSubmitService {
         if (CollectionUtils.isEmpty(orders)) {
         if (CollectionUtils.isEmpty(orders)) {
             return Collections.emptyList();
             return Collections.emptyList();
         }
         }
-        List<Bill> billOne = billDao.getBillByUseruuAndEnuuAndKind(sysConf.getAdminUU(), sysConf.getEnUU(),Type.Bill_Deduct.value());
+        List<Bill> billOne = billDao.getBillByEnuuAndKindAndDissociative(sysConf.getEnUU(),Type.Bill_Deduct.value(), Type.ENTERPRISING.value());
         if (CollectionUtils.isEmpty(billOne)) {
         if (CollectionUtils.isEmpty(billOne)) {
             throw new IllegalOperatorException("商城专票信息被删除,请联系商城管理员添加");
             throw new IllegalOperatorException("商城专票信息被删除,请联系商城管理员添加");
         }
         }

+ 3 - 37
src/main/java/com/uas/platform/b2c/logistics/dao/AddressDao.java

@@ -27,17 +27,6 @@ public interface AddressDao extends JpaSpecificationExecutor<Address>, JpaReposi
 	 */
 	 */
 	public List<Address> findByUseruuAndTypeAndUsetypeOrderByNumAsc(Long useruu, Integer type, Short usetype);
 	public List<Address> findByUseruuAndTypeAndUsetypeOrderByNumAsc(Long useruu, Integer type, Short usetype);
 
 
-	/**
-	 * 根据uu号,enuu为空类型 查找收货地址
-	 *
-	 * @param useruu       the useruu 个人uu
-	 * @param type         the type 类型 发货,收货
-	 * @param usetype      the usetype 使用类型,1 个人,2 企业
-	 * @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")
-	List<Address> findByUseruuAndTypeAndUsetype(Long useruu, Integer type, Short usetype);
-
 	/**
 	/**
 	 * 根据企业uu号,类型查询平台收货地址
 	 * 根据企业uu号,类型查询平台收货地址
 	 *
 	 *
@@ -71,15 +60,6 @@ public interface AddressDao extends JpaSpecificationExecutor<Address>, JpaReposi
 	 */
 	 */
 	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
-	 * @author yujia 获取企业的收/发货地址
-	 *
-	 * @param enuu    the enuu 企业enuu
-	 * @param usetype the usetype 使用类型
-	 * @return list 返回查找的address列表
-	 */
-	public List<Address> getByEnuuAndUsetypeOrderByNumAsc(Long enuu, Short usetype);
 
 
 	/**
 	/**
 	 * 2016年5月25日 下午3:20:23
 	 * 2016年5月25日 下午3:20:23
@@ -90,8 +70,8 @@ public interface AddressDao extends JpaSpecificationExecutor<Address>, JpaReposi
 	 * @param usetype the usetype
 	 * @param usetype the usetype
 	 * @return Integer 返回地址总数
 	 * @return Integer 返回地址总数
 	 */
 	 */
-	@Query(value="select count(*) from Address a where a.enuu =:enuu and a.type=:type and a.usetype =:usetype")
-	Integer getCountByTypeAndUsetype(@Param("enuu") Long enuu, @Param("type") int type, @Param("usetype") Short usetype);
+	@Query(value="select count(1) from Address a where a.enuu =:enuu and a.type=:type and a.usetype =:usetype")
+	Integer getCountByEnuuAndTypeAndUsetype(@Param("enuu") Long enuu, @Param("type") int type, @Param("usetype") Short usetype);
 
 
 	/**
 	/**
 	 * @author yujia  获取个人地址某种类型的个数
 	 * @author yujia  获取个人地址某种类型的个数
@@ -99,22 +79,8 @@ public interface AddressDao extends JpaSpecificationExecutor<Address>, JpaReposi
 	 * @param useruu       个人uu号
 	 * @param useruu       个人uu号
 	 * @param type         地址的类型
 	 * @param type         地址的类型
 	 * @param usetype      使用类型
 	 * @param usetype      使用类型
-	 * @param dissociative 是否为个人用户
 	 * @return Integer 返回地址总数
 	 * @return Integer 返回地址总数
 	 */
 	 */
 	@Query(value="select count(1) from Address a where a.useruu=:useruu and a.dissociative=:dissociative and a.type=:type and a.usetype =:usetype")
 	@Query(value="select count(1) from Address a where a.useruu=:useruu and a.dissociative=:dissociative and a.type=:type and a.usetype =:usetype")
-	Integer getCountByUseruuTypeUsetypeAndDissociative(@Param("useruu") Long useruu, @Param("type") int type, @Param("usetype") Short usetype, @Param("dissociative") Integer dissociative);
-
-
-	/**
-	 * 2016年5月25日 下午3:23:15
-	 * @author yujia  获取企业地址某种类型的个数
-	 *
-	 * @param enuu    企业的uu号
-	 * @param type    地址类型
-	 * @param usetype 使用类型
-	 * @return Integer 返回地址总数
-	 */
-	@Query(value = "select count(*) from Address a where a.enuu =:enuu and a.type =:type and a.usetype =:usetype")
-	Integer getCountByEnuuAndTypeAndUsetype(@Param("enuu") Long enuu, @Param("type") int type,  @Param("usetype") Short usetype);
+	Integer getCountByUseruuAndTypeAndUsetype(@Param("useruu") Long useruu, @Param("type") int type, @Param("usetype") Short usetype);
 }
 }

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

@@ -140,12 +140,12 @@ public class AddressServiceImpl implements AddressService {
 			if (user.getEnterprise() == null) {
 			if (user.getEnterprise() == null) {
 				address.setUsetype((short)1);
 				address.setUsetype((short)1);
 				address.setDissociative(Type.PERSONAL.value());
 				address.setDissociative(Type.PERSONAL.value());
-				num =addressDao.getCountByUseruuTypeUsetypeAndDissociative(user.getUserUU(),address.getType(), address.getUsetype(), Type.PERSONAL.value());
+				num =addressDao.getCountByUseruuAndTypeAndUsetype(user.getUserUU(), address.getType(), address.getUsetype());
 			} else {
 			} else {
 				address.setEnuu(user.getEnterprise().getUu());
 				address.setEnuu(user.getEnterprise().getUu());
 				address.setDissociative(Type.ENTERPRISING.value());
 				address.setDissociative(Type.ENTERPRISING.value());
 				address.setUsetype((short)2);
 				address.setUsetype((short)2);
-				num =addressDao.getCountByTypeAndUsetype(user.getEnterprise().getUu(), address.getType(), address.getUsetype());
+				num =addressDao.getCountByEnuuAndTypeAndUsetype(user.getEnterprise().getUu(), address.getType(), address.getUsetype());
 			}
 			}
 			address.setNum(num == 0 ? 1 : ++num);
 			address.setNum(num == 0 ? 1 : ++num);
 		}
 		}
@@ -168,9 +168,9 @@ public class AddressServiceImpl implements AddressService {
 		List<Address> address = new ArrayList<Address>();
 		List<Address> address = new ArrayList<Address>();
 		Integer type = send ? Type.Address_Sending_Code.value() :Type.Address_Shipping_Code.value();
 		Integer type = send ? Type.Address_Sending_Code.value() :Type.Address_Shipping_Code.value();
 		if (enuu != null) {
 		if (enuu != null) {
-			address = addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(enuu, type, (short)2);
+			address = addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(enuu, type, Address.USE_TYPE.Enterprise.getValue());
 		} else {
 		} else {
-			address = addressDao.findByUseruuAndTypeAndUsetype(useruu, type, (short)1);
+			address = addressDao.findByUseruuAndTypeAndUsetypeOrderByNumAsc(useruu, type, Address.USE_TYPE.Personal.getValue());
 		}
 		}
 		return address;
 		return address;
 	}
 	}

+ 4 - 4
src/main/java/com/uas/platform/b2c/trade/order/service/impl/OrderServiceImpl.java

@@ -875,11 +875,11 @@ public class OrderServiceImpl implements OrderService {
             if (order.getInvoiceid() != null && order.getInvoicetype() == Type.Bill_NoDeduct.value()){ //发票为普票
             if (order.getInvoiceid() != null && order.getInvoicetype() == Type.Bill_NoDeduct.value()){ //发票为普票
                 //将普票类型修改为专票
                 //将普票类型修改为专票
                 List<Bill> billOne;
                 List<Bill> billOne;
-                if (SystemSession.getUser().getEnterprise() != null){
-                    billOne = billDao.getBillByUseruuAndEnuuAndKind(SystemSession.getUser().getUserUU(),
-                            SystemSession.getUser().getEnterprise().getUu(), Type.Bill_Deduct.value());
+                User user = SystemSession.getUser();
+                if (user.getEnterprise() != null){
+                    billOne = billDao.getBillByEnuuAndKindAndDissociative(user.getEnterprise().getUu(), Type.Bill_Deduct.value(), Type.ENTERPRISING.value());
                 }else {
                 }else {
-                    billOne = billDao.getBillByUseruuAndDissociativeAndKind(SystemSession.getUser().getUserUU(),
+                    billOne = billDao.getBillByUseruuAndDissociativeAndKind(user.getUserUU(),
                             Type.PERSONAL.value(), Type.Bill_Deduct.value());
                             Type.PERSONAL.value(), Type.Bill_Deduct.value());
                 }
                 }
                 if (CollectionUtils.isEmpty(billOne)){
                 if (CollectionUtils.isEmpty(billOne)){

+ 1 - 1
src/main/java/com/uas/platform/b2c/trade/order/service/impl/PurchaseServiceImpl.java

@@ -405,7 +405,7 @@ public class PurchaseServiceImpl implements PurchaseService {
 			} else {
 			} else {
 				purchase.setJsonAddress(FastjsonUtils.toJson(addresss.get(0)));
 				purchase.setJsonAddress(FastjsonUtils.toJson(addresss.get(0)));
 			}
 			}
-			List<Bill> billOne = billDao.getBillByUseruuAndEnuuAndKind(sysConf.getAdminUU(), sysConf.getEnUU(),Type.Bill_Deduct.value());
+			List<Bill> billOne = billDao.getBillByEnuuAndKindAndDissociative(sysConf.getEnUU(),Type.Bill_Deduct.value(), Type.ENTERPRISING.value());
 //			List<BillInfo> billInfos = billInfoDao.getBillByUseruuAndEnuuAndKind(sysConf.getAdminUU(), sysConf.getEnUU(), Type.Bill_Deduct.value());
 //			List<BillInfo> billInfos = billInfoDao.getBillByUseruuAndEnuuAndKind(sysConf.getAdminUU(), sysConf.getEnUU(), Type.Bill_Deduct.value());
 			if(CollectionUtils.isEmpty(billOne)) {
 			if(CollectionUtils.isEmpty(billOne)) {
 				throw new IllegalOperatorException("优软商城的专用发票信息不存在,请联系商城客服");
 				throw new IllegalOperatorException("优软商城的专用发票信息不存在,请联系商城客服");