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 b87223f2b..a36b9334c 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java @@ -137,80 +137,80 @@ public class TtMerchantPoiController extends BaseController { return ttMerchantPoiService.supplierQuery(getTenantInfo(),id); } - @ApiOperation("获取商品可用的POI") - @GetMapping("/findPoi") - @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) - @SystemControllerLog(description = "查询") - public ResultData findPoi(Long couponChannelId) { - logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::findPoi"); - if(couponChannelId == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); - } - return ttMerchantPoiService.findPoi(getTenantInfo(),couponChannelId); - } - - @ApiOperation("商品同步") - @PostMapping("spuSync") - @SystemControllerLog(description = "商品同步") - public ResultData spuSync(@RequestBody Map param) { - logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuSync"); - String couponChannelIdStr = param.get("couponChannelId"); - Long couponChannelId = null; - try{ - couponChannelId = Long.parseLong(couponChannelIdStr); - }catch(Exception e){ - return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); - } - if(couponChannelId == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); - } -// String merchantIdStr = param.get("merchantIds"); -// List merchantIds = new ArrayList<>(); +// @ApiOperation("获取商品可用的POI") +// @GetMapping("/findPoi") +// @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) +// @SystemControllerLog(description = "查询") +// public ResultData findPoi(Long couponChannelId) { +// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::findPoi"); +// if(couponChannelId == null){ +// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); +// } +// return ttMerchantPoiService.findPoi(getTenantInfo(),couponChannelId); +// } + +// @ApiOperation("商品同步") +// @PostMapping("spuSync") +// @SystemControllerLog(description = "商品同步") +// public ResultData spuSync(@RequestBody Map param) { +// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuSync"); +// String couponChannelIdStr = param.get("couponChannelId"); +// Long couponChannelId = null; // try{ -// List strings = Arrays.asList(merchantIdStr.split(",")); -// merchantIds = strings.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()); +// couponChannelId = Long.parseLong(couponChannelIdStr); // }catch(Exception e){ // return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); // } -// if(merchantIds == null || merchantIds.size() == 0){ +// if(couponChannelId == null){ // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); // } - return ttMerchantPoiService.spuSync(getTenantInfo(),couponChannelId,null); - } - - @ApiOperation("商品同步查询") - @GetMapping("spuGet") - @SystemControllerLog(description = "商品同步查询") - public ResultData spuGet(Long couponChannelId) { - logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuGet"); - if(couponChannelId == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); - } - return ttMerchantPoiService.spuGet(getTenantInfo(),couponChannelId); - } - - @ApiOperation("商品状态同步") - @PostMapping("spuStatusSync") - @SystemControllerLog(description = "商品状态同步") - public ResultData spuStatusSync(@RequestBody Map param) { - logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStatusSync"); - Long couponChannelId = param.get("couponChannelId"); - if(couponChannelId == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); - } - return ttMerchantPoiService.spuStatusSync(getTenantInfo(),couponChannelId); - } - - @ApiOperation("商品库存同步") - @PostMapping("spuStockSync") - @SystemControllerLog(description = "商品库存同步") - public ResultData spuStockSync(@RequestBody Map param) { - logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStockSync"); - Long couponChannelId = param.get("couponChannelId"); - if(couponChannelId == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); - } - return ttMerchantPoiService.spuStockSync(getTenantInfo(),couponChannelId); - } +//// String merchantIdStr = param.get("merchantIds"); +//// List merchantIds = new ArrayList<>(); +//// try{ +//// List strings = Arrays.asList(merchantIdStr.split(",")); +//// merchantIds = strings.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()); +//// }catch(Exception e){ +//// return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); +//// } +//// if(merchantIds == null || merchantIds.size() == 0){ +//// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); +//// } +// return ttMerchantPoiService.spuSync(getTenantInfo(),couponChannelId,null); +// } + +// @ApiOperation("商品同步查询") +// @GetMapping("spuGet") +// @SystemControllerLog(description = "商品同步查询") +// public ResultData spuGet(Long couponChannelId) { +// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuGet"); +// if(couponChannelId == null){ +// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); +// } +// return ttMerchantPoiService.spuGet(getTenantInfo(),couponChannelId); +// } +// +// @ApiOperation("商品状态同步") +// @PostMapping("spuStatusSync") +// @SystemControllerLog(description = "商品状态同步") +// public ResultData spuStatusSync(@RequestBody Map param) { +// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStatusSync"); +// Long couponChannelId = param.get("couponChannelId"); +// if(couponChannelId == null){ +// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); +// } +// return ttMerchantPoiService.spuStatusSync(getTenantInfo(),couponChannelId); +// } +// +// @ApiOperation("商品库存同步") +// @PostMapping("spuStockSync") +// @SystemControllerLog(description = "商品库存同步") +// public ResultData spuStockSync(@RequestBody Map param) { +// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStockSync"); +// Long couponChannelId = param.get("couponChannelId"); +// if(couponChannelId == null){ +// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); +// } +// return ttMerchantPoiService.spuStockSync(getTenantInfo(),couponChannelId); +// } } diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java index 10c4bd5eb..2dc3622d7 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java @@ -68,13 +68,13 @@ public class CouponExpiringSchedule { wxCouponSendMapper.offExpiriedCouponSendByCouponStatus(mall.getTenantId()); - List ids = wxCouponChannelMapper.getExpiriedCouponChannelIdsByCouponStatus(mall.getTenantId()); + List couponIds = wxCouponChannelMapper.getExpiriedCouponIdsByCouponStatus(mall.getTenantId()); wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus(mall.getTenantId()); //同步poi - if(ids != null && ids.size() > 0){ - for (Long id: ids) { + if(couponIds != null && couponIds.size() > 0){ + for (Long couponId: couponIds) { try{ - wxCouponChannelService.spuStatusSync(mall,id); + wxCouponChannelService.spuStatusSyncByCoupon(mall,couponId); }catch(Exception e){ logger.error("send spuStatusSync error: " + e.getMessage()); } @@ -107,34 +107,34 @@ public class CouponExpiringSchedule { List malls = getMalls(); for (WxMall mall : malls) { try { - List ids = new ArrayList<>(); + List couponIds = new ArrayList<>(); - List id1s = wxCouponChannelMapper.getExpiriedCouponChannelIdsByEndTime(mall.getTenantId()); - if(id1s != null && id1s.size() > 0){ - ids.removeAll(id1s); - ids.addAll(id1s); + List couponId1s = wxCouponChannelMapper.getExpiriedCouponIdsByEndTime(mall.getTenantId()); + if(couponId1s != null && couponId1s.size() > 0){ + couponIds.removeAll(couponId1s); + couponIds.addAll(couponId1s); } wxCouponChannelMapper.offExpiriedCouponChannelByEndTime(mall.getTenantId()); - List id2s = wxCouponChannelMapper.getExpiriedCouponChannelIdsByValidDate(mall.getTenantId()); - if(id2s != null && id2s.size() > 0){ - ids.removeAll(id2s); - ids.addAll(id2s); + List couponId2s = wxCouponChannelMapper.getExpiriedCouponIdsByValidDate(mall.getTenantId()); + if(couponId2s != null && couponId2s.size() > 0){ + couponIds.removeAll(couponId2s); + couponIds.addAll(couponId2s); } wxCouponChannelMapper.offExpiriedCouponChannelByValidDate(mall.getTenantId()); - List id3s = wxCouponChannelMapper.getExpiriedCouponChannelIdsByCouponStatus(mall.getTenantId()); + List id3s = wxCouponChannelMapper.getExpiriedCouponIdsByCouponStatus(mall.getTenantId()); if(id3s != null && id3s.size() > 0){ - ids.removeAll(id3s); - ids.addAll(id3s); + couponIds.removeAll(id3s); + couponIds.addAll(id3s); } wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus(mall.getTenantId()); //同步poi - if(ids != null && ids.size() > 0){ - for (Long id: ids) { + if(couponIds != null && couponIds.size() > 0){ + for (Long couponId: couponIds) { try{ - wxCouponChannelService.spuStatusSync(mall,id); + wxCouponChannelService.spuStatusSyncByCoupon(mall,couponId); }catch(Exception e){ logger.error("send spuStatusSync error: " + e.getMessage()); } diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantPoiSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantPoiSchedule.java index af09e3eb8..eb5268081 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantPoiSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantPoiSchedule.java @@ -59,21 +59,21 @@ public class TtMerchantPoiSchedule { // } // } - @Async - @Scheduled(cron = "0 0 */1 * * *?") // 每小时检查一次 - public void supplierQueryTaskSchedule() { - TtCouponChannelPoi ttCouponChannelPoi = new TtCouponChannelPoi(); - ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode()); - List list = ttCouponChannelPoiMapper.findList(ttCouponChannelPoi); - if(list != null && list.size() > 0){ - for (TtCouponChannelPoi poi:list) { - try{ - ttMerchantPoiService.spuGet(poi,poi.getId()); - }catch(Exception e){ - logger.error("查询商品同步任务失败"); - } - } - } - } +// @Async +// @Scheduled(cron = "0 0 */1 * * *?") // 每小时检查一次 +// public void supplierQueryTaskSchedule() { +// TtCouponChannelPoi ttCouponChannelPoi = new TtCouponChannelPoi(); +// ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode()); +// List list = ttCouponChannelPoiMapper.findList(ttCouponChannelPoi); +// if(list != null && list.size() > 0){ +// for (TtCouponChannelPoi poi:list) { +// try{ +// ttMerchantPoiService.spuGet(poi,poi.getId()); +// }catch(Exception e){ +// logger.error("查询商品同步任务失败"); +// } +// } +// } +// } } \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideProductPushMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideProductPushMsg.java index 36941991c..49605fece 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideProductPushMsg.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideProductPushMsg.java @@ -10,8 +10,8 @@ import lombok.ToString; @EqualsAndHashCode(callSuper = true) public class FmInsideProductPushMsg extends BaseMsg{ - @io.swagger.annotations.ApiModelProperty(value = "卷Id", name = "couponChannelId") - private Long couponChannelId; + @io.swagger.annotations.ApiModelProperty(value = "卷Id", name = "couponId") + private Long couponId; @io.swagger.annotations.ApiModelProperty(value = "同步类型", name = "syncType") private EnumPushType syncType; diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java index 87bafb55b..ed4ad3011 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java @@ -26,13 +26,13 @@ public interface WxCouponChannelMapper extends CommonMapper getExpiriedCouponChannelIdsByEndTime(@Param("tenantId")String tenantId);//同步poi状态 + List getExpiriedCouponIdsByEndTime(@Param("tenantId")String tenantId);//同步poi状态 void offExpiriedCouponChannelByEndTime(@Param("tenantId")String tenantId); - List getExpiriedCouponChannelIdsByValidDate(@Param("tenantId")String tenantId);//同步poi状态 + List getExpiriedCouponIdsByValidDate(@Param("tenantId")String tenantId);//同步poi状态 void offExpiriedCouponChannelByValidDate(@Param("tenantId")String tenantId); - List getExpiriedCouponChannelIdsByCouponStatus(@Param("tenantId")String tenantId);//同步poi状态 + List getExpiriedCouponIdsByCouponStatus(@Param("tenantId")String tenantId);//同步poi状态 void offExpiriedCouponChannelByCouponStatus(@Param("tenantId")String tenantId); void offExpiriedCouponChannel2ByEndTime(@Param("tenantId")String tenantId); @@ -51,14 +51,6 @@ public interface WxCouponChannelMapper extends CommonMapper newfindCList(WxCouponChannel wxCouponChannel); List liveHomeList(WxCouponChannel wxCouponChannel); - - /** - * 查询已同步的上架卷的Id - * @param tenantId - * @param id - * @return - */ - List getPoiProductIdList(@Param("tenantId")String tenantId, @Param("couponId")Long couponId); Integer reduceChannelStock(@Param("id")Long id,@Param("tenantId")String tenantId,@Param("number")Integer number); diff --git a/mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java b/mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java index 2baa3490a..b6887ae9c 100644 --- a/mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java +++ b/mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java @@ -43,14 +43,14 @@ public interface TtMerchantPoiService { TtWebService getTtWebService(TenantEntity tenantInfo); - ResultData findPoi(TenantEntity tenantInfo, Long couponChannelId); +// ResultData findPoi(TenantEntity tenantInfo, Long couponChannelId); - ResultData spuSync(TenantEntity tenantInfo, Long couponChannelId,List merchantIds); +// ResultData spuSync(TenantEntity tenantInfo, Long couponChannelId,List merchantIds); - ResultData spuGet(TenantEntity tenantInfo, Long couponChannelId); +// ResultData spuGet(TenantEntity tenantInfo, Long couponChannelId); - ResultData spuStatusSync(TenantEntity tenantInfo, Long couponChannelId); +// ResultData spuStatusSync(TenantEntity tenantInfo, Long couponChannelId); - ResultData spuStockSync(TenantEntity tenantInfo, Long couponChannelId); +// ResultData spuStockSync(TenantEntity tenantInfo, Long couponChannelId); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java index 7db48b56b..335b5907d 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java @@ -46,7 +46,7 @@ public interface WxCouponChannelService { */ ResultData saveOrUpdate(WxCouponChannel record); - void spuStatusSync(TenantEntity tenantEntity,Long id); + void spuStatusSyncByCoupon(TenantEntity tenantEntity,Long couponId); /** * 创建二维码 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 8d1eb5155..852d2cf2e 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java @@ -505,45 +505,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 list = new ArrayList<>(); -// TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong(tenantInfo.getTenantId())); -//// TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong("1038")); -// list.add(merchantPoi); - - List 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 poiList = ttMerchantPoiMapper.findList(poi); - if(poiList != null && merchantIds.size() == poiList.size()){ - return new ResultData(poiList); - }else{ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该商品店铺与poi门店不匹配"); - } - - } +// @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 list = new ArrayList<>(); +//// TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong(tenantInfo.getTenantId())); +////// TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong("1038")); +//// list.add(merchantPoi); +// +// List 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 poiList = ttMerchantPoiMapper.findList(poi); +// if(poiList != null && merchantIds.size() == poiList.size()){ +// return new ResultData(poiList); +// }else{ +// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该商品店铺与poi门店不匹配"); +// } +// +// } private void updateWebAccessToken(WxAppinfo appinfo, TtWebService ttWebService) { try { @@ -565,386 +565,386 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { } } - @Override - public ResultData spuSync(TenantEntity tenantInfo, Long couponChannelId, List 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(),"未找到上架卷数据"); - } - 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 couponMerchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), tenantInfo.getTenantId()); - if(couponMerchantIds == null || couponMerchantIds.size() == 0 ){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到门店"); - } - - TtMerchantPoi poi = new TtMerchantPoi(); - poi.updateTenantInfo(tenantInfo); - poi.setIds(couponMerchantIds); - poi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode()); - poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); - List poiList = ttMerchantPoiMapper.findList(poi); - if(poiList == null || poiList.isEmpty()){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到匹配的poi"); - } -// List collect = poiList.stream().map(p -> p.getId()).collect(Collectors.toList()); - - String spuId = spuSync(coupon,couponChannel,couponMerchantIds); - if(StringUtils.isBlank(spuId)){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"同步失败"); - } - WxCouponChannel ccUpd = new WxCouponChannel(); - ccUpd.setId(couponChannel.getId()); - ccUpd.updateTenantInfo(couponChannel); - ccUpd.setTtSpuId(spuId); - ccUpd.setUpdateDate(new Date()); - wxCouponChannelMapper.updateById(ccUpd); - - syncCouponChannelPoi(ccUpd); - return new ResultData(); - } - - private void syncCouponChannelPoi(WxCouponChannel ccUpd){ - TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(ccUpd.getTenantId(),ccUpd.getId()); - if(ttCouponChannelPoi != null){ - ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode()); - ttCouponChannelPoi.setLastStatusDesc(""); - ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate()); - ttCouponChannelPoiMapper.updateById(ttCouponChannelPoi); - }else{ - ttCouponChannelPoi = new TtCouponChannelPoi(); - ttCouponChannelPoi.setId(ccUpd.getId()); - ttCouponChannelPoi.updateTenantInfo(ccUpd); - ttCouponChannelPoi.setSpuId(ccUpd.getTtSpuId()); - ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode()); - ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode()); - ttCouponChannelPoi.setCreateDate(ccUpd.getUpdateDate()); - ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate()); - ttCouponChannelPoiMapper.insert(ttCouponChannelPoi); - } - } - - private String spuSync(WxCoupon coupon,WxCouponChannel couponChannel, List merchantIds){ - TtSpuSync spuSync = new TtSpuSync(); - spuSync.setEntryInfo(getEntryInfo(couponChannel)); -// spuSync.setFrontCategoryTag();//前台品类标签 -// spuSync.setRecommendWord();//推荐语,5~20个字 -// spuSync.setSortWeight();//排序权重,按降序排列 - List collect = merchantIds.stream().map(merchantId -> merchantId.toString()).collect(Collectors.toList()); - spuSync.setSupplierExtIdList(collect); - spuSync.setPrice(coupon.getSalePrice()); - spuSync.setSpuExtId(couponChannel.getId().toString()); - spuSync.setImageList(JSONArray.parseArray(coupon.getCoverPicture(),String.class)); -// spuSync.setMpSettletype();//小程序结算类型 1-包销 2-代销 - spuSync.setOriginPrice(coupon.getPrice()); -// spuSync.setTakeRate();//商品的抽佣率,万分数 - spuSync.setAttribute(getAttribute(coupon,couponChannel)); -// spuSync.setHighlights(getHighlights(coupon)); - spuSync.setName(coupon.getTitle()); -// spuSync.setOrderDependsOnDate(false);//下单是否依赖日期 - spuSync.setSpuType(91);//spu类型号,1-日历房,30-酒店民宿预售券,90-门票,91-团购券 - if(EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ - spuSync.setStatus(1); - }else{ - spuSync.setStatus(2); - } - spuSync.setStock(coupon.getRemainInventory()); - - String spuId = null; - try { - spuId = getTtWebService(coupon).getProductService().spuSync(spuSync); - } catch (WxErrorException e) { - logger.error("发起商品同步error"+e.getMessage()); - throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); - } - return spuId; - } +// @Override +// public ResultData spuSync(TenantEntity tenantInfo, Long couponChannelId, List 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(),"未找到上架卷数据"); +// } +// 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 couponMerchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), tenantInfo.getTenantId()); +// if(couponMerchantIds == null || couponMerchantIds.size() == 0 ){ +// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到门店"); +// } +// +// TtMerchantPoi poi = new TtMerchantPoi(); +// poi.updateTenantInfo(tenantInfo); +// poi.setIds(couponMerchantIds); +// poi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode()); +// poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); +// List poiList = ttMerchantPoiMapper.findList(poi); +// if(poiList == null || poiList.isEmpty()){ +// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到匹配的poi"); +// } +//// List collect = poiList.stream().map(p -> p.getId()).collect(Collectors.toList()); +// +// String spuId = spuSync(coupon,couponChannel,couponMerchantIds); +// if(StringUtils.isBlank(spuId)){ +// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"同步失败"); +// } +// WxCouponChannel ccUpd = new WxCouponChannel(); +// ccUpd.setId(couponChannel.getId()); +// ccUpd.updateTenantInfo(couponChannel); +// ccUpd.setTtSpuId(spuId); +// ccUpd.setUpdateDate(new Date()); +// wxCouponChannelMapper.updateById(ccUpd); +// +// syncCouponChannelPoi(ccUpd); +// return new ResultData(); +// } + +// private void syncCouponChannelPoi(WxCouponChannel ccUpd){ +// TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(ccUpd.getTenantId(),ccUpd.getId()); +// if(ttCouponChannelPoi != null){ +// ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode()); +// ttCouponChannelPoi.setLastStatusDesc(""); +// ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate()); +// ttCouponChannelPoiMapper.updateById(ttCouponChannelPoi); +// }else{ +// ttCouponChannelPoi = new TtCouponChannelPoi(); +// ttCouponChannelPoi.setId(ccUpd.getId()); +// ttCouponChannelPoi.updateTenantInfo(ccUpd); +// ttCouponChannelPoi.setSpuId(ccUpd.getTtSpuId()); +// ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode()); +// ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode()); +// ttCouponChannelPoi.setCreateDate(ccUpd.getUpdateDate()); +// ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate()); +// ttCouponChannelPoiMapper.insert(ttCouponChannelPoi); +// } +// } + +// private String spuSync(WxCoupon coupon,WxCouponChannel couponChannel, List merchantIds){ +// TtSpuSync spuSync = new TtSpuSync(); +// spuSync.setEntryInfo(getEntryInfo(couponChannel)); +//// spuSync.setFrontCategoryTag();//前台品类标签 +//// spuSync.setRecommendWord();//推荐语,5~20个字 +//// spuSync.setSortWeight();//排序权重,按降序排列 +// List collect = merchantIds.stream().map(merchantId -> merchantId.toString()).collect(Collectors.toList()); +// spuSync.setSupplierExtIdList(collect); +// spuSync.setPrice(coupon.getSalePrice()); +// spuSync.setSpuExtId(couponChannel.getId().toString()); +// spuSync.setImageList(JSONArray.parseArray(coupon.getCoverPicture(),String.class)); +//// spuSync.setMpSettletype();//小程序结算类型 1-包销 2-代销 +// spuSync.setOriginPrice(coupon.getPrice()); +//// spuSync.setTakeRate();//商品的抽佣率,万分数 +// spuSync.setAttribute(getAttribute(coupon,couponChannel)); +//// spuSync.setHighlights(getHighlights(coupon)); +// spuSync.setName(coupon.getTitle()); +//// spuSync.setOrderDependsOnDate(false);//下单是否依赖日期 +// spuSync.setSpuType(91);//spu类型号,1-日历房,30-酒店民宿预售券,90-门票,91-团购券 +// if(EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ +// spuSync.setStatus(1); +// }else{ +// spuSync.setStatus(2); +// } +// spuSync.setStock(coupon.getRemainInventory()); +// +// String spuId = null; +// try { +// spuId = getTtWebService(coupon).getProductService().spuSync(spuSync); +// } catch (WxErrorException e) { +// logger.error("发起商品同步error"+e.getMessage()); +// throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); +// } +// return spuId; +// } //__________________________________商品同步_______________________________________________ //获取入口信息 - private JsonObject getEntryInfo(WxCouponChannel couponChannel){ - JsonObject object = new JsonObject(); - object.addProperty("entry_type",2);//入口类型(1:H5,2:抖音小程序,3:抖音链接) - JsonObject miniApp = new JsonObject(); - miniApp.addProperty("params",couponChannel.getTtparams()); - miniApp.addProperty("path",couponChannel.getTtPath()); - WxAppinfo appInfo = wxAppinfoService.getCAppInfo(couponChannel, EnumAppPlat.TOUTIAO); - miniApp.addProperty("app_id",appInfo.getAppId()); - object.add("entry_miniApp",miniApp); - return object; - } - - //获取SPU属性字段 - private JsonObject getAttribute(WxCoupon coupon,WxCouponChannel couponChannel){ +// private JsonObject getEntryInfo(WxCouponChannel couponChannel){ // JsonObject object = new JsonObject(); - JsonObject productObjuct = new JsonObject(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - productObjuct.addProperty("groupon_valid_start",dateFormat.format(couponChannel.getShowBeginTime()));//团购售卖时间开始 - // todo 要求必传, 可能为空 - productObjuct.addProperty("groupon_valid_end",dateFormat.format(coupon.getValidEndDate()));//******* - - productObjuct.addProperty("order_limit",coupon.getUseLimitQuantity());//单个用户购买数量限制 - if(EnumCouponValidType.BETWEEN_TWO_TIME.getCode().equals(coupon.getValidType())){ - productObjuct.addProperty("order_valid_start",dateFormat.format(coupon.getValidStartDate())); - productObjuct.addProperty("order_valid_end",dateFormat.format(coupon.getValidEndDate())); - }else if(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode().equals(coupon.getValidType())){ - productObjuct.addProperty("post_purchase_day",coupon.getValidDays()); - } - //todo 商家客服电话 目前传的广场的客服电话 联系人广场名称 - WxMall mall = wxMallMapper.getByTenantId(coupon.getTenantId()); - JsonArray phoneArray = new JsonArray(); - phoneArray.add(mall.getServicePhone()); - productObjuct.add("service_phone",phoneArray); - productObjuct.addProperty("contact_name",mall.getName()); - - //todo 团购须知 要求格式 标题加类容 是否二选一 待测试 - JsonArray notificationArray = new JsonArray(); -// for ( : ) { - JsonObject contentObject = new JsonObject(); - contentObject.addProperty("title","");//标题 - contentObject.addProperty("content",coupon.getRemark());//内容 - notificationArray.add(contentObject); -// } - productObjuct.add("notification",notificationArray); - if(EnumCouponContentType.HTML.getCode().equals(coupon.getContentType())){ - productObjuct.addProperty("notification_rich_text",coupon.getHtml()); - } - productObjuct.addProperty("sub_title",coupon.getSubTitle()); - - //todo 团购详情 要求必传, 待测试 - if(StringUtils.isNotBlank(coupon.getItemGroup())){ - JsonArray groupArray = new JsonParser().parse(coupon.getItemGroup()).getAsJsonArray(); - productObjuct.add("pay_item_groups",groupArray); - } -// JsonArray groupArray = new JsonArray(); -// for ( : ) { -// JsonObject groupObject = new JsonObject(); -// groupObject.addProperty("group_name","标题");//标题 -// JsonArray itemArray = new JsonArray(); //菜品 -// for (:) { -// JsonObject itemObject = new JsonObject(); -// itemObject.addProperty("name","菜名"); -// itemObject.addProperty("count","数量"); -// itemObject.addProperty("price","价格"); -// itemArray.add(itemObject); -// } -// groupObject.add("item_list",itemArray); -// groupArray.add(groupObject); -// } -// productObjuct.add("pay_item_groups",groupArray); - - //使用日期规则 -// JsonObject dateRuleObject = new JsonObject(); -// JsonObject unDateObject = new JsonObject();//不可用日期 -// JsonArray dateArray = new JsonArray();//日期列表,格式yyyy-mm-dd,最多传100个 -// JsonArray weekDayArray = new JsonArray();//星期列表,1-7代表周一到周天,[1,2]代表周一周二不可用 -// unDateObject.add("date_list",dateArray); -// unDateObject.add("weekday_list",weekDayArray); -// dateRuleObject.add("unavailable_date",unDateObject); -// productObjuct.add("date_rule",dateRuleObject); - - return productObjuct; - } - - //商品亮点标签 - private JsonArray getHighlights(WxCoupon coupon){ - JsonArray array = new JsonArray(); -// for (:) { -// JsonObject object = new JsonObject(); -// object.addProperty("content",);//介绍,字符串长度<=5 -// object.addProperty("priority",);//优先级,数字越小优先级越高 -// array.add(object); +// object.addProperty("entry_type",2);//入口类型(1:H5,2:抖音小程序,3:抖音链接) +// JsonObject miniApp = new JsonObject(); +// miniApp.addProperty("params",couponChannel.getTtparams()); +// miniApp.addProperty("path",couponChannel.getTtPath()); +// WxAppinfo appInfo = wxAppinfoService.getCAppInfo(couponChannel, EnumAppPlat.TOUTIAO); +// miniApp.addProperty("app_id",appInfo.getAppId()); +// object.add("entry_miniApp",miniApp); +// return object; +// } +// +// //获取SPU属性字段 +// private JsonObject getAttribute(WxCoupon coupon,WxCouponChannel couponChannel){ +//// JsonObject object = new JsonObject(); +// JsonObject productObjuct = new JsonObject(); +// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// productObjuct.addProperty("groupon_valid_start",dateFormat.format(couponChannel.getShowBeginTime()));//团购售卖时间开始 +// // todo 要求必传, 可能为空 +// productObjuct.addProperty("groupon_valid_end",dateFormat.format(coupon.getValidEndDate()));//******* +// +// productObjuct.addProperty("order_limit",coupon.getUseLimitQuantity());//单个用户购买数量限制 +// if(EnumCouponValidType.BETWEEN_TWO_TIME.getCode().equals(coupon.getValidType())){ +// productObjuct.addProperty("order_valid_start",dateFormat.format(coupon.getValidStartDate())); +// productObjuct.addProperty("order_valid_end",dateFormat.format(coupon.getValidEndDate())); +// }else if(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode().equals(coupon.getValidType())){ +// productObjuct.addProperty("post_purchase_day",coupon.getValidDays()); // } - return array; - } +// //todo 商家客服电话 目前传的广场的客服电话 联系人广场名称 +// WxMall mall = wxMallMapper.getByTenantId(coupon.getTenantId()); +// JsonArray phoneArray = new JsonArray(); +// phoneArray.add(mall.getServicePhone()); +// productObjuct.add("service_phone",phoneArray); +// productObjuct.addProperty("contact_name",mall.getName()); +// +// //todo 团购须知 要求格式 标题加类容 是否二选一 待测试 +// JsonArray notificationArray = new JsonArray(); +//// for ( : ) { +// JsonObject contentObject = new JsonObject(); +// contentObject.addProperty("title","");//标题 +// contentObject.addProperty("content",coupon.getRemark());//内容 +// notificationArray.add(contentObject); +//// } +// productObjuct.add("notification",notificationArray); +// if(EnumCouponContentType.HTML.getCode().equals(coupon.getContentType())){ +// productObjuct.addProperty("notification_rich_text",coupon.getHtml()); +// } +// productObjuct.addProperty("sub_title",coupon.getSubTitle()); +// +// //todo 团购详情 要求必传, 待测试 +// if(StringUtils.isNotBlank(coupon.getItemGroup())){ +// JsonArray groupArray = new JsonParser().parse(coupon.getItemGroup()).getAsJsonArray(); +// productObjuct.add("pay_item_groups",groupArray); +// } +//// JsonArray groupArray = new JsonArray(); +//// for ( : ) { +//// JsonObject groupObject = new JsonObject(); +//// groupObject.addProperty("group_name","标题");//标题 +//// JsonArray itemArray = new JsonArray(); //菜品 +//// for (:) { +//// JsonObject itemObject = new JsonObject(); +//// itemObject.addProperty("name","菜名"); +//// itemObject.addProperty("count","数量"); +//// itemObject.addProperty("price","价格"); +//// itemArray.add(itemObject); +//// } +//// groupObject.add("item_list",itemArray); +//// groupArray.add(groupObject); +//// } +//// productObjuct.add("pay_item_groups",groupArray); +// +// //使用日期规则 +//// JsonObject dateRuleObject = new JsonObject(); +//// JsonObject unDateObject = new JsonObject();//不可用日期 +//// JsonArray dateArray = new JsonArray();//日期列表,格式yyyy-mm-dd,最多传100个 +//// JsonArray weekDayArray = new JsonArray();//星期列表,1-7代表周一到周天,[1,2]代表周一周二不可用 +//// unDateObject.add("date_list",dateArray); +//// unDateObject.add("weekday_list",weekDayArray); +//// dateRuleObject.add("unavailable_date",unDateObject); +//// productObjuct.add("date_rule",dateRuleObject); +// +// return productObjuct; +// } +// +// //商品亮点标签 +// private JsonArray getHighlights(WxCoupon coupon){ +// JsonArray array = new JsonArray(); +//// for (:) { +//// JsonObject object = new JsonObject(); +//// object.addProperty("content",);//介绍,字符串长度<=5 +//// object.addProperty("priority",);//优先级,数字越小优先级越高 +//// array.add(object); +//// } +// return array; +// } //_________________________________________________________________________________ - @Override - public ResultData spuGet(TenantEntity tenantInfo, Long couponChannelId) { - WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); - if(couponChannel == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据"); - } - if(StringUtils.isBlank(couponChannel.getTtSpuId())){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi"); - } - TtSpuGet spuGet = new TtSpuGet(); - spuGet.setSpuExtId(couponChannel.getId().toString()); - spuGet.setNeedSpuDraft(true); - spuGet.setSpuDraftcount(3); - try { - TtSpuGetResult spuGetResult = getTtWebService(tenantInfo).getProductService().spuGet(spuGet); - handSyncCouponChannelPoi(tenantInfo,spuGetResult); - //处理一下数据 - Map map = new HashMap<>(); - if(spuGetResult.getSpuDetail() != null){//线上数据 - TtSpuSync spuDetail = spuGetResult.getSpuDetail(); - map.put("spuDetail",handSpuSync(spuDetail)); - } - if(spuGetResult.getSpuDraft() != null && spuGetResult.getSpuDraft().size() > 0){//最近一次审核数据 - TtSpuSync spuDraft = spuGetResult.getSpuDraft().get(0); - map.put("spuDraft",handSpuSync(spuDraft)); - } - return new ResultData(map); - } catch (WxErrorException e) { - logger.error("couponChannelId:"+couponChannelId +" 多门店SPU信息查询error "+e.getMessage()); - return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); - } - } - - private void handSyncCouponChannelPoi(TenantEntity tenantInfo,TtSpuGetResult spuGetResult){ - Date now = new Date(); - TtSpuSync spuDetail = spuGetResult.getSpuDetail(); - if(spuDetail != null && StringUtils.isNotBlank(spuDetail.getSpuId()) && StringUtils.isNotBlank(spuDetail.getSpuExtId()) - && spuDetail.getStatus() != null){ - TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),Long.parseLong(spuDetail.getSpuExtId())); - if(ttCouponChannelPoi != null && !spuDetail.getStatus().equals(ttCouponChannelPoi.getStatus())){ - TtCouponChannelPoi ccPoi = new TtCouponChannelPoi(); - ccPoi.setId(ttCouponChannelPoi.getId()); - ccPoi.setStatus(spuDetail.getStatus()); - ccPoi.setStatusDesc(spuDetail.getStatusDesc()); - ccPoi.setUpdateDate(now); - ttCouponChannelPoiMapper.updateById(ccPoi); - }else if(ttCouponChannelPoi == null){ - ttCouponChannelPoi = new TtCouponChannelPoi(); - ttCouponChannelPoi.setId(Long.parseLong(spuDetail.getSpuExtId())); - ttCouponChannelPoi.updateTenantInfo(tenantInfo); - ttCouponChannelPoi.setSpuId(spuDetail.getSpuId()); - ttCouponChannelPoi.setStatus(spuDetail.getStatus()); - ttCouponChannelPoi.setStatusDesc(spuDetail.getStatusDesc()); - ttCouponChannelPoi.setCreateDate(now); - ttCouponChannelPoi.setUpdateDate(now); - ttCouponChannelPoiMapper.insert(ttCouponChannelPoi); - } - } - List spuDraftList = spuGetResult.getSpuDraft(); - if(spuDraftList != null && spuDraftList.size() > 0){ - TtSpuSync spuDraft = spuDraftList.get(0); - if(spuDraft != null && StringUtils.isNotBlank(spuDraft.getSpuId()) && StringUtils.isNotBlank(spuDraft.getSpuExtId()) - && spuDraft.getStatus() != null){ - TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),Long.parseLong(spuDraft.getSpuExtId())); - if(ttCouponChannelPoi != null && !spuDraft.getStatus().equals(ttCouponChannelPoi.getStatus())){ - TtCouponChannelPoi ccPoi = new TtCouponChannelPoi(); - ccPoi.setId(ttCouponChannelPoi.getId()); - ccPoi.setLastStatus(spuDraft.getStatus()); - ccPoi.setLastStatusDesc(spuDraft.getStatusDesc()); - ccPoi.setUpdateDate(now); - ttCouponChannelPoiMapper.updateById(ccPoi); - }else if(ttCouponChannelPoi == null){ - ttCouponChannelPoi = new TtCouponChannelPoi(); - ttCouponChannelPoi.setId(Long.parseLong(spuDraft.getSpuExtId())); - ttCouponChannelPoi.updateTenantInfo(tenantInfo); - ttCouponChannelPoi.setSpuId(spuDraft.getSpuId()); - ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode()); - ttCouponChannelPoi.setLastStatus(spuDraft.getStatus()); - ttCouponChannelPoi.setLastStatusDesc(spuDraft.getStatusDesc()); - ttCouponChannelPoi.setCreateDate(now); - ttCouponChannelPoi.setUpdateDate(now); - ttCouponChannelPoiMapper.insert(ttCouponChannelPoi); - } - } - } - } - - private Map handSpuSync(TtSpuSync spuSync){ - Map map = new HashMap<>(); - map.put("id",spuSync.getSpuExtId()); - map.put("spu_id",spuSync.getSpuId()); - map.put("image_list",spuSync.getImageList()); - map.put("name",spuSync.getName()); - if(spuSync.getAttribute() != null){ - JsonObject attribute = spuSync.getAttribute(); - JsonArray pay_item_groups = attribute.getAsJsonArray("pay_item_groups"); - map.put("pay_item_groups",pay_item_groups.toString()); - JsonArray notification = attribute.getAsJsonArray("notification"); - map.put("notification",notification.toString()); - map.put("order_limit", GsonHelper.getString(attribute, "order_limit")); - //售卖有效期 - map.put("groupon_valid_start", GsonHelper.getString(attribute, "groupon_valid_start")); - map.put("groupon_valid_end", GsonHelper.getString(attribute, "groupon_valid_end")); - //卷有效期 - map.put("order_valid_start", GsonHelper.getString(attribute, "order_valid_start")); - map.put("order_valid_end", GsonHelper.getString(attribute, "order_valid_end")); - - } - - map.put("price",spuSync.getPrice()); - map.put("origin_price",spuSync.getOriginPrice()); - map.put("stock",spuSync.getStock()); - map.put("status",spuSync.getStatus()); - map.put("status_desc",spuSync.getStatusDesc()); - return map; - } - - @Override - public ResultData spuStatusSync(TenantEntity tenantInfo, Long couponChannelId) { - WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); - if(couponChannel == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据"); - } - if(StringUtils.isBlank(couponChannel.getTtSpuId())){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi"); - } - TtSpuStatusSync statusSync = new TtSpuStatusSync(); - List ids = new ArrayList<>(); - ids.add(couponChannel.getId().toString()); - statusSync.setSpuExtIdList(ids); - if(EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ - statusSync.setStatus(1); - }else{ - statusSync.setStatus(2); - } - try { - TtSpuStatusSync statusSyncResult = getTtWebService(tenantInfo).getProductService().spuStatusSync(statusSync); - if(statusSyncResult.getSpuExtIdList() != null && statusSyncResult.getSpuExtIdList().containsAll(ids)){ - return new ResultData(); - } - } catch (WxErrorException e) { - logger.error("couponChannelId:"+couponChannelId +" 多门店SPU状态同步error "+e.getMessage()); - throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); -// return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); - } - throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); -// return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); - } - - @Override - public ResultData spuStockSync(TenantEntity tenantInfo, Long couponChannelId) { - WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); - if(couponChannel == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据"); - } - if(StringUtils.isBlank(couponChannel.getTtSpuId())){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi"); - } - WxCoupon coupon = wxCouponMapper.selectById(couponChannel.getCouponId(), tenantInfo.getTenantId()); - if(coupon == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到卷数据"); - } - TtSpuStockSync stockSync = new TtSpuStockSync(); - stockSync.setSpuExtId(couponChannel.getId().toString()); - stockSync.setStock(coupon.getRemainInventory()); - try { - boolean syncResult = getTtWebService(tenantInfo).getProductService().spuStockUpdate(stockSync); - if(syncResult){ - return new ResultData(); - } - } catch (WxErrorException e) { - logger.error("couponChannelId:"+couponChannelId +" 多门店SPU状态同步error "+e.getMessage()); - throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); +// @Override +// public ResultData spuGet(TenantEntity tenantInfo, Long couponChannelId) { +// WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); +// if(couponChannel == null){ +// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据"); +// } +// if(StringUtils.isBlank(couponChannel.getTtSpuId())){ +// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi"); +// } +// TtSpuGet spuGet = new TtSpuGet(); +// spuGet.setSpuExtId(couponChannel.getId().toString()); +// spuGet.setNeedSpuDraft(true); +// spuGet.setSpuDraftcount(3); +// try { +// TtSpuGetResult spuGetResult = getTtWebService(tenantInfo).getProductService().spuGet(spuGet); +// handSyncCouponChannelPoi(tenantInfo,spuGetResult); +// //处理一下数据 +// Map map = new HashMap<>(); +// if(spuGetResult.getSpuDetail() != null){//线上数据 +// TtSpuSync spuDetail = spuGetResult.getSpuDetail(); +// map.put("spuDetail",handSpuSync(spuDetail)); +// } +// if(spuGetResult.getSpuDraft() != null && spuGetResult.getSpuDraft().size() > 0){//最近一次审核数据 +// TtSpuSync spuDraft = spuGetResult.getSpuDraft().get(0); +// map.put("spuDraft",handSpuSync(spuDraft)); +// } +// return new ResultData(map); +// } catch (WxErrorException e) { +// logger.error("couponChannelId:"+couponChannelId +" 多门店SPU信息查询error "+e.getMessage()); // return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); - } - throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); -// return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); - } +// } +// } +// +// private void handSyncCouponChannelPoi(TenantEntity tenantInfo,TtSpuGetResult spuGetResult){ +// Date now = new Date(); +// TtSpuSync spuDetail = spuGetResult.getSpuDetail(); +// if(spuDetail != null && StringUtils.isNotBlank(spuDetail.getSpuId()) && StringUtils.isNotBlank(spuDetail.getSpuExtId()) +// && spuDetail.getStatus() != null){ +// TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),Long.parseLong(spuDetail.getSpuExtId())); +// if(ttCouponChannelPoi != null && !spuDetail.getStatus().equals(ttCouponChannelPoi.getStatus())){ +// TtCouponChannelPoi ccPoi = new TtCouponChannelPoi(); +// ccPoi.setId(ttCouponChannelPoi.getId()); +// ccPoi.setStatus(spuDetail.getStatus()); +// ccPoi.setStatusDesc(spuDetail.getStatusDesc()); +// ccPoi.setUpdateDate(now); +// ttCouponChannelPoiMapper.updateById(ccPoi); +// }else if(ttCouponChannelPoi == null){ +// ttCouponChannelPoi = new TtCouponChannelPoi(); +// ttCouponChannelPoi.setId(Long.parseLong(spuDetail.getSpuExtId())); +// ttCouponChannelPoi.updateTenantInfo(tenantInfo); +// ttCouponChannelPoi.setSpuId(spuDetail.getSpuId()); +// ttCouponChannelPoi.setStatus(spuDetail.getStatus()); +// ttCouponChannelPoi.setStatusDesc(spuDetail.getStatusDesc()); +// ttCouponChannelPoi.setCreateDate(now); +// ttCouponChannelPoi.setUpdateDate(now); +// ttCouponChannelPoiMapper.insert(ttCouponChannelPoi); +// } +// } +// List spuDraftList = spuGetResult.getSpuDraft(); +// if(spuDraftList != null && spuDraftList.size() > 0){ +// TtSpuSync spuDraft = spuDraftList.get(0); +// if(spuDraft != null && StringUtils.isNotBlank(spuDraft.getSpuId()) && StringUtils.isNotBlank(spuDraft.getSpuExtId()) +// && spuDraft.getStatus() != null){ +// TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),Long.parseLong(spuDraft.getSpuExtId())); +// if(ttCouponChannelPoi != null && !spuDraft.getStatus().equals(ttCouponChannelPoi.getStatus())){ +// TtCouponChannelPoi ccPoi = new TtCouponChannelPoi(); +// ccPoi.setId(ttCouponChannelPoi.getId()); +// ccPoi.setLastStatus(spuDraft.getStatus()); +// ccPoi.setLastStatusDesc(spuDraft.getStatusDesc()); +// ccPoi.setUpdateDate(now); +// ttCouponChannelPoiMapper.updateById(ccPoi); +// }else if(ttCouponChannelPoi == null){ +// ttCouponChannelPoi = new TtCouponChannelPoi(); +// ttCouponChannelPoi.setId(Long.parseLong(spuDraft.getSpuExtId())); +// ttCouponChannelPoi.updateTenantInfo(tenantInfo); +// ttCouponChannelPoi.setSpuId(spuDraft.getSpuId()); +// ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode()); +// ttCouponChannelPoi.setLastStatus(spuDraft.getStatus()); +// ttCouponChannelPoi.setLastStatusDesc(spuDraft.getStatusDesc()); +// ttCouponChannelPoi.setCreateDate(now); +// ttCouponChannelPoi.setUpdateDate(now); +// ttCouponChannelPoiMapper.insert(ttCouponChannelPoi); +// } +// } +// } +// } +// +// private Map handSpuSync(TtSpuSync spuSync){ +// Map map = new HashMap<>(); +// map.put("id",spuSync.getSpuExtId()); +// map.put("spu_id",spuSync.getSpuId()); +// map.put("image_list",spuSync.getImageList()); +// map.put("name",spuSync.getName()); +// if(spuSync.getAttribute() != null){ +// JsonObject attribute = spuSync.getAttribute(); +// JsonArray pay_item_groups = attribute.getAsJsonArray("pay_item_groups"); +// map.put("pay_item_groups",pay_item_groups.toString()); +// JsonArray notification = attribute.getAsJsonArray("notification"); +// map.put("notification",notification.toString()); +// map.put("order_limit", GsonHelper.getString(attribute, "order_limit")); +// //售卖有效期 +// map.put("groupon_valid_start", GsonHelper.getString(attribute, "groupon_valid_start")); +// map.put("groupon_valid_end", GsonHelper.getString(attribute, "groupon_valid_end")); +// //卷有效期 +// map.put("order_valid_start", GsonHelper.getString(attribute, "order_valid_start")); +// map.put("order_valid_end", GsonHelper.getString(attribute, "order_valid_end")); +// +// } +// +// map.put("price",spuSync.getPrice()); +// map.put("origin_price",spuSync.getOriginPrice()); +// map.put("stock",spuSync.getStock()); +// map.put("status",spuSync.getStatus()); +// map.put("status_desc",spuSync.getStatusDesc()); +// return map; +// } + +// @Override +// public ResultData spuStatusSync(TenantEntity tenantInfo, Long couponChannelId) { +// WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); +// if(couponChannel == null){ +// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据"); +// } +// if(StringUtils.isBlank(couponChannel.getTtSpuId())){ +// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi"); +// } +// TtSpuStatusSync statusSync = new TtSpuStatusSync(); +// List ids = new ArrayList<>(); +// ids.add(couponChannel.getId().toString()); +// statusSync.setSpuExtIdList(ids); +// if(EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ +// statusSync.setStatus(1); +// }else{ +// statusSync.setStatus(2); +// } +// try { +// TtSpuStatusSync statusSyncResult = getTtWebService(tenantInfo).getProductService().spuStatusSync(statusSync); +// if(statusSyncResult.getSpuExtIdList() != null && statusSyncResult.getSpuExtIdList().containsAll(ids)){ +// return new ResultData(); +// } +// } catch (WxErrorException e) { +// logger.error("couponChannelId:"+couponChannelId +" 多门店SPU状态同步error "+e.getMessage()); +// throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); +//// return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); +// } +// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); +//// return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); +// } + +// @Override +// public ResultData spuStockSync(TenantEntity tenantInfo, Long couponChannelId) { +// WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); +// if(couponChannel == null){ +// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据"); +// } +// if(StringUtils.isBlank(couponChannel.getTtSpuId())){ +// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi"); +// } +// WxCoupon coupon = wxCouponMapper.selectById(couponChannel.getCouponId(), tenantInfo.getTenantId()); +// if(coupon == null){ +// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到卷数据"); +// } +// TtSpuStockSync stockSync = new TtSpuStockSync(); +// stockSync.setSpuExtId(couponChannel.getId().toString()); +// stockSync.setStock(coupon.getRemainInventory()); +// try { +// boolean syncResult = getTtWebService(tenantInfo).getProductService().spuStockUpdate(stockSync); +// if(syncResult){ +// return new ResultData(); +// } +// } catch (WxErrorException e) { +// logger.error("couponChannelId:"+couponChannelId +" 多门店SPU状态同步error "+e.getMessage()); +// throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); +//// return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); +// } +// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); +//// return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); +// } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java index c25d4132e..8af6b2267 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -157,19 +157,17 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { wxCardInfoMapper.updateTransferStatusByCouponId(orignal.getCouponId()); //浮层下架 wxFloatingLayerMapper.updateStatus(orignal.getCouponId()); + + try{ + spuStatusSyncByCoupon(orignal,orignal.getCouponId()); + }catch(Exception e){ + logger.error("send spuStatusSync error: " + e.getMessage()); + } } } record.setUpdateDate(new Date()); wxCouponChannelMapper.updateById(record); - if(EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode().equals(record.getStatus())){ - try{ - spuStatusSync(record,record.getId()); - }catch(Exception e){ - logger.error("send spuStatusSync error: " + e.getMessage()); - } - } - } //清除缓存 @@ -178,12 +176,12 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { } @Override - public void spuStatusSync(TenantEntity tenantEntity, Long id) { + public void spuStatusSyncByCoupon(TenantEntity tenantEntity, Long couponId) { FmInsideProductPushMsg productPush = new FmInsideProductPushMsg(); productPush.setDelayTimeLevel(3); productPush.setMsgType(EnumMsgRecordType.INSIDE_PRODUCT_PUSH.getCode()); productPush.updateTenantInfo(tenantEntity); - productPush.setCouponChannelId(id); + productPush.setCouponId(couponId); productPush.setSyncType(EnumPushType.SPU_STATUS_SYNC); logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush); mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); @@ -304,24 +302,6 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { } } - private void spuStatusSyncByCoupon(TenantEntity tenantEntity, Long couponId){ - - List couponChannelIds = wxCouponChannelMapper.getPoiProductIdList(tenantEntity.getTenantId(),couponId); - if(couponChannelIds != null && couponChannelIds.size() > 0){ - for (Long couponChannelId:couponChannelIds) { - FmInsideProductPushMsg productPush = new FmInsideProductPushMsg(); - productPush.setDelayTimeLevel(3); - productPush.setMsgType(EnumMsgRecordType.INSIDE_PRODUCT_PUSH.getCode()); - productPush.updateTenantInfo(tenantEntity); - productPush.setCouponChannelId(couponChannelId); - productPush.setSyncType(EnumPushType.SPU_STATUS_SYNC); - logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush); - mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); - } - } - - } - @Override public ResultData change(WxCouponChannel record) { Long couponId = 0L; diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index 70a2efe9f..44e9b947f 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -1020,11 +1020,11 @@ public class WxCouponServiceImpl implements WxCouponService { if (num == 0) { throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); } - try{ - spuStockSync(tenantEntity,id); - }catch(Exception e){ - logger.error("send spuStockSync error: " + e.getMessage()); - } +// try{ +// spuStockSync(tenantEntity,id); +// }catch(Exception e){ +// logger.error("send spuStockSync error: " + e.getMessage()); +// } } @Override @@ -1034,14 +1034,14 @@ public class WxCouponServiceImpl implements WxCouponService { if (num == 0) { throw new MallinkException(ErrorCode.REMAIN_BACK_FAIL); } - try{ - spuStockSync(tenantEntity,id); - }catch(Exception e){ - logger.error("send spuStockSync error: " + e.getMessage()); - } +// try{ +// spuStockSync(tenantEntity,id); +// }catch(Exception e){ +// logger.error("send spuStockSync error: " + e.getMessage()); +// } } - private void spuStockSync(TenantEntity tenantEntity,Long id){ + private void spuStockSync(TenantEntity tenantEntity,Long couponId){ // new Thread(() -> { // //1秒之后同步poi // try { @@ -1050,19 +1050,14 @@ public class WxCouponServiceImpl implements WxCouponService { // logger.error("sleep error: " + e.getMessage()); // } - List couponChannelIds = wxCouponChannelMapper.getPoiProductIdList(tenantEntity.getTenantId(),id); - if(couponChannelIds != null && couponChannelIds.size() > 0){ - for (Long couponChannelId:couponChannelIds) { - FmInsideProductPushMsg productPush = new FmInsideProductPushMsg(); - productPush.setDelayTimeLevel(3); - productPush.setMsgType(EnumMsgRecordType.INSIDE_PRODUCT_PUSH.getCode()); - productPush.updateTenantInfo(tenantEntity); - productPush.setCouponChannelId(couponChannelId); - productPush.setSyncType(EnumPushType.SPU_STOCK_SYNC); - logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush); - mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); - } - } + FmInsideProductPushMsg productPush = new FmInsideProductPushMsg(); + productPush.setDelayTimeLevel(3); + productPush.setMsgType(EnumMsgRecordType.INSIDE_PRODUCT_PUSH.getCode()); + productPush.updateTenantInfo(tenantEntity); + productPush.setCouponId(couponId); + productPush.setSyncType(EnumPushType.SPU_STOCK_SYNC); + logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush); + mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); // }).start(); diff --git a/mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideProductPushMsgServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideProductPushMsgServiceImpl.java index ceecd8398..4a93820e1 100644 --- a/mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideProductPushMsgServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideProductPushMsgServiceImpl.java @@ -3,6 +3,8 @@ package com.iformall.service.msg.impl; import com.iformall.domain.po.msg.BaseMsg; import com.iformall.domain.po.msg.FmInsideProductPushMsg; import com.iformall.enums.EnumPushType; +import com.iformall.service.TtCouponGoodsService; +import com.iformall.service.TtGoodsCategoryService; import com.iformall.service.TtMerchantPoiService; import com.iformall.service.msg.MsgSendService; import org.slf4j.Logger; @@ -23,14 +25,19 @@ public class FmInsideProductPushMsgServiceImpl implements MsgSendService { @Autowired private TtMerchantPoiService poiService; + @Autowired + private TtCouponGoodsService ttCouponGoodsService; + @Override public void send(BaseMsg baseMsg) throws Exception{ FmInsideProductPushMsg msg = (FmInsideProductPushMsg)baseMsg; if(EnumPushType.SPU_STATUS_SYNC.equals(msg.getSyncType())){ - poiService.spuStatusSync(msg.getTenantInfo(),msg.getCouponChannelId()); + ttCouponGoodsService.productOperate(msg.getTenantInfo(),msg.getCouponId()); +// poiService.spuStatusSync(msg.getTenantInfo(),msg.getCouponId()); }else if(EnumPushType.SPU_STOCK_SYNC.equals(msg.getSyncType())){ - poiService.spuStockSync(msg.getTenantInfo(),msg.getCouponChannelId()); + ttCouponGoodsService.productOperate(msg.getTenantInfo(),msg.getCouponId()); +// poiService.spuStockSync(msg.getTenantInfo(),msg.getCouponId()); } } diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index f69862b47..26ae13e33 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -192,10 +192,9 @@ - + select distinct coupon_id from wx_coupon_channel where status = 0 and tenant_id = #{tenantId} and end_time < now() - and `tt_spu_id` is not null @@ -203,11 +202,10 @@ where status = 0 and tenant_id = #{tenantId} and end_time < now() - + select distinct cc.coupon_id from wx_coupon_channel cc, wx_coupon c where cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now() and cc.status = 0 and cc.tenant_id = #{tenantId} - and cc.`tt_spu_id` is not null @@ -215,11 +213,10 @@ where cc.status = 0 and cc.tenant_id = #{tenantId} and cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now() - + select distinct cc.coupon_id from wx_coupon_channel cc, wx_coupon c where cc.coupon_id = c.id and c.status = 1 and cc.status = 0 and cc.tenant_id = #{tenantId} - and cc.`tt_spu_id` is not null @@ -359,14 +356,6 @@ order by ${sortColumns} - - - update wx_coupon_channel SET channel_stock = channel_stock - #{number} where id = #{id} and tenant_id =#{tenantId} and channel_stock is not null and channel_stock - #{number} >= 0