1. add price list api
This commit is contained in:
2025-10-16 11:54:17 +08:00
parent 99917f8103
commit 10783b28cb
3 changed files with 19 additions and 6 deletions

View File

@@ -37,7 +37,6 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.kiosk.pojo.entity.CategoryEntity; import org.springblade.modules.kiosk.pojo.entity.CategoryEntity;

View File

@@ -138,7 +138,7 @@ public class KioskApiController {
* @return List<DictBizApiVO> * @return List<DictBizApiVO>
*/ */
@GetMapping("/price-list") @GetMapping("/price-list")
@Operation(summary = "形状目录") @Operation(summary = "价格查询")
public R<List<PriceListApiVO>> shapeList(Long id) { public R<List<PriceListApiVO>> shapeList(Long id) {
List<PriceListApiVO> list = kioskApiService.priceList(id); List<PriceListApiVO> list = kioskApiService.priceList(id);
return R.data(list); return R.data(list);

View File

@@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -149,7 +150,7 @@ public class KioskServiceImpl implements IKioskApiService {
order.setSerialNumber(StringUtil.random(8, RandomType.INT)); order.setSerialNumber(StringUtil.random(8, RandomType.INT));
orderService.save(order); orderService.save(order);
BigDecimal totalAmount = BigDecimal.ZERO; List<BigDecimal> totalAmount = new ArrayList<>();
request.getData().forEach(item -> { request.getData().forEach(item -> {
OrderDetailEntity orderDetail = new OrderDetailEntity(); OrderDetailEntity orderDetail = new OrderDetailEntity();
orderDetail.setOrderId(order.getId()); orderDetail.setOrderId(order.getId());
@@ -189,12 +190,24 @@ public class KioskServiceImpl implements IKioskApiService {
throw new ServiceException("Invalid snapshot."); throw new ServiceException("Invalid snapshot.");
} }
orderDetail.setSnapshotLink(snapshotPhoto.getLink()); orderDetail.setSnapshotLink(snapshotPhoto.getLink());
//todo: add amount!
PriceListEntity price = priceListService.getOne(Wrappers.<PriceListEntity>lambdaQuery()
.eq(PriceListEntity::getCategoryId, category.getId())
.eq(PriceListEntity::getShape, Integer.valueOf(shapeTypeKey))
.eq(PriceListEntity::getSize, item.getSize())
.eq(PriceListEntity::getMaterial, item.getMaterial())
);
if (price == null) {
throw new ServiceException("Invalid price.");
}
orderDetail.setTotalAmount(price.getPrice());
totalAmount.add(price.getPrice());
orderDetailService.save(orderDetail); orderDetailService.save(orderDetail);
item.getPhotos().forEach(photo -> photoAttachmentService.createPhotoDetail(photo, orderDetail.getId())); item.getPhotos().forEach(photo -> photoAttachmentService.createPhotoDetail(photo, orderDetail.getId()));
}); });
order.setTotalAmount(totalAmount); BigDecimal sum = totalAmount.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
order.setTotalAmount(sum);
orderService.updateById(order); orderService.updateById(order);
log.info("Order submitted successfully: {}", order.getSerialNumber()); log.info("Order submitted successfully: {}", order.getSerialNumber());
@@ -259,7 +272,8 @@ public class KioskServiceImpl implements IKioskApiService {
List<PriceListEntity> list = priceListService.list(Wrappers.<PriceListEntity>lambdaQuery() List<PriceListEntity> list = priceListService.list(Wrappers.<PriceListEntity>lambdaQuery()
.eq(PriceListEntity::getIsDeleted, 0) .eq(PriceListEntity::getIsDeleted, 0)
.eq(PriceListEntity::getCategoryId, id) .eq(PriceListEntity::getCategoryId, id)
.eq(PriceListEntity::getDeptId, Long.valueOf(AuthUtil.getDeptId()))); // .eq(PriceListEntity::getDeptId, Long.valueOf(AuthUtil.getDeptId())));
.eq(PriceListEntity::getDeptId, -1));
return list.stream().map(p -> { return list.stream().map(p -> {
PriceListApiVO vo = new PriceListApiVO(); PriceListApiVO vo = new PriceListApiVO();
vo.setShape(p.getShape()); vo.setShape(p.getShape());