Procházet zdrojové kódy

//add poi

release_toaliyun_real
xhxu před 4 roky
rodič
revize
768c0630eb
5 změnil soubory, kde provedl 124 přidání a 64 odebrání
  1. +58
    -40
      mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantPoiSchedule.java
  2. +1
    -1
      mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebProductService.java
  3. +4
    -4
      mallinkService/src/main/java/com/iformall/enums/EnumSupplierSyncStatus.java
  4. +4
    -0
      mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java
  5. +57
    -19
      mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java

+ 58
- 40
mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantPoiSchedule.java Zobrazit soubor

@@ -1,40 +1,58 @@
package com.iformall.schedule;

import com.iformall.domain.po.*;
import com.iformall.enums.EnumSupplierMathStatus;
import com.iformall.service.TtMerchantPoiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class TtMerchantPoiSchedule {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private TtMerchantPoiService ttMerchantPoiService;

@Async
@Scheduled(cron = "0 0 */1 * * *?") // 每小时检查一次
public void merchantCountSchedule() {
TtMerchantPoi merchantPoiQ = new TtMerchantPoi();
merchantPoiQ.setMatchStatus(EnumSupplierMathStatus.match_ing.getCode());
List<TtMerchantPoi> pois = ttMerchantPoiService.findTaskIdList(merchantPoiQ);
if(pois != null && pois.size() > 0){
for (TtMerchantPoi poi:pois) {
try{
ttMerchantPoiService.supplierQueryTask(poi);
}catch(Exception e){
logger.error("查询匹配任务失败");
}
}
}
}

}
//package com.iformall.schedule;
//
//import com.iformall.domain.po.*;
//import com.iformall.enums.EnumSupplierMathStatus;
//import com.iformall.enums.EnumSupplierSyncStatus;
//import com.iformall.service.TtMerchantPoiService;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.util.List;
//
//@Component
//public class TtMerchantPoiSchedule {
//
// private final Logger logger = LoggerFactory.getLogger(this.getClass());
//
// @Autowired
// private TtMerchantPoiService ttMerchantPoiService;
//
// @Async
// @Scheduled(cron = "0 0 */1 * * *?") // 每小时检查一次
// public void supplierQueryTaskSchedule() {
// TtMerchantPoi merchantPoiQ = new TtMerchantPoi();
// merchantPoiQ.setMatchStatus(EnumSupplierMathStatus.match_ing.getCode());
// List<TtMerchantPoi> pois = ttMerchantPoiService.findTaskIdList(merchantPoiQ);
// if(pois != null && pois.size() > 0){
// for (TtMerchantPoi poi:pois) {
// try{
// ttMerchantPoiService.supplierQueryTask(poi);
// }catch(Exception e){
// logger.error("查询匹配任务失败");
// }
// }
// }
// }
//
// @Async
// @Scheduled(cron = "0 0 */1 * * *?") // 每小时检查一次
// public void supplierQuerySchedule() {
// TtMerchantPoi merchantPoiQ = new TtMerchantPoi();
// merchantPoiQ.setLastSyncStatus(EnumSupplierSyncStatus.sync_wait.getCode());
// List<Long> ids = ttMerchantPoiService.findIdList(merchantPoiQ);
// if(ids != null && ids.size() > 0){
// for (Long id:ids) {
// try{
// ttMerchantPoiService.supplierQuery(id);
// }catch(Exception e){
// logger.error("查询匹配任务失败");
// }
// }
// }
// }
//
//}

+ 1
- 1
mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebProductService.java Zobrazit soubor

