| @@ -366,6 +366,26 @@ public class WxCoupon extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "审批流参数", name = "flowParams") | |||
| private Map<String, Object> 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; | |||
| @@ -24,7 +24,7 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str | |||
| WxCouponChannel findVoStatusDetail(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| void updateStatusByCouponId(WxCouponChannel wxCouponChannel); | |||
| int updateStatusByCouponId(WxCouponChannel wxCouponChannel); | |||
| int updateEndTimeByCouponId(WxCouponChannel wxCouponChannel); | |||
| @@ -70,4 +70,8 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str | |||
| List<TtCouponChannelVo> ttChannelList(TtCouponChannelVo ttChannelVo); | |||
| Long findCouponIdById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| int updateStatusByTargetAd(WxCouponChannel updCC); | |||
| int selectCountExclude(WxCouponChannel ccQ); | |||
| } | |||
| @@ -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<WxCouponChannel> wxCouponChannels = wxCouponChannelMapper.findList(wxCouponChannelQuery); | |||
| if(wxCouponChannels.size() > 0){ | |||
| @@ -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); | |||
| @@ -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<Integer> couponTypes = EnumCouponChannelType.getCouponTypeBy(wxCoupon.getTargetAd()); | |||
| if(couponTypes.isEmpty()){ | |||
| wxCoupon.setId(-999L); | |||
| @@ -535,4 +535,33 @@ | |||
| and id = #{id} | |||
| </select> | |||
| <update id="updateStatusByTargetAd" parameterType="com.iformall.domain.po.WxCouponChannel"> | |||
| update wx_coupon_channel | |||
| set status=#{status}, update_date=#{updateDate} | |||
| where status != #{status} | |||
| and coupon_id = #{couponId} | |||
| and target_ad = #{targetAd} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| </update> | |||
| <select id="selectCountExclude" parameterType="com.iformall.domain.po.WxCouponChannel" resultType="Integer"> | |||
| select count(1) from wx_coupon_channel | |||
| where status = #{status} | |||
| and coupon_id = #{couponId} | |||
| and id != #{id} | |||
| and target_ad != #{targetAd} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| </select> | |||
| </mapper> | |||
| @@ -60,6 +60,12 @@ | |||
| <result column="product_type" jdbcType="INTEGER" property="productType"/> | |||
| <result column="category_id" jdbcType="INTEGER" property="categoryId"/> | |||
| <result column="goods_id" jdbcType="VARCHAR" property="goodsId"/> | |||
| <result column="spu_id" jdbcType="VARCHAR" property="spuId"/> | |||
| <result column="poi_status" jdbcType="INTEGER" property="poiStatus"/> | |||
| <result column="status_desc" jdbcType="VARCHAR" property="statusDesc"/> | |||
| <result column="last_status" jdbcType="INTEGER" property="lastStatus"/> | |||
| <result column="last_status_desc" jdbcType="VARCHAR" property="lastStatusDesc"/> | |||
| </resultMap> | |||
| <resultMap id="statisMap" type="com.iformall.domain.vo.WxCouponStatisVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| @@ -476,13 +482,6 @@ | |||
| <sql id="dynamicWhereConditionsForCoupon"> | |||
| where c.is_del = 0 | |||
| <if test=" null != targetAd "> | |||
| and 0 = (select count(*) from wx_coupon_channel cc | |||
| where c.`id` = cc.coupon_id | |||
| and cc.status = 0 | |||
| and cc.target_ad = #{targetAd}) | |||
| </if> | |||
| <if test=" null != id "> | |||
| and c.`id` = #{id} | |||
| @@ -646,6 +645,13 @@ | |||
| and JSON_CONTAINS(c.gift_list,json_array(#{giftList})) | |||
| </if> | |||
| <if test=" null != targetAd "> | |||
| and 0 = (select count(*) from wx_coupon_channel cc | |||
| where c.`id` = cc.coupon_id | |||
| and cc.status = 0 | |||
| and cc.target_ad = #{targetAd}) | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and c.id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -667,14 +673,34 @@ | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </sql> | |||
| <select id="findCouponList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| <if test="plat != null and plat == 3"> | |||
| ,poi.spu_id,poi.status poi_status,poi.status_desc,poi.last_status,poi.last_status_desc | |||
| </if> | |||
| from wx_coupon c | |||
| <if test="plat != null and plat == 3"> | |||
| left join tt_coupon_channel_poi poi on poi.id = c.id | |||
| </if> | |||
| where c.is_del = 0 | |||
| <if test="plat != null and plat == 3"> | |||
| <if test=" null != spuId and '' != spuId"> | |||
| and poi.`spu_id` = #{spuId} | |||
| </if> | |||
| <if test=" null != poiStatus"> | |||
| and poi.`status` = #{poiStatus} | |||
| </if> | |||
| <if test=" null != lastStatus"> | |||
| and poi.`last_status` = #{lastStatus} | |||
| </if> | |||
| </if> | |||
| <include refid="dynamicWhereConditionsForCoupon"/> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| <if test="null != limitStart and null != limitEnd"> | |||
| limit #{limitStart},#{limitEnd} | |||
| @@ -685,6 +711,23 @@ | |||
| select | |||
| count(c.id) | |||
| from wx_coupon c | |||
| <if test="plat != null and plat == 3"> | |||
| left join tt_coupon_channel_poi poi on poi.id = c.id | |||
| </if> | |||
| where c.is_del = 0 | |||
| <if test="plat != null and plat == 3"> | |||
| <if test=" null != spuId and '' != spuId"> | |||
| and poi.`spu_id` = #{spuId} | |||
| </if> | |||
| <if test=" null != poiStatus"> | |||
| and poi.`status` = #{poiStatus} | |||
| </if> | |||
| <if test=" null != lastStatus"> | |||
| and poi.`last_status` = #{lastStatus} | |||
| </if> | |||
| </if> | |||
| <include refid="dynamicWhereConditionsForCoupon"/> | |||
| </select> | |||