订单管理所有模块以及商品管理BUG修改

zhc4dev
Gitea 2 years ago
parent bb9db75745
commit 2d8b4339c5
  1. 3
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zygoods/service/IZyGoodsService.java
  2. 42
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zygoods/service/impl/ZyGoodsServiceImpl.java

@ -1,5 +1,6 @@
package org.jeecg.modules.demo.zygoods.service;
import org.jeecg.modules.demo.ordergoods.entity.OrderGoodsJk;
import org.jeecg.modules.demo.zygoods.entity.ZyGoods;
import com.baomidou.mybatisplus.extension.service.IService;
@ -13,5 +14,7 @@ import java.util.List;
*/
public interface IZyGoodsService extends IService<ZyGoods> {
public List<ZyGoods> selectByMainId(String mainId);
//随机获取商品
List<OrderGoodsJk> SJgetOrder();
}

@ -1,5 +1,7 @@
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.mapper.ZyGoodsMapper;
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 java.util.ArrayList;
import java.util.List;
/**
@ -26,4 +29,43 @@ public class ZyGoodsServiceImpl extends ServiceImpl<ZyGoodsMapper, ZyGoods> impl
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;
}
}

Loading…
Cancel
Save