@@ -55,7 +55,7 @@ public interface TtWebProductService {
* https://open.douyin.com/platform/doc?doc=docs/openapi/life-service-open-ability/shop/search * https://open.douyin.com/platform/doc?doc=docs/openapi/life-service-open-ability/shop/search
* *
* @param supplierExtId * @param supplierExtId
* supplier_ext_id 第三方上传任务id列表,多个任务id用 , 分割,单次查询最多10个任务。
* supplier_ext_id
*/ */
TtSupplierSyncQuery supplierQuery(String supplierExtId) throws WxErrorException ; TtSupplierSyncQuery supplierQuery(String supplierExtId) throws WxErrorException ;




+ 4
- 4
mallinkService/src/main/java/com/iformall/enums/EnumSupplierSyncStatus.java Zobrazit soubor

@@ -5,10 +5,10 @@ package com.iformall.enums;
*/ */
public enum EnumSupplierSyncStatus { public enum EnumSupplierSyncStatus {
// 最近一次同步状态, 0 - 未处理; 1 - 通过; 2 - 未通过 // 最近一次同步状态, 0 - 未处理; 1 - 通过; 2 - 未通过
// match_update(-1, "等待重新同步"),
match_wait(0, " 未处理"),
match_success(1, "通过"),
match_fail(2, "未通过"),
// sync_update(-1, "等待重新同步"),
sync_wait(0, " 未处理"),
sync_success(1, "通过"),
sync_fail(2, "未通过"),
; ;


public static EnumSupplierSyncStatus getEnum(Integer code) { public static EnumSupplierSyncStatus getEnum(Integer code) {


+ 4
- 0
mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java Zobrazit soubor

@@ -37,6 +37,10 @@ public interface TtMerchantPoiService {


ResultData merchantSync(TenantEntity tenantInfo, Long id); ResultData merchantSync(TenantEntity tenantInfo, Long id);


List<Long> findIdList(TtMerchantPoi merchantPoiQ);

void supplierQuery(Long id);

TtWebService getTtWebService(TenantEntity tenantInfo); TtWebService getTtWebService(TenantEntity tenantInfo);


} }

+ 57
- 19
mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java Zobrazit soubor

@@ -14,6 +14,7 @@ import com.iformall.douyin.web.api.TtWebService;
import com.iformall.douyin.web.bean.TtSupplierMatch; import com.iformall.douyin.web.bean.TtSupplierMatch;
import com.iformall.douyin.web.bean.TtSupplierMatchList; import com.iformall.douyin.web.bean.TtSupplierMatchList;
import com.iformall.douyin.web.bean.TtSupplierSync; import com.iformall.douyin.web.bean.TtSupplierSync;
import com.iformall.douyin.web.bean.TtSupplierSyncQuery;
import com.iformall.enums.*; import com.iformall.enums.*;
import com.iformall.exception.MallinkException; import com.iformall.exception.MallinkException;
import com.iformall.mapper.*; import com.iformall.mapper.*;
@@ -149,6 +150,31 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
return new ResultData(); 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 @Override
public List<TtMerchantPoi> findTaskIdList(TtMerchantPoi merchantPoiQ) { public List<TtMerchantPoi> findTaskIdList(TtMerchantPoi merchantPoiQ) {
return ttMerchantPoiMapper.findTaskIdList(merchantPoiQ); return ttMerchantPoiMapper.findTaskIdList(merchantPoiQ);
@@ -175,8 +201,12 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
ttMerchantPoiMapper.updateById(poiUpd); ttMerchantPoiMapper.updateById(poiUpd);
}else if(EnumSupplierMathStatus.match_fail.getCode().equals(match.getMatchStatus())){ }else if(EnumSupplierMathStatus.match_fail.getCode().equals(match.getMatchStatus())){
ttMerchantPoiMapper.updateById(poiUpd); ttMerchantPoiMapper.updateById(poiUpd);
}else{
logger.error("门店id["+match.getSupplierExtId()+"]暂未处理成功"+match.getMismatchStatusDesc());
} }
} }
}else{
logger.error("请求接口返回为空");
} }
} catch (WxErrorException e) { } catch (WxErrorException e) {
logger.error("查询匹配任务error"+e.getMessage()); logger.error("查询匹配任务error"+e.getMessage());
@@ -200,7 +230,7 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
TtMerchantPoi updPoi = new TtMerchantPoi(); TtMerchantPoi updPoi = new TtMerchantPoi();
updPoi.setId(id); updPoi.setId(id);
updPoi.setSupplierId(supplierId); updPoi.setSupplierId(supplierId);
updPoi.setLastSyncStatus(EnumSupplierSyncStatus.match_wait.getCode());
updPoi.setLastSyncStatus(EnumSupplierSyncStatus.sync_wait.getCode());
updPoi.setUpdateDate(new Date()); updPoi.setUpdateDate(new Date());
ttMerchantPoiMapper.updateById(merchantPoi); ttMerchantPoiMapper.updateById(merchantPoi);
return new ResultData(); return new ResultData();
@@ -246,29 +276,37 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
return supplierId; 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 { 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) { } 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;
} }






Načítá se…
Zrušit
Uložit