update:
1. update order submit
This commit is contained in:
@@ -142,6 +142,7 @@ CREATE TABLE `kiosk_order_detail_photo_attachment_r`
|
||||
`tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
|
||||
`detail_id` bigint NOT NULL COMMENT 'did',
|
||||
`photo_id` bigint NOT NULL COMMENT 'pid',
|
||||
`snapshot` bigint NULL DEFAULT NULL COMMENT '快照id',
|
||||
`create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
|
||||
`create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
@@ -159,7 +160,7 @@ CREATE TABLE `kiosk_text_attachment_r`
|
||||
(
|
||||
`id` bigint NOT NULL COMMENT '主键',
|
||||
`tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
|
||||
`detail_id` bigint NOT NULL COMMENT 'did',
|
||||
`photo_id` bigint NOT NULL COMMENT 'pid',
|
||||
`font_name` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字体名称',
|
||||
`font_size` int NOT NULL DEFAULT 16 COMMENT '字体大小',
|
||||
`text_content` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文字内容',
|
||||
@@ -180,7 +181,7 @@ CREATE TABLE `kiosk_stickers_attachment_r`
|
||||
(
|
||||
`id` bigint NOT NULL COMMENT '主键',
|
||||
`tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
|
||||
`detail_id` bigint NOT NULL COMMENT 'did',
|
||||
`photo_id` bigint NOT NULL COMMENT 'pid',
|
||||
`stickers_id` bigint NOT NULL COMMENT 'sid',
|
||||
`create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
|
||||
`create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门',
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.springblade.modules.kiosk.controller;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.modules.kiosk.pojo.dto.OrderApiRequest;
|
||||
@@ -13,6 +14,7 @@ import org.springblade.modules.kiosk.pojo.vo.StickersApiVO;
|
||||
import org.springblade.modules.kiosk.service.IKioskApiService;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
@@ -45,13 +47,11 @@ public class KioskApiController {
|
||||
*/
|
||||
@GetMapping("/stickers-list")
|
||||
@Operation(summary = "贴纸列表查询")
|
||||
@Cacheable(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
|
||||
public R<List<StickersApiVO>> stickersList() {
|
||||
List<StickersApiVO> list = kioskApiService.stickersList();
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 材质目录查询
|
||||
*
|
||||
@@ -88,7 +88,6 @@ public class KioskApiController {
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成上传地址
|
||||
*
|
||||
@@ -124,4 +123,15 @@ public class KioskApiController {
|
||||
return R.data(kioskApiService.submitOrder(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param file 文件
|
||||
* @return ObjectStat
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("/upload")
|
||||
public R<Long> upload(@RequestParam MultipartFile file) {
|
||||
return R.data(kioskApiService.upload(file.getOriginalFilename(), file.getInputStream()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,6 @@ import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.modules.kiosk.pojo.entity.StickersEntity;
|
||||
@@ -99,7 +97,6 @@ public class StickersController extends BladeController {
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入stickers")
|
||||
@CacheEvict(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
|
||||
public R save(@Valid @RequestBody StickersEntity stickers) {
|
||||
return R.status(stickersService.save(stickers));
|
||||
}
|
||||
@@ -110,7 +107,6 @@ public class StickersController extends BladeController {
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入stickers")
|
||||
@CacheEvict(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
|
||||
public R update(@Valid @RequestBody StickersEntity stickers) {
|
||||
return R.status(stickersService.updateById(stickers));
|
||||
}
|
||||
@@ -121,7 +117,6 @@ public class StickersController extends BladeController {
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入stickers")
|
||||
@CacheEvict(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
|
||||
public R submit(@Valid @RequestBody StickersEntity stickers) {
|
||||
return R.status(stickersService.saveOrUpdate(stickers));
|
||||
}
|
||||
@@ -132,7 +127,6 @@ public class StickersController extends BladeController {
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "删除", description = "传入ids")
|
||||
@CacheEvict(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(stickersService.removeByIds(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
@@ -20,27 +20,47 @@ public class OrderApiRequest implements Serializable {
|
||||
|
||||
@Data
|
||||
public static class Item {
|
||||
|
||||
@NotNull(message = "category is missing")
|
||||
private Long category;
|
||||
@NotNull(message = "snapshot is missing")
|
||||
private Long snapshot;
|
||||
|
||||
@NotEmpty(message = "snapshot is missing")
|
||||
private String snapshot;
|
||||
|
||||
@NotEmpty(message = "photos is missing")
|
||||
private List<Long> photos = List.of();
|
||||
private List<Photo> photos = List.of();
|
||||
|
||||
@NotNull(message = "size is missing")
|
||||
private Integer size;
|
||||
|
||||
@NotNull(message = "material is missing")
|
||||
private Integer material;
|
||||
|
||||
private Integer shape;
|
||||
private List<Text> text = List.of();
|
||||
private List<Long> stickers = List.of();
|
||||
|
||||
private List<Long> accessories = List.of();
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Text {
|
||||
private Integer size;
|
||||
|
||||
private String content;
|
||||
|
||||
private String font;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Photo {
|
||||
|
||||
@NotNull(message = "photo is missing")
|
||||
private Long photo;
|
||||
|
||||
@NotNull(message = "snapshot is missing")
|
||||
private Long snapshot;
|
||||
|
||||
private List<Text> text = List.of();
|
||||
|
||||
private List<Long> stickers = List.of();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,5 +66,10 @@ public class OrderDetailPhotoAttachmentREntity extends TenantEntity {
|
||||
*/
|
||||
@Schema(description = "pid")
|
||||
private Long photoId;
|
||||
/**
|
||||
* snapshot_id
|
||||
*/
|
||||
@Schema(description = "snapshot")
|
||||
private Long snapshot;
|
||||
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ public class StickersAttachmentREntity extends TenantEntity {
|
||||
/**
|
||||
* did
|
||||
*/
|
||||
@Schema(description = "did")
|
||||
private Long detailId;
|
||||
@Schema(description = "pid")
|
||||
private Long photoId;
|
||||
/**
|
||||
* sid
|
||||
*/
|
||||
|
||||
@@ -59,8 +59,8 @@ public class TextAttachmentREntity extends TenantEntity {
|
||||
/**
|
||||
* did
|
||||
*/
|
||||
@Schema(description = "did")
|
||||
private Long detailId;
|
||||
@Schema(description = "pid")
|
||||
private Long photoId;
|
||||
/**
|
||||
* 字体名称
|
||||
*/
|
||||
|
||||
@@ -29,4 +29,7 @@ public interface IKioskApiService {
|
||||
List<DictBizApiVO> sizeList();
|
||||
|
||||
List<DictBizApiVO> shapeList();
|
||||
|
||||
Long upload(String fileName, InputStream stream);
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package org.springblade.modules.kiosk.service;
|
||||
|
||||
import org.springblade.modules.kiosk.pojo.dto.OrderApiRequest;
|
||||
import org.springblade.modules.kiosk.pojo.entity.PhotoAttachmentEntity;
|
||||
import org.springblade.modules.kiosk.pojo.vo.PhotoAttachmentVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -49,4 +50,6 @@ public interface IPhotoAttachmentService extends IService<PhotoAttachmentEntity>
|
||||
IPage<PhotoAttachmentVO> selectPhotoAttachmentPage(IPage<PhotoAttachmentVO> page, PhotoAttachmentVO photoAttachment);
|
||||
|
||||
List<PhotoAttachmentEntity> selectPhotoAttachmentListByOrderDetailId(Long orderDetailId);
|
||||
|
||||
void createPhotoDetail(OrderApiRequest.Photo photo, Long orderDetailId);
|
||||
}
|
||||
|
||||
@@ -148,15 +148,18 @@ public class KioskServiceImpl implements IKioskApiService {
|
||||
public String submitOrder(OrderApiRequest request) {
|
||||
try {
|
||||
photoAttachmentService.update(Wrappers.<PhotoAttachmentEntity>lambdaUpdate().eq(PhotoAttachmentEntity::getCreateUser, AuthUtil.getUserId()).set(PhotoAttachmentEntity::getStatus, 2));
|
||||
|
||||
OrderEntity order = new OrderEntity();
|
||||
order.setUserPhone(request.getPhone());
|
||||
order.setUserEmail(request.getEmail());
|
||||
order.setSerialNumber(StringUtil.random(8, RandomType.INT));
|
||||
orderService.save(order);
|
||||
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
request.getData().forEach(item -> {
|
||||
OrderDetailEntity orderDetail = new OrderDetailEntity();
|
||||
orderDetail.setOrderId(order.getId());
|
||||
|
||||
CategoryEntity category = categoryService.getById(item.getCategory());
|
||||
if (category == null) {
|
||||
throw new ServiceException("Invalid category.");
|
||||
@@ -167,22 +170,26 @@ public class KioskServiceImpl implements IKioskApiService {
|
||||
orderDetail.setCategoryId(item.getCategory());
|
||||
orderDetail.setCategoryType(category.getType());
|
||||
orderDetail.setCategoryName(category.getName());
|
||||
|
||||
String materialTypeValue = dictService.getValue(materialType, String.valueOf(item.getMaterial()));
|
||||
if (StringUtil.isBlank(materialTypeValue)) {
|
||||
throw new ServiceException("Invalid material.");
|
||||
}
|
||||
orderDetail.setMaterial(materialTypeValue);
|
||||
|
||||
String sizeTypeValue = dictService.getValue(sizeType, String.valueOf(item.getSize()));
|
||||
if (StringUtil.isBlank(sizeTypeValue)) {
|
||||
throw new ServiceException("Invalid size.");
|
||||
}
|
||||
orderDetail.setSize(sizeTypeValue);
|
||||
|
||||
String shapeTypeKey = category.getType() == 1 ? String.valueOf(item.getShape()) : category.getShape();
|
||||
String shapeTypeValue = dictService.getValue(shapeType, shapeTypeKey);
|
||||
if (StringUtil.isBlank(shapeTypeValue)) {
|
||||
throw new ServiceException("Invalid shape.");
|
||||
}
|
||||
orderDetail.setShape(shapeTypeValue);
|
||||
|
||||
PhotoAttachmentEntity snapshotPhoto = photoAttachmentService.getById(item.getSnapshot());
|
||||
if (snapshotPhoto == null) {
|
||||
throw new ServiceException("Invalid snapshot.");
|
||||
@@ -191,35 +198,7 @@ public class KioskServiceImpl implements IKioskApiService {
|
||||
//todo: add amount!
|
||||
orderDetailService.save(orderDetail);
|
||||
|
||||
List<OrderDetailPhotoAttachmentREntity> photoRList = item.getPhotos().stream().map(p -> {
|
||||
OrderDetailPhotoAttachmentREntity r = new OrderDetailPhotoAttachmentREntity();
|
||||
r.setPhotoId(p);
|
||||
r.setDetailId(orderDetail.getId());
|
||||
return r;
|
||||
}).toList();
|
||||
orderDetailPhotoAttachmentRService.saveBatch(photoRList);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(item.getStickers())) {
|
||||
List<StickersAttachmentREntity> stickerRList = item.getStickers().stream().map(s -> {
|
||||
StickersAttachmentREntity r = new StickersAttachmentREntity();
|
||||
r.setStickersId(s);
|
||||
r.setDetailId(orderDetail.getId());
|
||||
return r;
|
||||
}).toList();
|
||||
stickersAttachmentRService.saveBatch(stickerRList);
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(item.getText())) {
|
||||
List<TextAttachmentREntity> textRList = item.getText().stream().map(t -> {
|
||||
TextAttachmentREntity r = new TextAttachmentREntity();
|
||||
r.setDetailId(orderDetail.getId());
|
||||
r.setFontName(t.getFont());
|
||||
r.setFontSize(t.getSize());
|
||||
r.setTextContent(t.getContent());
|
||||
return r;
|
||||
}).toList();
|
||||
textAttachmentRService.saveBatch(textRList);
|
||||
}
|
||||
item.getPhotos().forEach(photo -> photoAttachmentService.createPhotoDetail(photo, orderDetail.getId()));
|
||||
});
|
||||
order.setTotalAmount(totalAmount);
|
||||
orderService.updateById(order);
|
||||
@@ -261,4 +240,23 @@ public class KioskServiceImpl implements IKioskApiService {
|
||||
return vo;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long upload(String fileName, InputStream stream) {
|
||||
BladeUser user = AuthUtil.getUser();
|
||||
BladeFile bladeFile = ossTemplate.putFile(fileName, stream);
|
||||
|
||||
PhotoAttachmentEntity photoAttachmentEntity = new PhotoAttachmentEntity();
|
||||
photoAttachmentEntity.setTenantId(user.getTenantId());
|
||||
photoAttachmentEntity.setLink(bladeFile.getLink());
|
||||
photoAttachmentEntity.setDomainUrl(bladeFile.getDomain());
|
||||
photoAttachmentEntity.setName(bladeFile.getName());
|
||||
photoAttachmentEntity.setOriginalName(bladeFile.getOriginalName());
|
||||
photoAttachmentEntity.setCreateUser(user.getUserId());
|
||||
photoAttachmentEntity.setCreateDept(Long.valueOf(user.getDeptId()));
|
||||
photoAttachmentEntity.setCreateTime(DateUtil.now());
|
||||
photoAttachmentService.save(photoAttachmentEntity);
|
||||
|
||||
return photoAttachmentEntity.getId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class OrderDetailServiceImpl extends BaseServiceImpl<OrderDetailMapper, O
|
||||
List<StickersEntity> stickersList = stickersService.selectStickersListByOrderDetailId(vo.getId());
|
||||
vo.setStickers(stickersList.stream().map(StickersEntity::getLink).toList());
|
||||
|
||||
List<TextAttachmentREntity> tList = textAttachmentRService.list(Wrappers.<TextAttachmentREntity>lambdaQuery().eq(TextAttachmentREntity::getDetailId, vo.getId()));
|
||||
List<TextAttachmentREntity> tList = textAttachmentRService.list(Wrappers.<TextAttachmentREntity>lambdaQuery().eq(TextAttachmentREntity::getPhotoId, vo.getId()));
|
||||
vo.setTexts(tList.stream().map(t -> {
|
||||
OrderDetailVO.Text tt = new OrderDetailVO.Text();
|
||||
tt.setContent(t.getTextContent());
|
||||
|
||||
@@ -26,15 +26,27 @@
|
||||
package org.springblade.modules.kiosk.service.impl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.tool.utils.CollectionUtil;
|
||||
import org.springblade.modules.kiosk.pojo.dto.OrderApiRequest;
|
||||
import org.springblade.modules.kiosk.pojo.entity.OrderDetailPhotoAttachmentREntity;
|
||||
import org.springblade.modules.kiosk.pojo.entity.PhotoAttachmentEntity;
|
||||
import org.springblade.modules.kiosk.pojo.entity.StickersAttachmentREntity;
|
||||
import org.springblade.modules.kiosk.pojo.entity.TextAttachmentREntity;
|
||||
import org.springblade.modules.kiosk.pojo.vo.PhotoAttachmentVO;
|
||||
import org.springblade.modules.kiosk.mapper.PhotoAttachmentMapper;
|
||||
import org.springblade.modules.kiosk.service.IOrderDetailPhotoAttachmentRService;
|
||||
import org.springblade.modules.kiosk.service.IPhotoAttachmentService;
|
||||
import org.springblade.modules.kiosk.service.IStickersAttachmentRService;
|
||||
import org.springblade.modules.kiosk.service.ITextAttachmentRService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 自助终端照片表 服务实现类
|
||||
@@ -42,10 +54,16 @@ import java.util.List;
|
||||
* @author Ray
|
||||
* @since 2025-10-07
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class PhotoAttachmentServiceImpl extends ServiceImpl<PhotoAttachmentMapper, PhotoAttachmentEntity> implements IPhotoAttachmentService {
|
||||
|
||||
private final IOrderDetailPhotoAttachmentRService orderDetailPhotoAttachmentRService;
|
||||
|
||||
private final IStickersAttachmentRService stickersAttachmentRService;
|
||||
|
||||
private final ITextAttachmentRService textAttachmentRService;
|
||||
|
||||
@Override
|
||||
public IPage<PhotoAttachmentVO> selectPhotoAttachmentPage(IPage<PhotoAttachmentVO> page, PhotoAttachmentVO photoAttachment) {
|
||||
@@ -57,4 +75,41 @@ public class PhotoAttachmentServiceImpl extends ServiceImpl<PhotoAttachmentMappe
|
||||
return baseMapper.selectPhotoAttachmentListByOrderDetailId(orderDetailId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createPhotoDetail(OrderApiRequest.Photo photo, Long orderDetailId) {
|
||||
try {
|
||||
OrderDetailPhotoAttachmentREntity r = new OrderDetailPhotoAttachmentREntity();
|
||||
r.setDetailId(orderDetailId);
|
||||
r.setPhotoId(photo.getPhoto());
|
||||
r.setSnapshot(photo.getSnapshot());
|
||||
orderDetailPhotoAttachmentRService.save(r);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(photo.getStickers())) {
|
||||
List<StickersAttachmentREntity> stickerRList = photo.getStickers().stream().map(s -> {
|
||||
StickersAttachmentREntity sar = new StickersAttachmentREntity();
|
||||
sar.setStickersId(s);
|
||||
sar.setPhotoId(photo.getPhoto());
|
||||
return sar;
|
||||
}).collect(Collectors.toList());
|
||||
stickersAttachmentRService.saveBatch(stickerRList);
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(photo.getText())) {
|
||||
List<TextAttachmentREntity> textRList = photo.getText().stream().map(t -> {
|
||||
TextAttachmentREntity tar = new TextAttachmentREntity();
|
||||
tar.setPhotoId(photo.getPhoto());
|
||||
tar.setFontName(t.getFont());
|
||||
tar.setTextContent(t.getContent());
|
||||
return tar;
|
||||
}).collect(Collectors.toList());
|
||||
textAttachmentRService.saveBatch(textRList);
|
||||
}
|
||||
log.info("createPhotoDetail successfully");
|
||||
}catch (Exception e){
|
||||
log.error("createPhotoDetail error:", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user