From f03507461a3bcf395d12cc7ae17df23e03eb146f Mon Sep 17 00:00:00 2001 From: xhxu Date: Tue, 15 Nov 2022 19:57:36 +0800 Subject: [PATCH] //coupon --- .../java/com/iformall/domain/po/WxCoupon.java | 20 +++++++ .../mapper/WxCouponChannelMapper.java | 6 +- .../impl/TtCouponGoodsServiceImpl.java | 2 +- .../impl/WxCouponChannelServiceImpl.java | 54 +++++++++++++++++ .../service/impl/WxCouponServiceImpl.java | 4 ++ .../mapper/WxCouponChannelMapper.xml | 29 +++++++++ .../main/resources/mapper/WxCouponMapper.xml | 59 ++++++++++++++++--- 7 files changed, 164 insertions(+), 10 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java index 773cdb50c..050f2f899 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java @@ -366,6 +366,26 @@ public class WxCoupon extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "审批流参数", name = "flowParams") private Map flowParams; + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="spuId",name="spuId")//goodsId + private String spuId; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="状态:0-审核中,1-上架,2-下架,3-审核拒绝 4-审核通过",name="poiStatus") + private Integer poiStatus; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="描述",name="statusDesc") + private String statusDesc; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="状态:0-审核中,1-上架,2-下架,3-审核拒绝 4-审核通过",name="lastStatus") + private Integer lastStatus; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="描述",name="lastStatusDesc") + private String lastStatusDesc; + @io.swagger.annotations.ApiModelProperty(value = "是否删除1是0否", name = "isDel") private Integer isDel; diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java index 7a6ab3547..a32c0b20b 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java @@ -24,7 +24,7 @@ public interface WxCouponChannelMapper extends CommonMapper ttChannelList(TtCouponChannelVo ttChannelVo); Long findCouponIdById(@Param("id")Long id,@Param("tenantId")String tenantId); + + int updateStatusByTargetAd(WxCouponChannel updCC); + + int selectCountExclude(WxCouponChannel ccQ); } 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 e89e2db42..71c1bfc5b 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java @@ -379,7 +379,7 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { WxCouponChannel wxCouponChannelQuery = new WxCouponChannel(); wxCouponChannelQuery.updateTenantInfo(wxCoupon); wxCouponChannelQuery.setCouponId(wxCoupon.getId()); - wxCouponChannelQuery.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode()); +// 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){ 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 267d08bf5..6010053f0 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -153,6 +153,16 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { if (list != null && list.size() > 0) { return new ResultData(ErrorCode.COUPON_CHANNEL_IS_EXISTED); } + + if(EnumCouponType.getDouYinType().contains(orignal.getType())){ + TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(wxCoupon.getTenantId(),wxCoupon.getId()); + if(ttCouponChannelPoi == null || !EnumSpuSyncStatus.sync_audit_pass.getCode().equals(ttCouponChannelPoi.getLastStatus())){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该商品未提交审核或审核未通过"); + } + //上架该券的审核渠道 + updateOnlineDouyin(orignal,orignal.getCouponId()); + } + } } Long couponId = null; @@ -169,6 +179,10 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { //浮层下架 wxFloatingLayerMapper.updateStatus(orignal.getCouponId()); + if(EnumCouponType.getDouYinType().contains(orignal.getType())){ + //下架该券的审核渠道(如所有渠道都已下线) + updateTakeOffDouyin(orignal); + } } } record.setUpdateDate(new Date()); @@ -190,6 +204,45 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { return new ResultData(); } + /** + * 前置 该券已审核通过 + * //上架该券的审核渠道 + * @param tenantEntity + * @param couponId + */ + public void updateOnlineDouyin(TenantEntity tenantEntity,Long couponId){ + WxCouponChannel updCC = new WxCouponChannel(); + updCC.updateTenantInfo(tenantEntity); + updCC.setCouponId(couponId); + updCC.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN.getCode()); + updCC.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); + updCC.setUpdateDate(new Date()); + wxCouponChannelMapper.updateStatusByTargetAd(updCC); + } + + /** + * //下架该券的审核渠道(如所有其他渠道都已下线) + * @param couponChannel + */ + public void updateTakeOffDouyin(WxCouponChannel couponChannel){ + WxCouponChannel ccQ = new WxCouponChannel(); + ccQ.updateTenantInfo(couponChannel); + ccQ.setCouponId(couponChannel.getCouponId()); + ccQ.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); + //Exclude + ccQ.setId(couponChannel.getId()); + ccQ.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN.getCode()); + if(wxCouponChannelMapper.selectCountExclude(ccQ) == 0){ + WxCouponChannel updCC = new WxCouponChannel(); + updCC.updateTenantInfo(couponChannel); + updCC.setCouponId(couponChannel.getCouponId()); + updCC.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN.getCode()); + updCC.setStatus(EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()); + updCC.setUpdateDate(new Date()); + wxCouponChannelMapper.updateStatusByTargetAd(updCC); + } + } + @Override public void spuStatusSyncByCoupon(TenantEntity tenantEntity, Long couponId) { FmInsideProductPushMsg productPush = new FmInsideProductPushMsg(); @@ -646,6 +699,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { wxCouponChannel.setBusiness(wxCoupon.getBusiness()); wxCouponChannel.setSubBusiness(wxCoupon.getSubBusiness()); wxCouponChannel.setTitle(wxCoupon.getTitle()); + wxCouponChannel.setTtSpuId(wxCoupon.getGoodsId()); wxCouponChannel.setChannelPrice(channelPrice); wxCouponChannel.setChannelStock(channelStock); ResultData resultData = saveOrUpdate(wxCouponChannel); 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 a2c36b592..4a53c384a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -240,6 +240,10 @@ public class WxCouponServiceImpl implements WxCouponService { if(wxCoupon.getPlat() == null){ wxCoupon.setPlat(EnumCouponChannelType.getAppPlat(wxCoupon.getTargetAd()).getCode()); } + if(EnumAppPlat.TOUTIAO.getCode().equals(wxCoupon.getPlat())){ + //渠道查询时只查询审核通过的 + wxCoupon.setLastStatus(EnumSpuSyncStatus.sync_audit_pass.getCode()); + } List couponTypes = EnumCouponChannelType.getCouponTypeBy(wxCoupon.getTargetAd()); if(couponTypes.isEmpty()){ wxCoupon.setId(-999L); diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index 884f1810d..19e885475 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -535,4 +535,33 @@ and id = #{id} + + update wx_coupon_channel + set status=#{status}, update_date=#{updateDate} + where status != #{status} + and coupon_id = #{couponId} + and target_ad = #{targetAd} + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index 1ce966648..9e3af5585 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -60,6 +60,12 @@ + + + + + + @@ -476,13 +482,6 @@ - where c.is_del = 0 - - and 0 = (select count(*) from wx_coupon_channel cc - where c.`id` = cc.coupon_id - and cc.status = 0 - and cc.target_ad = #{targetAd}) - and c.`id` = #{id} @@ -646,6 +645,13 @@ and JSON_CONTAINS(c.gift_list,json_array(#{giftList})) + + and 0 = (select count(*) from wx_coupon_channel cc + where c.`id` = cc.coupon_id + and cc.status = 0 + and cc.target_ad = #{targetAd}) + + and c.id in @@ -667,14 +673,34 @@ - order by ${sortColumns}