| @@ -0,0 +1,7 @@ | |||||
| ALTER TABLE `wx_campaign` | |||||
| ADD COLUMN `produce_type` SMALLINT(2) NULL DEFAULT NULL COMMENT '产品类型,类型3适用(1-券,2-报名)', | |||||
| ADD COLUMN `produce_id` BIGINT(20) NULL DEFAULT NULL COMMENT '产品ID,类型3适用', | |||||
| ADD COLUMN `page_path` VARCHAR(50) NULL DEFAULT NULL COMMENT '小程序跳转路径,类型3适用', | |||||
| ADD COLUMN `page_scene` VARCHAR(50) NULL DEFAULT NULL COMMENT '小程序跳转二维码,类型3适用', | |||||
| CHANGE COLUMN `type` `type` SMALLINT(11) NULL DEFAULT NULL COMMENT '类型 1-固定格式,2-自由图文,3-小程序路径' ; | |||||
| @@ -1,6 +1,7 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import com.iformall.enums.EnumCampaignType; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| @@ -57,7 +58,7 @@ public class WxCampaign extends BaseEntity { | |||||
| private Date validEndDate; | private Date validEndDate; | ||||
| @io.swagger.annotations.ApiModelProperty(value="图文详情",name="imgDetail") | @io.swagger.annotations.ApiModelProperty(value="图文详情",name="imgDetail") | ||||
| private String imgDetail; | private String imgDetail; | ||||
| @io.swagger.annotations.ApiModelProperty(value="类型:0:促销 1:宣传页",name="type") | |||||
| @io.swagger.annotations.ApiModelProperty(value="类型:1-固定格式,2-自由图文,3-小程序路径",name="type") | |||||
| private Integer type; | private Integer type; | ||||
| @io.swagger.annotations.ApiModelProperty(value="优惠券ids",name="couponIds") | @io.swagger.annotations.ApiModelProperty(value="优惠券ids",name="couponIds") | ||||
| private String couponIds; | private String couponIds; | ||||
| @@ -71,7 +72,7 @@ public class WxCampaign extends BaseEntity { | |||||
| private Date createTime; | private Date createTime; | ||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") | @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") | ||||
| private Date updateTime; | private Date updateTime; | ||||
| @io.swagger.annotations.ApiModelProperty(value="富文本",name="html") | |||||
| @io.swagger.annotations.ApiModelProperty(value="富文本,类型2适用",name="html") | |||||
| private String html; | private String html; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "报名人数", name = "personLimit") | @io.swagger.annotations.ApiModelProperty(value = "报名人数", name = "personLimit") | ||||
| @@ -91,6 +92,15 @@ public class WxCampaign extends BaseEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "活动类型1直接投放2限时投放", name = "activityType") | @io.swagger.annotations.ApiModelProperty(value = "活动类型1直接投放2限时投放", name = "activityType") | ||||
| private Integer activityType; | private Integer activityType; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "产品类型,类型3适用(1-券,2-报名)", name = "produceType") | |||||
| private Integer produceType; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "产品ID,类型3适用", name = "produceId") | |||||
| private Long produceId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "小程序跳转路径,类型3适用", name = "pagePath") | |||||
| private String pagePath; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "小程序跳转二维码,类型3适用", name = "pageScene") | |||||
| private String pageScene; | |||||
| @Transient | @Transient | ||||
| @io.swagger.annotations.ApiModelProperty(value = "开始时间", name = "starttime") | @io.swagger.annotations.ApiModelProperty(value = "开始时间", name = "starttime") | ||||
| protected Date starttime; | protected Date starttime; | ||||
| @@ -100,22 +110,28 @@ public class WxCampaign extends BaseEntity { | |||||
| protected Date endtime; | protected Date endtime; | ||||
| @Transient | @Transient | ||||
| @io.swagger.annotations.ApiModelProperty(value="小程序路径",name="weappPath") | |||||
| @io.swagger.annotations.ApiModelProperty(value="营销物料-小程序路径",name="weappPath") | |||||
| protected String weappPath; | protected String weappPath; | ||||
| @Transient | @Transient | ||||
| @io.swagger.annotations.ApiModelProperty(value="小程序二维码Scene",name="weappScene") | |||||
| @io.swagger.annotations.ApiModelProperty(value="营销物料-小程序二维码Scene",name="weappScene") | |||||
| protected String weappScene; | protected String weappScene; | ||||
| public String getWeappPath() { | public String getWeappPath() { | ||||
| if(type == null) | if(type == null) | ||||
| return "pages/index/index"; | return "pages/index/index"; | ||||
| if(type.equals(EnumCampaignType.PAGEPATH.getCode())) { | |||||
| return pagePath; | |||||
| } | |||||
| return "pages/index/index?type=bd&bt="+type+"&id="+id; | return "pages/index/index?type=bd&bt="+type+"&id="+id; | ||||
| } | } | ||||
| public String getWeappScene() { | public String getWeappScene() { | ||||
| if(type == null) | if(type == null) | ||||
| return ""; | return ""; | ||||
| if(type.equals(EnumCampaignType.PAGEPATH.getCode())) { | |||||
| return pageScene; | |||||
| } | |||||
| return "t:bd:" + type + ":" +id; | return "t:bd:" + type + ":" +id; | ||||
| } | } | ||||
| @@ -7,6 +7,7 @@ public enum EnumCampaignType { | |||||
| STABLE(1, "固定格式"), | STABLE(1, "固定格式"), | ||||
| FREE(2, "自由图文"), | FREE(2, "自由图文"), | ||||
| PAGEPATH(3, "小程序路径"), | |||||
| ; | ; | ||||
| public static EnumCampaignType getEnum(Integer code) { | public static EnumCampaignType getEnum(Integer code) { | ||||
| @@ -10,43 +10,53 @@ public interface WxCampaignService { | |||||
| /** | /** | ||||
| * 根据实体查询分页列表 | * 根据实体查询分页列表 | ||||
| * | |||||
| * @param record | * @param record | ||||
| * @param pageIndex | * @param pageIndex | ||||
| * @param pageSize | * @param pageSize | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| PageInfo<WxCampaign> listAsPage(WxCampaign record, Integer pageIndex, Integer pageSize); | |||||
| PageInfo<WxCampaign> listAsPage(WxCampaign record, Integer pageIndex, Integer pageSize); | |||||
| /** | /** | ||||
| * 根据实体查询分页列表 | * 根据实体查询分页列表 | ||||
| * | |||||
| * @param record | * @param record | ||||
| * @param pageIndex | * @param pageIndex | ||||
| * @param pageSize | * @param pageSize | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| PageInfo<WxCampaign> clistAsPage(WxCampaign record, Integer pageIndex, Integer pageSize); | PageInfo<WxCampaign> clistAsPage(WxCampaign record, Integer pageIndex, Integer pageSize); | ||||
| /** | |||||
| /** | |||||
| * 根据Id获得实体 | * 根据Id获得实体 | ||||
| * | * | ||||
| * @param id | * @param id | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| WxCampaign getById(Long id); | WxCampaign getById(Long id); | ||||
| /** | |||||
| /** | |||||
| * 保存或更新实体 | * 保存或更新实体 | ||||
| * | * | ||||
| * @param record | |||||
| */ | |||||
| * @param record | |||||
| */ | |||||
| ResultData saveOrUpdate(WxCampaign record); | ResultData saveOrUpdate(WxCampaign record); | ||||
| /** | |||||
| * 基于小程序路径发布 | |||||
| * @param wxCampaign | |||||
| * @return | |||||
| */ | |||||
| ResultData addForPath(WxCampaign wxCampaign); | |||||
| /** | /** | ||||
| * 根据Id删除实体 | * 根据Id删除实体 | ||||
| * | * | ||||
| * @param id | * @param id | ||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| int getMaxSortNum(String tenantId); | int getMaxSortNum(String tenantId); | ||||
| @@ -89,7 +89,7 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||||
| if (StringUtils.isEmpty(wxCampaign.getDetail())) { | if (StringUtils.isEmpty(wxCampaign.getDetail())) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "活动说明不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "活动说明不能为空"); | ||||
| } | } | ||||
| } else { | |||||
| } else if(wxCampaign.getType().equals(EnumCampaignType.FREE.getCode())){ | |||||
| if (StringUtils.isEmpty(wxCampaign.getHtml())) { | if (StringUtils.isEmpty(wxCampaign.getHtml())) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "图文不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "图文不能为空"); | ||||
| } | } | ||||
| @@ -97,6 +97,43 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||||
| if (length >= 0xFFFFFF) { //Mysql MiddleText length limited | if (length >= 0xFFFFFF) { //Mysql MiddleText length limited | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "图文内容过大无法保存"); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "图文内容过大无法保存"); | ||||
| } | } | ||||
| } else { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | |||||
| wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); | |||||
| if (wxCampaign.getId() == null) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| wxCampaign.setId(idWorker.nextId()); | |||||
| wxCampaignMapper.insertSelective(wxCampaign); | |||||
| } else { | |||||
| wxCampaignMapper.updateByPrimaryKeySelective(wxCampaign); | |||||
| } | |||||
| //type 为固定格式才会有券的信息 才会有投放的问题 | |||||
| couponInject(wxCampaign); | |||||
| return new ResultData(Result.SUCCESS,"操作成功"); | |||||
| } | |||||
| @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||||
| @Override | |||||
| public ResultData addForPath(WxCampaign wxCampaign) { | |||||
| if(wxCampaign.getType().equals(EnumCampaignType.PAGEPATH.getCode())) { | |||||
| if (StringUtils.isBlank(wxCampaign.getCoverImg())) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "封面图不能为空"); | |||||
| } | |||||
| if (wxCampaign.getProduceType() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "produceType不能为空"); | |||||
| } | |||||
| if (wxCampaign.getProduceId() == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "produceId不能为空"); | |||||
| } | |||||
| if (StringUtils.isBlank(wxCampaign.getPagePath())) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "pagePath不能为空"); | |||||
| } | |||||
| if (StringUtils.isBlank(wxCampaign.getPageScene())) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "pageScene不能为空"); | |||||
| } | |||||
| } else { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | } | ||||
| wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); | wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); | ||||
| if (wxCampaign.getId() == null) { | if (wxCampaign.getId() == null) { | ||||