|
|
|
@ -1,6 +1,8 @@ |
|
|
|
package cn.chjyj.szwh.service.impl; |
|
|
|
|
|
|
|
import cn.chjyj.szwh.bean.Goods; |
|
|
|
import cn.chjyj.szwh.mapper.FestivalsMapper; |
|
|
|
import cn.chjyj.szwh.mapper.GoodsMapper; |
|
|
|
import cn.chjyj.szwh.service.GoodsService; |
|
|
|
import cn.chjyj.szwh.utils.ApiGoodsUtils; |
|
|
|
import cn.chjyj.szwh.utils.DateUtils; |
|
|
|
@ -17,8 +19,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.sql.Timestamp; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import static org.junit.Assert.*; |
|
|
|
|
|
|
|
@ -26,6 +27,8 @@ import static org.junit.Assert.*; |
|
|
|
@RunWith(SpringJUnit4ClassRunner.class) |
|
|
|
@Transactional |
|
|
|
public class GoodsServiceImplTest { |
|
|
|
@Autowired |
|
|
|
private GoodsMapper goodsMapper; |
|
|
|
@Autowired |
|
|
|
private GoodsService goodsService; |
|
|
|
// 节假日mapper
|
|
|
|
@ -72,8 +75,44 @@ public class GoodsServiceImplTest { |
|
|
|
public void delRank() { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 测试排序操作 |
|
|
|
*/ |
|
|
|
@Rollback(true) |
|
|
|
@Test |
|
|
|
public void ranksort() { |
|
|
|
//商品编号
|
|
|
|
String goods_isliCode="010007-00000000187499999999-1"; |
|
|
|
// 1:add 2: reduce
|
|
|
|
int sortType=1; |
|
|
|
|
|
|
|
String where="is_deleted=0 and is_recommend=1"; |
|
|
|
List<Goods> tmpRanklist = goodsMapper.getGoodsByCondition(where,8, "recommend_sort", "DESC"); |
|
|
|
//tmpRanklist.get(0);
|
|
|
|
for(int i=0;i<tmpRanklist.size()-1;i++){ |
|
|
|
if(goods_isliCode.equals(tmpRanklist.get(i).getGoodsIslicode()) ){ |
|
|
|
// for add
|
|
|
|
if(sortType==1) { |
|
|
|
if(i==0){ |
|
|
|
break; |
|
|
|
}else { |
|
|
|
goodsMapper.updateRecommend(tmpRanklist.get(i-1).getGoodsIslicode(), |
|
|
|
tmpRanklist.get(i).getRecommendSort()); |
|
|
|
goodsMapper.updateRecommend(tmpRanklist.get(i).getGoodsIslicode(), |
|
|
|
tmpRanklist.get(i-1).getRecommendSort()); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
if(i==tmpRanklist.size()-1){ |
|
|
|
break; |
|
|
|
}else{ |
|
|
|
goodsMapper.updateRecommend(tmpRanklist.get(i+1).getGoodsIslicode(), |
|
|
|
tmpRanklist.get(i).getRecommendSort()); |
|
|
|
goodsMapper.updateRecommend(tmpRanklist.get(i).getGoodsIslicode(), |
|
|
|
tmpRanklist.get(i+1).getRecommendSort()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -146,12 +185,6 @@ public class GoodsServiceImplTest { |
|
|
|
// 委托开始时间 匹配时间格式,防止转码出错
|
|
|
|
Date wtStart = sdf.parse(ncstart); |
|
|
|
ncst = new Timestamp(wtStart.getTime()); |
|
|
|
// 判断周几
|
|
|
|
calendar.setTime(wtStart); |
|
|
|
int wkday = calendar.get(Calendar.DAY_OF_WEEK); |
|
|
|
//周末顺延
|
|
|
|
// notice:在节假日调休时候,会有变动
|
|
|
|
iday += wkday > 5 ? (wkday - 5 + 1) : 0; |
|
|
|
// 委托终止时间
|
|
|
|
Date wtEnd = DateUtils.daysAgoOrAfter(wtStart, iday); |
|
|
|
// 统计该时间段内的节假日
|
|
|
|
|