|
@@ -1,12 +1,16 @@
|
|
|
package com.iamberry.rst.service.order;
|
|
|
|
|
|
import com.iamberry.app.tool.util.MD5;
|
|
|
+import com.iamberry.rst.core.address.City;
|
|
|
+import com.iamberry.rst.core.address.District;
|
|
|
+import com.iamberry.rst.core.address.Province;
|
|
|
import com.iamberry.rst.core.cm.SalesOrder;
|
|
|
import com.iamberry.rst.core.cm.SalesOrderItem;
|
|
|
import com.iamberry.rst.core.dm.DealerChannel;
|
|
|
import com.iamberry.rst.core.dm.DealerProduct;
|
|
|
import com.iamberry.rst.core.order.*;
|
|
|
import com.iamberry.rst.core.tools.LogisticsInfo;
|
|
|
+import com.iamberry.rst.faces.address.AddressService;
|
|
|
import com.iamberry.rst.faces.cm.SalesOrderService;
|
|
|
import com.iamberry.rst.faces.dm.DealerChannelService;
|
|
|
import com.iamberry.rst.faces.dm.DealerProductService;
|
|
@@ -65,6 +69,8 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
|
|
|
private DealerChannelService dealerChannelService;
|
|
|
@Autowired
|
|
|
private DealerProductService dealerProductService;
|
|
|
+ @Autowired
|
|
|
+ private AddressService addressService;
|
|
|
|
|
|
//Map最大容量
|
|
|
static int maxSize = 20;
|
|
@@ -81,10 +87,7 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
|
|
|
private static OrderSyncPlatform XYT_PLATFORM = null; //小亚通平台信息
|
|
|
|
|
|
private OrderSyncPlatform getXYTPlatform(){
|
|
|
- if(XYT_PLATFORM == null){
|
|
|
- XYT_PLATFORM = orderSyncPlatformMapper.getSyncPlatformById(XYT_ID);
|
|
|
- }
|
|
|
- return XYT_PLATFORM;
|
|
|
+ return orderSyncPlatformMapper.getSyncPlatformById(XYT_ID);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -126,6 +129,10 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
|
|
|
@Override
|
|
|
public synchronized Integer syncXYTOrder(Integer type,Date creatTime) {
|
|
|
OrderSyncPlatform orderSyncPlatform = getXYTPlatform();
|
|
|
+ if(orderSyncPlatform.getSyncPlatStatus() != 1){
|
|
|
+ logger.info("小亚通接口已关闭!");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
Map<String,Object> paramsMap = new HashMap<>();
|
|
|
List<Map<String,Object>> conditionTypeList = new ArrayList<>();
|
|
|
Map<String,Object> beginCreateTimeMap = new HashMap<>();
|
|
@@ -640,6 +647,10 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
|
|
|
* @return
|
|
|
*/
|
|
|
private Map<String,Object> saveOrder(Integer type,String json,String batchId){
|
|
|
+
|
|
|
+ //获取省份
|
|
|
+ List<Province> provinceList = addressService.listProvince(new Province());
|
|
|
+
|
|
|
//返回保存订单结果
|
|
|
Map<String,Object> returnMap = new HashMap<>();
|
|
|
|
|
@@ -685,17 +696,105 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
|
|
|
salesOrder.setSalesOrderId(String.valueOf(orderId)); //小亚通订单编号
|
|
|
salesOrder.setSalesDealCode(String.valueOf(orderId)); //小亚通订单编号
|
|
|
//收货人信息
|
|
|
- salesOrder.setSalesAddressPostcode(consigneeObj.getString("receiverZip"));//收件人邮政编码
|
|
|
salesOrder.setSalesAddressName(consigneeObj.getString("receiverName"));//收件人姓名
|
|
|
salesOrder.setSalesAddressTel(consigneeObj.getString("receiverMobile"));//收件人手机号码
|
|
|
//salesOrder.setSalesAddressDesc(consigneeObj.getString(""));//地址详情
|
|
|
String receiverState = consigneeObj.getString("receiverState");//省
|
|
|
String receiverCity = consigneeObj.getString("receiverCity");//市
|
|
|
- String receiverDistrict = consigneeObj.getString("receiverDistrict");//区
|
|
|
+ String receiverDistrict = consigneeObj.getString("receiverCountry");//区
|
|
|
String receiverAddress = consigneeObj.getString("receiverAddress");//地址
|
|
|
+ if(receiverState.indexOf("上海")>-1 || receiverState.indexOf("北京")>-1
|
|
|
+ || receiverState.indexOf("重庆")>-1 || receiverState.indexOf("天津")>-1 ){
|
|
|
+ receiverDistrict = receiverCity;
|
|
|
+ receiverCity = receiverState;
|
|
|
+ }
|
|
|
+ String address = receiverState+" "+receiverCity+" "+receiverDistrict+" "+receiverAddress;
|
|
|
salesOrder.setSalesAddressInfo(receiverState+" "+receiverCity+" "+receiverDistrict+" "+receiverAddress);//详细地址
|
|
|
salesOrder.setSalesOpenId(consigneeObj.getString("receiverMobile"));
|
|
|
|
|
|
+ if(consigneeObj.has("receiverZip")){
|
|
|
+ salesOrder.setSalesAddressPostcode(consigneeObj.getString("receiverZip"));//收件人邮政编码
|
|
|
+ }else{
|
|
|
+ if(provinceList != null && provinceList.size() >0 ){
|
|
|
+ int provinceIdNum = 0;
|
|
|
+ int provinceId = 0;
|
|
|
+ for (Province proiv:provinceList) {
|
|
|
+ int proNum = 0;
|
|
|
+ String newPro = proiv.getProvince().replaceAll("省|自治区|壮族自治区|特别行政区|维吾尔自治区","");
|
|
|
+ if(newPro.indexOf(receiverState) > -1){
|
|
|
+ proNum++;
|
|
|
+ }
|
|
|
+ if(receiverState.indexOf(newPro) > -1){
|
|
|
+ proNum++;
|
|
|
+ }
|
|
|
+ if(proNum > provinceIdNum){
|
|
|
+ provinceIdNum = proNum;
|
|
|
+ provinceId = proiv.getProvinceId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ receiverCity = receiverCity.replaceAll("市|州|地区|自治区|特别行政区","");
|
|
|
+
|
|
|
+ int cityNum = 0;
|
|
|
+ Integer cityId = null;
|
|
|
+
|
|
|
+ City city = new City();
|
|
|
+ city.setProvinceId(provinceId);
|
|
|
+ List<City> cityList = addressService.listCity(city);
|
|
|
+ for (City ci:cityList) {
|
|
|
+ int ciNum = 0;
|
|
|
+ String newCi = ci.getCity().replaceAll("市|州|地区|自治区|特别行政区","");
|
|
|
+ if(receiverCity.indexOf(newCi)>-1){
|
|
|
+ ciNum ++;
|
|
|
+ }
|
|
|
+ if(newCi.indexOf(receiverCity)>-1){
|
|
|
+ ciNum ++;
|
|
|
+ }
|
|
|
+ if(cityNum < ciNum){
|
|
|
+ cityNum = ciNum;
|
|
|
+ cityId = ci.getCityId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(cityId == null){
|
|
|
+ throw new Exception("未查询到该县区:"+address);
|
|
|
+ }
|
|
|
+
|
|
|
+ int districtNum = 0;
|
|
|
+ String postcode = null;
|
|
|
+
|
|
|
+ District district = new District();
|
|
|
+ district.setCityId(cityId);
|
|
|
+ List<District> districtList = addressService.listDistrict(district);
|
|
|
+ for (District dis:districtList) {
|
|
|
+ int disNum = 0;
|
|
|
+
|
|
|
+ String newDIs = dis.getDistrict();
|
|
|
+ String newLastNewArea = newDIs.substring(newDIs.length()-1,newDIs.length());
|
|
|
+ newLastNewArea = newLastNewArea.replaceAll("县|区|镇|乡|市|州|洲","");
|
|
|
+ newDIs = newDIs.substring(0,newDIs.length()-1);
|
|
|
+ newDIs += newLastNewArea;
|
|
|
+
|
|
|
+ if(newDIs.indexOf(receiverDistrict) > -1){
|
|
|
+ disNum++;
|
|
|
+ }
|
|
|
+ if(receiverDistrict.indexOf(newDIs) > -1){
|
|
|
+ disNum++;
|
|
|
+ }
|
|
|
+ if(districtNum < disNum){
|
|
|
+ districtNum = disNum;
|
|
|
+ postcode = dis.getPostcode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(postcode != null){
|
|
|
+ salesOrder.setSalesAddressPostcode(postcode);
|
|
|
+ }else{
|
|
|
+ throw new Exception("未查询到该县区,原地址:"+address);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ throw new Exception("未查询到该省份,原地址:"+address);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//平台 SELF- 自身
|
|
|
//有赞平台:KDT 虚拟店铺:OFFLINE 天猫:TMALL 微店:WEIDIAN 京东:JD 阿里巴巴:1688 微盟微商城:WEIMENGWSC
|
|
|
//有量平台:YOULIANG 拼多多:PINDUODUO 楚楚街:CHUCHUJIE 蘑菇街:MGJ 美丽说:MLS 贝贝网:BEIBEI 云集:YUNJI
|