...
|
...
|
@@ -14,7 +14,6 @@ import java.util.stream.Collectors; |
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import com.yoho.ufo.order.request.SaveQualityCheckInfoRequest;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.elasticsearch.common.collect.Lists;
|
...
|
...
|
@@ -51,6 +50,7 @@ import com.yoho.order.dal.QualityCheckMapper; |
|
|
import com.yoho.order.dal.SellerOrderGoodsMapper;
|
|
|
import com.yoho.order.dal.SellerOrderMapper;
|
|
|
import com.yoho.order.dal.SellerOrderMetaMapper;
|
|
|
import com.yoho.order.model.AppraiseAddress;
|
|
|
import com.yoho.order.model.Area;
|
|
|
import com.yoho.order.model.BuyerOrder;
|
|
|
import com.yoho.order.model.BuyerOrderFeedback;
|
...
|
...
|
@@ -75,11 +75,13 @@ import com.yoho.ufo.dal.ProductMapper; |
|
|
import com.yoho.ufo.dal.model.IdentifyRecords;
|
|
|
import com.yoho.ufo.dal.model.Product;
|
|
|
import com.yoho.ufo.order.constant.Constant;
|
|
|
import com.yoho.ufo.order.request.SaveQualityCheckInfoRequest;
|
|
|
import com.yoho.ufo.order.service.IBuyerOrderService;
|
|
|
import com.yoho.ufo.service.impl.UserHelper;
|
|
|
import com.yoho.ufo.service.model.PageResponseBO;
|
|
|
import com.yoho.ufo.util.ImagesConstant;
|
|
|
import com.yoho.ufo.util.ImagesHelper;
|
|
|
import com.yoho.ufo.util.MobileHelper;
|
|
|
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
|
|
|
import com.yohobuy.ufo.model.order.common.EnumExpressType;
|
|
|
import com.yohobuy.ufo.model.order.common.EnumQualityCheckStatus;
|
...
|
...
|
@@ -188,6 +190,14 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
@Resource(name="restTemplate")
|
|
|
RestTemplate restTemplate;
|
|
|
|
|
|
//南京月结账号
|
|
|
// private static final String NANJING_CUSTID = "0255045253";
|
|
|
private static final String NANJING_CUSTID = "9999999999";
|
|
|
|
|
|
//北京月结账号
|
|
|
// private static final String BEIJING_CUSTID = "0100026158";
|
|
|
private static final String BEIJING_CUSTID = "9999999999";
|
|
|
|
|
|
//已收货
|
|
|
private static final Byte QC_STATUS_RECEIVED = 0;
|
|
|
|
...
|
...
|
@@ -1585,9 +1595,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
// @Override
|
|
|
public String getSfWaybillCode(String orderCode) {
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
|
|
|
@Override
|
|
|
public JSONObject getSfWaybillCode(BuyerOrderReq req) {
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(req.getOrderCode());
|
|
|
if(null == buyerOrder) {
|
|
|
return null;
|
|
|
}
|
...
|
...
|
@@ -1608,25 +1618,68 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
|
|
|
SellerOrderGoods sellerGoods = sellerGoodsList.get(0);
|
|
|
|
|
|
AppraiseAddress appraiseAddress = appraiseAddressMapper.selectByType(sellerGoods.getDepotNo());
|
|
|
|
|
|
String url = erpDomain + PlatformConstant.ERP_GET_SF_WAYBILLCODE;
|
|
|
HttpHeaders headers = getHttpHeaders();
|
|
|
HttpEntity<String> formEntity = getStringHttpEntity(buyerOrder, sellerGoods, headers);
|
|
|
|
|
|
ResponseEntity<Object> responseResponseEntity = restTemplate.postForEntity(url, formEntity, Object.class);
|
|
|
Map<String, Object> body = (Map<String, Object>) responseResponseEntity.getBody();
|
|
|
|
|
|
return null;
|
|
|
JSONObject jsonReqObj = getStringHttpEntity(buyerOrder, sellerGoods, appraiseAddress.getAddress(), skup, req.getPayMethod());
|
|
|
HttpEntity<String> formEntity = new HttpEntity<>(jsonReqObj.toString(), getHttpHeaders());
|
|
|
|
|
|
ResponseEntity<JSONObject> responseResponseEntity = restTemplate.postForEntity(url, formEntity, JSONObject.class);
|
|
|
JSONObject body = responseResponseEntity.getBody();
|
|
|
LOGGER.info("erp result is {}", body);
|
|
|
int code = body.getIntValue("code");
|
|
|
if(code != 200) {
|
|
|
return body;
|
|
|
}
|
|
|
|
|
|
Product product = productMapper.selectByPrimaryKey(sellerGoods.getProductId());
|
|
|
|
|
|
JSONObject data = body.getJSONObject("data");
|
|
|
data.put("createTime", DateUtil.getcurrentDateTime());
|
|
|
data.put("dContact", jsonReqObj.getString("dContact"));
|
|
|
data.put("dMobile", MobileHelper.coverMobile(jsonReqObj.getString("dMobile")));
|
|
|
data.put("dProvince", jsonReqObj.getString("dProvince"));
|
|
|
data.put("dCity", jsonReqObj.getString("dCity"));
|
|
|
data.put("dDistrict", jsonReqObj.getString("dDistrict"));
|
|
|
data.put("dAddress", jsonReqObj.getString("dAddress"));
|
|
|
data.put("jContact", "UFO鉴定中心");
|
|
|
data.put("jMobile", MobileHelper.coverMobile(appraiseAddress.getMobile()));
|
|
|
data.put("jProvince", jsonReqObj.getString("jProvince"));
|
|
|
data.put("jCity", jsonReqObj.getString("jCity"));
|
|
|
data.put("jDistrict", jsonReqObj.getString("jDistrict"));
|
|
|
data.put("jAddress", jsonReqObj.getString("jAddress"));
|
|
|
data.put("orderCode", buyerOrder.getOrderCode());
|
|
|
data.put("productCode", product.getProductCode());
|
|
|
data.put("sizeName", sellerGoods.getSizeName());
|
|
|
data.put("shipFee", "**元");
|
|
|
data.put("amount", "**元");
|
|
|
data.put("businessType", data.getString("proCode").equals("T6") ? "顺丰特惠" : "标准快递");
|
|
|
data.put("custid", "***");
|
|
|
|
|
|
//建立订单与运单号的关联
|
|
|
String receiverType = jsonReqObj.getString("receiverType");
|
|
|
BuyerOrderReq relationReq = new BuyerOrderReq();
|
|
|
relationReq.setOrderCode(buyerOrder.getOrderCode());
|
|
|
relationReq.setWaybillCode(data.getString("mailNo"));
|
|
|
relationReq.setExpressCompanyId(23);//顺丰
|
|
|
relationReq.setDepotNo(sellerGoods.getDepotNo());
|
|
|
relationReq.setMobile(jsonReqObj.getString("dMobile"));
|
|
|
if(receiverType.equals("buyer")) {
|
|
|
deliveryGoodsToBuyer(relationReq);
|
|
|
}else if(receiverType.equals("seller")) {
|
|
|
sendBackGoodsToSeller(relationReq);
|
|
|
}
|
|
|
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
private HttpEntity<String> getStringHttpEntity(BuyerOrder buyerOrder, SellerOrderGoods sellerGoods, HttpHeaders headers) {
|
|
|
private JSONObject getStringHttpEntity(BuyerOrder buyerOrder, SellerOrderGoods sellerGoods, String appraiseAddress, Integer skup, Integer payMethod) {
|
|
|
JSONObject jsonObj = new JSONObject();
|
|
|
jsonObj.put("orderCode", buyerOrder.getOrderCode());
|
|
|
jsonObj.put("uid", buyerOrder.getUid());
|
|
|
|
|
|
Integer depotNo = sellerGoods.getDepotNo();
|
|
|
String platformAddress = appraiseAddressMapper.selectAddressByType(depotNo);
|
|
|
Map<String, String> addressMap = subAddress(platformAddress);
|
|
|
Map<String, String> addressMap = subAddress(appraiseAddress);
|
|
|
|
|
|
//寄件人信息
|
|
|
jsonObj.put("jCompany", "Yoho!Buy有货");
|
...
|
...
|
@@ -1636,23 +1689,68 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
jsonObj.put("jCountry", "中国");
|
|
|
jsonObj.put("jProvince", addressMap.get("province"));
|
|
|
jsonObj.put("jCity", addressMap.get("city"));
|
|
|
jsonObj.put("jDistrict", addressMap.get("district"));
|
|
|
jsonObj.put("jAddress", addressMap.get("address"));
|
|
|
jsonObj.put("expressType", 2);//快件产品类型 1:标准快递 2:顺丰特惠(便宜,全程陆运)
|
|
|
jsonObj.put("payMethod", payMethod);//1:寄方付 2:收方付 3:第三方付
|
|
|
jsonObj.put("businessCode", "UFO");
|
|
|
jsonObj.put("custid", sellerGoods.getDepotNo().intValue() == 0 ? BEIJING_CUSTID : NANJING_CUSTID);
|
|
|
|
|
|
//收件人信息
|
|
|
if(buyerOrder.getStatus().equals(Constant.BUYER_ORDER_STATUS_JUDGE_PASS.getByteVal())
|
|
|
|| buyerOrder.getStatus().equals(Constant.BUYER_ORDER_STATUS_MINI_FAULT_ACCEPT.getByteVal())) {//收件人为买家
|
|
|
BuyerOrderMeta buyerMeta = buyerOrderMetaMapper.selectByOrderCodeAndKey(buyerOrder.getOrderCode(), BUYER_ORDER_META_KEY_DELIVERY_ADDRESS);
|
|
|
JSONObject metaValue = JSONObject.parseObject(buyerMeta.getMetaValue());
|
|
|
buildAddressInfo(metaValue, jsonObj);
|
|
|
jsonObj.put("receiverType", "buyer");
|
|
|
}else if(buyerOrder.getStatus().equals(Constant.BUYER_ORDER_STATUS_JUDGE_NOT_PASS.getByteVal())
|
|
|
|| buyerOrder.getStatus().equals(Constant.BUYER_ORDER_STATUS_BUYER_CANCEL_AFTER_SELLER_DELIVERY.getByteVal())
|
|
|
|| buyerOrder.getStatus().equals(Constant.CANCEL_QUALITY_CHECK_FAKE.getByteVal())
|
|
|
|| buyerOrder.getStatus().equals(Constant.CANCEL_MINI_FAULT_REJECT.getByteVal())
|
|
|
|| buyerOrder.getStatus().equals(Constant.CANCEL_MINI_FAULT_OUT_TIME_REJECT.getByteVal())) {//收件人为卖家
|
|
|
SellerOrderMeta sellerMeta = sellerOrderMetaMapper.selectBySkupAndKey(skup, SELLER_ORDER_META_KEY_BACK_DELIVERY_ADDRESS);
|
|
|
JSONObject sellerMetaValue = JSONObject.parseObject(sellerMeta.getMetaValue());
|
|
|
buildAddressInfo(sellerMetaValue, jsonObj);
|
|
|
jsonObj.put("receiverType", "seller");
|
|
|
}
|
|
|
|
|
|
return new HttpEntity<String>(jsonObj.toString(), headers);
|
|
|
return jsonObj;
|
|
|
}
|
|
|
|
|
|
private void buildAddressInfo(JSONObject metaValue, JSONObject jsonObj) {
|
|
|
// jsonObj.put("dCompany", "");
|
|
|
jsonObj.put("dContact", metaValue.getString("consignee"));
|
|
|
jsonObj.put("dTel", metaValue.getString("mobile"));
|
|
|
jsonObj.put("dMobile", metaValue.getString("mobile"));
|
|
|
String areaCode = metaValue.getString("areaCode");
|
|
|
//查询四级地址,比如id=110102001:北京市北京市西城区西长安街街道办事处,11-北京市, 1101-北京市, 110102-西城区 110102001-西长安街街道办事处
|
|
|
Integer firstId = Integer.valueOf(areaCode.substring(0, 2));
|
|
|
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));
|
|
|
String dProvince = areaMap.get(firstId).replace("省", "").replace("市", "");
|
|
|
jsonObj.put("dProvince", dProvince);
|
|
|
jsonObj.put("dCity", areaMap.get(secondId).replace("市", ""));
|
|
|
jsonObj.put("dDistrict", areaMap.get(thirdId));
|
|
|
jsonObj.put("dCountry", "中国");
|
|
|
jsonObj.put("dAddress", areaMap.get(fourthId) + metaValue.getString("address"));
|
|
|
}
|
|
|
|
|
|
private Map<String, String> subAddress(String address){
|
|
|
Map<String, String> map = Maps.newHashMap();
|
|
|
String[] str1 = address.split("省");
|
|
|
if(StringUtils.isNotEmpty(str1[0])) {
|
|
|
map.put("province", str1[0]);
|
|
|
String[] str2 = str1[1].split("市");
|
|
|
if(str1.length == 1) {
|
|
|
String[] str2 = str1[0].split("市");
|
|
|
map.put("province", str2[0]);
|
|
|
map.put("city", str2[0]);
|
|
|
String[] str3 = str2[1].split("区");
|
|
|
map.put("district", str3[0]);
|
|
|
map.put("address", str3[1]);
|
|
|
}else {
|
|
|
map.put("province", str1[0]);
|
|
|
String[] str2 = str1[1].split("市");
|
|
|
map.put("provice", str2[0]);
|
|
|
map.put("city", str2[0]);
|
|
|
String[] str3 = str2[1].split("区");
|
|
|
map.put("district", str3[0]);
|
...
|
...
|
|