Authored by 张帅

Merge branch 'dev-grasspublish-6.9.1' into test6.9.1

# Conflicts:
#	grass/src/main/java/com/yohobuy/platform/grass/service/impl/GrassArticleServiceImpl.java
#	operations/pom.xml
#	pom.xml
... ... @@ -14,6 +14,7 @@ import com.yoho.service.model.social.response.UserInfoRspBO;
import com.yohobuy.platform.common.enums.ArticleTypeEnum;
import com.yohobuy.platform.common.exception.PlatformException;
import com.yohobuy.platform.common.helper.ImagesHelper;
import com.yohobuy.platform.common.util.CollectionUtil;
import com.yohobuy.platform.common.util.DateUtil;
import com.yohobuy.platform.dal.grass.*;
import com.yohobuy.platform.dal.grass.model.*;
... ... @@ -22,6 +23,7 @@ import com.yohobuy.platform.dal.guang.model.Author;
import com.yohobuy.platform.grass.service.IGrassArticleService;
import com.yohobuy.platform.grass.service.IGrassRefreshCacheService;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.GrassArticleProductBo;
import com.yohobuy.platform.model.grass.request.GrassArticleReq;
import com.yohobuy.platform.model.grass.request.GrassCacheReq;
import com.yohobuy.platform.model.grass.response.ArticleDetailRspBo;
... ... @@ -99,10 +101,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
List<Integer> labels = Lists.newArrayList();
String[] urls = req.getArticleImages().split(",");
String[] skns = null;
if(StringUtils.isNotEmpty(req.getArticleSkns())){
skns = req.getArticleSkns().split(",");
if(skns.length > 10){
if(CollectionUtils.isNotEmpty(req.getProducts())){
if(req.getProducts().size() > 10){
logger.info("publishArticle , article products more than most publish number");
throw new PlatformException("publish products most number is 10 ", 405);
}
... ... @@ -163,21 +163,18 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
}
try{
if(StringUtils.isNotEmpty( req.getArticleSkns())){
if(CollectionUtils.isNotEmpty( req.getProducts())){
int orderby = 0;
List<GrassArticleProduct> sknList = Lists.newArrayList();
if(skns != null){
Integer sknType = Optional.ofNullable(req.getSknType()).orElse(1);
for (String skn: skns) {
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
grassArticleSkn.setArticleId(article.getId());
grassArticleSkn.setProductSkn(Integer.valueOf(skn));
grassArticleSkn.setCreateTime(now);
grassArticleSkn.setOrderBy(orderby);
grassArticleSkn.setProductSource(sknType);
orderby++;
sknList.add(grassArticleSkn);
}
for (GrassArticleProductBo skn: req.getProducts()) {
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
grassArticleSkn.setArticleId(article.getId());
grassArticleSkn.setProductSkn(skn.getProductSkn());
grassArticleSkn.setCreateTime(now);
grassArticleSkn.setOrderBy(orderby);
grassArticleSkn.setProductSource(skn.getProductType());
orderby++;
sknList.add(grassArticleSkn);
}
if(CollectionUtils.isNotEmpty(sknList)){
... ... @@ -465,70 +462,6 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
}
//编辑文章 没地方用到
if(type == 1){
Integer articleId = req.getArticleId();
if(articleId == null){
throw new PlatformException("articleId is null", 402);
}
//修改文章主体内容
if(req.getTopicId() !=null){
GrassArticle grassArticle = new GrassArticle();
grassArticle.setId(articleId);
grassArticle.setUpdateTime(System.currentTimeMillis());
grassArticleDao.updateByPrimaryKeySelective(grassArticle);
}
//文章内容
grassArticleBlockDao.deleteByArticleId(articleId);
//图片内容
List<String> reqlist = req.getArticleImages() == null ? Lists.newArrayList() : Lists.newArrayList(req.getArticleImages().split(","));
//新增
List<GrassArticleBlock> addList = Lists.newArrayList();
int contentOrder = 0;
for (String src : reqlist) {
GrassArticleBlock content = new GrassArticleBlock();
content.setArticleId(articleId);
content.setContentData(getBlock(BLOCK_IMAGE,src));
content.setCreateTime(System.currentTimeMillis());
content.setTemplateKey("image");
content.setOrderBy(contentOrder);
contentOrder++;
addList.add(content);
}
//文字内容
if(StringUtils.isNotEmpty(req.getContent())){
GrassArticleBlock content = new GrassArticleBlock();
content.setArticleId(articleId);
content.setContentData(getBlock(BLOCK_TEXT,req.getContent()));
content.setCreateTime(System.currentTimeMillis());
content.setTemplateKey("text");
content.setOrderBy(contentOrder);
addList.add(content);
}
if(CollectionUtils.isNotEmpty(addList)){
grassArticleBlockDao.insertArticleContents(addList);
updateArticleImageSize(articleId);
}
//商品
grassArticleProductDao.deleteByArticleId(articleId);
List<String> reqSknlist = req.getArticleSkns() == null ? Lists.newArrayList() : Lists.newArrayList(req.getArticleSkns().split(","));
//新增
List<GrassArticleProduct> addSknList = Lists.newArrayList();
int orderBy = 0;
for (String skn : reqSknlist) {
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
grassArticleSkn.setArticleId(articleId);
grassArticleSkn.setProductSkn(Integer.valueOf(skn));
grassArticleSkn.setCreateTime(System.currentTimeMillis());
grassArticleSkn.setOrderBy(orderBy);
orderBy++;
addSknList.add(grassArticleSkn);
}
if(CollectionUtils.isNotEmpty(addSknList)){
grassArticleProductDao.insertArticleSkns(addSknList);
}
}
... ... @@ -776,19 +709,21 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
//商品
grassArticleProductDao.deleteByArticleId(articleId);
List<String> reqSknlist = StringUtils.isEmpty(req.getArticleSkns()) ? Lists.newArrayList() : Lists.newArrayList(req.getArticleSkns().split(","));
// List<String> reqSknlist = StringUtils.isEmpty(req.getArticleSkns()) ? Lists.newArrayList() : Lists.newArrayList(req.getArticleSkns().split(","));
//新增
List<GrassArticleProduct> addSknList = Lists.newArrayList();
int orderBy = 0;
for (String skn : reqSknlist) {
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
grassArticleSkn.setArticleId(articleId);
grassArticleSkn.setProductSkn(Integer.valueOf(skn));
grassArticleSkn.setCreateTime(System.currentTimeMillis());
grassArticleSkn.setOrderBy(orderBy);
grassArticleSkn.setProductSource(req.getSknType());
orderBy++;
addSknList.add(grassArticleSkn);
if(CollectionUtils.isNotEmpty(req.getProducts())){
for (GrassArticleProductBo skn : req.getProducts()) {
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
grassArticleSkn.setArticleId(articleId);
grassArticleSkn.setProductSkn(skn.getProductSkn());
grassArticleSkn.setCreateTime(System.currentTimeMillis());
grassArticleSkn.setOrderBy(orderBy);
grassArticleSkn.setProductSource(skn.getProductType());
orderBy++;
addSknList.add(grassArticleSkn);
}
}
if(CollectionUtils.isNotEmpty(addSknList)){
grassArticleProductDao.insertArticleSkns(addSknList);
... ... @@ -867,10 +802,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
List<Integer> labels = Lists.newArrayList();
String[] urls = req.getArticleImages().split(",");
String[] skns = null;
if(StringUtils.isNotEmpty(req.getArticleSkns())){
skns = req.getArticleSkns().split(",");
if(skns.length > 10){
if(CollectionUtils.isNotEmpty(req.getProducts())){
if(req.getProducts().size() > 10){
logger.info("timerPublish , article products more than most publish number");
throw new PlatformException("publish products most number is 10 ", 405);
}
... ... @@ -930,21 +863,18 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
}
try{
if(StringUtils.isNotEmpty( req.getArticleSkns())){
if(CollectionUtils.isNotEmpty(req.getProducts())){
int orderby = 0;
List<GrassArticleProduct> sknList = Lists.newArrayList();
if(skns != null){
Integer sknType = Optional.ofNullable(req.getSknType()).orElse(1);
for (String skn: skns) {
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
grassArticleSkn.setArticleId(article.getId());
grassArticleSkn.setProductSkn(Integer.valueOf(skn));
grassArticleSkn.setCreateTime(time);
grassArticleSkn.setOrderBy(orderby);
grassArticleSkn.setProductSource(sknType);
orderby++;
sknList.add(grassArticleSkn);
}
for (GrassArticleProductBo skn: req.getProducts()) {
GrassArticleProduct grassArticleSkn = new GrassArticleProduct();
grassArticleSkn.setArticleId(article.getId());
grassArticleSkn.setProductSkn(skn.getProductSkn());
grassArticleSkn.setCreateTime(time);
grassArticleSkn.setOrderBy(orderby);
grassArticleSkn.setProductSource(skn.getProductSkn());
orderby++;
sknList.add(grassArticleSkn);
}
if(CollectionUtils.isNotEmpty(sknList)){
... ... @@ -1175,8 +1105,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
});
Map<Integer, List<String>> imgMap = Maps.newHashMap();
Map<Integer,String> textMap = Maps.newHashMap();
Map<Integer, List<Integer>> sknMap = Maps.newHashMap();
Map<Integer, Integer> sknTypeMap = Maps.newHashMap();
Map<Integer, List<GrassArticleProductBo>> sknMap = Maps.newHashMap();
Map<Integer, List<JSONObject>> labelMap = buildLabelInfoMap(labelList);
Map<Integer, GrassTopic> topicMap = buildTopicInfoMap(grassArticleTopics);
grassArticleContentList.forEach(content -> {
... ... @@ -1200,13 +1129,15 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
});
grassArticlePoductList.forEach(product -> {
List<Integer> skns = sknMap.get(product.getArticleId());
List<GrassArticleProductBo> skns = sknMap.get(product.getArticleId());
if (skns == null) {
skns = Lists.newArrayList();
}
skns.add(product.getProductSkn());
GrassArticleProductBo bo = new GrassArticleProductBo();
bo.setProductSkn(product.getProductSkn());
bo.setProductType(product.getProductSource());
skns.add(bo);
sknMap.put(product.getArticleId(), skns);
sknTypeMap.put(product.getArticleId(), product.getProductSource());
});
... ... @@ -1246,8 +1177,12 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
rspBo.setIsTop(article.getIsTop());
rspBo.setIsRecommend(article.getIsRecommend());
rspBo.setAuthorizeAccount(article.getAuthorizeAccount());
rspBo.setSknList(sknMap.get(article.getId()));
rspBo.setSknType(sknTypeMap.get(article.getId()));
List<GrassArticleProductBo> productBos = sknMap.get(article.getId());
if(CollectionUtils.isNotEmpty(productBos)){
rspBo.setSknList(productBos);
rspBo.setYohoList(productBos.stream().filter(x -> x.getProductType()==1).map(GrassArticleProductBo::getProductSkn).collect(Collectors.toList()));
rspBo.setUfoList(productBos.stream().filter(x -> x.getProductType()==2).map(GrassArticleProductBo::getProductSkn).collect(Collectors.toList()));
}
Long authTime = article.getAuthTime();
rspBo.setAuthTimeStr(DateUtil.long2DateStr(authTime, DateUtil.DATE_TIME_FORMAT));
rspBo.setRecomTimeStr(DateUtil.long2DateStr(article.getRecommendTime(), DateUtil.DATE_TIME_FORMAT));
... ...
... ... @@ -47,7 +47,7 @@
<dependency>
<groupId>com.yohobuy.platform</groupId>
<artifactId>platform-dal</artifactId>
<version>1.0.3-6.9.0-SNAPSHOT</version>
<version>1.0.3-6.9.1-SNAPSHOT</version>
</dependency>
</dependencies>
... ...
... ... @@ -5,7 +5,7 @@
<parent>
<groupId>com.yoho</groupId>
<artifactId>yoho-starter</artifactId>
<version>1.5.4-SNAPSHOT</version>
<version>1.5.6-SNAPSHOT</version>
</parent>
... ... @@ -24,7 +24,7 @@
<dependency>
<groupId>com.yoho.service.platform.model</groupId>
<artifactId>platform-service-model</artifactId>
<version>1.2.3-6.9.0-SNAPSHOT</version>
<version>1.2.3-6.9.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhplatform</groupId>
... ... @@ -59,7 +59,7 @@
<dependency>
<groupId>com.yohobuy.platform</groupId>
<artifactId>platform-common</artifactId>
<version>1.0.3-6.9.0-SNAPSHOT</version>
<version>1.0.3-6.9.1-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
... ...
... ... @@ -36,10 +36,6 @@
<artifactId>platform-cms-suggest</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhplatform</groupId>
<artifactId>platform-cms-grass</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.service.platform.model</groupId>
<artifactId>platform-service-model</artifactId>
<exclusions>
... ...
... ... @@ -119,8 +119,7 @@
<span style="color:red">1.支持商品编号(SKN&SKUP)查询商品;&nbsp&nbsp&nbsp
2.至多添加10个商品,非必填项</span><label></label><br>
<a id="addSkn" class="btn btn-primary" style="font-size: 15px">选择商品+</a>
<input id="skns" name="articleSkns" hidden="hidden"/>
<input id="sknType" name="sknType" hidden="hidden"/>
<span id ="products"></span>
</td>
</tr>
... ... @@ -473,6 +472,12 @@
}
});
$("#labelIds").val(labels);
var html = '';
for (var i = 0; i < checkedItems.length; i++) {
html += "<input name='products["+i+"].productSkn' hidden value='"+checkedItems[i].productSkn+"'/><br>";
html += "<input name='products["+i+"].productType' hidden value='"+checkedItems[i].productType+"'/>";
}
$("#products").html(html);
return true;
},
success : function(data) {
... ... @@ -551,6 +556,12 @@
}
});
$("#labelIds").val(labels);
var html = '';
for (var i = 0; i < checkedItems.length; i++) {
html += "<input name='products["+i+"].productSkn' hidden value='"+checkedItems[i].productSkn+"'/><br>";
html += "<input name='products["+i+"].productType' hidden value='"+checkedItems[i].productType+"'/>";
}
$("#products").html(html);
return true;
},
success : function(data) {
... ... @@ -685,9 +696,15 @@
debugger
if(data.sknList!=null && data.sknList.length>0){
initGoods(data.sknList,data.sknType);
$("#sknType").val(data.sknType);
checkedItems =data.sknList;
}
if(data.yohoList!=null && data.yohoList.length>0){
initGoods(data.yohoList,1);
}
if(data.ufoList!=null && data.ufoList.length>0){
initGoods(data.ufoList,2);
}
initGoodsDiv();
}
});
... ... @@ -827,17 +844,10 @@
$("#goodstd").html("<div id=\"good0\" style=\"float: left;margin-left: 30px;width: 300px\">\n" +
" </div>");
var skns = '';
for (var i = 0; i < checkedItems.length; i++) {
buildgood(i,checkedItems[i]);
if( i == checkedItems.length -1){
skns = skns+ checkedItems[i]
}else{
skns = skns+ checkedItems[i] +","
}
buildgood(i,checkedItems[i].productSkn);
}
$("#skns").val(skns);
$("#sknType").val(checkType);
$(labelGroupList).dialog("close");
}
}, {
... ... @@ -988,14 +998,13 @@
}
function findCheckedItem(ID) {
for (var i = 0; i < checkedItems.length; i++) {
if (checkedItems[i] == ID) return i;
if (checkedItems[i].productSkn == ID) return i;
}
return -1;
}
function addcheckItem() {
if(searchType != checkType && checkedItems.length>0){
checkedItems=[];
}
// if(searchType != checkType && checkedItems.length>0){
// }
checkType = searchType;
var i=0;
$("input[type='checkbox'][name='product_skn']:checked").each(function () {
... ... @@ -1005,7 +1014,10 @@
}
var k = findCheckedItem($(this).val());
if (k == -1) {
checkedItems.push($(this).val());
var product = {};
product.productSkn = $(this).val();
product.productType = checkType;
checkedItems.push(product);
}
i++;
... ... @@ -1026,7 +1038,7 @@
$("input[type='checkbox'][name='product_skn']").each(function () {
var cb=$(this);
$.each(checkedItems,function(index,value){
if(value==cb.val()){
if(value.productSkn==cb.val()){
cb.attr("checked",true);
return false;
}
... ... @@ -1059,7 +1071,6 @@
}else{
query = query+","+skns[i];
}
checkedItems.push(skns[i]);
}
if(type==1){
params = "?query="+query;
... ... @@ -1067,25 +1078,25 @@
if(type==2){
params = "?query="+query+"&type=UFO";
}
$.post(url+params, function (data) {
debugger
if(data.code == 200){
for (var i=0; i<data.data.list.length;i++){
var rowdata = data.data.list[i]
checkedItemsObj[rowdata.product_skn] = rowdata;
}
var skns1 = '';
for (var j = 0; j < checkedItems.length; j++) {
buildgood(j,checkedItems[j]);
if( j == checkedItems.length -1){
skns1 = skns1+ checkedItems[j]
}else{
skns1 = skns1+ checkedItems[j] +","
$.ajax({
type : "post",
url : url+params,
async : false,
success : function(data){
debugger
if(data.code == 200){
for (var i=0; i<data.data.list.length;i++){
var rowdata = data.data.list[i]
checkedItemsObj[rowdata.product_skn] = rowdata;
}
}
$("#skns").val(skns1);
}
}, "json");
});
}
function initGoodsDiv() {
for (var i = 0; i < checkedItems.length; i++) {
buildgood(i,checkedItems[i].productSkn);
}
}
</script>
... ...
... ... @@ -135,8 +135,9 @@
<span style="color:red">1.支持商品编号(SKN&SKUP)查询商品;&nbsp&nbsp&nbsp
2.至多添加10个商品,非必填项</span><label></label><br>
<a id="addSkn" class="btn btn-primary" style="font-size: 15px">选择商品+</a>
<input id="skns" name="articleSkns" hidden="hidden"/>
<input id="sknType" name="sknType" hidden="hidden"/>
<!--<input id="skns" name="articleSkns" hidden="hidden"/>-->
<!--<input id="sknType" name="sknType" hidden="hidden"/>-->
<span id ="products"></span>
</td>
</tr>
... ... @@ -437,14 +438,14 @@
var product_skn = $(this).attr("data-index");
removeSingleItemById(product_skn);
var skns = '';
for (var i = 0; i < checkedItems.length; i++) {
if( i == checkedItems.length -1){
skns = skns+ checkedItems[i]
}else{
skns = skns+ checkedItems[i] +","
}
}
$("#skns").val(skns);
// for (var i = 0; i < checkedItems.length; i++) {
// if( i == checkedItems.length -1){
// skns = skns+ checkedItems[i]
// }else{
// skns = skns+ checkedItems[i] +","
// }
// }
// $("#skns").val(skns);
var div= $(this).parent("span").parent("div");
div.remove();
});
... ... @@ -502,6 +503,13 @@
}
});
$("#labelIds").val(labels);
var html = '';
for (var i = 0; i < checkedItems.length; i++) {
html += "<input name='products["+i+"].productSkn' hidden value='"+checkedItems[i].productSkn+"'/><br>";
html += "<input name='products["+i+"].productType' hidden value='"+checkedItems[i].productType+"'/>";
}
$("#products").html(html);
return true;
},
success : function(data) {
... ... @@ -573,6 +581,12 @@
}
});
$("#labelIds").val(labels);
var html = '';
for (var i = 0; i < checkedItems.length; i++) {
html += "<input name='products["+i+"].productSkn' hidden value='"+checkedItems[i].productSkn+"'/><br>";
html += "<input name='products["+i+"].productType' hidden value='"+checkedItems[i].productType+"'/>";
}
$("#products").html(html);
return true;
},
success : function(data) {
... ... @@ -744,6 +758,12 @@
}
});
$("#labelIds").val(labels);
var html = '';
for (var i = 0; i < checkedItems.length; i++) {
html += "<input name='products["+i+"].productSkn' hidden value='"+checkedItems[i].productSkn+"'/><br>";
html += "<input name='products["+i+"].productType' hidden value='"+checkedItems[i].productType+"'/>";
}
$("#products").html(html);
return true;
},
success : function(data) {
... ... @@ -803,14 +823,8 @@
var skns = '';
for (var i = 0; i < checkedItems.length; i++) {
buildgood(i,checkedItems[i]);
if( i == checkedItems.length -1){
skns = skns+ checkedItems[i]
}else{
skns = skns+ checkedItems[i] +","
}
}
$("#skns").val(skns);
$("#sknType").val(checkType);
$(labelGroupList).dialog("close");
}
}, {
... ... @@ -933,7 +947,7 @@
function buildgood(index,obj) {
debugger;
var data = checkedItemsObj[obj];
var data = checkedItemsObj[obj.productSkn];
$("#good"+index).html(gooddiv(data));
$div = $("#good"+(index+1));
$("#good"+index).after('<div id="good'+(index+1)+'"style="float: left;margin-left: 30px;width: 300px"> </div>');
... ... @@ -972,14 +986,14 @@
}
function findCheckedItem(ID) {
for (var i = 0; i < checkedItems.length; i++) {
if (checkedItems[i] == ID) return i;
if (checkedItems[i].productSkn == ID) return i;
}
return -1;
}
function addcheckItem() {
if(searchType != checkType && checkedItems.length>0){
checkedItems=[];
}
// if(searchType != checkType && checkedItems.length>0){
// checkedItems=[];
// }
checkType = searchType;
var i=0;
$("input[type='checkbox'][name='product_skn']:checked").each(function () {
... ... @@ -989,7 +1003,10 @@
}
var k = findCheckedItem($(this).val());
if (k == -1) {
checkedItems.push($(this).val());
var product = {};
product.productSkn = $(this).val();
product.productType = checkType;
checkedItems.push(product);
}
i++;
... ... @@ -1010,7 +1027,7 @@
$("input[type='checkbox'][name='product_skn']").each(function () {
var cb=$(this);
$.each(checkedItems,function(index,value){
if(value==cb.val()){
if(value.productSkn==cb.val()){
cb.attr("checked",true);
return false;
}
... ...