|
|
|
@ -47,8 +47,8 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Goods> getGoodsList(int page) { |
|
|
|
int startrs = page>0?(page-1)* ChConstant.PAGESIZE:0; |
|
|
|
List<Goods> goodsList = goodsMapper.getGoodsList(startrs,ChConstant.PAGESIZE); |
|
|
|
int startrs = page > 0 ? (page - 1) * ChConstant.PAGESIZE : 0; |
|
|
|
List<Goods> goodsList = goodsMapper.getGoodsList(startrs, ChConstant.PAGESIZE); |
|
|
|
//todo 字段转化啥的
|
|
|
|
return goodsList; |
|
|
|
} |
|
|
|
@ -60,31 +60,32 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新产品,并统计更新数量 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public int getApiGoods() { |
|
|
|
int count=0; //统计更新数量
|
|
|
|
int count = 0; //统计更新数量
|
|
|
|
|
|
|
|
String host = ProperUtils.getSzwhProp("ENTRUST_URL"); |
|
|
|
String apiurl=host+"/consign/exchange/v1/selectEntrustSource/exchange"; |
|
|
|
log.info("get apigoods :"+apiurl); |
|
|
|
String apiurl = host + "/consign/exchange/v1/selectEntrustSource/exchange"; |
|
|
|
log.info("get apigoods :" + apiurl); |
|
|
|
|
|
|
|
//创建签名
|
|
|
|
String sign= SignUtils.createSign("entrust"); |
|
|
|
String sign = SignUtils.createSign("entrust"); |
|
|
|
// 请求头
|
|
|
|
Map<String,Object> hmap =new HashMap(); |
|
|
|
hmap.put("token",sign); |
|
|
|
hmap.put("Content-Type","application/json"); |
|
|
|
Map<String, Object> hmap = new HashMap(); |
|
|
|
hmap.put("token", sign); |
|
|
|
hmap.put("Content-Type", "application/json"); |
|
|
|
// get 方式获取
|
|
|
|
JSONObject jsonObject = RequestUtils.GetData(apiurl,hmap); |
|
|
|
log.info("goods api result : "+jsonObject); |
|
|
|
JSONObject jsonObject = RequestUtils.GetData(apiurl, hmap); |
|
|
|
log.info("goods api result : " + jsonObject); |
|
|
|
|
|
|
|
// 检索出对象
|
|
|
|
JSONArray jsonArray = jsonObject.getJSONArray("data"); |
|
|
|
log.info("goods jsonarray: "+jsonArray); |
|
|
|
log.info("goods jsonarray: " + jsonArray); |
|
|
|
// 产品详情地址
|
|
|
|
String gdurl=host+"/consign/exchange/v1/selectEntrustDetails"; |
|
|
|
String gdurl = host + "/consign/exchange/v1/selectEntrustDetails"; |
|
|
|
|
|
|
|
return count; |
|
|
|
} |
|
|
|
@ -92,61 +93,61 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
@Override |
|
|
|
public List getMapDataByTyep(int type) { |
|
|
|
Map retmap = new HashMap(); |
|
|
|
String order="";//排序条件
|
|
|
|
String order = "";//排序条件
|
|
|
|
|
|
|
|
String where="is_deleted=0 ";//排序
|
|
|
|
int limit=10; |
|
|
|
String where = "is_deleted=0 ";//排序
|
|
|
|
int limit = 10; |
|
|
|
// 点击量倒序
|
|
|
|
if (type==1){ |
|
|
|
order="click_count"; |
|
|
|
if (type == 1) { |
|
|
|
order = "click_count"; |
|
|
|
} |
|
|
|
|
|
|
|
// 销售量
|
|
|
|
if(type==2){ |
|
|
|
order="sale_count"; |
|
|
|
if (type == 2) { |
|
|
|
order = "sale_count"; |
|
|
|
} |
|
|
|
|
|
|
|
//推荐,just 8
|
|
|
|
if(type==3){ |
|
|
|
limit=8; |
|
|
|
order="recommend_sort"; |
|
|
|
where+= "and is_recommend=1"; |
|
|
|
if (type == 3) { |
|
|
|
limit = 8; |
|
|
|
order = "recommend_sort"; |
|
|
|
where += "and is_recommend=1"; |
|
|
|
} |
|
|
|
|
|
|
|
// 商品结果列表
|
|
|
|
List nglist = new ArrayList(); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
// 排序索引
|
|
|
|
int index=0; |
|
|
|
List<Goods> glist = goodsMapper.getGoodsByCondition(where,limit,order,"DESC"); |
|
|
|
int index = 0; |
|
|
|
List<Goods> glist = goodsMapper.getGoodsByCondition(where, limit, order, "DESC"); |
|
|
|
// 查询到的list 进行排序
|
|
|
|
List<Goods> newgoodsList = new LinkedList<>(); |
|
|
|
Collections.sort(glist, new Comparator<Goods>() { |
|
|
|
@Override |
|
|
|
public int compare(Goods o1, Goods o2) { |
|
|
|
if(o1.getRecommendSort()>o2.getRecommendSort()){ |
|
|
|
if (o1.getRecommendSort() > o2.getRecommendSort()) { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
if(o1.getRecommendSort()== o2.getRecommendSort()){ |
|
|
|
if (o1.getRecommendSort() == o2.getRecommendSort()) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
return 1; |
|
|
|
} |
|
|
|
}); |
|
|
|
if(glist!=null){ |
|
|
|
for(Goods g:glist){ |
|
|
|
Map<String,Object> ngmap = new HashMap<>(); |
|
|
|
if (glist != null) { |
|
|
|
for (Goods g : glist) { |
|
|
|
Map<String, Object> ngmap = new HashMap<>(); |
|
|
|
GoodsDetail goodsDetail = goodsDetailMapper.getGoodsDetailBygid(g.getGoodsDetailId()); |
|
|
|
//添加内容
|
|
|
|
ngmap.put("createtime",sdf.format(g.getCreateTime())); |
|
|
|
ngmap.put("goods_islicode",g.getGoodsIslicode()); |
|
|
|
ngmap.put("goods_name",goodsDetail.getGoodsName()); |
|
|
|
ngmap.put("goods_status",g.getGoodsStatus()); |
|
|
|
ngmap.put("goods_type",goodsDetail.getGoodsType()); |
|
|
|
ngmap.put("id",index+1); |
|
|
|
ngmap.put("key",g.getGoodsIslicode()); |
|
|
|
ngmap.put("recommend_sort",g.getRecommendSort()); |
|
|
|
ngmap.put("username",g.getUsername()); |
|
|
|
ngmap.put("createtime", sdf.format(g.getCreateTime())); |
|
|
|
ngmap.put("goods_islicode", g.getGoodsIslicode()); |
|
|
|
ngmap.put("goods_name", goodsDetail.getGoodsName()); |
|
|
|
ngmap.put("goods_status", g.getGoodsStatus()); |
|
|
|
ngmap.put("goods_type", goodsDetail.getGoodsType()); |
|
|
|
ngmap.put("id", index + 1); |
|
|
|
ngmap.put("key", g.getGoodsIslicode()); |
|
|
|
ngmap.put("recommend_sort", g.getRecommendSort()); |
|
|
|
ngmap.put("username", g.getUsername()); |
|
|
|
nglist.add(ngmap); |
|
|
|
index++; |
|
|
|
} |
|
|
|
@ -156,20 +157,21 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
|
|
|
|
/** |
|
|
|
* map 对象查询 |
|
|
|
* |
|
|
|
* @param gmap 查询对象 |
|
|
|
* @param limit 条目 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Map<String,Object> getGoodsByMap(Map gmap, int page,int limit) { |
|
|
|
Map retmap =new HashMap(); |
|
|
|
public Map<String, Object> getGoodsByMap(Map gmap, int page, int limit) { |
|
|
|
Map retmap = new HashMap(); |
|
|
|
|
|
|
|
int start = page>1?(page-1)*limit:0; |
|
|
|
int end =page*limit; |
|
|
|
int start = page > 1 ? (page - 1) * limit : 0; |
|
|
|
int end = page * limit; |
|
|
|
|
|
|
|
//排序方式
|
|
|
|
String orderkey = ""; |
|
|
|
if(gmap.size()>0) { |
|
|
|
if (gmap.size() > 0) { |
|
|
|
String ordway = (String) gmap.get("orderway"); |
|
|
|
if (StringUtils.isNotBlank(ordway)) { |
|
|
|
switch (ordway) { |
|
|
|
@ -185,6 +187,9 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
case "4": |
|
|
|
orderkey = "g.click_count"; |
|
|
|
break; |
|
|
|
default: |
|
|
|
orderkey = "g.id"; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -192,39 +197,39 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
// 获取是否推荐
|
|
|
|
Integer ishow = (Integer) gmap.get("g.is_recommend"); |
|
|
|
|
|
|
|
List nglist= new ArrayList(); |
|
|
|
List<GoodsListVo> goodsListVoList = goodsMapper.getGoodsVoList(gmap,orderkey,"DESC",limit,start); |
|
|
|
for(GoodsListVo gl:goodsListVoList){ |
|
|
|
List nglist = new ArrayList(); |
|
|
|
List<GoodsListVo> goodsListVoList = goodsMapper.getGoodsVoList(gmap, orderkey, "DESC", limit, start); |
|
|
|
for (GoodsListVo gl : goodsListVoList) { |
|
|
|
Map glmap = new HashMap(); |
|
|
|
glmap.put("id",gl.getId()); |
|
|
|
glmap.put("createtime",gl.getCreatetime()); |
|
|
|
glmap.put("goods_islicode",gl.getGoods_islicode()); |
|
|
|
glmap.put("goods_name",gl.getGoods_name()); |
|
|
|
glmap.put("username",gl.getUsername()); |
|
|
|
glmap.put("user_islicode",gl.getUser_islicode()); |
|
|
|
glmap.put("goods_type",gl.getGoods_type()); |
|
|
|
glmap.put("goods_status",gl.getGoods_status()); |
|
|
|
glmap.put("goods_detail_id",gl.getGoods_detail_id()); |
|
|
|
glmap.put("is_recommend",gl.getIsRecommend()); |
|
|
|
glmap.put("entrust_status",gl.getEntrust_status()); |
|
|
|
glmap.put("id", gl.getId()); |
|
|
|
glmap.put("createtime", gl.getCreatetime()); |
|
|
|
glmap.put("goods_islicode", gl.getGoods_islicode()); |
|
|
|
glmap.put("goods_name", gl.getGoods_name()); |
|
|
|
glmap.put("username", gl.getUsername()); |
|
|
|
glmap.put("user_islicode", gl.getUser_islicode()); |
|
|
|
glmap.put("goods_type", gl.getGoods_type()); |
|
|
|
glmap.put("goods_status", gl.getGoods_status()); |
|
|
|
glmap.put("goods_detail_id", gl.getGoods_detail_id()); |
|
|
|
glmap.put("is_recommend", gl.getIsRecommend()); |
|
|
|
glmap.put("entrust_status", gl.getEntrust_status()); |
|
|
|
//处理其他操作
|
|
|
|
glmap.put("key",gl.getGoods_islicode()); |
|
|
|
glmap.put("key", gl.getGoods_islicode()); |
|
|
|
nglist.add(glmap); |
|
|
|
} |
|
|
|
retmap.put("data",nglist); |
|
|
|
retmap.put("data", nglist); |
|
|
|
// 总的记录
|
|
|
|
int total = goodsMapper.countGoodsListVo(gmap); |
|
|
|
retmap.put("total",total); |
|
|
|
retmap.put("total", total); |
|
|
|
|
|
|
|
if(total<end){ |
|
|
|
end=total; |
|
|
|
if (total < end) { |
|
|
|
end = total; |
|
|
|
} |
|
|
|
|
|
|
|
retmap.put("per_page",limit); |
|
|
|
retmap.put("start",start+1); // start 默认为0
|
|
|
|
retmap.put("end",end); |
|
|
|
retmap.put("curr_page",page); |
|
|
|
retmap.put("per_page",limit); |
|
|
|
retmap.put("per_page", limit); |
|
|
|
retmap.put("start", start + 1); // start 默认为0
|
|
|
|
retmap.put("end", end); |
|
|
|
retmap.put("curr_page", page); |
|
|
|
retmap.put("per_page", limit); |
|
|
|
|
|
|
|
|
|
|
|
return retmap; |
|
|
|
@ -232,63 +237,63 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, Object> getGoodsDetail(String islicode) { |
|
|
|
Map retmap= new HashMap(); |
|
|
|
Map retmap = new HashMap(); |
|
|
|
/** |
|
|
|
* 联合查询的结果 |
|
|
|
*/ |
|
|
|
GoodsDetailVo gdv= goodsDetailMapper.getGoodsDetailVoList(islicode); |
|
|
|
retmap.put("entrust_goods",gdv); |
|
|
|
if(gdv==null){ |
|
|
|
log.warn("goods islicode: "+islicode+" ,不存在"); |
|
|
|
GoodsDetailVo gdv = goodsDetailMapper.getGoodsDetailVoList(islicode); |
|
|
|
retmap.put("entrust_goods", gdv); |
|
|
|
if (gdv == null) { |
|
|
|
log.warn("goods islicode: " + islicode + " ,不存在"); |
|
|
|
throw new ChException("未查询到该商品"); |
|
|
|
} |
|
|
|
// 取到用户信息
|
|
|
|
// 返回后远程获取用户信息 userinfo
|
|
|
|
retmap.put("user_isli",gdv.getUser_islicode()); |
|
|
|
retmap.put("user_isli", gdv.getUser_islicode()); |
|
|
|
|
|
|
|
// 商品资源
|
|
|
|
//List gatherarr=new ArrayList();
|
|
|
|
Set gatherarr=new HashSet(); |
|
|
|
List oneSource=new ArrayList(); |
|
|
|
Set gatherarr = new HashSet(); |
|
|
|
List oneSource = new ArrayList(); |
|
|
|
List<GoodsSource> goodsSourceList = goodsSourceMapper.getGoodsSourceByIsli(gdv.getGoods_islicode()); |
|
|
|
//if(goodsSourceList!=null){ //not null
|
|
|
|
for(GoodsSource gs:goodsSourceList){ |
|
|
|
for (GoodsSource gs : goodsSourceList) { |
|
|
|
// 解析json
|
|
|
|
JSONObject sdjson = JSONObject.parseObject(gs.getSourceData()); |
|
|
|
log.info("source :"+sdjson); |
|
|
|
log.info("goods source data :"+gs.getSourceData()); |
|
|
|
Integer datatype=gs.getDatatype(); |
|
|
|
log.info("goods source datatype :"+datatype); |
|
|
|
log.info("source :" + sdjson); |
|
|
|
log.info("goods source data :" + gs.getSourceData()); |
|
|
|
Integer datatype = gs.getDatatype(); |
|
|
|
log.info("goods source datatype :" + datatype); |
|
|
|
Map info = new HashMap(); |
|
|
|
if(datatype==1){ //机构数据
|
|
|
|
info.put("name",gs.getSourceName()); |
|
|
|
info.put("class",gs.getSourceType()); |
|
|
|
if (datatype == 1) { //机构数据
|
|
|
|
info.put("name", gs.getSourceName()); |
|
|
|
info.put("class", gs.getSourceType()); |
|
|
|
// 从json data 中获取
|
|
|
|
info.put("registerDate",sdjson.getString("registerDate")); |
|
|
|
info.put("identifier",sdjson.getString("identifier")); |
|
|
|
info.put("registerDate", sdjson.getString("registerDate")); |
|
|
|
info.put("identifier", sdjson.getString("identifier")); |
|
|
|
|
|
|
|
//符合条件的数量
|
|
|
|
int count = goodsSourceMapper.countGoodSource(gdv.getGoods_islicode(),1,gs.getSourceidentify()); |
|
|
|
info.put("count",count); |
|
|
|
int count = goodsSourceMapper.countGoodSource(gdv.getGoods_islicode(), 1, gs.getSourceidentify()); |
|
|
|
info.put("count", count); |
|
|
|
gatherarr.add(info); |
|
|
|
}else{ |
|
|
|
Long filesize= sdjson.getLongValue("metadataFileSize"); |
|
|
|
info.put("name",gs.getSourceName()); |
|
|
|
info.put("class",gs.getSourceType()); |
|
|
|
info.put("registerDate",sdjson.getString("registerDate")); |
|
|
|
} else { |
|
|
|
Long filesize = sdjson.getLongValue("metadataFileSize"); |
|
|
|
info.put("name", gs.getSourceName()); |
|
|
|
info.put("class", gs.getSourceType()); |
|
|
|
info.put("registerDate", sdjson.getString("registerDate")); |
|
|
|
info.put("filesize", SzFileUtils.fileSizeFormat(filesize)); |
|
|
|
info.put("identifier",sdjson.getString("identifier")); |
|
|
|
info.put("metadataFileFormat",sdjson.getString("metadataFileFormat")); |
|
|
|
info.put("identifier", sdjson.getString("identifier")); |
|
|
|
info.put("metadataFileFormat", sdjson.getString("metadataFileFormat")); |
|
|
|
//符合条件的数量
|
|
|
|
int count = goodsSourceMapper.countGoodSource(gdv.getGoods_islicode(),1,gs.getSourceidentify()); |
|
|
|
info.put("count",count); |
|
|
|
int count = goodsSourceMapper.countGoodSource(gdv.getGoods_islicode(), 1, gs.getSourceidentify()); |
|
|
|
info.put("count", count); |
|
|
|
|
|
|
|
oneSource.add(info); |
|
|
|
} |
|
|
|
} |
|
|
|
//
|
|
|
|
retmap.put("gather_arr",gatherarr); |
|
|
|
retmap.put("oneSource",oneSource); |
|
|
|
retmap.put("gather_arr", gatherarr); |
|
|
|
retmap.put("oneSource", oneSource); |
|
|
|
//}
|
|
|
|
|
|
|
|
return retmap; |
|
|
|
@ -296,67 +301,69 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 下架操作 |
|
|
|
* |
|
|
|
* @param goodsIsli |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Map<String, Object> whetherOff(String goodsIsli) { |
|
|
|
Map retmap = new HashMap(); |
|
|
|
String msg="没有该条委托数据"; |
|
|
|
int code=400; |
|
|
|
String msg = "没有该条委托数据"; |
|
|
|
int code = 400; |
|
|
|
Goods goods = goodsMapper.getGoodsFuelByIsLi(goodsIsli); |
|
|
|
// 非空,继续判断
|
|
|
|
if(goods!=null) { |
|
|
|
if (goods != null) { |
|
|
|
// 非在售状态
|
|
|
|
if (goods.getGoodsStatus() != 1 && goods.getGoodsStatus() != 5) { |
|
|
|
msg = "暂时只支持对已发布/暂停中文化数据进行撤销!"; |
|
|
|
}else if (goods.getApplyOut() == 1) { |
|
|
|
} else if (goods.getApplyOut() == 1) { |
|
|
|
msg = "请勿重复提交撤销委托申请!"; |
|
|
|
}else{ |
|
|
|
code=200; |
|
|
|
msg="可以下架"; |
|
|
|
} else { |
|
|
|
code = 200; |
|
|
|
msg = "可以下架"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
retmap.put("msg",msg); |
|
|
|
retmap.put("code",code); |
|
|
|
retmap.put("msg", msg); |
|
|
|
retmap.put("code", code); |
|
|
|
|
|
|
|
return retmap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 委托撤销商品 |
|
|
|
* |
|
|
|
* @param goodsIsli |
|
|
|
* @param reason |
|
|
|
* @param username |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Map<String,Object> offGoods(String goodsIsli, String reason,String username) { |
|
|
|
int code =200; |
|
|
|
String msg="成功"; |
|
|
|
public Map<String, Object> offGoods(String goodsIsli, String reason, String username) { |
|
|
|
int code = 200; |
|
|
|
String msg = "成功"; |
|
|
|
// 查询商品信息
|
|
|
|
Goods goods = goodsMapper.getGoodsFuelByIsLi(goodsIsli); |
|
|
|
if(goods==null ){ |
|
|
|
msg="没有该条委托数据"; |
|
|
|
code=400; |
|
|
|
if (goods == null) { |
|
|
|
msg = "没有该条委托数据"; |
|
|
|
code = 400; |
|
|
|
} |
|
|
|
if(goods.getGoodsStatus()!=1 && goods.getGoodsStatus()!=5){ |
|
|
|
msg="暂时只支持对已发布/暂停中文化数据进行撤销!"; |
|
|
|
code=400; |
|
|
|
if (goods.getGoodsStatus() != 1 && goods.getGoodsStatus() != 5) { |
|
|
|
msg = "暂时只支持对已发布/暂停中文化数据进行撤销!"; |
|
|
|
code = 400; |
|
|
|
} |
|
|
|
if(goods.getApplyOut() == 1){ |
|
|
|
msg="请勿重复提交撤销委托申请!"; |
|
|
|
code=400; |
|
|
|
if (goods.getApplyOut() == 1) { |
|
|
|
msg = "请勿重复提交撤销委托申请!"; |
|
|
|
code = 400; |
|
|
|
} |
|
|
|
// 满足上述条件后进行远程处理
|
|
|
|
JSONObject retjson = SzwhApiUtils.offGoods(reason,goodsIsli); |
|
|
|
log.info("remote offgoods result:"+retjson.toString()); |
|
|
|
String errorcode =retjson.getString("resultCode"); |
|
|
|
JSONObject retjson = SzwhApiUtils.offGoods(reason, goodsIsli); |
|
|
|
log.info("remote offgoods result:" + retjson.toString()); |
|
|
|
String errorcode = retjson.getString("resultCode"); |
|
|
|
String errmsg = retjson.getString("resultMsg"); |
|
|
|
if(!"00000000".equals(errorcode)){ |
|
|
|
msg= errmsg; |
|
|
|
code=400; |
|
|
|
}else { |
|
|
|
if (!"00000000".equals(errorcode)) { |
|
|
|
msg = errmsg; |
|
|
|
code = 400; |
|
|
|
} else { |
|
|
|
// 更新状态
|
|
|
|
Map gmap = new HashMap(); |
|
|
|
gmap.put("apply_out", 1); |
|
|
|
@ -372,88 +379,89 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
oplog.setMessage(message); |
|
|
|
operationLogMapper.addLog(oplog); |
|
|
|
//
|
|
|
|
msg="成功"; |
|
|
|
code=200; |
|
|
|
msg = "成功"; |
|
|
|
code = 200; |
|
|
|
} |
|
|
|
// 返回的map 集合
|
|
|
|
Map retmap = new HashMap(); |
|
|
|
retmap.put("code",code); |
|
|
|
retmap.put("msg",msg); |
|
|
|
retmap.put("code", code); |
|
|
|
retmap.put("msg", msg); |
|
|
|
return retmap; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String,Object> addRank(List<String> goodsisliArr) { |
|
|
|
String msg="成功"; |
|
|
|
int code=200; |
|
|
|
Map remap =new HashMap(); |
|
|
|
remap.put("is_recommend",1); //推荐商品
|
|
|
|
remap.put("is_deleted",0); |
|
|
|
public Map<String, Object> addRank(List<String> goodsisliArr) { |
|
|
|
String msg = "成功"; |
|
|
|
int code = 200; |
|
|
|
Map remap = new HashMap(); |
|
|
|
remap.put("is_recommend", 1); //推荐商品
|
|
|
|
remap.put("is_deleted", 0); |
|
|
|
int hasrecomend = goodsMapper.goodsCount(remap); |
|
|
|
if(hasrecomend>=8){ |
|
|
|
code=400; |
|
|
|
msg="你推荐的商品数量超过8个"; |
|
|
|
if (hasrecomend >= 8) { |
|
|
|
code = 400; |
|
|
|
msg = "你推荐的商品数量超过8个"; |
|
|
|
} |
|
|
|
//
|
|
|
|
for(String ss:goodsisliArr){ |
|
|
|
if(hasrecomend<8){ |
|
|
|
for (String ss : goodsisliArr) { |
|
|
|
if (hasrecomend < 8) { |
|
|
|
Goods goods = goodsMapper.getGoodsFuelByIsLi(ss); |
|
|
|
if(goods==null){ |
|
|
|
if (goods == null) { |
|
|
|
continue; |
|
|
|
}else{ |
|
|
|
if(goods.getIsRecommend()==1){ |
|
|
|
} else { |
|
|
|
if (goods.getIsRecommend() == 1) { |
|
|
|
continue; |
|
|
|
}else{ |
|
|
|
goodsMapper.updateRecommend(goods.getGoodsIslicode(),1); |
|
|
|
} else { |
|
|
|
goodsMapper.updateRecommend(goods.getGoodsIslicode(), 1); |
|
|
|
} |
|
|
|
} |
|
|
|
hasrecomend++; |
|
|
|
} |
|
|
|
} |
|
|
|
Map outmap = new HashMap(); |
|
|
|
outmap.put("code",code); |
|
|
|
outmap.put("msg",msg); |
|
|
|
outmap.put("code", code); |
|
|
|
outmap.put("msg", msg); |
|
|
|
return outmap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移除推荐榜 |
|
|
|
* |
|
|
|
* @param goodsisliArr |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Map<String, Object> delRank(List<String> goodsisliArr) { |
|
|
|
int code=200; |
|
|
|
String msg="成功"; |
|
|
|
for(String srt:goodsisliArr){ |
|
|
|
String gis =srt; |
|
|
|
int code = 200; |
|
|
|
String msg = "成功"; |
|
|
|
for (String srt : goodsisliArr) { |
|
|
|
String gis = srt; |
|
|
|
Goods goods = goodsMapper.getGoodsFuelByIsLi(gis); |
|
|
|
if(goods==null){ |
|
|
|
if (goods == null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if(goods.getIsRecommend()==0){ |
|
|
|
if (goods.getIsRecommend() == 0) { |
|
|
|
continue; |
|
|
|
}else{ |
|
|
|
int ret = goodsMapper.updateRecommend(gis,0); |
|
|
|
} else { |
|
|
|
int ret = goodsMapper.updateRecommend(gis, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
Map retmap = new HashMap(); |
|
|
|
retmap.put("code",code); |
|
|
|
retmap.put("msg",msg); |
|
|
|
retmap.put("code", code); |
|
|
|
retmap.put("msg", msg); |
|
|
|
return retmap; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public int ranksort(String goodsIsli, int type) { |
|
|
|
int ret=0; |
|
|
|
int ret = 0; |
|
|
|
Goods goods = goodsMapper.getGoodsByIsli(goodsIsli); |
|
|
|
if(goods!=null ){ |
|
|
|
if (goods != null) { |
|
|
|
int ranksort = goods.getRecommendSort(); |
|
|
|
int sortaval = type==1?ranksort+1:ranksort-1; |
|
|
|
if(sortaval<0){ |
|
|
|
sortaval=0; |
|
|
|
int sortaval = type == 1 ? ranksort + 1 : ranksort - 1; |
|
|
|
if (sortaval < 0) { |
|
|
|
sortaval = 0; |
|
|
|
} |
|
|
|
ret = goodsMapper.updateRankSort(goodsIsli,sortaval); |
|
|
|
ret = goodsMapper.updateRankSort(goodsIsli, sortaval); |
|
|
|
} |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|