Authored by tanling

Merge branch 'test6.9.9' of http://git.yoho.cn/platform/platform-cms into test6.9.9

... ... @@ -1751,6 +1751,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService {
if(!topicSend){
sendPublishReward(articleId, uid, (int)(createTime/1000));
}
//首帖奖励和以上两种奖励可叠加
sendFirstPublishReward(articleId, uid, (int)(createTime/1000));
}
//发放审核奖励
... ... @@ -1758,19 +1760,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService {
try{
List<GrassRewardsConfig> rewardsConfigList = grassRewardsConfigDAO.selectByType(1);
// int now = DateUtil.getCurrentTimeSeconds();
GrassRewardsConfig grassRewardsConfig =null;
for (GrassRewardsConfig rewardsConfig : rewardsConfigList) {
if(rewardsConfig.getStartTime()!= 0 && publishTime < rewardsConfig.getStartTime()){
logger.info("sendPublishReward rewardsConfig not start, rewardId is {}, startTime is {}",rewardsConfig.getId(), rewardsConfig.getStartTime());
continue;
}
if(rewardsConfig.getEndTime()!= 0 && publishTime > rewardsConfig.getEndTime()){
logger.info("sendPublishReward rewardsConfig already end, rewardId is {}, endTime is {}",rewardsConfig.getId(), rewardsConfig.getEndTime());
continue;
}
grassRewardsConfig = rewardsConfig;
break;
}
GrassRewardsConfig grassRewardsConfig = getValidRewardConfig(rewardsConfigList, publishTime);
if(grassRewardsConfig == null){
return;
}
... ... @@ -1868,6 +1858,66 @@ public class GrassArticleServiceImpl implements IGrassArticleService {
return hasSend;
}
//首次发帖奖励
private void sendFirstPublishReward(Integer articleId,Integer uid,int publishTime){
try{
//查询奖励配置,type=3, 没有配置则不奖励
List<GrassRewardsConfig> rewardsConfigList = grassRewardsConfigDAO.selectByType(3);
// int now = DateUtil.getCurrentTimeSeconds();
GrassRewardsConfig grassRewardsConfig = getValidRewardConfig(rewardsConfigList, publishTime);
if(grassRewardsConfig == null){
logger.info("sendFirstPublishReward : no rewards config found");
return;
}
//判断用户时候发过帖子且被审核通过 大于一:当前帖子已被审核通过
List<GrassArticle> userPublishList = grassArticleDao.selectByAuthorAndStatus(uid, 1);
if(CollectionUtils.isNotEmpty(userPublishList) && userPublishList.size() > 1){
logger.info("sendFirstPublishReward: user already published article, userPublishList size is {}", userPublishList.size());
return;
}
//虽然首帖奖励只应该奖励一次,但是还是走通用流程,按配置来,由配置保证次数
//一个奖励周期, 单位 天 //未配置 则 奖励周期为活动的开始结束时间
Integer rewardInterval = grassRewardsConfig.getRewardInterval();
Integer startTime = grassRewardsConfig.getStartTime();
Integer endTime = grassRewardsConfig.getEndTime();
if(rewardInterval != null && rewardInterval != 0){
startTime = getTimeIntInterval(startTime, publishTime , rewardInterval);
}
List<RewardsSendRecords> userRecords = rewardsSendRecordsDAO.selectByRewardsIdAndTimeBetween(uid,grassRewardsConfig.getId(), startTime,endTime);
if(userRecords.stream().anyMatch(rewardsSendRecords -> rewardsSendRecords.getArticleId().equals(articleId))){
logger.info("sendFirstPublishReward user has recieved reward, rewardId is {}, articleId is {},uid is {}",grassRewardsConfig.getId(), articleId, uid);
return;
}
if(CollectionUtils.isNotEmpty(userRecords) && userRecords.size() >= grassRewardsConfig.getMaxTime()){
logger.info("sendFirstPublishReward reward send times reach maxtimes, rewardId is {}, articleId is {}, uid is {}",grassRewardsConfig.getId(), articleId, uid);
return;
}
callSnsSendReward(articleId, grassRewardsConfig.getId(), 3, uid);
}catch (Exception e){
logger.warn("sendFirstPublishReward error, articleId is {}, e is {}", articleId, e);
}
}
private GrassRewardsConfig getValidRewardConfig(List<GrassRewardsConfig> rewardsConfigList, int publishTime){
GrassRewardsConfig grassRewardsConfig =null;
for (GrassRewardsConfig rewardsConfig : rewardsConfigList) {
if(rewardsConfig.getStartTime()!= 0 && publishTime < rewardsConfig.getStartTime()){
logger.info("sendPublishReward rewardsConfig not start, rewardId is {}, startTime is {}",rewardsConfig.getId(), rewardsConfig.getStartTime());
continue;
}
if(rewardsConfig.getEndTime()!= 0 && publishTime > rewardsConfig.getEndTime()){
logger.info("sendPublishReward rewardsConfig already end, rewardId is {}, endTime is {}",rewardsConfig.getId(), rewardsConfig.getEndTime());
continue;
}
grassRewardsConfig = rewardsConfig;
break;
}
return grassRewardsConfig;
}
private void callSnsSendReward(Integer articleId, Integer rewardId, Integer type,Integer uid){
try {
Map<String, Object> reqMap = Maps.newHashMap();
... ...
... ... @@ -66,8 +66,8 @@
<span style="color:red">*</span><label style="font-size: 14px;">文字内容(必填项,内容不能为空)</label> <br>
<div style="width:600px; word-wrap:break-word;float: left;position: relative" >
<textarea rows="5" id="content" style="width:60%; white-space: pre-wrap;" name = "content" class="form-control" placeholder="请在这里输入1-500字的笔记" required="" maxlength="500"></textarea>
<div style="position: absolute;bottom:0;right:-50px"> <span id="content-count">0</span>/500</div>
<textarea rows="5" id="content" style="width:60%; white-space: pre-wrap;" name = "content" class="form-control" placeholder="请在这里输入1-2000字的笔记" required="" maxlength="2000"></textarea>
<div style="position: absolute;bottom:0;right:-50px"> <span id="content-count">0</span>/2000</div>
</div>
... ... @@ -271,8 +271,8 @@
var $this = $(this);
var count = $this[0].getText().length;
var content = $this[0].getText();
if(count>500){
$this[0].setText(content.substring(0,500));
if(count>2000){
$this[0].setText(content.substring(0,2000));
count = $this[0].getText().length;
}
$("#content-count").text(count);
... ... @@ -427,8 +427,8 @@
$.messager.alert("发布失败", "请输入文字内容", "error");
return false;
}
if(content.length>500){
$.messager.alert("发布失败", "内容长度超过500,请重新输入", "error");
if(content.length>2000){
$.messager.alert("发布失败", "内容长度超过2000,请重新输入", "error");
return false;
}
var imgs = '';
... ... @@ -512,8 +512,8 @@
$.messager.alert("保存失败", "请输入文字内容", "error");
return false;
}
if(content.length>500){
$.messager.alert("发布失败", "内容长度超过500,请重新输入", "error");
if(content.length>2000){
$.messager.alert("发布失败", "内容长度超过2000,请重新输入", "error");
return false;
}
var imgs = '';
... ... @@ -662,8 +662,8 @@
$.messager.alert("保存失败", "请输入文字内容", "error");
return false;
}
if(content.length>500){
$.messager.alert("发布失败", "内容长度超过500,请重新输入", "error");
if(content.length>2000){
$.messager.alert("发布失败", "内容长度超过2000,请重新输入", "error");
return false;
}
param.publishTime =time;
... ...
... ... @@ -82,8 +82,8 @@
<span style="color:red">*</span><label style="font-size: 14px;">文字内容(必填项,内容不能为空)</label> <br>
<div style="width:600px; word-wrap:break-word;float: left;position: relative" >
<textarea rows="5" id="content" style="width:60%; white-space: pre-wrap;" name = "content" class="form-control" placeholder="请在这里输入1-500字的笔记" required="" maxlength="500"></textarea>
<div style="position: absolute;bottom:0;right:-50px"> <span id="content-count">0</span>/500</div>
<textarea rows="5" id="content" style="width:60%; white-space: pre-wrap;" name = "content" class="form-control" placeholder="请在这里输入1-2000字的笔记" required="" maxlength="2000"></textarea>
<div style="position: absolute;bottom:0;right:-50px"> <span id="content-count">0</span>/2000</div>
</div>
... ... @@ -273,8 +273,8 @@
var $this = $(this);
var count = $this[0].getText().length;
var content = $this[0].getText();
if(count>500){
$this[0].setText(content.substring(0,500));
if(count>2000){
$this[0].setText(content.substring(0,2000));
count = $this[0].getText().length;
}
$("#content-count").text(count);
... ... @@ -404,8 +404,8 @@
$.messager.alert("发布失败", "请输入文字内容", "error");
return false;
}
if(content.length>500){
$.messager.alert("发布失败", "内容长度超过500,请重新输入", "error");
if(content.length>2000){
$.messager.alert("发布失败", "内容长度超过2000,请重新输入", "error");
return false;
}
var imgs = '';
... ... @@ -504,8 +504,8 @@
$.messager.alert("保存失败", "请输入文字内容", "error");
return false;
}
if(content.length>500){
$.messager.alert("发布失败", "内容长度超过500,请重新输入", "error");
if(content.length>2000){
$.messager.alert("发布失败", "内容长度超过2000,请重新输入", "error");
return false;
}
var imgs = '';
... ... @@ -745,8 +745,8 @@
$.messager.alert("保存失败", "请输入文字内容", "error");
return false;
}
if(content.length>500){
$.messager.alert("发布失败", "内容长度超过500,请重新输入", "error");
if(content.length>2000){
$.messager.alert("发布失败", "内容长度超过2000,请重新输入", "error");
return false;
}
param.publishTime =time;
... ...
... ... @@ -67,8 +67,8 @@
<td>
<span style="color:red">*</span><label style="font-size: 14px;">文字内容(必填项,内容不能为空)</label> <br>
<div style="width:600px; word-wrap:break-word;float: left;position: relative" >
<textarea rows="5" id="content" style="width:60%; white-space: pre-wrap;" name = "content" class="form-control" placeholder="请在这里输入1-500字的笔记" required="" maxlength="500"></textarea>
<div style="position: absolute;bottom:0;right:-50px"> <span id="content-count">0</span>/500</div>
<textarea rows="5" id="content" style="width:60%; white-space: pre-wrap;" name = "content" class="form-control" placeholder="请在这里输入1-2000字的笔记" required="" maxlength="2000"></textarea>
<div style="position: absolute;bottom:0;right:-50px"> <span id="content-count">0</span>/2000</div>
</div>
</td>
... ... @@ -281,8 +281,8 @@
var $this = $(this);
var count = $this[0].getText().length;
var content = $this[0].getText();
if(count>500){
$this[0].setText(content.substring(0,500));
if(count>2000){
$this[0].setText(content.substring(0,2000));
count = $this[0].getText().length;
}
$("#content-count").text(count);
... ... @@ -437,8 +437,8 @@
$.messager.alert("保存失败", "请输入文字内容", "error");
return false;
}
if(content.length>500){
$.messager.alert("发布失败", "内容长度超过500,请重新输入", "error");
if(content.length>2000){
$.messager.alert("发布失败", "内容长度超过2000,请重新输入", "error");
return false;
}
$("#draftType").val(2);
... ... @@ -520,8 +520,8 @@
$.messager.alert("保存失败", "请输入文字内容", "error");
return false;
}
if(content.length>500){
$.messager.alert("发布失败", "内容长度超过500,请重新输入", "error");
if(content.length>2000){
$.messager.alert("发布失败", "内容长度超过2000,请重新输入", "error");
return false;
}
var imgs = '';
... ... @@ -731,8 +731,8 @@
$.messager.alert("保存失败", "请输入文字内容", "error");
return false;
}
if(content.length>500){
$.messager.alert("发布失败", "内容长度超过500,请重新输入", "error");
if(content.length>2000){
$.messager.alert("发布失败", "内容长度超过2000,请重新输入", "error");
return false;
}
param.publishTime =time;
... ...