|
|
@@ -75,48 +75,48 @@ public class AddressServiceImpl implements AddressService {
|
|
|
Long useruu = address.getUseruu();
|
|
|
int type = address.getType();
|
|
|
List<Address> addresses = null;
|
|
|
- if(useruu != null) {
|
|
|
+ if (Type.Address_Shipping_Code.value() == address.getType()) {
|
|
|
addresses = addressDao.findByUseruuAndEnuuAndTypeAndUsetypeOrderByNumAsc(useruu, address.getEnuu(), type, (short)1);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
addresses = addressDao.findByEnuuAndTypeAndUsetypeOrderByNumAsc(address.getEnuu(), type, (short)2);
|
|
|
}
|
|
|
int num = 1;
|
|
|
- long modifyId = address.getId().longValue();
|
|
|
- int modifyNum = address.getNum().intValue();
|
|
|
- if (setTop){
|
|
|
+ long modifyId = address.getId();
|
|
|
+ int modifyNum = address.getNum();
|
|
|
+ if (setTop) {
|
|
|
for (Address add : addresses) {
|
|
|
- if (add.getId().longValue() == modifyId) {
|
|
|
+ if (add.getId() == modifyId) {
|
|
|
add.setNum(1);
|
|
|
} else {
|
|
|
// 这里拿到的已经是排序了的,直接依次设置num即可
|
|
|
add.setNum(++num);
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
- if (modifyNum == 1){ //取消默认地址
|
|
|
+ } else {
|
|
|
+ if (modifyNum == 1) { //取消默认地址
|
|
|
for (Address add : addresses) { //空出默认地址位置
|
|
|
add.setNum(++num);
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
int firstNum = addresses.get(0).getNum();
|
|
|
- if (firstNum == 1){ //有默认地址情况
|
|
|
+ if (firstNum == 1) { //有默认地址情况
|
|
|
num++; //空出默认地址位置
|
|
|
for (Address add : addresses) {
|
|
|
- if (add.getNum() != 1){
|
|
|
- if (add.getId().longValue() != modifyId){
|
|
|
+ if (add.getNum() != 1) {
|
|
|
+ if (add.getId() != modifyId) {
|
|
|
//不是修改的地址或者默认地址,则重新排序
|
|
|
add.setNum(++num);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
add.setNum(2);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }else { //没有默认地址情况
|
|
|
+ } else { //没有默认地址情况
|
|
|
num++; //空出默认地址位置
|
|
|
for (Address add : addresses) {
|
|
|
- if (add.getId().longValue() != modifyId){
|
|
|
+ if (add.getId() != modifyId) {
|
|
|
add.setNum(++num);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
add.setNum(2);
|
|
|
}
|
|
|
}
|