|
|
|
@@ -271,7 +271,7 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { |
|
|
|
TtMerchantPoi updPoi = new TtMerchantPoi(); |
|
|
|
updPoi.setId(id); |
|
|
|
updPoi.setSupplierId(supplierId); |
|
|
|
updPoi.setLastSyncStatus(EnumSupplierSyncStatus.sync_wait.getCode()); |
|
|
|
updPoi.setLastSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); |
|
|
|
updPoi.setUpdateDate(new Date()); |
|
|
|
ttMerchantPoiMapper.updateById(merchantPoi); |
|
|
|
return new ResultData(); |
|
|
|
@@ -475,6 +475,45 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { |
|
|
|
return ttWebService; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData findPoi(TenantEntity tenantInfo, Long couponChannelId) { |
|
|
|
WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); |
|
|
|
if(couponChannel == null || !EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到上架卷数据"); |
|
|
|
} |
|
|
|
if(!EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode().equals(couponChannel.getTargetAd())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"只有投放在列表的卷才能进行同步poi"); |
|
|
|
} |
|
|
|
WxCoupon coupon = wxCouponMapper.selectById(couponChannel.getCouponId(), tenantInfo.getTenantId()); |
|
|
|
if(coupon == null || !EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode().equals(coupon.getStatus())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到可投放的卷"); |
|
|
|
} |
|
|
|
if(!EnumCouponType.getSpuSyncType().contains(coupon.getType())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"卷类型不支持同步poi"); |
|
|
|
} |
|
|
|
List<TtMerchantPoi> list = new ArrayList<>(); |
|
|
|
// TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong(tenantInfo.getTenantId())); |
|
|
|
TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong("1038")); |
|
|
|
list.add(merchantPoi); |
|
|
|
|
|
|
|
List<Long> merchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), tenantInfo.getTenantId()); |
|
|
|
if(merchantIds == null || merchantIds.size() == 0 ){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到门店"); |
|
|
|
} |
|
|
|
|
|
|
|
TtMerchantPoi poi = new TtMerchantPoi(); |
|
|
|
poi.updateTenantInfo(tenantInfo); |
|
|
|
poi.setIds(merchantIds); |
|
|
|
poi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode()); |
|
|
|
poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); |
|
|
|
List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi); |
|
|
|
if(poiList != null && poiList.size() > 0){ |
|
|
|
list.addAll(poiList); |
|
|
|
} |
|
|
|
|
|
|
|
return new ResultData(list); |
|
|
|
} |
|
|
|
|
|
|
|
private void updateWebAccessToken(WxAppinfo appinfo, TtWebService ttWebService) { |
|
|
|
try { |
|
|
|
String accessToken = ttWebService.getAccessToken(true); |
|
|
|
@@ -496,7 +535,7 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData spuSync(TenantEntity tenantInfo, Long couponChannelId) { |
|
|
|
public ResultData spuSync(TenantEntity tenantInfo, Long couponChannelId, List<Long> merchantIds) { |
|
|
|
WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); |
|
|
|
if(couponChannel == null || !EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到上架卷数据"); |
|
|
|
@@ -511,19 +550,16 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { |
|
|
|
if(!EnumCouponType.getSpuSyncType().contains(coupon.getType())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"卷类型不支持同步poi"); |
|
|
|
} |
|
|
|
List<Long> merchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), tenantInfo.getTenantId()); |
|
|
|
if(merchantIds == null || merchantIds.size() == 0 ){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到门店"); |
|
|
|
} |
|
|
|
TtMerchantPoi poiQ = new TtMerchantPoi(); |
|
|
|
poiQ.updateTenantInfo(tenantInfo); |
|
|
|
poiQ.setIds(merchantIds); |
|
|
|
poiQ.setMatchStatus(EnumSupplierMathStatus.match_success.getCode()); |
|
|
|
poiQ.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); |
|
|
|
List<TtMerchantPoi> list = ttMerchantPoiMapper.findList(poiQ); |
|
|
|
if(list == null || list.size() != merchantIds.size()){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"部分商品门店未同步,请先同步门店"); |
|
|
|
TtMerchantPoi poi = new TtMerchantPoi(); |
|
|
|
poi.updateTenantInfo(tenantInfo); |
|
|
|
poi.setIds(merchantIds); |
|
|
|
poi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode()); |
|
|
|
poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); |
|
|
|
List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi); |
|
|
|
if(merchantIds.size() != poiList.size()){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到poi或poi不匹配"); |
|
|
|
} |
|
|
|
|
|
|
|
String spuId = spuSync(coupon,couponChannel,merchantIds); |
|
|
|
if(StringUtils.isBlank(spuId)){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"同步失败"); |
|
|
|
|