From c5bef7aab6443adba4f517af60883edeb936c50c Mon Sep 17 00:00:00 2001 From: xhxu Date: Wed, 26 Jul 2023 17:42:27 +0800 Subject: [PATCH] //..coupon_ --- .../market/TtCouponGoodsController.java | 56 +++++++- .../market/WxCouponChannelController.java | 2 +- .../controller/market/WxCouponController.java | 2 + .../controller/WxCouponChannelController.java | 2 +- .../mapper/WxCouponChannelMapper.java | 1 + .../service/TtCouponGoodsService.java | 4 +- .../impl/TtCouponGoodsServiceImpl.java | 122 ++++++++++-------- .../service/impl/WxCampaignServiceImpl.java | 4 +- .../impl/WxCouponChannelServiceImpl.java | 2 +- .../FmInsideProductPushMsgServiceImpl.java | 32 ++++- 10 files changed, 162 insertions(+), 65 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java index 778334f59..2339011d9 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java @@ -7,6 +7,7 @@ import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; import com.iformall.controller.base.DouyinBaseController; +import com.iformall.domain.po.TtCouponChannelPoi; import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.base.BaseEntity; import com.iformall.domain.vo.TtCouponChannelVo; @@ -153,6 +154,39 @@ public class TtCouponGoodsController extends DouyinBaseController { } } + @TenantIgnore + @ApiOperation("根据id更新接口") + @PostMapping("updateOnlieStatus") + @SystemControllerLog(description = "抖音poi 上下架") + public ResultData updateOnlieStatus(@RequestBody WxCoupon wxCoupon) { + logger.debug("[" + getIpAddr() + "] WxCouponController::updateOnlieStatus"); + if (wxCoupon.getId() == null) { + return new ResultData(ResultData.ERROR, "缺少id"); + } + TtCouponChannelPoi ttCouponChannelPoi = ttCouponGoodsService.getCouponChannelByCouponId(getTenantInfo(), wxCoupon.getId()); + if(ttCouponChannelPoi == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"审核数据异常"); + } + EnumSpuSyncStatus poiStatus = EnumSpuSyncStatus.getEnum(ttCouponChannelPoi.getStatus()); + if(poiStatus == null || EnumSpuSyncStatus.sync_auditing.equals(poiStatus) || EnumSpuSyncStatus.sync_audit_rejection.equals(poiStatus)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"审核状态异常"); + } + if (wxCoupon.getPoiStatus() == null) { + return new ResultData(ResultData.ERROR, "缺少状态值"); + } + EnumSpuSyncStatus updPoiStatus = EnumSpuSyncStatus.getEnum(wxCoupon.getPoiStatus()); + if(updPoiStatus == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"上下架参数异常"); + } + try { + boolean isSaas = this.isGoodLifeSaas(); + return ttCouponGoodsService.productOperate(getTenantInfo(), wxCoupon.getId(),updPoiStatus,isSaas); + } catch (Exception e) { + logger.error("product draft error.",e); + return new ResultData(Result.ERROR,e.getMessage()); + } + } + @TenantIgnore @ApiOperation("实时查询审核状态") @GetMapping("product/draft") @@ -188,6 +222,7 @@ public class TtCouponGoodsController extends DouyinBaseController { } + @ApiOperation("实时同步上下架状态") @GetMapping("product/operate") @SystemControllerLog(description = "实时同步上下架状态") @@ -195,9 +230,17 @@ public class TtCouponGoodsController extends DouyinBaseController { if (id == null) { return new ResultData(ResultData.ERROR, "缺少id"); } + TtCouponChannelPoi ttCouponChannelPoi = ttCouponGoodsService.getCouponChannelByCouponId(getTenantInfo(), id); + if(ttCouponChannelPoi == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"审核数据异常"); + } + EnumSpuSyncStatus poiStatus = EnumSpuSyncStatus.getEnum(ttCouponChannelPoi.getStatus()); + if(poiStatus == null || EnumSpuSyncStatus.sync_auditing.equals(poiStatus) || EnumSpuSyncStatus.sync_audit_rejection.equals(poiStatus)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"审核状态异常"); + } try { boolean isSaas = this.isGoodLifeSaas(); - return ttCouponGoodsService.productOperate(getTenantInfo(),id,isSaas); + return ttCouponGoodsService.productOperate(getTenantInfo(),id,poiStatus,isSaas); } catch (Exception e) { logger.error("allTreeList error.",e); return new ResultData(Result.ERROR,e.getMessage()); @@ -212,9 +255,18 @@ public class TtCouponGoodsController extends DouyinBaseController { if (id == null) { return new ResultData(ResultData.ERROR, "缺少id"); } + TtCouponChannelPoi ttCouponChannelPoi = ttCouponGoodsService.getCouponChannelByCouponId(getTenantInfo(), id); + if(ttCouponChannelPoi == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"审核数据异常"); + } + EnumSpuSyncStatus poiStatus = EnumSpuSyncStatus.getEnum(ttCouponChannelPoi.getStatus()); + if(poiStatus == null || EnumSpuSyncStatus.sync_auditing.equals(poiStatus) || EnumSpuSyncStatus.sync_audit_rejection.equals(poiStatus)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"审核状态异常"); + } try { boolean isSaas = this.isGoodLifeSaas(); - return ttCouponGoodsService.productStockSync(getTenantInfo(),id,isSaas); + + return ttCouponGoodsService.productStockSync(getTenantInfo(),id,isSaas); } catch (Exception e) { logger.error("allTreeList error.",e); return new ResultData(Result.ERROR,e.getMessage()); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java index 598ec006b..0caeb4d22 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java @@ -100,7 +100,7 @@ public class WxCouponChannelController extends BaseController { if(couponChannel!=null){ wxCouponChannelService.updateQrCode(couponChannel,couponChannel.getId(),couponChannel.getType()); - wxCouponChannelService.spuStatusSyncByCoupon(couponChannel,couponChannel.getCouponId()); +// wxCouponChannelService.spuStatusSyncByCoupon(couponChannel,couponChannel.getCouponId()); } CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId()); CouponCacheUtils.removeDouyinLivePageCache(redisTemplate, wxCouponChannel.getTenantId(), null, null); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java index c3eff8bf9..4f2ef3df6 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java @@ -47,6 +47,8 @@ public class WxCouponController extends BaseController { @Autowired private WxCouponChannelService wxCouponChannelService; @Autowired + private TtCouponGoodsService ttCouponGoodsService; + @Autowired private WxFlowService wxFlowService; @Autowired private WxMallService wxMallService; diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java index 33c021485..aa8fdf3c7 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java @@ -84,7 +84,7 @@ public class WxCouponChannelController extends BaseController { if(couponChannel!=null){ wxCouponChannelService.updateQrCode(couponChannel,couponChannel.getId(),couponChannel.getType()); - wxCouponChannelService.spuStatusSyncByCoupon(couponChannel,couponChannel.getCouponId()); +// wxCouponChannelService.spuStatusSyncByCoupon(couponChannel,couponChannel.getCouponId()); } CouponCacheUtils.removeCouponChannelCache(redisTemplate, wxCouponChannel.getId()); return resultData; diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java index a32c0b20b..ac3f78028 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java @@ -74,4 +74,5 @@ public interface WxCouponChannelMapper extends CommonMapper wxCouponChannels = wxCouponChannelMapper.findList(wxCouponChannelQuery); - if(wxCouponChannels.size() > 0){ - op_type = EnumSpuSyncStatus.sync_put_on.getCode(); + TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),couponId); + if(ttCouponChannelPoi == null || + (!EnumSpuSyncStatus.sync_put_on.getCode().equals(ttCouponChannelPoi.getStatus()) + && !EnumSpuSyncStatus.sync_pull_off.getCode().equals(ttCouponChannelPoi.getStatus()))){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券上下架状态异常"); + } + if(!op_type.equals(ttCouponChannelPoi.getStatus())){ + if(EnumSpuSyncStatus.sync_put_on.getCode().equals(op_type)){ + WxCouponChannel couponChannel = new WxCouponChannel(); + couponChannel.setId(ttCouponChannelPoi.getCouponChannelId()); + couponChannel.updateTenantInfo(ttCouponChannelPoi); + couponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); + couponChannel.setUpdateDate(new Date()); + wxCouponChannelMapper.updateById(couponChannel); + }else{ + WxCouponChannel couponChannel = new WxCouponChannel(); + couponChannel.updateTenantInfo(ttCouponChannelPoi); + couponChannel.setCouponId(ttCouponChannelPoi.getId()); + couponChannel.setStatus(EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()); + couponChannel.setUpdateDate(new Date()); + wxCouponChannelMapper.updateStatusByCouponId(couponChannel); } } - if(op_type.equals(ttCouponChannelPoi.getStatus())){ - logger.info("与线上状态一致, 无需同步{}"+wxCoupon.getId()); - return new ResultData(); - } - try { boolean b = false; if (isSaas) { - b = ttMerchantPoiService.getTtGoodLifeSassService(ttCouponChannelPoi).getGoodsService().productOperate(getDouyinLaikeId(wxCoupon),null,wxCoupon.getId().toString(),op_type); + b = ttMerchantPoiService.getTtGoodLifeSassService(tenantInfo).getGoodsService().productOperate(getDouyinLaikeId(tenantInfo),null,ttCouponChannelPoi.getId().toString(),op_type); }else { - b = ttMerchantPoiService.getTtWebService(ttCouponChannelPoi).getGoodsService().productOperate(null,wxCoupon.getId().toString(),op_type); + b = ttMerchantPoiService.getTtWebService(tenantInfo).getGoodsService().productOperate(null,ttCouponChannelPoi.getId().toString(),op_type); } if(b){ - TtCouponChannelPoi ccPoi = new TtCouponChannelPoi(); - ccPoi.setId(ttCouponChannelPoi.getId()); - ccPoi.updateTenantInfo(ttCouponChannelPoi); - ccPoi.setStatus(op_type); - ccPoi.setUpdateDate(new Date()); - ttCouponChannelPoiMapper.updateById(ccPoi); return new ResultData(); }else{ - return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); +// return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); } - } catch (WxErrorException e) { e.printStackTrace(); - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),e.getError().getErrorMsg()); + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),e.getError().getErrorMsg()); +// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),e.getError().getErrorMsg()); } catch (Exception e) { - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),e.getMessage()); + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),e.getMessage()); +// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),e.getMessage()); } } @@ -701,17 +724,17 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { if(wxCoupon == null){ return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未找到"); } - TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),id); - if(ttCouponChannelPoi == null || EnumSpuSyncStatus.sync_auditing.getCode().equals(ttCouponChannelPoi.getStatus()) - || EnumSpuSyncStatus.sync_audit_rejection.getCode().equals(ttCouponChannelPoi.getStatus())){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未提交审核或审核未通过"); - } +// TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),id); +// if(ttCouponChannelPoi == null || EnumSpuSyncStatus.sync_auditing.getCode().equals(ttCouponChannelPoi.getStatus()) +// || EnumSpuSyncStatus.sync_audit_rejection.getCode().equals(ttCouponChannelPoi.getStatus())){ +// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未提交审核或审核未通过"); +// } try { boolean b = false; if (isSaas) { - b = ttMerchantPoiService.getTtGoodLifeSassService(ttCouponChannelPoi).getGoodsService().stockSync(getDouyinLaikeId(ttCouponChannelPoi),null,wxCoupon.getId().toString(),wxCoupon.getInventory()); + b = ttMerchantPoiService.getTtGoodLifeSassService(tenantInfo).getGoodsService().stockSync(getDouyinLaikeId(tenantInfo),null,wxCoupon.getId().toString(),wxCoupon.getInventory()); } else { - b = ttMerchantPoiService.getTtWebService(ttCouponChannelPoi).getGoodsService().stockSync(null,wxCoupon.getId().toString(),wxCoupon.getInventory()); + b = ttMerchantPoiService.getTtWebService(tenantInfo).getGoodsService().stockSync(null,wxCoupon.getId().toString(),wxCoupon.getInventory()); } if(b){ return new ResultData(); @@ -733,18 +756,13 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { if(wxCoupon == null){ return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未找到"); } - TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),id); - if(ttCouponChannelPoi == null || EnumSpuSyncStatus.sync_auditing.getCode().equals(ttCouponChannelPoi.getStatus()) - || EnumSpuSyncStatus.sync_audit_rejection.getCode().equals(ttCouponChannelPoi.getStatus())){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未提交审核或审核未通过"); - } try { boolean b = false; if (isSaas) { - b = ttMerchantPoiService.getTtGoodLifeSassService(ttCouponChannelPoi).getGoodsService().productFreeAudit(getDouyinLaikeId(ttCouponChannelPoi),null,wxCoupon.getId().toString(), + b = ttMerchantPoiService.getTtGoodLifeSassService(tenantInfo).getGoodsService().productFreeAudit(getDouyinLaikeId(tenantInfo),null,wxCoupon.getId().toString(), null,wxCoupon.getInventory()); }else { - b = ttMerchantPoiService.getTtWebService(ttCouponChannelPoi).getGoodsService().productFreeAudit(null,wxCoupon.getId().toString(), + b = ttMerchantPoiService.getTtWebService(tenantInfo).getGoodsService().productFreeAudit(null,wxCoupon.getId().toString(), null,wxCoupon.getInventory()); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java index eafb05727..81b2a7c41 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java @@ -284,7 +284,7 @@ public class WxCampaignServiceImpl implements WxCampaignService { wxCouponChannel.setUpdateDate(new Date()); wxCouponChannelMapper.updateById(wxCouponChannel); - wxCouponChannelService.spuStatusSyncByCoupon(wxCouponChannel,wxCouponChannel.getCouponId()); +// wxCouponChannelService.spuStatusSyncByCoupon(wxCouponChannel,wxCouponChannel.getCouponId()); } } } @@ -382,7 +382,7 @@ public class WxCampaignServiceImpl implements WxCampaignService { wxCouponChannelService.updateQrCode(wxCouponChannel,wxCouponChannel.getId(),wxCouponChannel.getType()); } - wxCouponChannelService.spuStatusSyncByCoupon(wxCouponChannel,couponId); +// wxCouponChannelService.spuStatusSyncByCoupon(wxCouponChannel,couponId); } @Override 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 eda0cd00b..905fee4e0 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -765,7 +765,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { this.updateQrCode(channel,channel.getId(),channel.getType()); - this.spuStatusSyncByCoupon(channel,channel.getCouponId()); +// this.spuStatusSyncByCoupon(channel,channel.getCouponId()); } return vo; } 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 d34c3c83e..a116ffbe6 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 @@ -1,10 +1,16 @@ package com.iformall.service.msg.impl; +import com.iformall.common.ErrorCode; +import com.iformall.common.ResultData; +import com.iformall.domain.po.TtCouponChannelPoi; import com.iformall.domain.po.WxMallVersion; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.msg.BaseMsg; import com.iformall.domain.po.msg.FmInsideProductPushMsg; import com.iformall.enums.EnumDouyinApplicationVersion; import com.iformall.enums.EnumPushType; +import com.iformall.enums.EnumSpuSyncStatus; +import com.iformall.mapper.TtCouponChannelPoiMapper; import com.iformall.service.TtCouponGoodsService; import com.iformall.service.TtGoodsCategoryService; import com.iformall.service.TtMerchantPoiService; @@ -34,24 +40,40 @@ public class FmInsideProductPushMsgServiceImpl implements MsgSendService { @Autowired private WxMallService wxMallService; + @Autowired + private TtCouponChannelPoiMapper ttCouponChannelPoiMapper; + @Override public void send(BaseMsg baseMsg) throws Exception{ FmInsideProductPushMsg msg = (FmInsideProductPushMsg)baseMsg; + TenantEntity tenantInfo = msg.getTenantInfo(); + try{ Thread.currentThread().sleep(1000);//延时秒 }catch(Exception e){} - EnumDouyinApplicationVersion douyinApplicationVersion = wxMallService.getDouyinApplicationVersion(msg.getTenantInfo()); + EnumDouyinApplicationVersion douyinApplicationVersion = wxMallService.getDouyinApplicationVersion(tenantInfo); boolean isSaas = EnumDouyinApplicationVersion.GOODLIFE_SAAS.equals(douyinApplicationVersion); - + + TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),msg.getCouponId()); + if(ttCouponChannelPoi == null){ + logger.error("处理抖音商品同步数据异常(审核数据为空){}"+tenantInfo.getTenantId()+"--"+msg.getCouponId()); + return; + } + EnumSpuSyncStatus poiStatus = EnumSpuSyncStatus.getEnum(ttCouponChannelPoi.getStatus()); + if(poiStatus == null || EnumSpuSyncStatus.sync_auditing.equals(poiStatus) || EnumSpuSyncStatus.sync_audit_rejection.equals(poiStatus)){ + logger.error("处理抖音商品同步数据异常(状态异常){}"+tenantInfo.getTenantId()+"--"+msg.getCouponId()); + return; + } + if(EnumPushType.SPU_STATUS_SYNC.equals(msg.getSyncType())){ - ttCouponGoodsService.productOperate(msg.getTenantInfo(),msg.getCouponId(),isSaas); + ttCouponGoodsService.productOperate(tenantInfo,ttCouponChannelPoi,msg.getCouponId(),poiStatus,isSaas); // poiService.spuStatusSync(msg.getTenantInfo(),msg.getCouponId()); }else if(EnumPushType.SPU_STOCK_SYNC.equals(msg.getSyncType())){ - ttCouponGoodsService.productStockSync(msg.getTenantInfo(),msg.getCouponId(),isSaas); + ttCouponGoodsService.productStockSync(tenantInfo,msg.getCouponId(),isSaas); // poiService.spuStockSync(msg.getTenantInfo(),msg.getCouponId()); }else if(EnumPushType.SPU_FREE_AUDIT_SYNC.equals(msg.getSyncType())){ - ttCouponGoodsService.productFreeAudit(msg.getTenantInfo(),msg.getCouponId(),isSaas); + ttCouponGoodsService.productFreeAudit(tenantInfo,msg.getCouponId(),isSaas); } }