|
@@ -17,7 +17,6 @@ import com.alibaba.fastjson.JSONArray; |
|
@@ -17,7 +17,6 @@ import com.alibaba.fastjson.JSONArray; |
17
|
import com.alibaba.fastjson.JSONObject;
|
17
|
import com.alibaba.fastjson.JSONObject;
|
18
|
import com.yoho.error.ServiceError;
|
18
|
import com.yoho.error.ServiceError;
|
19
|
import com.yoho.error.exception.ServiceException;
|
19
|
import com.yoho.error.exception.ServiceException;
|
20
|
-import com.yoho.global.common.cache.Cachable;
|
|
|
21
|
import com.yoho.global.common.cache.CacheEnum;
|
20
|
import com.yoho.global.common.cache.CacheEnum;
|
22
|
import com.yoho.global.common.cache.CacheRedis;
|
21
|
import com.yoho.global.common.cache.CacheRedis;
|
23
|
import com.yoho.global.common.rest.client.YHMethodContants;
|
22
|
import com.yoho.global.common.rest.client.YHMethodContants;
|
|
@@ -48,7 +47,13 @@ public class AddressServiceImpl implements AddressService { |
|
@@ -48,7 +47,13 @@ public class AddressServiceImpl implements AddressService { |
48
|
public JSONObject addAddress(AddressBO addressBo) {
|
47
|
public JSONObject addAddress(AddressBO addressBo) {
|
49
|
//校验入参
|
48
|
//校验入参
|
50
|
validGlobalBuyAddressRequest(addressBo);
|
49
|
validGlobalBuyAddressRequest(addressBo);
|
51
|
-
|
50
|
+
|
|
|
51
|
+ // 验证身份证号码
|
|
|
52
|
+ if(!IDCardUtil.isIDCard(addressBo.getCardNumber())) {
|
|
|
53
|
+ logger.warn("globalbuy address params invalid, cardId: {}", addressBo.getCardNumber());
|
|
|
54
|
+ throw new ServiceException(ServiceError.GLOBALBUY_ADDRESS_IDCARD_INVALID);
|
|
|
55
|
+ }
|
|
|
56
|
+
|
52
|
//1、添加收货地址
|
57
|
//1、添加收货地址
|
53
|
Map<String, String> params = new HashMap<String, String>();
|
58
|
Map<String, String> params = new HashMap<String, String>();
|
54
|
params.put("uid", String.valueOf(addressBo.getUid()));
|
59
|
params.put("uid", String.valueOf(addressBo.getUid()));
|
|
@@ -92,11 +97,7 @@ public class AddressServiceImpl implements AddressService { |
|
@@ -92,11 +97,7 @@ public class AddressServiceImpl implements AddressService { |
92
|
throw new ServiceException(ServiceError.GLOBALBUY_ADDRESS_MOBILE_INVALID);
|
97
|
throw new ServiceException(ServiceError.GLOBALBUY_ADDRESS_MOBILE_INVALID);
|
93
|
}
|
98
|
}
|
94
|
}
|
99
|
}
|
95
|
-
|
|
|
96
|
- if(!IDCardUtil.isIDCard(addressBo.getCardNumber())) {
|
|
|
97
|
- logger.warn("globalbuy address params invalid, cardId: {}", addressBo.getCardNumber());
|
|
|
98
|
- throw new ServiceException(ServiceError.GLOBALBUY_ADDRESS_IDCARD_INVALID);
|
|
|
99
|
- }
|
100
|
+
|
100
|
}
|
101
|
}
|
101
|
|
102
|
|
102
|
/**
|
103
|
/**
|
|
@@ -134,9 +135,24 @@ public class AddressServiceImpl implements AddressService { |
|
@@ -134,9 +135,24 @@ public class AddressServiceImpl implements AddressService { |
134
|
public JSONObject editAddress(AddressBO addressBo) {
|
135
|
public JSONObject editAddress(AddressBO addressBo) {
|
135
|
//校验入参
|
136
|
//校验入参
|
136
|
validGlobalBuyAddressRequest(addressBo);
|
137
|
validGlobalBuyAddressRequest(addressBo);
|
137
|
-
|
138
|
+ TblCustomerIdcard customerIdcard = idCardMapper.selectByUidAndAddressId(addressBo.getUid(),addressBo.getAddressId());
|
|
|
139
|
+ // 验证身份证号码
|
|
|
140
|
+ if(addressBo.getCardNumber() == null || addressBo.getCardNumber().contains( "*" )){
|
|
|
141
|
+ if(customerIdcard == null){
|
|
|
142
|
+ logger.warn("globalbuy address params invalid, cardId: {}", addressBo.getCardNumber());
|
|
|
143
|
+ throw new ServiceException(ServiceError.GLOBALBUY_ADDRESS_IDCARD_INVALID);
|
|
|
144
|
+ }
|
|
|
145
|
+ // 不修改身份证号码
|
|
|
146
|
+ addressBo.setCardNumber( null );
|
|
|
147
|
+ } else {
|
|
|
148
|
+ if(!IDCardUtil.isIDCard(addressBo.getCardNumber())) {
|
|
|
149
|
+ logger.warn("globalbuy address params invalid, cardId: {}", addressBo.getCardNumber());
|
|
|
150
|
+ throw new ServiceException(ServiceError.GLOBALBUY_ADDRESS_IDCARD_INVALID);
|
|
|
151
|
+ }
|
|
|
152
|
+ }
|
|
|
153
|
+
|
138
|
//1、添加收货地址
|
154
|
//1、添加收货地址
|
139
|
- Map<String, String> params = new HashMap<String, String>();
|
155
|
+ Map<String, String> params = new HashMap<>();
|
140
|
params.put("id", String.valueOf(addressBo.getAddressId()));
|
156
|
params.put("id", String.valueOf(addressBo.getAddressId()));
|
141
|
params.put("uid", String.valueOf(addressBo.getUid()));
|
157
|
params.put("uid", String.valueOf(addressBo.getUid()));
|
142
|
params.put("address", addressBo.getAddress());
|
158
|
params.put("address", addressBo.getAddress());
|
|
@@ -145,12 +161,16 @@ public class AddressServiceImpl implements AddressService { |
|
@@ -145,12 +161,16 @@ public class AddressServiceImpl implements AddressService { |
145
|
params.put("consignee", addressBo.getConsignee());
|
161
|
params.put("consignee", addressBo.getConsignee());
|
146
|
JSONObject addressJson = yhRestCaller.yhbGetMethod(YHMethodContants.YH_ADDRESS_EDIT, params, JSONObject.class);
|
162
|
JSONObject addressJson = yhRestCaller.yhbGetMethod(YHMethodContants.YH_ADDRESS_EDIT, params, JSONObject.class);
|
147
|
logger.info("edit globalbuy address to yohobuy: {}", addressJson);
|
163
|
logger.info("edit globalbuy address to yohobuy: {}", addressJson);
|
148
|
-
|
|
|
149
|
- Map<String, String> idCardInfos = addIDCard(addressBo, addressBo.getAddressId());
|
164
|
+
|
|
|
165
|
+ Map<String, String> idCardInfos;
|
|
|
166
|
+ if(customerIdcard == null){
|
|
|
167
|
+ idCardInfos = addIDCard(addressBo, addressBo.getAddressId());
|
|
|
168
|
+ } else {
|
|
|
169
|
+ idCardInfos = updateIDCard(addressBo, customerIdcard);
|
|
|
170
|
+ }
|
150
|
addressJson.putAll(idCardInfos);
|
171
|
addressJson.putAll(idCardInfos);
|
151
|
addressJson.put("address_id", addressBo.getAddressId());
|
172
|
addressJson.put("address_id", addressBo.getAddressId());
|
152
|
addressJson.put("user_id", addressBo.getUid());
|
173
|
addressJson.put("user_id", addressBo.getUid());
|
153
|
-
|
|
|
154
|
clearAddressCache(addressBo.getUid());
|
174
|
clearAddressCache(addressBo.getUid());
|
155
|
return addressJson;
|
175
|
return addressJson;
|
156
|
}
|
176
|
}
|
|
@@ -167,6 +187,36 @@ public class AddressServiceImpl implements AddressService { |
|
@@ -167,6 +187,36 @@ public class AddressServiceImpl implements AddressService { |
167
|
return respData;
|
187
|
return respData;
|
168
|
}
|
188
|
}
|
169
|
|
189
|
|
|
|
190
|
+ /**
|
|
|
191
|
+ * 全球购身份证入库
|
|
|
192
|
+ * @param addressBo
|
|
|
193
|
+ * @param idCardRecord
|
|
|
194
|
+ * @return
|
|
|
195
|
+ */
|
|
|
196
|
+ private Map<String, String> updateIDCard(AddressBO addressBo, TblCustomerIdcard idCardRecord) {
|
|
|
197
|
+ if(StringUtils.isNotEmpty( addressBo.getCardNumber() )){
|
|
|
198
|
+ idCardRecord.setCardNumber(addressBo.getCardNumber());
|
|
|
199
|
+ }
|
|
|
200
|
+
|
|
|
201
|
+ //必须正反面都有才可以存入
|
|
|
202
|
+ String cardPositive = addressBo.getCardPosition();
|
|
|
203
|
+ String cardNegative = addressBo.getCardNegative();
|
|
|
204
|
+ if(StringUtils.isBlank(cardPositive) || StringUtils.isBlank(cardNegative)) {
|
|
|
205
|
+ cardPositive = "";
|
|
|
206
|
+ cardNegative = "";
|
|
|
207
|
+ }
|
|
|
208
|
+ idCardRecord.setCardPositive(cardPositive);
|
|
|
209
|
+ idCardRecord.setCardNegative(cardNegative);
|
|
|
210
|
+
|
|
|
211
|
+ idCardMapper.updateByPrimaryKeySelective(idCardRecord);
|
|
|
212
|
+
|
|
|
213
|
+ Map<String, String> retMap = formatIdCardRecord(idCardRecord);
|
|
|
214
|
+
|
|
|
215
|
+ clearAddressCache(addressBo.getUid());
|
|
|
216
|
+ logger.info("add IDCard info end: {}", retMap);
|
|
|
217
|
+ return retMap;
|
|
|
218
|
+ }
|
|
|
219
|
+
|
170
|
@Override
|
220
|
@Override
|
171
|
//@Cachable(key="globalbuy:order:addressList:{}", expire=300, includeArgs={0}) //不要缓存,依赖user缓存
|
221
|
//@Cachable(key="globalbuy:order:addressList:{}", expire=300, includeArgs={0}) //不要缓存,依赖user缓存
|
172
|
public JSONArray getAddressList(int uid) {
|
222
|
public JSONArray getAddressList(int uid) {
|