|
|
@ -1,5 +1,7 @@ |
|
|
|
package org.jeecg.modules.demo.zygoods.service.impl; |
|
|
|
package org.jeecg.modules.demo.zygoods.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
|
|
|
import org.jeecg.modules.demo.ordergoods.entity.OrderGoodsJk; |
|
|
|
import org.jeecg.modules.demo.zygoods.entity.ZyGoods; |
|
|
|
import org.jeecg.modules.demo.zygoods.entity.ZyGoods; |
|
|
|
import org.jeecg.modules.demo.zygoods.mapper.ZyGoodsMapper; |
|
|
|
import org.jeecg.modules.demo.zygoods.mapper.ZyGoodsMapper; |
|
|
|
import org.jeecg.modules.demo.zygoods.service.IZyGoodsService; |
|
|
|
import org.jeecg.modules.demo.zygoods.service.IZyGoodsService; |
|
|
@ -8,6 +10,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -26,4 +29,43 @@ public class ZyGoodsServiceImpl extends ServiceImpl<ZyGoodsMapper, ZyGoods> impl |
|
|
|
return zyGoodsMapper.selectByMainId(mainId); |
|
|
|
return zyGoodsMapper.selectByMainId(mainId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 随机获取商品 |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<OrderGoodsJk> SJgetOrder() { |
|
|
|
|
|
|
|
List<OrderGoodsJk> orderGoodsJkList = new ArrayList<>(); |
|
|
|
|
|
|
|
QueryWrapper<ZyGoods> wrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
List<ZyGoods> goodsList = baseMapper.selectList(wrapper); |
|
|
|
|
|
|
|
if(goodsList.size()>10){ |
|
|
|
|
|
|
|
//随机取商品数(1-5)个
|
|
|
|
|
|
|
|
int number = (int)(Math.random()*5)+1; |
|
|
|
|
|
|
|
for(int i = 0 ; i < number ; i++){ |
|
|
|
|
|
|
|
//goodsList的随机下标数
|
|
|
|
|
|
|
|
int numberxb = (int)(Math.random()*goodsList.size()); |
|
|
|
|
|
|
|
//随机取商品数量(1-5)个
|
|
|
|
|
|
|
|
int numbersl = (int)(Math.random()*5)+1; |
|
|
|
|
|
|
|
OrderGoodsJk orderGoodsJk = new OrderGoodsJk(); |
|
|
|
|
|
|
|
orderGoodsJk.setGoodsId(goodsList.get(numberxb).getId()); |
|
|
|
|
|
|
|
orderGoodsJk.setGoodsNum(numbersl); |
|
|
|
|
|
|
|
orderGoodsJkList.add(orderGoodsJk); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
if(goodsList.size()>0){ |
|
|
|
|
|
|
|
//goodsList的随机下标数
|
|
|
|
|
|
|
|
int numberxb1 = (int)(Math.random()*goodsList.size()); |
|
|
|
|
|
|
|
//随机取商品数量(1-5)个
|
|
|
|
|
|
|
|
int numbersl = (int)(Math.random()*5)+1; |
|
|
|
|
|
|
|
OrderGoodsJk orderGoodsJk = new OrderGoodsJk(); |
|
|
|
|
|
|
|
orderGoodsJk.setGoodsId(goodsList.get(numberxb1).getId()); |
|
|
|
|
|
|
|
orderGoodsJk.setGoodsNum(numbersl); |
|
|
|
|
|
|
|
orderGoodsJkList.add(orderGoodsJk); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return orderGoodsJkList; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|