|
|
@@ -132,36 +132,20 @@ public class AddressServiceImpl implements AddressService {
|
|
|
@Override
|
|
|
public Address saveShippingAddress(Address address, Boolean isSetTop, Boolean send, Boolean isPersonal) {
|
|
|
if(address.getId() == null) { //默认的只要是已经保存过的地址,就不能再变更地址类型。
|
|
|
- if (send) {
|
|
|
- address.setTypeSending();
|
|
|
- } else {
|
|
|
- address.setTypeShipping();
|
|
|
- }
|
|
|
+ Integer type = send ? Type.Address_Sending_Code.value() : Type.Address_Shipping_Code.value();
|
|
|
+ address.setType(type);
|
|
|
Integer num = 0;
|
|
|
User user = SystemSession.getUser();
|
|
|
- if(isPersonal) {
|
|
|
- address.setUseruu(user.getUserUU());
|
|
|
+ address.setUseruu(user.getUserUU());
|
|
|
+ if (user.getEnterprise() == null) {
|
|
|
address.setUsetype((short)1);
|
|
|
- address.setEnuu(user.getEnterprise() != null ? user.getEnterprise().getUu() : null);
|
|
|
- if (address.getEnuu() != null) {
|
|
|
- address.setDissociative(Type.ENTERPRISING.value());
|
|
|
- num =addressDao.getCountByUseruuAndTypeAndUsetype(user.getUserUU(), user.getEnterprise().getUu(), address.getType(), address.getUsetype());
|
|
|
- } else {
|
|
|
- address.setDissociative(Type.PERSONAL.value());
|
|
|
- num =addressDao.getCountByUseruuTypeUsetypeAndDissociative(user.getUserUU(),address.getType(), address.getUsetype(), Type.PERSONAL.value());
|
|
|
- }
|
|
|
- }else {
|
|
|
- address.setUseruu(user.getUserUU());
|
|
|
- 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.setDissociative(Type.PERSONAL.value());
|
|
|
+ num =addressDao.getCountByUseruuTypeUsetypeAndDissociative(user.getUserUU(),address.getType(), address.getUsetype(), Type.PERSONAL.value());
|
|
|
+ } else {
|
|
|
+ address.setEnuu(user.getEnterprise().getUu());
|
|
|
+ address.setDissociative(Type.ENTERPRISING.value());
|
|
|
+ address.setUsetype((short)2);
|
|
|
+ num =addressDao.getCountByTypeAndUsetype(user.getEnterprise().getUu(), address.getType(), address.getUsetype());
|
|
|
}
|
|
|
address.setNum(num == 0 ? 1 : ++num);
|
|
|
}
|
|
|
@@ -198,10 +182,12 @@ public class AddressServiceImpl implements AddressService {
|
|
|
|
|
|
@Override
|
|
|
public List<Address> findEnShippingAdd(boolean ship) {
|
|
|
- if(ship) {
|
|
|
- return addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(SystemSession.getUser().getEnterprise().getUu(), Type.Address_Shipping_Code.value(), (short)2);
|
|
|
- }else {
|
|
|
- return addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(SystemSession.getUser().getEnterprise().getUu(), Type.Address_Sending_Code.value(), (short)2);
|
|
|
+ Integer type = ship ? Type.Address_Shipping_Code.value() : Type.Address_Sending_Code.value();
|
|
|
+ User user = SystemSession.getUser();
|
|
|
+ if (user.getEnterprise() == null) {
|
|
|
+ return addressDao.findByUseruuAndTypeAndUsetypeOrderByNumAsc(user.getUserUU(), type, (short)1);
|
|
|
+ } else {
|
|
|
+ return addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(user.getEnterprise().getUu(), type, (short)2);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -221,11 +207,27 @@ public class AddressServiceImpl implements AddressService {
|
|
|
@Override
|
|
|
public List<Address> findB2cAdd(boolean send) {
|
|
|
// boo判断查询的是收货地址还是发货地址(默认收货地址)
|
|
|
- if (send) {
|
|
|
- return addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(sysConf.getEnUU(), Type.Address_Sending_Code.value(), (short)2);
|
|
|
+ Integer type = send ? Type.Address_Sending_Code.value() : Type.Address_Shipping_Code.value();
|
|
|
+ return addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(sysConf.getEnUU(), type, (short)2);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param page 一页的参数
|
|
|
+ * @return Page 返回Address的page对象
|
|
|
+ * @author yujia 获取企业一页的地址信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Page<Address> getEnterpriseAddress(PageParams page) {
|
|
|
+ PageInfo info = new PageInfo(page);
|
|
|
+ User user = SystemSession.getUser();
|
|
|
+ if (user.getEnterprise() == null) {
|
|
|
+ info.filter("enuu", user.getEnterprise().getUu());
|
|
|
+ info.filter("usetype", (short)2);
|
|
|
} else {
|
|
|
- return addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(sysConf.getEnUU(), Type.Address_Shipping_Code.value(), (short)2);
|
|
|
+ info.filter("enuu", user.getUserUU());
|
|
|
+ info.filter("usetype", (short)1);
|
|
|
}
|
|
|
+ return getEnterprise(info);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -247,35 +249,20 @@ public class AddressServiceImpl implements AddressService {
|
|
|
* @return Page 返回Address的page对象
|
|
|
*/
|
|
|
@Override
|
|
|
- public Page<Address> getEnterpriseReceiveAddress(PageParams page) {
|
|
|
+ public Page<Address> getEnterpriseReceiveAddress(PageParams page, Boolean send) {
|
|
|
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);
|
|
|
+ if (send) {
|
|
|
+ info.filter("type", Type.Address_Sending_Code.value());
|
|
|
} else {
|
|
|
- info.filter("useruu", SystemSession.getUser().getUserUU());
|
|
|
- info.filter("usetype", (short)1);
|
|
|
+ info.filter("type", Type.Address_Shipping_Code.value());
|
|
|
}
|
|
|
- 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);
|
|
|
+ User user = SystemSession.getUser();
|
|
|
+ if (user.getEnterprise() != null) {
|
|
|
+ info.filter("enuu", user.getEnterprise().getUu());
|
|
|
+ info.filter("usetype", Address.USE_TYPE.Enterprise.getValue());
|
|
|
} else {
|
|
|
info.filter("useruu", SystemSession.getUser().getUserUU());
|
|
|
- info.filter("usetype", (short)1);
|
|
|
+ info.filter("usetype", Address.USE_TYPE.Personal.getValue());
|
|
|
}
|
|
|
return getEnterprise(info);
|
|
|
}
|
|
|
@@ -283,12 +270,12 @@ public class AddressServiceImpl implements AddressService {
|
|
|
@Override
|
|
|
public List<Address> findDefaultEnterpriseAddress(boolean bool) {
|
|
|
// boo判断查询的是收货地址还是发货地址(默认收货地址)
|
|
|
- if (bool) {
|
|
|
- return addressDao.findByEnuuAndTypeAndNumAndUsetypeOrderByNumAsc(SystemSession.getUser().getEnterprise().getUu(),
|
|
|
- Type.Address_Shipping_Code.value(), (int) Constant.YES, (short)2);
|
|
|
+ User user = SystemSession.getUser();
|
|
|
+ Integer type = bool ? Type.Address_Shipping_Code.value() : Type.Address_Sending_Code.value();
|
|
|
+ if (user.getEnterprise() == null) {
|
|
|
+ return addressDao.findByUseruuAndTypeAndNumAndUsetypeOrderByNumAsc(user.getEnterprise().getUu(), type, (int) Constant.YES, (short)1);
|
|
|
} else {
|
|
|
- return addressDao.findByEnuuAndTypeAndNumAndUsetypeOrderByNumAsc(SystemSession.getUser().getEnterprise().getUu(),
|
|
|
- Type.Address_Sending_Code.value(), (int) Constant.YES, (short)2);
|
|
|
+ return addressDao.findByEnuuAndTypeAndNumAndUsetypeOrderByNumAsc(user.getUserUU(), type, (int) Constant.YES, (short)2);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -300,23 +287,14 @@ public class AddressServiceImpl implements AddressService {
|
|
|
// 设置where条件
|
|
|
Long userUU = SystemSession.getUser().getUserUU();
|
|
|
Long enUU = SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu() : null;
|
|
|
- if (isSend) {
|
|
|
- pageInfo.expression(new SimpleExpression("type", Type.Address_Sending_Code.value(), CriterionExpression.Operator.EQ));
|
|
|
- if (enUU != null) {
|
|
|
- pageInfo.expression(new SimpleExpression("enuu", enUU, CriterionExpression.Operator.EQ));
|
|
|
- } else {
|
|
|
- pageInfo.expression(new SimpleExpression("dissociative", Type.PERSONAL.value(), CriterionExpression.Operator.EQ));
|
|
|
- }
|
|
|
- pageInfo.expression(new SimpleExpression("usetype", (short)2, CriterionExpression.Operator.EQ));
|
|
|
+ Integer type = isSend ? Type.Address_Sending_Code.value() : Type.Address_Shipping_Code.value();
|
|
|
+ pageInfo.expression(new SimpleExpression("type", type, CriterionExpression.Operator.EQ));
|
|
|
+ if (enUU != null) {
|
|
|
+ pageInfo.expression(new SimpleExpression("enuu", enUU, CriterionExpression.Operator.EQ));
|
|
|
+ pageInfo.expression(new SimpleExpression("usetype", Address.USE_TYPE.Enterprise.getValue(), CriterionExpression.Operator.EQ));
|
|
|
} else {
|
|
|
- pageInfo.expression(new SimpleExpression("type", Type.Address_Shipping_Code.value(), CriterionExpression.Operator.EQ));
|
|
|
+ pageInfo.expression(new SimpleExpression("usetype", Address.USE_TYPE.Personal.getValue(), CriterionExpression.Operator.EQ));
|
|
|
pageInfo.expression(new SimpleExpression("useruu", userUU, CriterionExpression.Operator.EQ));
|
|
|
- if (enUU != null) {
|
|
|
- pageInfo.expression(new SimpleExpression("enuu", enUU, CriterionExpression.Operator.EQ));
|
|
|
- } else {
|
|
|
- pageInfo.expression(new SimpleExpression("dissociative", Type.PERSONAL.value(), CriterionExpression.Operator.EQ));
|
|
|
- }
|
|
|
- pageInfo.expression(new SimpleExpression("usetype", (short)1, CriterionExpression.Operator.EQ));
|
|
|
}
|
|
|
// 获取查询数据
|
|
|
return addressDao.findAll(new Specification<Address>() {
|