Authored by mali

地址的调整

... ... @@ -114,4 +114,6 @@ public class BuyerOrderReq extends PageRequestBO{
private Integer clientType; //订单来源 1-PC,3-iphone, 4-android, 5-ipad, 6-h5, 7-miniapp
private Integer attributes; //订单类型 1-普通现货订单,2-线下店订单,3-急速发货订单,4-普通预售
private String area; // 四级地址
}
... ...
package com.yoho.ufo.order.service.impl;
import com.yoho.order.dal.AreaMapper;
import com.yoho.order.model.Area;
import org.elasticsearch.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Created by li.ma on 2019/4/26.
* 地址code 服务接口
*/
@Service
public class AreaService {
private static final Logger LOGGER = LoggerFactory.getLogger(AreaService.class);
@Autowired
private AreaMapper areaMapper;
public Map<Integer, String> selectByCodeList(List<Integer> codeList) {
List<Area> areaList = areaMapper.selectByCodeList(codeList);
Map<Integer, String> areaMap = areaList.stream().collect(Collectors.toMap(Area::getId, Area::getCaption));
return areaMap;
}
public Map<Integer, String> selectByParentCode(String parentCode) {
List<Area> areaList = areaMapper.selectByParentCode(parentCode);
return areaList.stream().collect(Collectors.toMap(Area::getId, Area::getCaption));
}
}
... ...
... ... @@ -98,7 +98,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
private AppraiseAddressMapper appraiseAddressMapper;
@Autowired
private AreaMapper areaMapper;
private AreaService areaService;
@Autowired
private OrderOperateRecordMapper orderOperateRecordMapper;
... ... @@ -1351,7 +1351,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
result.setPlatformWaybillTitle("发货信息");
result.setReceiveName(metaValue.getString("consignee"));
result.setReceiveMobile(metaValue.getString("mobile"));
result.setReceiveAddress(getAddressInfo(metaValue.getString("areaCode")) + metaValue.getString("address"));
result.setReceiveAddress(metaValue.getString("area") + metaValue.getString("address"));
ExpressRecord record = expressRecordMapper.selectByOrderCodeAndType(req.getOrderCode(), null, EXPRESS_TYPE_JUDGE_TO_BUYER);
if(null == record) {
return result;
... ... @@ -1434,7 +1434,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
result.setPlatformWaybillTitle("寄回信息");
result.setReceiveName(metaValue.getString("consignee"));
result.setReceiveMobile(metaValue.getString("mobile"));
result.setReceiveAddress(getAddressInfo(metaValue.getString("areaCode")) + metaValue.getString("address"));
result.setReceiveAddress(metaValue.getString("area") + metaValue.getString("address"));
if(StringUtils.isEmpty(req.getOrderCode())) {
return result;
... ... @@ -1506,7 +1506,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
resp.setReceiveAddressDetail(metaValue.getString("address"));
resp.setZipCode("null".equals(metaValue.getString("zipCode")) ? "--" : metaValue.getString("zipCode"));
String receiveAddressCode = metaValue.getString("areaCode");
resp.setReceiveAddress(getAddressInfo(receiveAddressCode));
resp.setReceiveAddress(metaValue.getString("area"));
//查询buyer_order_goods
List<BuyerOrderGoods> goodsList = buyerOrderGoodsMapper.selectByOrderCode(Lists.newArrayList(buyerOrder.getOrderCode()));
... ... @@ -1526,7 +1526,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
if(sellerMeta!=null){
JSONObject sellerMetaValue = JSONObject.parseObject(sellerMeta.getMetaValue());
resp.setSellerRebackAddressDetail(sellerMetaValue.getString("address"));
resp.setSellerRebackAddress(getAddressInfo(sellerMetaValue.getString("areaCode")));
resp.setSellerRebackAddress(sellerMetaValue.getString("area"));
resp.setSellerRebackMobile(sellerMetaValue.getString("mobile"));
resp.setSellerZipCode("null".equals(sellerMetaValue.getString("zipCode")) ? "--" : sellerMetaValue.getString("zipCode"));
}
... ... @@ -1853,8 +1853,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
Integer secondId = Integer.valueOf(areaCode.substring(0, 4));
Integer thirdId = Integer.valueOf(areaCode.substring(0, 6));
Integer fourthId = Integer.valueOf(areaCode);
List<Area> areaList = areaMapper.selectByCodeList(Lists.newArrayList(firstId, secondId, thirdId, fourthId));
Map<Integer, String> areaMap = areaList.stream().collect(Collectors.toMap(Area::getId, Area::getCaption));
Map<Integer, String> areaMap = areaService.selectByCodeList(Lists.newArrayList(firstId, secondId, thirdId, fourthId));
String dProvince = areaMap.get(firstId).replace("省", "").replace("市", "");
jsonObj.put("dProvince", dProvince);
jsonObj.put("dCity", areaMap.get(secondId).replace("市", ""));
... ... @@ -1902,7 +1901,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
resp.setReceiveMobile(metaValue.getString("mobile"));
resp.setReceiveAddressDetail(metaValue.getString("address"));
String receiveAddressCode = metaValue.getString("areaCode");
resp.setReceiveAddress(getAddressInfo(receiveAddressCode));
resp.setReceiveAddress(metaValue.getString("area"));
}
if(buyerOrder.getStatus().byteValue() == Constant.BUYER_ORDER_STATUS_JUDGE_NOT_PASS.getByteVal()) {
... ... @@ -1912,7 +1911,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
if(sellerMeta!=null){
JSONObject sellerMetaValue = JSONObject.parseObject(sellerMeta.getMetaValue());
resp.setSellerRebackAddressDetail(sellerMetaValue.getString("address"));
resp.setSellerRebackAddress(getAddressInfo(sellerMetaValue.getString("areaCode")));
resp.setSellerRebackAddress(sellerMetaValue.getString("area"));
resp.setSellerRebackMobile(sellerMetaValue.getString("mobile"));
}
}
... ... @@ -2154,16 +2153,14 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return Lists.newArrayList();
}
List<Area> areaList = areaMapper.selectByParentCode(parentCode);
List<JSONObject> result = new ArrayList<>();
for (Area area : areaList) {
JSONObject jo = new JSONObject();
// 地区
jo.put("id", area.getId());
jo.put("caption", area.getCaption());
result.add(jo);
}
Map<Integer, String> stringMap = areaService.selectByParentCode(parentCode);
List<JSONObject> result = new ArrayList<>();
for (Map.Entry<Integer, String> item : stringMap.entrySet()) {
JSONObject jo = new JSONObject();
jo.put("id", item.getKey());
jo.put("caption", item.getValue()); // 地区
result.add(jo);
}
return result;
}
... ... @@ -2237,7 +2234,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
metaValue.replace("address", req.getReceiveAddressDetail());
metaValue.replace("zipCode", req.getReceiveZipCode());
metaValue.replace("areaCode", req.getReceiveAreaCode());
metaValue.replace("area", getAddressInfo(req.getReceiveAreaCode()));
metaValue.replace("area", req.getArea());
BuyerOrderMetaUpdateReq metaReq = new BuyerOrderMetaUpdateReq();
metaReq.setOrderCode(Long.valueOf(req.getOrderCode()));
... ... @@ -2272,7 +2269,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
orderOperateRecordMapper.insert(optRecord);
}
private String getAddressInfo(String areaCode) {
/*private String getAddressInfo(String areaCode) {
//查询四级地址,比如id=110102001:北京市北京市西城区西长安街街道办事处,11-北京市, 1101-北京市, 110102-西城区 110102001-西长安街街道办事处
Integer firstId = Integer.valueOf(areaCode.substring(0, 2));
Integer secondId = Integer.valueOf(areaCode.substring(0, 4));
... ... @@ -2281,7 +2278,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
List<Area> areaList = areaMapper.selectByCodeList(Lists.newArrayList(firstId, secondId, thirdId, fourthId));
Map<Integer, String> areaMap = areaList.stream().collect(Collectors.toMap(Area::getId, Area::getCaption));
return areaMap.get(firstId) + " " + areaMap.get(secondId) + " " + areaMap.get(thirdId) + " " + areaMap.get(fourthId);
}
}*/
private String getMobileByUid(Integer uid) {
LOGGER.info("call getMobileByUid uid is{}", uid);
... ... @@ -2455,8 +2452,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
resp.setReceiveName(metaValue.getString("consignee"));
resp.setReceiveMobile(metaValue.getString("mobile"));
String receiveAddressCode = metaValue.getString("areaCode");
resp.setReceiveAddress(getAddressInfo(receiveAddressCode));
resp.setNfcStatus(CollectionUtils.isEmpty(identifyMap.get(item.getOrderCode())) ? 0 : 1);//0:未写入,1:已写入
resp.setReceiveAddress(metaValue.getString("area"));
resp.setNfcStatus(CollectionUtils.isEmpty(identifyMap.get(item.getOrderCode())) ? 0 : 1);//0:未写入,1:已写入
respList.add(resp);
}
... ...
... ... @@ -257,6 +257,7 @@ function updateOrderInfo(orderCode){
var receiveAddressDetail = $("#input_receiveAddressDetail").val();
var receiveZipCode = $("#input_zipCode").val();
var receiveAreaCode = $("#jiedao").combobox('getValue');
var area = $("#sheng").combobox('getText') + ' ' + $("#shi").combobox('getText') + ' ' + $("#quxian").combobox('getText') + ' ' + $("#jiedao").combobox('getText');
if(receiveName == '' || receiveMobile == '' || receiveAddressDetail == '' || receiveAreaCode == ''){
alert("收货人姓名,手机号码,收货地址,详细地址不能有空值!");
return;
... ... @@ -268,7 +269,8 @@ function updateOrderInfo(orderCode){
receiveAddressDetail : receiveAddressDetail,
receiveZipCode : receiveZipCode,
receiveAreaCode : receiveAreaCode,
sellerWaybillCode : sellerWaybillCode
sellerWaybillCode : sellerWaybillCode,
area : area
}, function(data) {
if (data.code == 200) {
getOrderInfo(orderCode);
... ...