|
|
|
@@ -14,6 +14,7 @@ import com.iformall.douyin.web.api.TtWebService; |
|
|
|
import com.iformall.douyin.web.bean.TtSupplierMatch; |
|
|
|
import com.iformall.douyin.web.bean.TtSupplierMatchList; |
|
|
|
import com.iformall.douyin.web.bean.TtSupplierSync; |
|
|
|
import com.iformall.douyin.web.bean.TtSupplierSyncQuery; |
|
|
|
import com.iformall.enums.*; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.mapper.*; |
|
|
|
@@ -149,6 +150,31 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
private String supplierMatch(TenantEntity tenantInfo, List<TtMerchantPoi> merchantPoiList) throws MallinkException{ |
|
|
|
TtSupplierMatchList matchList = new TtSupplierMatchList(); |
|
|
|
for (TtMerchantPoi poi:merchantPoiList) { |
|
|
|
TtSupplierMatch match = new TtSupplierMatch(); |
|
|
|
match.setSupplierExtId(poi.getSupplierExtId()); |
|
|
|
match.setPoiName(poi.getMerchantName()); |
|
|
|
match.setProvince(poi.getMerchantProvince()); |
|
|
|
match.setCity(poi.getMerchantCity()); |
|
|
|
match.setAddress(poi.getMerchantAddr()); |
|
|
|
match.setLongitude(poi.getLongitude()); |
|
|
|
match.setLatitude(poi.getLatitude()); |
|
|
|
match.setAmapId(poi.getAmapId()); |
|
|
|
|
|
|
|
matchList.getMatchDataList().add(match); |
|
|
|
} |
|
|
|
String taskId = null; |
|
|
|
try { |
|
|
|
taskId = getTtWebService(tenantInfo).getShopMatchService().supplierMatch(matchList); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error("发起店铺匹配POI同步任务error"+e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); |
|
|
|
} |
|
|
|
return taskId; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<TtMerchantPoi> findTaskIdList(TtMerchantPoi merchantPoiQ) { |
|
|
|
return ttMerchantPoiMapper.findTaskIdList(merchantPoiQ); |
|
|
|
@@ -175,8 +201,12 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { |
|
|
|
ttMerchantPoiMapper.updateById(poiUpd); |
|
|
|
}else if(EnumSupplierMathStatus.match_fail.getCode().equals(match.getMatchStatus())){ |
|
|
|
ttMerchantPoiMapper.updateById(poiUpd); |
|
|
|
}else{ |
|
|
|
logger.error("门店id["+match.getSupplierExtId()+"]暂未处理成功"+match.getMismatchStatusDesc()); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
logger.error("请求接口返回为空"); |
|
|
|
} |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error("查询匹配任务error"+e.getMessage()); |
|
|
|
@@ -200,7 +230,7 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { |
|
|
|
TtMerchantPoi updPoi = new TtMerchantPoi(); |
|
|
|
updPoi.setId(id); |
|
|
|
updPoi.setSupplierId(supplierId); |
|
|
|
updPoi.setLastSyncStatus(EnumSupplierSyncStatus.match_wait.getCode()); |
|
|
|
updPoi.setLastSyncStatus(EnumSupplierSyncStatus.sync_wait.getCode()); |
|
|
|
updPoi.setUpdateDate(new Date()); |
|
|
|
ttMerchantPoiMapper.updateById(merchantPoi); |
|
|
|
return new ResultData(); |
|
|
|
@@ -246,29 +276,37 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { |
|
|
|
return supplierId; |
|
|
|
} |
|
|
|
|
|
|
|
private String supplierMatch(TenantEntity tenantInfo, List<TtMerchantPoi> merchantPoiList) throws MallinkException{ |
|
|
|
TtSupplierMatchList matchList = new TtSupplierMatchList(); |
|
|
|
for (TtMerchantPoi poi:merchantPoiList) { |
|
|
|
TtSupplierMatch match = new TtSupplierMatch(); |
|
|
|
match.setSupplierExtId(poi.getSupplierExtId()); |
|
|
|
match.setPoiName(poi.getMerchantName()); |
|
|
|
match.setProvince(poi.getMerchantProvince()); |
|
|
|
match.setCity(poi.getMerchantCity()); |
|
|
|
match.setAddress(poi.getMerchantAddr()); |
|
|
|
match.setLongitude(poi.getLongitude()); |
|
|
|
match.setLatitude(poi.getLatitude()); |
|
|
|
match.setAmapId(poi.getAmapId()); |
|
|
|
@Override |
|
|
|
public List<Long> findIdList(TtMerchantPoi merchantPoiQ) { |
|
|
|
return ttMerchantPoiMapper.findIdList(merchantPoiQ); |
|
|
|
} |
|
|
|
|
|
|
|
matchList.getMatchDataList().add(match); |
|
|
|
@Override |
|
|
|
public void supplierQuery(Long id) { |
|
|
|
TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(id); |
|
|
|
if(merchantPoi == null){ |
|
|
|
logger.error("未找到数据"); |
|
|
|
return; |
|
|
|
} |
|
|
|
if(!EnumSupplierSyncStatus.sync_wait.getCode().equals(merchantPoi.getLastSyncStatus())){ |
|
|
|
logger.error("该店铺暂未申请同步或已知同步结果"); |
|
|
|
return; |
|
|
|
} |
|
|
|
String taskId = null; |
|
|
|
try { |
|
|
|
taskId = getTtWebService(tenantInfo).getShopMatchService().supplierMatch(matchList); |
|
|
|
TtSupplierSyncQuery syncQuery = getTtWebService(merchantPoi).getProductService().supplierQuery(merchantPoi.getSupplierExtId()); |
|
|
|
if(syncQuery != null && syncQuery.getSyncStatus() != null ){ |
|
|
|
TtMerchantPoi poiUpd = new TtMerchantPoi(); |
|
|
|
poiUpd.setId(id); |
|
|
|
poiUpd.setLastSyncStatus(syncQuery.getSyncStatus().getLastSyncStatus()); |
|
|
|
poiUpd.setFailReason(syncQuery.getSyncStatus().getFailReason()); |
|
|
|
poiUpd.setUpdateDate(new Date()); |
|
|
|
ttMerchantPoiMapper.updateById(poiUpd); |
|
|
|
}else{ |
|
|
|
logger.error("请求接口返回为空"); |
|
|
|
} |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error("发起店铺匹配POI同步任务error"+e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); |
|
|
|
logger.error("查询匹配任务error"+e.getMessage()); |
|
|
|
} |
|
|
|
return taskId; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|