diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java index 274b8164c..0a7e2baa9 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java @@ -78,6 +78,7 @@ public class TtMerchantPoiController extends BaseController { return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该状态不允许修改"); } record.updateTenantInfo(getTenantInfo()); + record.setMatchStatus(EnumSupplierMathStatus.match_update.getCode()); ttMerchantPoiService.updateById(record); return new ResultData(record); } @@ -104,4 +105,15 @@ public class TtMerchantPoiController extends BaseController { return ttMerchantPoiService.matchAgain(getTenantInfo(),id); } + @ApiOperation("商铺同步") + @PostMapping("merchantSync") + @SystemControllerLog(description = "重新匹配任务") + public ResultData merchantSync(@RequestBody Long id) { + logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::merchantSync"); + if(id == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); + } + return ttMerchantPoiService.merchantSync(getTenantInfo(),id); + } + } diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantPoiSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantPoiSchedule.java new file mode 100644 index 000000000..159c89a25 --- /dev/null +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantPoiSchedule.java @@ -0,0 +1,40 @@ +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 pois = ttMerchantPoiService.findTaskIdList(merchantPoiQ); + if(pois != null && pois.size() > 0){ + for (TtMerchantPoi poi:pois) { + try{ + ttMerchantPoiService.supplierQueryTask(poi); + }catch(Exception e){ + logger.error("查询匹配任务失败"); + } + } + } + } + +} \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebShopMatchService.java b/mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebShopMatchService.java index 8a804d370..3c943bd9c 100644 --- a/mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebShopMatchService.java +++ b/mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebShopMatchService.java @@ -39,6 +39,7 @@ public interface TtWebShopMatchService { /** * 店铺匹配任务结果查询 + * https://open.douyin.com/platform/doc?doc=docs/openapi/life-service-open-ability/shop/task-query * * @param supplierTaskIds * supplier_task_ids 第三方上传任务id列表,多个任务id用 , 分割,单次查询最多10个任务。 @@ -47,6 +48,7 @@ public interface TtWebShopMatchService { /** * 店铺匹配状态查询 + * https://open.douyin.com/platform/doc?doc=docs/openapi/life-service-open-ability/shop/status-query * * @param supplierExtId * supplier_ext_id 第三方店铺id列表,多个商铺id用 , 分割,单次查询最多50个店铺。 diff --git a/mallinkService/src/main/java/com/iformall/mapper/TtMerchantPoiMapper.java b/mallinkService/src/main/java/com/iformall/mapper/TtMerchantPoiMapper.java index 9f78d7736..41a821b41 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/TtMerchantPoiMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/TtMerchantPoiMapper.java @@ -11,7 +11,7 @@ public interface TtMerchantPoiMapper extends CommonMapper { List findIdList(TtMerchantPoi record); - List findTaskIdList(TtMerchantPoi record); + List findTaskIdList(TtMerchantPoi record); int deleteByUpdate(Long id); diff --git a/mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java b/mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java index cb2bcfaeb..52613a933 100644 --- a/mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java +++ b/mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java @@ -31,5 +31,12 @@ public interface TtMerchantPoiService { ResultData matchAgain(TenantEntity tenantInfo, Long id); + List findTaskIdList(TtMerchantPoi merchantPoiQ); + + void supplierQueryTask(TtMerchantPoi poi); + + ResultData merchantSync(TenantEntity tenantInfo, Long id); + TtWebService getTtWebService(TenantEntity tenantInfo); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java index 46315a957..117116993 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java @@ -63,6 +63,7 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { @Override public int updateById(TtMerchantPoi record) { + record.setUpdateDate(new Date()); return ttMerchantPoiMapper.updateById(record); } @@ -145,6 +146,54 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { return new ResultData(); } + @Override + public List findTaskIdList(TtMerchantPoi merchantPoiQ) { + return ttMerchantPoiMapper.findTaskIdList(merchantPoiQ); + } + + @Override + public void supplierQueryTask(TtMerchantPoi poi) { + try { + TtSupplierMatchList matchList = getTtWebService(poi).getShopMatchService().supplierQueryTask(poi.getTaskId()); + if(matchList != null && matchList.getMatchDataList().size() > 0 ){ + for (TtSupplierMatch match:matchList.getMatchDataList()) { + Date now = new Date(); + TtMerchantPoi poiUpd = new TtMerchantPoi(); + poiUpd.setId(Long.parseLong(match.getSupplierExtId())); + poiUpd.setMatchStatus(match.getMatchStatus()); + poiUpd.setMismatchStatusDesc(match.getMismatchStatusDesc()); + poiUpd.setUpdateDate(now); + if(EnumSupplierMathStatus.match_success.getCode().equals(match.getMatchStatus())){ + poiUpd.setPoiId(match.getPoiId()); + poiUpd.setPoiName(match.getPoiName()); + poiUpd.setProvince(match.getProvince()); + poiUpd.setCity(match.getCity()); + poiUpd.setAddress(match.getAddress()); + ttMerchantPoiMapper.updateById(poiUpd); + }else if(EnumSupplierMathStatus.match_fail.getCode().equals(match.getMatchStatus())){ + ttMerchantPoiMapper.updateById(poiUpd); + } + } + } + } catch (WxErrorException e) { + logger.error("查询匹配任务error"+e.getMessage()); + } + } + + @Override + public ResultData merchantSync(TenantEntity tenantInfo, Long id) { + TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(id); + if(merchantPoi == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到数据"); + } + if(!EnumSupplierMathStatus.match_success.getCode().equals(merchantPoi.getMatchStatus())){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该店铺未匹配成功,暂不能同步"); + } + + + return null; + } + private String supplierMatch(TenantEntity tenantInfo, List merchantPoiList){ TtSupplierMatchList matchList = new TtSupplierMatchList(); for (TtMerchantPoi poi:merchantPoiList) { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMsgValidationcodeServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMsgValidationcodeServiceImpl.java index b5cc683eb..3751eb6b3 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMsgValidationcodeServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMsgValidationcodeServiceImpl.java @@ -96,7 +96,7 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic String systemTime = DateUtils.getSystemTime("yyyy-MM-dd"); wxMsgValidationcode.setCreatetimeStr(systemTime); List list = wxMsgValidationcodeMapper.findList(wxMsgValidationcode); - if (list.size() == 3) { + if (list.size() >= 8) { return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "验证码发送超限"); } diff --git a/mallinkService/src/main/resources/mapper/TtMerchantPoiMapper.xml b/mallinkService/src/main/resources/mapper/TtMerchantPoiMapper.xml index a09a559e1..2cfabf2ed 100644 --- a/mallinkService/src/main/resources/mapper/TtMerchantPoiMapper.xml +++ b/mallinkService/src/main/resources/mapper/TtMerchantPoiMapper.xml @@ -86,7 +86,7 @@