From 717387cf6555bb1f791abe03f72b5a67eea71af9 Mon Sep 17 00:00:00 2001 From: xhxu Date: Fri, 10 Jun 2022 10:37:34 +0800 Subject: [PATCH] //tt product --- .../market/TtCouponGoodsController.java | 21 ++++++ .../domain/po/TtCouponChannelPoi.java | 1 + .../service/TtCouponGoodsService.java | 3 + .../impl/TtCouponGoodsServiceImpl.java | 69 ++++++++++++++++++- 4 files changed, 91 insertions(+), 3 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 b2113ac6e..74fefdbb1 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java @@ -158,6 +158,27 @@ public class TtCouponGoodsController extends BaseController { return ttCouponGoodsService.productOnlineGet(getTenantInfo(),id); } + @ApiOperation("实时同步上下架状态") + @GetMapping("product/operate") + @SystemControllerLog(description = "实时同步上下架状态") + public ResultData productOperate(Long id) { + if (id == null) { + return new ResultData(ResultData.ERROR, "缺少id"); + } + + return ttCouponGoodsService.productOperate(getTenantInfo(),id); + } + + @ApiOperation("实时同步库存") + @GetMapping("product/stock/sync") + @SystemControllerLog(description = "实时同步库存") + public ResultData productStockSync(Long id) { + if (id == null) { + return new ResultData(ResultData.ERROR, "缺少id"); + } + return ttCouponGoodsService.productStockSync(getTenantInfo(),id); + } + } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/TtCouponChannelPoi.java b/mallinkService/src/main/java/com/iformall/domain/po/TtCouponChannelPoi.java index 183a0cf3e..03866d5ab 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/TtCouponChannelPoi.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/TtCouponChannelPoi.java @@ -25,6 +25,7 @@ public class TtCouponChannelPoi extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="spuId",name="spuId") private String spuId; + //该字段状态更新不及时,不作为业务使用 @io.swagger.annotations.ApiModelProperty(value="状态:0-审核中,1-上架,2-下架,3-审核拒绝 4-审核通过",name="status") private Integer status; diff --git a/mallinkService/src/main/java/com/iformall/service/TtCouponGoodsService.java b/mallinkService/src/main/java/com/iformall/service/TtCouponGoodsService.java index 41a90efee..adcf68944 100644 --- a/mallinkService/src/main/java/com/iformall/service/TtCouponGoodsService.java +++ b/mallinkService/src/main/java/com/iformall/service/TtCouponGoodsService.java @@ -22,4 +22,7 @@ public interface TtCouponGoodsService { ResultData productOnlineGet(TenantEntity tenantEntity,Long id); + ResultData productOperate(TenantEntity tenantInfo, Long id); + + ResultData productStockSync(TenantEntity tenantInfo, Long id); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java index d2c79e153..3c35860eb 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java @@ -156,7 +156,7 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { wxCouponChannel.setShowBeginTime(new Date()); wxCouponChannel.setBeginTime(new Date()); wxCouponChannel.setEndTime(coupon.getValidEndDate()); - wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_AFTER.getCode()); + wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_BEFORE.getCode()); wxCouponChannel.setCouponId(coupon.getId()); wxCouponChannel.setType(coupon.getType()); wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode()); @@ -221,7 +221,7 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { public ResultData productDraftGet(TenantEntity tenantEntity,Long id) { TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantEntity.getTenantId(),id); if(ttCouponChannelPoi == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该商品未提交审核"); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该券未提交审核"); } try { TtWebService ttWebService = ttMerchantPoiService.getTtWebService(ttCouponChannelPoi); @@ -255,7 +255,7 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { public ResultData productOnlineGet(TenantEntity tenantEntity,Long id) { TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantEntity.getTenantId(),id); if(ttCouponChannelPoi == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该商品未提交审核"); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该券未提交审核"); } try { TtWebService ttWebService = ttMerchantPoiService.getTtWebService(ttCouponChannelPoi); @@ -285,6 +285,69 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { } } + @Override + public ResultData productOperate(TenantEntity tenantInfo, Long id) { + WxCoupon wxCoupon = wxCouponMapper.selectById(id, tenantInfo.getTenantId()); + if(wxCoupon == null || EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未找到或已作废"); + } + TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),id); + if(ttCouponChannelPoi == null || !EnumSpuSyncStatus.sync_audit_pass.getCode().equals(ttCouponChannelPoi.getLastStatus())){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未提交审核或审核未通过"); + } + //查询上架 + //op_type int64 TRUE 1-上线 2-下线 + Integer op_type = 2; + WxCouponChannel wxCouponChannelQuery = new WxCouponChannel(); + wxCouponChannelQuery.updateTenantInfo(wxCoupon); + wxCouponChannelQuery.setCouponId(wxCoupon.getId()); + wxCouponChannelQuery.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode()); + wxCouponChannelQuery.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); + List wxCouponChannels = wxCouponChannelMapper.findList(wxCouponChannelQuery); + if(wxCouponChannels.size() > 0){ + op_type = 1; + } + + try { + TtWebService ttWebService = ttMerchantPoiService.getTtWebService(ttCouponChannelPoi); + boolean b = ttWebService.getGoodsService().productOperate(null,wxCoupon.getId().toString(),op_type); + if(b){ + return new ResultData(); + }else{ + return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); + } + + } catch (WxErrorException e) { + e.printStackTrace(); + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),e.getMessage()); + } + } + + @Override + public ResultData productStockSync(TenantEntity tenantInfo, Long id) { + WxCoupon wxCoupon = wxCouponMapper.selectById(id, tenantInfo.getTenantId()); + if(wxCoupon == null || EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未找到或已作废"); + } + TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),id); + if(ttCouponChannelPoi == null || !EnumSpuSyncStatus.sync_audit_pass.getCode().equals(ttCouponChannelPoi.getLastStatus())){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未提交审核或审核未通过"); + } + try { + TtWebService ttWebService = ttMerchantPoiService.getTtWebService(ttCouponChannelPoi); + boolean b = ttWebService.getGoodsService().stockSync(null,wxCoupon.getId().toString(),wxCoupon.getInventory()); + if(b){ + return new ResultData(); + }else{ + return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); + } + + } catch (WxErrorException e) { + e.printStackTrace(); + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),e.getMessage()); + } + } + private void syncCouponChannelPoi(WxCoupon coupon,Long couponChannelId,String productId){ TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(coupon.getTenantId(),coupon.getId()); Date date = new Date();