|
@@ -14,7 +14,6 @@ import java.util.stream.Collectors; |
|
@@ -14,7 +14,6 @@ import java.util.stream.Collectors; |
14
|
|
14
|
|
15
|
import javax.annotation.Resource;
|
15
|
import javax.annotation.Resource;
|
16
|
|
16
|
|
17
|
-import com.yoho.ufo.order.request.SaveQualityCheckInfoRequest;
|
|
|
18
|
import org.apache.commons.collections.CollectionUtils;
|
17
|
import org.apache.commons.collections.CollectionUtils;
|
19
|
import org.apache.commons.lang3.StringUtils;
|
18
|
import org.apache.commons.lang3.StringUtils;
|
20
|
import org.elasticsearch.common.collect.Lists;
|
19
|
import org.elasticsearch.common.collect.Lists;
|
|
@@ -51,6 +50,7 @@ import com.yoho.order.dal.QualityCheckMapper; |
|
@@ -51,6 +50,7 @@ import com.yoho.order.dal.QualityCheckMapper; |
51
|
import com.yoho.order.dal.SellerOrderGoodsMapper;
|
50
|
import com.yoho.order.dal.SellerOrderGoodsMapper;
|
52
|
import com.yoho.order.dal.SellerOrderMapper;
|
51
|
import com.yoho.order.dal.SellerOrderMapper;
|
53
|
import com.yoho.order.dal.SellerOrderMetaMapper;
|
52
|
import com.yoho.order.dal.SellerOrderMetaMapper;
|
|
|
53
|
+import com.yoho.order.model.AppraiseAddress;
|
54
|
import com.yoho.order.model.Area;
|
54
|
import com.yoho.order.model.Area;
|
55
|
import com.yoho.order.model.BuyerOrder;
|
55
|
import com.yoho.order.model.BuyerOrder;
|
56
|
import com.yoho.order.model.BuyerOrderFeedback;
|
56
|
import com.yoho.order.model.BuyerOrderFeedback;
|
|
@@ -75,11 +75,13 @@ import com.yoho.ufo.dal.ProductMapper; |
|
@@ -75,11 +75,13 @@ import com.yoho.ufo.dal.ProductMapper; |
75
|
import com.yoho.ufo.dal.model.IdentifyRecords;
|
75
|
import com.yoho.ufo.dal.model.IdentifyRecords;
|
76
|
import com.yoho.ufo.dal.model.Product;
|
76
|
import com.yoho.ufo.dal.model.Product;
|
77
|
import com.yoho.ufo.order.constant.Constant;
|
77
|
import com.yoho.ufo.order.constant.Constant;
|
|
|
78
|
+import com.yoho.ufo.order.request.SaveQualityCheckInfoRequest;
|
78
|
import com.yoho.ufo.order.service.IBuyerOrderService;
|
79
|
import com.yoho.ufo.order.service.IBuyerOrderService;
|
79
|
import com.yoho.ufo.service.impl.UserHelper;
|
80
|
import com.yoho.ufo.service.impl.UserHelper;
|
80
|
import com.yoho.ufo.service.model.PageResponseBO;
|
81
|
import com.yoho.ufo.service.model.PageResponseBO;
|
81
|
import com.yoho.ufo.util.ImagesConstant;
|
82
|
import com.yoho.ufo.util.ImagesConstant;
|
82
|
import com.yoho.ufo.util.ImagesHelper;
|
83
|
import com.yoho.ufo.util.ImagesHelper;
|
|
|
84
|
+import com.yoho.ufo.util.MobileHelper;
|
83
|
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
|
85
|
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
|
84
|
import com.yohobuy.ufo.model.order.common.EnumExpressType;
|
86
|
import com.yohobuy.ufo.model.order.common.EnumExpressType;
|
85
|
import com.yohobuy.ufo.model.order.common.EnumQualityCheckStatus;
|
87
|
import com.yohobuy.ufo.model.order.common.EnumQualityCheckStatus;
|
|
@@ -188,6 +190,14 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
@@ -188,6 +190,14 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
188
|
@Resource(name="restTemplate")
|
190
|
@Resource(name="restTemplate")
|
189
|
RestTemplate restTemplate;
|
191
|
RestTemplate restTemplate;
|
190
|
|
192
|
|
|
|
193
|
+ //南京月结账号
|
|
|
194
|
+// private static final String NANJING_CUSTID = "0255045253";
|
|
|
195
|
+ private static final String NANJING_CUSTID = "9999999999";
|
|
|
196
|
+
|
|
|
197
|
+ //北京月结账号
|
|
|
198
|
+// private static final String BEIJING_CUSTID = "0100026158";
|
|
|
199
|
+ private static final String BEIJING_CUSTID = "9999999999";
|
|
|
200
|
+
|
191
|
//已收货
|
201
|
//已收货
|
192
|
private static final Byte QC_STATUS_RECEIVED = 0;
|
202
|
private static final Byte QC_STATUS_RECEIVED = 0;
|
193
|
|
203
|
|
|
@@ -1585,9 +1595,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
@@ -1585,9 +1595,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
1585
|
return resp;
|
1595
|
return resp;
|
1586
|
}
|
1596
|
}
|
1587
|
|
1597
|
|
1588
|
-// @Override
|
|
|
1589
|
- public String getSfWaybillCode(String orderCode) {
|
|
|
1590
|
- BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
|
1598
|
+ @Override
|
|
|
1599
|
+ public JSONObject getSfWaybillCode(BuyerOrderReq req) {
|
|
|
1600
|
+ BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(req.getOrderCode());
|
1591
|
if(null == buyerOrder) {
|
1601
|
if(null == buyerOrder) {
|
1592
|
return null;
|
1602
|
return null;
|
1593
|
}
|
1603
|
}
|
|
@@ -1608,25 +1618,68 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
@@ -1608,25 +1618,68 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
1608
|
|
1618
|
|
1609
|
SellerOrderGoods sellerGoods = sellerGoodsList.get(0);
|
1619
|
SellerOrderGoods sellerGoods = sellerGoodsList.get(0);
|
1610
|
|
1620
|
|
|
|
1621
|
+ AppraiseAddress appraiseAddress = appraiseAddressMapper.selectByType(sellerGoods.getDepotNo());
|
1611
|
|
1622
|
|
1612
|
String url = erpDomain + PlatformConstant.ERP_GET_SF_WAYBILLCODE;
|
1623
|
String url = erpDomain + PlatformConstant.ERP_GET_SF_WAYBILLCODE;
|
1613
|
- HttpHeaders headers = getHttpHeaders();
|
|
|
1614
|
- HttpEntity<String> formEntity = getStringHttpEntity(buyerOrder, sellerGoods, headers);
|
|
|
1615
|
-
|
|
|
1616
|
- ResponseEntity<Object> responseResponseEntity = restTemplate.postForEntity(url, formEntity, Object.class);
|
|
|
1617
|
- Map<String, Object> body = (Map<String, Object>) responseResponseEntity.getBody();
|
|
|
1618
|
|
1624
|
|
1619
|
- return null;
|
1625
|
+ JSONObject jsonReqObj = getStringHttpEntity(buyerOrder, sellerGoods, appraiseAddress.getAddress(), skup, req.getPayMethod());
|
|
|
1626
|
+ HttpEntity<String> formEntity = new HttpEntity<>(jsonReqObj.toString(), getHttpHeaders());
|
|
|
1627
|
+
|
|
|
1628
|
+ ResponseEntity<JSONObject> responseResponseEntity = restTemplate.postForEntity(url, formEntity, JSONObject.class);
|
|
|
1629
|
+ JSONObject body = responseResponseEntity.getBody();
|
|
|
1630
|
+ LOGGER.info("erp result is {}", body);
|
|
|
1631
|
+ int code = body.getIntValue("code");
|
|
|
1632
|
+ if(code != 200) {
|
|
|
1633
|
+ return body;
|
|
|
1634
|
+ }
|
|
|
1635
|
+
|
|
|
1636
|
+ Product product = productMapper.selectByPrimaryKey(sellerGoods.getProductId());
|
|
|
1637
|
+
|
|
|
1638
|
+ JSONObject data = body.getJSONObject("data");
|
|
|
1639
|
+ data.put("createTime", DateUtil.getcurrentDateTime());
|
|
|
1640
|
+ data.put("dContact", jsonReqObj.getString("dContact"));
|
|
|
1641
|
+ data.put("dMobile", MobileHelper.coverMobile(jsonReqObj.getString("dMobile")));
|
|
|
1642
|
+ data.put("dProvince", jsonReqObj.getString("dProvince"));
|
|
|
1643
|
+ data.put("dCity", jsonReqObj.getString("dCity"));
|
|
|
1644
|
+ data.put("dDistrict", jsonReqObj.getString("dDistrict"));
|
|
|
1645
|
+ data.put("dAddress", jsonReqObj.getString("dAddress"));
|
|
|
1646
|
+ data.put("jContact", "UFO鉴定中心");
|
|
|
1647
|
+ data.put("jMobile", MobileHelper.coverMobile(appraiseAddress.getMobile()));
|
|
|
1648
|
+ data.put("jProvince", jsonReqObj.getString("jProvince"));
|
|
|
1649
|
+ data.put("jCity", jsonReqObj.getString("jCity"));
|
|
|
1650
|
+ data.put("jDistrict", jsonReqObj.getString("jDistrict"));
|
|
|
1651
|
+ data.put("jAddress", jsonReqObj.getString("jAddress"));
|
|
|
1652
|
+ data.put("orderCode", buyerOrder.getOrderCode());
|
|
|
1653
|
+ data.put("productCode", product.getProductCode());
|
|
|
1654
|
+ data.put("sizeName", sellerGoods.getSizeName());
|
|
|
1655
|
+ data.put("shipFee", "**元");
|
|
|
1656
|
+ data.put("amount", "**元");
|
|
|
1657
|
+ data.put("businessType", data.getString("proCode").equals("T6") ? "顺丰特惠" : "标准快递");
|
|
|
1658
|
+ data.put("custid", "***");
|
|
|
1659
|
+
|
|
|
1660
|
+ //建立订单与运单号的关联
|
|
|
1661
|
+ String receiverType = jsonReqObj.getString("receiverType");
|
|
|
1662
|
+ BuyerOrderReq relationReq = new BuyerOrderReq();
|
|
|
1663
|
+ relationReq.setOrderCode(buyerOrder.getOrderCode());
|
|
|
1664
|
+ relationReq.setWaybillCode(data.getString("mailNo"));
|
|
|
1665
|
+ relationReq.setExpressCompanyId(23);//顺丰
|
|
|
1666
|
+ relationReq.setDepotNo(sellerGoods.getDepotNo());
|
|
|
1667
|
+ relationReq.setMobile(jsonReqObj.getString("dMobile"));
|
|
|
1668
|
+ if(receiverType.equals("buyer")) {
|
|
|
1669
|
+ deliveryGoodsToBuyer(relationReq);
|
|
|
1670
|
+ }else if(receiverType.equals("seller")) {
|
|
|
1671
|
+ sendBackGoodsToSeller(relationReq);
|
|
|
1672
|
+ }
|
|
|
1673
|
+
|
|
|
1674
|
+ return data;
|
1620
|
}
|
1675
|
}
|
1621
|
|
1676
|
|
1622
|
- private HttpEntity<String> getStringHttpEntity(BuyerOrder buyerOrder, SellerOrderGoods sellerGoods, HttpHeaders headers) {
|
1677
|
+ private JSONObject getStringHttpEntity(BuyerOrder buyerOrder, SellerOrderGoods sellerGoods, String appraiseAddress, Integer skup, Integer payMethod) {
|
1623
|
JSONObject jsonObj = new JSONObject();
|
1678
|
JSONObject jsonObj = new JSONObject();
|
1624
|
jsonObj.put("orderCode", buyerOrder.getOrderCode());
|
1679
|
jsonObj.put("orderCode", buyerOrder.getOrderCode());
|
1625
|
jsonObj.put("uid", buyerOrder.getUid());
|
1680
|
jsonObj.put("uid", buyerOrder.getUid());
|
1626
|
|
1681
|
|
1627
|
- Integer depotNo = sellerGoods.getDepotNo();
|
|
|
1628
|
- String platformAddress = appraiseAddressMapper.selectAddressByType(depotNo);
|
|
|
1629
|
- Map<String, String> addressMap = subAddress(platformAddress);
|
1682
|
+ Map<String, String> addressMap = subAddress(appraiseAddress);
|
1630
|
|
1683
|
|
1631
|
//寄件人信息
|
1684
|
//寄件人信息
|
1632
|
jsonObj.put("jCompany", "Yoho!Buy有货");
|
1685
|
jsonObj.put("jCompany", "Yoho!Buy有货");
|
|
@@ -1636,23 +1689,68 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
@@ -1636,23 +1689,68 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
1636
|
jsonObj.put("jCountry", "中国");
|
1689
|
jsonObj.put("jCountry", "中国");
|
1637
|
jsonObj.put("jProvince", addressMap.get("province"));
|
1690
|
jsonObj.put("jProvince", addressMap.get("province"));
|
1638
|
jsonObj.put("jCity", addressMap.get("city"));
|
1691
|
jsonObj.put("jCity", addressMap.get("city"));
|
|
|
1692
|
+ jsonObj.put("jDistrict", addressMap.get("district"));
|
|
|
1693
|
+ jsonObj.put("jAddress", addressMap.get("address"));
|
|
|
1694
|
+ jsonObj.put("expressType", 2);//快件产品类型 1:标准快递 2:顺丰特惠(便宜,全程陆运)
|
|
|
1695
|
+ jsonObj.put("payMethod", payMethod);//1:寄方付 2:收方付 3:第三方付
|
|
|
1696
|
+ jsonObj.put("businessCode", "UFO");
|
|
|
1697
|
+ jsonObj.put("custid", sellerGoods.getDepotNo().intValue() == 0 ? BEIJING_CUSTID : NANJING_CUSTID);
|
|
|
1698
|
+
|
|
|
1699
|
+ //收件人信息
|
|
|
1700
|
+ if(buyerOrder.getStatus().equals(Constant.BUYER_ORDER_STATUS_JUDGE_PASS.getByteVal())
|
|
|
1701
|
+ || buyerOrder.getStatus().equals(Constant.BUYER_ORDER_STATUS_MINI_FAULT_ACCEPT.getByteVal())) {//收件人为买家
|
|
|
1702
|
+ BuyerOrderMeta buyerMeta = buyerOrderMetaMapper.selectByOrderCodeAndKey(buyerOrder.getOrderCode(), BUYER_ORDER_META_KEY_DELIVERY_ADDRESS);
|
|
|
1703
|
+ JSONObject metaValue = JSONObject.parseObject(buyerMeta.getMetaValue());
|
|
|
1704
|
+ buildAddressInfo(metaValue, jsonObj);
|
|
|
1705
|
+ jsonObj.put("receiverType", "buyer");
|
|
|
1706
|
+ }else if(buyerOrder.getStatus().equals(Constant.BUYER_ORDER_STATUS_JUDGE_NOT_PASS.getByteVal())
|
|
|
1707
|
+ || buyerOrder.getStatus().equals(Constant.BUYER_ORDER_STATUS_BUYER_CANCEL_AFTER_SELLER_DELIVERY.getByteVal())
|
|
|
1708
|
+ || buyerOrder.getStatus().equals(Constant.CANCEL_QUALITY_CHECK_FAKE.getByteVal())
|
|
|
1709
|
+ || buyerOrder.getStatus().equals(Constant.CANCEL_MINI_FAULT_REJECT.getByteVal())
|
|
|
1710
|
+ || buyerOrder.getStatus().equals(Constant.CANCEL_MINI_FAULT_OUT_TIME_REJECT.getByteVal())) {//收件人为卖家
|
|
|
1711
|
+ SellerOrderMeta sellerMeta = sellerOrderMetaMapper.selectBySkupAndKey(skup, SELLER_ORDER_META_KEY_BACK_DELIVERY_ADDRESS);
|
|
|
1712
|
+ JSONObject sellerMetaValue = JSONObject.parseObject(sellerMeta.getMetaValue());
|
|
|
1713
|
+ buildAddressInfo(sellerMetaValue, jsonObj);
|
|
|
1714
|
+ jsonObj.put("receiverType", "seller");
|
|
|
1715
|
+ }
|
1639
|
|
1716
|
|
1640
|
- return new HttpEntity<String>(jsonObj.toString(), headers);
|
1717
|
+ return jsonObj;
|
|
|
1718
|
+ }
|
|
|
1719
|
+
|
|
|
1720
|
+ private void buildAddressInfo(JSONObject metaValue, JSONObject jsonObj) {
|
|
|
1721
|
+// jsonObj.put("dCompany", "");
|
|
|
1722
|
+ jsonObj.put("dContact", metaValue.getString("consignee"));
|
|
|
1723
|
+ jsonObj.put("dTel", metaValue.getString("mobile"));
|
|
|
1724
|
+ jsonObj.put("dMobile", metaValue.getString("mobile"));
|
|
|
1725
|
+ String areaCode = metaValue.getString("areaCode");
|
|
|
1726
|
+ //查询四级地址,比如id=110102001:北京市北京市西城区西长安街街道办事处,11-北京市, 1101-北京市, 110102-西城区 110102001-西长安街街道办事处
|
|
|
1727
|
+ Integer firstId = Integer.valueOf(areaCode.substring(0, 2));
|
|
|
1728
|
+ Integer secondId = Integer.valueOf(areaCode.substring(0, 4));
|
|
|
1729
|
+ Integer thirdId = Integer.valueOf(areaCode.substring(0, 6));
|
|
|
1730
|
+ Integer fourthId = Integer.valueOf(areaCode);
|
|
|
1731
|
+ List<Area> areaList = areaMapper.selectByCodeList(Lists.newArrayList(firstId, secondId, thirdId, fourthId));
|
|
|
1732
|
+ Map<Integer, String> areaMap = areaList.stream().collect(Collectors.toMap(Area::getId, Area::getCaption));
|
|
|
1733
|
+ String dProvince = areaMap.get(firstId).replace("省", "").replace("市", "");
|
|
|
1734
|
+ jsonObj.put("dProvince", dProvince);
|
|
|
1735
|
+ jsonObj.put("dCity", areaMap.get(secondId).replace("市", ""));
|
|
|
1736
|
+ jsonObj.put("dDistrict", areaMap.get(thirdId));
|
|
|
1737
|
+ jsonObj.put("dCountry", "中国");
|
|
|
1738
|
+ jsonObj.put("dAddress", areaMap.get(fourthId) + metaValue.getString("address"));
|
1641
|
}
|
1739
|
}
|
1642
|
|
1740
|
|
1643
|
private Map<String, String> subAddress(String address){
|
1741
|
private Map<String, String> subAddress(String address){
|
1644
|
Map<String, String> map = Maps.newHashMap();
|
1742
|
Map<String, String> map = Maps.newHashMap();
|
1645
|
String[] str1 = address.split("省");
|
1743
|
String[] str1 = address.split("省");
|
1646
|
- if(StringUtils.isNotEmpty(str1[0])) {
|
|
|
1647
|
- map.put("province", str1[0]);
|
|
|
1648
|
- String[] str2 = str1[1].split("市");
|
1744
|
+ if(str1.length == 1) {
|
|
|
1745
|
+ String[] str2 = str1[0].split("市");
|
|
|
1746
|
+ map.put("province", str2[0]);
|
1649
|
map.put("city", str2[0]);
|
1747
|
map.put("city", str2[0]);
|
1650
|
String[] str3 = str2[1].split("区");
|
1748
|
String[] str3 = str2[1].split("区");
|
1651
|
map.put("district", str3[0]);
|
1749
|
map.put("district", str3[0]);
|
1652
|
map.put("address", str3[1]);
|
1750
|
map.put("address", str3[1]);
|
1653
|
}else {
|
1751
|
}else {
|
|
|
1752
|
+ map.put("province", str1[0]);
|
1654
|
String[] str2 = str1[1].split("市");
|
1753
|
String[] str2 = str1[1].split("市");
|
1655
|
- map.put("provice", str2[0]);
|
|
|
1656
|
map.put("city", str2[0]);
|
1754
|
map.put("city", str2[0]);
|
1657
|
String[] str3 = str2[1].split("区");
|
1755
|
String[] str3 = str2[1].split("区");
|
1658
|
map.put("district", str3[0]);
|
1756
|
map.put("district", str3[0]);
|