| @@ -78,6 +78,7 @@ public class TtMerchantPoiController extends BaseController { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该状态不允许修改"); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该状态不允许修改"); | ||||
| } | } | ||||
| record.updateTenantInfo(getTenantInfo()); | record.updateTenantInfo(getTenantInfo()); | ||||
| record.setMatchStatus(EnumSupplierMathStatus.match_update.getCode()); | |||||
| ttMerchantPoiService.updateById(record); | ttMerchantPoiService.updateById(record); | ||||
| return new ResultData(record); | return new ResultData(record); | ||||
| } | } | ||||
| @@ -104,4 +105,15 @@ public class TtMerchantPoiController extends BaseController { | |||||
| return ttMerchantPoiService.matchAgain(getTenantInfo(),id); | 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); | |||||
| } | |||||
| } | } | ||||
| @@ -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<TtMerchantPoi> pois = ttMerchantPoiService.findTaskIdList(merchantPoiQ); | |||||
| if(pois != null && pois.size() > 0){ | |||||
| for (TtMerchantPoi poi:pois) { | |||||
| try{ | |||||
| ttMerchantPoiService.supplierQueryTask(poi); | |||||
| }catch(Exception e){ | |||||
| logger.error("查询匹配任务失败"); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -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 | * @param supplierTaskIds | ||||
| * supplier_task_ids 第三方上传任务id列表,多个任务id用 , 分割,单次查询最多10个任务。 | * 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 | * @param supplierExtId | ||||
| * supplier_ext_id 第三方店铺id列表,多个商铺id用 , 分割,单次查询最多50个店铺。 | * supplier_ext_id 第三方店铺id列表,多个商铺id用 , 分割,单次查询最多50个店铺。 | ||||
| @@ -11,7 +11,7 @@ public interface TtMerchantPoiMapper extends CommonMapper<TtMerchantPoi, Long> { | |||||
| List<Long> findIdList(TtMerchantPoi record); | List<Long> findIdList(TtMerchantPoi record); | ||||
| List<String> findTaskIdList(TtMerchantPoi record); | |||||
| List<TtMerchantPoi> findTaskIdList(TtMerchantPoi record); | |||||
| int deleteByUpdate(Long id); | int deleteByUpdate(Long id); | ||||
| @@ -31,5 +31,12 @@ public interface TtMerchantPoiService { | |||||
| ResultData matchAgain(TenantEntity tenantInfo, Long id); | ResultData matchAgain(TenantEntity tenantInfo, Long id); | ||||
| List<TtMerchantPoi> findTaskIdList(TtMerchantPoi merchantPoiQ); | |||||
| void supplierQueryTask(TtMerchantPoi poi); | |||||
| ResultData merchantSync(TenantEntity tenantInfo, Long id); | |||||
| TtWebService getTtWebService(TenantEntity tenantInfo); | TtWebService getTtWebService(TenantEntity tenantInfo); | ||||
| } | } | ||||
| @@ -63,6 +63,7 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||||
| @Override | @Override | ||||
| public int updateById(TtMerchantPoi record) { | public int updateById(TtMerchantPoi record) { | ||||
| record.setUpdateDate(new Date()); | |||||
| return ttMerchantPoiMapper.updateById(record); | return ttMerchantPoiMapper.updateById(record); | ||||
| } | } | ||||
| @@ -145,6 +146,54 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @Override | |||||
| public List<TtMerchantPoi> 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<TtMerchantPoi> merchantPoiList){ | private String supplierMatch(TenantEntity tenantInfo, List<TtMerchantPoi> merchantPoiList){ | ||||
| TtSupplierMatchList matchList = new TtSupplierMatchList(); | TtSupplierMatchList matchList = new TtSupplierMatchList(); | ||||
| for (TtMerchantPoi poi:merchantPoiList) { | for (TtMerchantPoi poi:merchantPoiList) { | ||||
| @@ -96,7 +96,7 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| String systemTime = DateUtils.getSystemTime("yyyy-MM-dd"); | String systemTime = DateUtils.getSystemTime("yyyy-MM-dd"); | ||||
| wxMsgValidationcode.setCreatetimeStr(systemTime); | wxMsgValidationcode.setCreatetimeStr(systemTime); | ||||
| List<WxMsgValidationcode> list = wxMsgValidationcodeMapper.findList(wxMsgValidationcode); | List<WxMsgValidationcode> list = wxMsgValidationcodeMapper.findList(wxMsgValidationcode); | ||||
| if (list.size() == 3) { | |||||
| if (list.size() >= 8) { | |||||
| return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "验证码发送超限"); | return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "验证码发送超限"); | ||||
| } | } | ||||
| @@ -86,7 +86,7 @@ | |||||
| </select> | </select> | ||||
| <select id="findTaskIdList" parameterType="com.iformall.domain.po.TtMerchantPoi" resultType="String"> | <select id="findTaskIdList" parameterType="com.iformall.domain.po.TtMerchantPoi" resultType="String"> | ||||
| select distinct task_id | |||||
| select distinct `tenant_id`,`parent_tenant_id`,`task_id` | |||||
| from tt_merchant_poi | from tt_merchant_poi | ||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| </select> | </select> | ||||