|
|
|
@ -448,6 +448,7 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
/** |
|
|
|
* 处理排序问题 |
|
|
|
* 与前一个元素的排序进行互换,需要同时更新两条记录 |
|
|
|
* |
|
|
|
* @param goodsIsli |
|
|
|
* @param type |
|
|
|
* @return |
|
|
|
@ -460,30 +461,30 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
//List<Goods> tmpRanklist = goodsMapper.getGoodsByCondition(where, 8, "recommend_sort", "DESC");
|
|
|
|
List<Goods> tmpRanklist = queryRankList(); |
|
|
|
int ret = 0; |
|
|
|
for(int i=0;i<tmpRanklist.size();i++){ |
|
|
|
if(goodsIsli.equals(tmpRanklist.get(i).getGoodsIslicode()) ){ |
|
|
|
for (int i = 0; i < tmpRanklist.size(); i++) { |
|
|
|
if (goodsIsli.equals(tmpRanklist.get(i).getGoodsIslicode())) { |
|
|
|
// 当前项目sort
|
|
|
|
int curSort = tmpRanklist.get(i).getRecommendSort(); |
|
|
|
// 上移
|
|
|
|
if(type==1) { |
|
|
|
if(i==0){ |
|
|
|
if (type == 1) { |
|
|
|
if (i == 0) { |
|
|
|
break; |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
//前序sort
|
|
|
|
int frontSort = tmpRanklist.get(i-1).getRecommendSort(); |
|
|
|
int afterSort= (frontSort==curSort)?curSort+1:frontSort; |
|
|
|
log.info("更新后的sort:"+afterSort); |
|
|
|
int frontSort = tmpRanklist.get(i - 1).getRecommendSort(); |
|
|
|
int afterSort = (frontSort == curSort) ? curSort + 1 : frontSort; |
|
|
|
log.info("更新后的sort:" + afterSort); |
|
|
|
// 前序变更recommend sort
|
|
|
|
goodsMapper.updateRecommend(tmpRanklist.get(i-1).getGoodsIslicode(),curSort); |
|
|
|
ret = goodsMapper.updateRecommend(goodsIsli,afterSort); |
|
|
|
goodsMapper.updateRecommend(tmpRanklist.get(i - 1).getGoodsIslicode(), curSort); |
|
|
|
ret = goodsMapper.updateRecommend(goodsIsli, afterSort); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
if(i<tmpRanklist.size()){ |
|
|
|
} else { |
|
|
|
if (i < tmpRanklist.size()) { |
|
|
|
//前序sort
|
|
|
|
int frontSort = tmpRanklist.get(i+1).getRecommendSort(); |
|
|
|
int afterSort= (frontSort==curSort)?curSort-1:frontSort; |
|
|
|
int frontSort = tmpRanklist.get(i + 1).getRecommendSort(); |
|
|
|
int afterSort = (frontSort == curSort) ? curSort - 1 : frontSort; |
|
|
|
// 前序变更recommend sort
|
|
|
|
goodsMapper.updateRecommend(tmpRanklist.get(i+1).getGoodsIslicode(),curSort); |
|
|
|
goodsMapper.updateRecommend(tmpRanklist.get(i + 1).getGoodsIslicode(), curSort); |
|
|
|
ret = goodsMapper.updateRecommend(goodsIsli, afterSort); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -510,16 +511,16 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
@Override |
|
|
|
public List<Goods> getTypeGoods(String type, String createtime, String goods_type) { |
|
|
|
List<Goods> glist = new ArrayList<>(); |
|
|
|
String where="";//查询条件
|
|
|
|
if("1".equals(type)){ |
|
|
|
glist = goodsMapper.getGoodsByCondition("1=1",10,"click_count","DESC"); |
|
|
|
String where = "";//查询条件
|
|
|
|
if ("1".equals(type)) { |
|
|
|
glist = goodsMapper.getGoodsByCondition("1=1", 10, "click_count", "DESC"); |
|
|
|
} |
|
|
|
if("2".equals(type)){ |
|
|
|
glist = goodsMapper.getGoodsByCondition("1=1",10,"sale_count","DESC"); |
|
|
|
if ("2".equals(type)) { |
|
|
|
glist = goodsMapper.getGoodsByCondition("1=1", 10, "sale_count", "DESC"); |
|
|
|
} |
|
|
|
if("3".equals(type)){ |
|
|
|
where="is_recommend=1 and goods_status=1"; |
|
|
|
glist = goodsMapper.getGoodsByCondition(where,8,"recommend_sort","DESC"); |
|
|
|
if ("3".equals(type)) { |
|
|
|
where = "is_recommend=1 and goods_status=1"; |
|
|
|
glist = goodsMapper.getGoodsByCondition(where, 8, "recommend_sort", "DESC"); |
|
|
|
} |
|
|
|
|
|
|
|
return glist; |
|
|
|
@ -527,10 +528,11 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
|
|
|
|
/** |
|
|
|
* query rank list |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<Goods> queryRankList(){ |
|
|
|
String where="is_deleted=0 and is_recommend=1"; |
|
|
|
private List<Goods> queryRankList() { |
|
|
|
String where = "is_deleted=0 and is_recommend=1"; |
|
|
|
List<Goods> tmpRanklist = goodsMapper.getGoodsByCondition(where, 8, "recommend_sort", "DESC"); |
|
|
|
return tmpRanklist; |
|
|
|
} |
|
|
|
@ -571,9 +573,9 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
} |
|
|
|
//处理返回的结果
|
|
|
|
JSONArray gdArr = gdJson.getJSONArray("data"); |
|
|
|
if(gdArr==null){ |
|
|
|
if (gdArr == null) { |
|
|
|
continue; |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
log.info(gdArr.size()); |
|
|
|
} |
|
|
|
// add goodsSource,循环插入 商品资源
|
|
|
|
@ -618,15 +620,18 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
String ncstart = cstart + " " + curTime; |
|
|
|
// 委托周期
|
|
|
|
Integer day = nsdjson.getInteger("contractualCycle"); |
|
|
|
//转换为date
|
|
|
|
if (day == null) { |
|
|
|
day = 40; // 默认40个工作日
|
|
|
|
} |
|
|
|
// 委托终止日期
|
|
|
|
String cend = nsdjson.getString("contractualPeriodEnd"); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(cend)) { |
|
|
|
cend = "2099-12-31"; |
|
|
|
} |
|
|
|
//委托开始时间,取当前时间
|
|
|
|
Timestamp ncst=new Timestamp(System.currentTimeMillis()); |
|
|
|
Timestamp ncst = new Timestamp(System.currentTimeMillis()); |
|
|
|
//委托结束时间 default value 2099-12-31 23:59:59
|
|
|
|
Timestamp ncet=new Timestamp(4102415999000l); |
|
|
|
// 未设置结束委托时间
|
|
|
|
if (StringUtils.isBlank(cend) && day != null) { |
|
|
|
Timestamp ncet = new Timestamp(4102415999000l); |
|
|
|
//如果是一次性授权或单次授权,存在托管结束时间
|
|
|
|
if (iperiod == 2) { |
|
|
|
try { |
|
|
|
@ -635,36 +640,38 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
// 委托开始时间戳
|
|
|
|
ncst = new Timestamp(wtStart.getTime()); |
|
|
|
// 委托终止时间
|
|
|
|
Date wtEnd=WorkDayUtil.getWorkDay(wtStart,day); |
|
|
|
Date wtEnd = WorkDayUtil.getWorkDay(wtStart, day); |
|
|
|
// 统计该时间段内的节假日
|
|
|
|
//int fdays = festivalsMapper.countDayBetweenDays(wtStart, wtEnd, iyear);
|
|
|
|
// 节假日顺延后的日期
|
|
|
|
//Date fwtEnd = DateUtils.daysAgoOrAfter(wtEnd, fdays);
|
|
|
|
// 20221018 经咨询,不计算法定节假日的时长,故此暂作注释
|
|
|
|
Date fwtEnd = wtEnd; |
|
|
|
SimpleDateFormat ysdf =new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
cend = ysdf.format(fwtEnd)+" 23:59:59"; |
|
|
|
ncet=new Timestamp(sdf.parse(cend).getTime()); |
|
|
|
SimpleDateFormat ysdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
cend = ysdf.format(fwtEnd) + " 23:59:59"; |
|
|
|
ncet = new Timestamp(sdf.parse(cend).getTime()); |
|
|
|
} catch (Exception ex) { |
|
|
|
log.error("一次性委托日期转码出错:" + ex.getLocalizedMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
// 一次性委托时候,判断开始时间是否结束
|
|
|
|
// 周期性托管,判断开始时间是否结束
|
|
|
|
if (iperiod == 3) { |
|
|
|
//当前时间
|
|
|
|
SimpleDateFormat nowDateSdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
String nowStr = nowDateSdf.format(new Date()); |
|
|
|
// 判断是否为当前时间 上架状态
|
|
|
|
if (nowStr.equals(cstart)) { |
|
|
|
istatus = 1; |
|
|
|
} |
|
|
|
// 到期自动下架
|
|
|
|
if (nowStr.equals("2099-12-31")) { |
|
|
|
istatus = 2; |
|
|
|
} |
|
|
|
try{ |
|
|
|
// 委托开始时间 匹配时间格式,防止转码出错
|
|
|
|
Date wtStart = sdf.parse(ncstart); |
|
|
|
// 委托开始时间戳
|
|
|
|
ncst = new Timestamp(wtStart.getTime()); |
|
|
|
// 委托终止时间
|
|
|
|
Date wtEnd = sdf.parse(cend); |
|
|
|
SimpleDateFormat ysdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
cend = ysdf.format(wtEnd) + " 23:59:59"; |
|
|
|
// 委托终止时间时间戳
|
|
|
|
ncet = new Timestamp(sdf.parse(cend).getTime()); |
|
|
|
}catch (Exception ex){ |
|
|
|
log.error("周期性委托日期转码错误:"+ex.getLocalizedMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
//bind to goods properties
|
|
|
|
//绑定商品属性
|
|
|
|
goods.setContractualStartTime(ncst); |
|
|
|
goods.setContractualtimeEndTime(ncet); |
|
|
|
|
|
|
|
|