Commit 846af049 by 郑永强

自有条数不够推荐凑

parent 3d73fa9d
......@@ -236,17 +236,23 @@ public class AdNewsBizImpl implements AdNewsBiz {
// 查询要发的记录
List<AdNews> adNewsList = null;
AdContentFromEnum adContentFromEnum = AdContentFromEnum.WECHAT_ADVISER;
adNewsList = adNewsDao.getNewsToSendBySetIdAndAdviser4Own(adNewsSetId, adNewsSet.getCreateUser(), adNewsSet.getSendCount());
// 如果自有公众号的数据为空,则查询系统推荐公众号数据
if (ListUtils.isEmpty(adNewsList)) {
adContentFromEnum = AdContentFromEnum.WECHAT;
adNewsList = adNewsDao.getNewsToSendBySetIdAndAdviser(adNewsSetId, adNewsSet.getCreateUser(), adNewsSet.getSendCount());
}else if (adNewsList.size() < adNewsSet.getSendCount()) {
// 如果自有公众号的数据条数少于要发送的条数,则用系统推荐公众号的补齐剩余的条数
List<AdNews> _adNewsList = adNewsDao.getNewsToSendBySetIdAndAdviser(adNewsSetId, adNewsSet.getCreateUser(), adNewsSet.getSendCount()-adNewsList.size());
if(!ListUtils.isEmpty(_adNewsList)){
adNewsList.addAll(_adNewsList);
}
}
if (ListUtils.isEmpty(adNewsList)) {
LOGGER.info("记录为空,没有可供发送的早晚报!");
return;
}
}
// 构建记录对象
for (GroupQrcodeFoAdDTO groupQrcodeFoAdDTO : groupQrcodeFoAdDTOS) {
......@@ -259,6 +265,7 @@ public class AdNewsBizImpl implements AdNewsBiz {
adNewsGroupRecord.setQrcodeId(groupQrcodeFoAdDTO.getQrcodeId());
adNewsGroupRecord.setCreateUser(adNewsSet.getCreateUser());
adNewsGroupRecord.setUpdateUser(adNewsSet.getCreateUser());
adNewsGroupRecord.setContentFrom(adNews.getContentFrom());
adNewsGroupRecord.setInsertMark(groupQrcodeFoAdDTOS.indexOf(groupQrcodeFoAdDTO));
adNewsGroupRecords.add(adNewsGroupRecord);
}
......@@ -269,7 +276,6 @@ public class AdNewsBizImpl implements AdNewsBiz {
adNewsMessageStatistic.setClassifyId(groupQrcodeFoAdDTO.getClassifyId());
adNewsMessageStatistic.setQrcodeId(groupQrcodeFoAdDTO.getQrcodeId());
adNewsMessageStatistic.setCreateUser(adNewsSet.getCreateUser());
adNewsMessageStatistic.setContentFrom(adContentFromEnum.key);
adNewsMessageStatistic.setMessageCount(adNewsList.size());
adNewsMessageStatistic.setInsertMark(groupQrcodeFoAdDTOS.indexOf(groupQrcodeFoAdDTO));
adNewsMessageStatistics.add(adNewsMessageStatistic);
......@@ -327,6 +333,7 @@ public class AdNewsBizImpl implements AdNewsBiz {
adNewsGroupRecord.setCustomContent(customContent);
adNewsGroupRecord.setInsertMark(groupQrcodeFoAdDTOS.indexOf(groupQrcodeFoAdDTO));
adNewsGroupRecord.setContentType(adNewsSet.getContentType());
adNewsGroupRecord.setContentFrom(adNewsSet.getContentFrom());
adNewsGroupRecords.add(adNewsGroupRecord);
// 统计记录
adNewsMessageStatistic = new AdNewsMessageStatistic();
......@@ -335,7 +342,6 @@ public class AdNewsBizImpl implements AdNewsBiz {
adNewsMessageStatistic.setClassifyId(groupQrcodeFoAdDTO.getClassifyId());
adNewsMessageStatistic.setQrcodeId(groupQrcodeFoAdDTO.getQrcodeId());
adNewsMessageStatistic.setCreateUser(adNewsSet.getCreateUser());
adNewsMessageStatistic.setContentFrom(adNewsSet.getContentFrom());
adNewsMessageStatistic.setMessageCount(1);
adNewsMessageStatistic.setInsertMark(groupQrcodeFoAdDTOS.indexOf(groupQrcodeFoAdDTO));
adNewsMessageStatistics.add(adNewsMessageStatistic);
......
......@@ -44,6 +44,9 @@ public class AdNews extends BaseEntity {
@ApiModelProperty("公众号")
private String wechatName;
@ApiModelProperty("内容来源")
private Integer contentFrom;
public String getType() {
return type;
}
......@@ -124,6 +127,14 @@ public class AdNews extends BaseEntity {
this.wechatName = wechatName;
}
public Integer getContentFrom() {
return contentFrom;
}
public void setContentFrom(Integer contentFrom) {
this.contentFrom = contentFrom;
}
@Override
public String toString() {
return "AdNews{" +
......@@ -137,6 +148,7 @@ public class AdNews extends BaseEntity {
", hasUsed=" + hasUsed +
", hasBan=" + hasBan +
", wechatName='" + wechatName + '\'' +
", contentFrom=" + contentFrom +
'}';
}
}
......@@ -46,6 +46,9 @@ public class AdNewsGroupRecord extends BaseEntity{
@ApiModelProperty("内容类型,0:早报;1:晚报")
private Integer contentType;
@ApiModelProperty(value = "内容来源;0:来源于公众号;1:自定义早晚报;2:自有公众号;",dataType = "com.pcloud.book.adnews.enums.AdContentFromEnum")
private Integer contentFrom;
@ApiModelProperty("insert时父子表标识")
Integer insertMark;
}
......@@ -27,9 +27,6 @@ public class AdNewsMessageStatistic extends BaseEntity {
@ApiModelProperty("编辑新闻设置id")
private Long adNewsSetId;
@ApiModelProperty("内容来源")
private Integer contentFrom;
@ApiModelProperty("发送消息数")
private Integer messageCount;
......@@ -37,6 +34,9 @@ public class AdNewsMessageStatistic extends BaseEntity {
private Long createUser;
@ApiModelProperty("内容来源")
private String contentFroms;
@ApiModelProperty("insert时父子表标识")
private Integer insertMark;
}
......@@ -13,7 +13,7 @@ public enum AdContentFromEnum {
WECHAT(0, "系统推荐公众号"),
CUSTOM(1, "自定义内容 "),
WECHAT_ADVISER(2,"自有公众号"); // 目前只使用于 ad_news_message_statistic.content_from
WECHAT_ADVISER(2,"自有公众号");
public final Integer key;
......
......@@ -14,7 +14,8 @@
<result column="update_user" property="updateUser" jdbcType="BIGINT"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="custom_content" property="customContent" jdbcType="VARCHAR"/>
<result column="content_type" property="contentType" jdbcType="BIGINT"/>
<result column="content_type" property="contentType" jdbcType="INTEGER"/>
<result column="content_from" property="contentFrom" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
......@@ -41,7 +42,7 @@
ad_news_group_record a
INNER JOIN ad_news_message_statistic b ON a.message_statistic_id=b.id
LEFT JOIN ad_news c ON a.ad_news_id=c.id
LEFT JOIN ad_news_wechat d ON d.news_from=c.news_from AND ((b.content_from=2 AND d.adviser_id=#{partyId,jdbcType=BIGINT}) OR b.content_from <![CDATA[<>]]> 2)
LEFT JOIN ad_news_wechat d ON d.news_from=c.news_from AND ((a.content_from=2 AND d.adviser_id=#{partyId,jdbcType=BIGINT}) OR a.content_from <![CDATA[<>]]> 2)
WHERE a.message_statistic_id=#{messageStatisticId,jdbcType=BIGINT}
AND a.create_user=#{partyId,jdbcType=BIGINT}
</select>
......@@ -60,7 +61,8 @@
update_user,
update_time,
custom_content,
content_type
content_type,
content_from
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{messageStatisticId,jdbcType=BIGINT},
......@@ -74,7 +76,8 @@
#{updateUser,jdbcType=BIGINT},
NOW(),
#{customContent,jdbcType=VARCHAR},
#{contentType,jdbcType=INTEGER}
#{contentType,jdbcType=INTEGER},
#{contentFrom,jdbcType=INTEGER}
</trim>
</insert>
......@@ -127,7 +130,8 @@
update_user,
update_time,
custom_content,
content_type
content_type,
content_from
)
values
<foreach collection="list" item="item" index="index" separator="," >
......@@ -143,7 +147,8 @@
#{item.updateUser,jdbcType=BIGINT},
NOW(),
#{item.customContent,jdbcType=VARCHAR},
#{item.contentType,jdbcType=INTEGER}
#{item.contentType,jdbcType=INTEGER},
#{item.contentFrom,jdbcType=INTEGER}
)
</foreach>
</insert>
......
......@@ -11,6 +11,7 @@
<result column="short_url" property="shortUrl" jdbcType="VARCHAR"/>
<result column="news_date" property="newsDate" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="content_from" property="contentFrom" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
......@@ -110,7 +111,7 @@
-->
<select id="getNewsToSendBySetIdAndAdviser" parameterType="map" resultMap="BaseResultMap">
SELECT
a.id, a.type, a.news_from, a.title, a.publisher, a.url, a.short_url, a.news_date, a.create_time
a.id, a.type, a.news_from, a.title, a.publisher, a.url, a.short_url, a.news_date, a.create_time,0 content_from
FROM
ad_news a
INNER JOIN ad_news_wechat b ON a.news_from = b.news_from AND b.is_delete = 0
......@@ -130,7 +131,7 @@
-->
<select id="getNewsToSendBySetIdAndAdviser4Own" parameterType="map" resultMap="BaseResultMap">
SELECT
a.id, a.type, a.news_from, a.title, a.publisher, a.url, a.short_url, a.news_date, a.create_time
a.id, a.type, a.news_from, a.title, a.publisher, a.url, a.short_url, a.news_date, a.create_time,2 content_from
FROM
ad_news a
INNER JOIN ad_news_wechat b ON a.news_from = b.news_from AND b.is_delete = 0 AND b.adviser_id=#{adviserId}
......
......@@ -7,14 +7,14 @@
<result column="classify_id" property="classifyId" jdbcType="BIGINT"/>
<result column="book_group_id" property="bookGroupId" jdbcType="BIGINT"/>
<result column="ad_news_set_id" property="adNewsSetId" jdbcType="BIGINT"/>
<result column="content_from" property="contentFrom" jdbcType="INTEGER"/>
<result column="content_froms" property="contentFroms" jdbcType="VARCHAR"/>
<result column="message_count" property="messageCount" jdbcType="INTEGER"/>
<result column="create_user" property="createUser" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, qrcode_id, classify_id, book_group_id, ad_news_set_id, content_from, message_count, create_user, create_time
id, qrcode_id, classify_id, book_group_id, ad_news_set_id, message_count, create_user, create_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -37,7 +37,7 @@
b.pur_label_id purLabelId,
a.message_count messageCount,
a.create_time createTime,
a.content_from contentFrom,
(select GROUP_CONCAT(distinct ad_news_id SEPARATOR ',') FROM ad_news_group_record WHERE message_statistic_id=a.id) content_froms,
(SELECT COUNT(1) FROM ad_news_click_record x WHERE x.message_statistic_id=a.id) clickCount,
(SELECT COUNT(DISTINCT wechat_user_id) FROM ad_news_click_record x WHERE x.message_statistic_id=a.id) userCount
FROM
......@@ -82,7 +82,6 @@
classify_id,
book_group_id,
ad_news_set_id,
content_from,
message_count,
create_user,
create_time
......@@ -92,7 +91,6 @@
#{classifyId,jdbcType=BIGINT},
#{bookGroupId,jdbcType=BIGINT},
#{adNewsSetId,jdbcType=BIGINT},
#{contentFrom,jdbcType=INTEGER},
#{messageCount,jdbcType=INTEGER},
#{createUser,jdbcType=BIGINT},
NOW()
......@@ -106,7 +104,6 @@
classify_id,
book_group_id,
ad_news_set_id,
content_from,
message_count,
create_user,
create_time
......@@ -118,7 +115,6 @@
#{item.classifyId,jdbcType=BIGINT},
#{item.bookGroupId,jdbcType=BIGINT},
#{item.adNewsSetId,jdbcType=BIGINT},
#{item.contentFrom,jdbcType=INTEGER},
#{item.messageCount,jdbcType=INTEGER},
#{item.createUser,jdbcType=BIGINT},
NOW()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment