feat:适配食堂线下商品
This commit is contained in:
1 parent
4daf1069a9
commit
792da4ce7b
1 file changed
+33
-3
+33
-3
@@ -5,7 +5,9 @@ import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.canteen.api.feign.RemoteCanteenSpuService;
|
||||
import com.bsd.pjcloud.canteen.api.feign.RemoteOnlineCanteenSpuService;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
|
||||
import com.bsd.pjcloud.canteen.vo.app.CanteenOnlineSpuAppVO;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
@@ -51,6 +53,7 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
private final HardParentCarMapper hardParentCarMapper;
|
||||
|
||||
private final RemoteOnlineCanteenSpuService onlineCanteenSpuService;
|
||||
private final RemoteCanteenSpuService canteenSpuService;
|
||||
private final RemoteSupermarketUnitSkuService supermarketUnitSkuService;
|
||||
|
||||
@Override
|
||||
@@ -143,7 +146,13 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
}
|
||||
// 线下
|
||||
if (ObjectUtil.equals(HardOrderTypeEnum.BELOW, orderType)) {
|
||||
|
||||
List<CanteenSpuEntity> supList = canteenSpuService.getSpuListByIds(productIds).getData();
|
||||
for (HardCreateCarDto v : list) {
|
||||
supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> {
|
||||
int itemTotalPrice = v.getProductCount() * spu.getPrice();
|
||||
canteenTotalPrice.addAndGet(itemTotalPrice);
|
||||
});
|
||||
}
|
||||
}
|
||||
yield canteenTotalPrice.get();
|
||||
}
|
||||
@@ -180,6 +189,7 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
// 食堂
|
||||
if (ObjectUtil.equals(sysType, HardTypeEnum.CANTEEN)) {
|
||||
List<HardCarEntity> carObjectList = new ArrayList<>();
|
||||
// 线上
|
||||
if (ObjectUtil.equals(HardOrderTypeEnum.RESERVE, orderType)) {
|
||||
List<CanteenOnlineSpuAppVO> supList = onlineCanteenSpuService.getSpuListByIds(productIds).getData();
|
||||
for (HardCreateCarDto v : productList) {
|
||||
@@ -197,8 +207,23 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
});
|
||||
}
|
||||
}
|
||||
// 线下
|
||||
if (ObjectUtil.equals(HardOrderTypeEnum.BELOW, orderType)) {
|
||||
|
||||
List<CanteenSpuEntity> supList = canteenSpuService.getSpuListByIds(productIds).getData();
|
||||
for (HardCreateCarDto v : productList) {
|
||||
HardCarEntity item = HardCarEntity.builder().parentCarId(parentCarId).build();
|
||||
supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> {
|
||||
int totalPrice = v.getProductCount() * spu.getPrice();
|
||||
item.setProductId(spu.getId());
|
||||
item.setProductName(spu.getName());
|
||||
item.setProductPrice(spu.getPrice());
|
||||
item.setProductPic(spu.getPicUrl());
|
||||
item.setTotalPrice((long) totalPrice);
|
||||
item.setProductCount(v.getProductCount());
|
||||
item.setProductWeight(new BigDecimal(0));
|
||||
carObjectList.add(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
baseMapper.insert(carObjectList);
|
||||
return;
|
||||
@@ -244,7 +269,12 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
}
|
||||
// 线下
|
||||
if (ObjectUtil.equals(orderType, HardOrderTypeEnum.BELOW)) {
|
||||
|
||||
List<CanteenSpuEntity> supList = canteenSpuService.getSpuListByIds(productIds).getData();
|
||||
for (HardCreateCarDto v : list) {
|
||||
supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> {
|
||||
str.append(spu.getName()).append("x").append(v.getProductCount()).append(";");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// 超市
|
||||
|
||||
Reference in new issue
Block a user