...
|
...
|
@@ -17,7 +17,6 @@ import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yoho.global.common.cache.Cachable;
|
|
|
import com.yoho.global.common.cache.CacheEnum;
|
|
|
import com.yoho.global.common.cache.CacheRedis;
|
|
|
import com.yoho.global.common.rest.client.YHMethodContants;
|
...
|
...
|
@@ -48,7 +47,13 @@ public class AddressServiceImpl implements AddressService { |
|
|
public JSONObject addAddress(AddressBO addressBo) {
|
|
|
//校验入参
|
|
|
validGlobalBuyAddressRequest(addressBo);
|
|
|
|
|
|
|
|
|
// 验证身份证号码
|
|
|
if(!IDCardUtil.isIDCard(addressBo.getCardNumber())) {
|
|
|
logger.warn("globalbuy address params invalid, cardId: {}", addressBo.getCardNumber());
|
|
|
throw new ServiceException(ServiceError.GLOBALBUY_ADDRESS_IDCARD_INVALID);
|
|
|
}
|
|
|
|
|
|
//1、添加收货地址
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("uid", String.valueOf(addressBo.getUid()));
|
...
|
...
|
@@ -92,11 +97,7 @@ public class AddressServiceImpl implements AddressService { |
|
|
throw new ServiceException(ServiceError.GLOBALBUY_ADDRESS_MOBILE_INVALID);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(!IDCardUtil.isIDCard(addressBo.getCardNumber())) {
|
|
|
logger.warn("globalbuy address params invalid, cardId: {}", addressBo.getCardNumber());
|
|
|
throw new ServiceException(ServiceError.GLOBALBUY_ADDRESS_IDCARD_INVALID);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -134,9 +135,24 @@ public class AddressServiceImpl implements AddressService { |
|
|
public JSONObject editAddress(AddressBO addressBo) {
|
|
|
//校验入参
|
|
|
validGlobalBuyAddressRequest(addressBo);
|
|
|
|
|
|
TblCustomerIdcard customerIdcard = idCardMapper.selectByUidAndAddressId(addressBo.getUid(),addressBo.getAddressId());
|
|
|
// 验证身份证号码
|
|
|
if(addressBo.getCardNumber() == null || addressBo.getCardNumber().contains( "*" )){
|
|
|
if(customerIdcard == null){
|
|
|
logger.warn("globalbuy address params invalid, cardId: {}", addressBo.getCardNumber());
|
|
|
throw new ServiceException(ServiceError.GLOBALBUY_ADDRESS_IDCARD_INVALID);
|
|
|
}
|
|
|
// 不修改身份证号码
|
|
|
addressBo.setCardNumber( null );
|
|
|
} else {
|
|
|
if(!IDCardUtil.isIDCard(addressBo.getCardNumber())) {
|
|
|
logger.warn("globalbuy address params invalid, cardId: {}", addressBo.getCardNumber());
|
|
|
throw new ServiceException(ServiceError.GLOBALBUY_ADDRESS_IDCARD_INVALID);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//1、添加收货地址
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("id", String.valueOf(addressBo.getAddressId()));
|
|
|
params.put("uid", String.valueOf(addressBo.getUid()));
|
|
|
params.put("address", addressBo.getAddress());
|
...
|
...
|
@@ -145,12 +161,16 @@ public class AddressServiceImpl implements AddressService { |
|
|
params.put("consignee", addressBo.getConsignee());
|
|
|
JSONObject addressJson = yhRestCaller.yhbGetMethod(YHMethodContants.YH_ADDRESS_EDIT, params, JSONObject.class);
|
|
|
logger.info("edit globalbuy address to yohobuy: {}", addressJson);
|
|
|
|
|
|
Map<String, String> idCardInfos = addIDCard(addressBo, addressBo.getAddressId());
|
|
|
|
|
|
Map<String, String> idCardInfos;
|
|
|
if(customerIdcard == null){
|
|
|
idCardInfos = addIDCard(addressBo, addressBo.getAddressId());
|
|
|
} else {
|
|
|
idCardInfos = updateIDCard(addressBo, customerIdcard);
|
|
|
}
|
|
|
addressJson.putAll(idCardInfos);
|
|
|
addressJson.put("address_id", addressBo.getAddressId());
|
|
|
addressJson.put("user_id", addressBo.getUid());
|
|
|
|
|
|
clearAddressCache(addressBo.getUid());
|
|
|
return addressJson;
|
|
|
}
|
...
|
...
|
@@ -167,6 +187,36 @@ public class AddressServiceImpl implements AddressService { |
|
|
return respData;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 全球购身份证入库
|
|
|
* @param addressBo
|
|
|
* @param idCardRecord
|
|
|
* @return
|
|
|
*/
|
|
|
private Map<String, String> updateIDCard(AddressBO addressBo, TblCustomerIdcard idCardRecord) {
|
|
|
if(StringUtils.isNotEmpty( addressBo.getCardNumber() )){
|
|
|
idCardRecord.setCardNumber(addressBo.getCardNumber());
|
|
|
}
|
|
|
|
|
|
//必须正反面都有才可以存入
|
|
|
String cardPositive = addressBo.getCardPosition();
|
|
|
String cardNegative = addressBo.getCardNegative();
|
|
|
if(StringUtils.isBlank(cardPositive) || StringUtils.isBlank(cardNegative)) {
|
|
|
cardPositive = "";
|
|
|
cardNegative = "";
|
|
|
}
|
|
|
idCardRecord.setCardPositive(cardPositive);
|
|
|
idCardRecord.setCardNegative(cardNegative);
|
|
|
|
|
|
idCardMapper.updateByPrimaryKeySelective(idCardRecord);
|
|
|
|
|
|
Map<String, String> retMap = formatIdCardRecord(idCardRecord);
|
|
|
|
|
|
clearAddressCache(addressBo.getUid());
|
|
|
logger.info("add IDCard info end: {}", retMap);
|
|
|
return retMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
//@Cachable(key="globalbuy:order:addressList:{}", expire=300, includeArgs={0}) //不要缓存,依赖user缓存
|
|
|
public JSONArray getAddressList(int uid) {
|
...
|
...
|
|