1.change category attribution
This commit is contained in:
2025-11-13 15:12:31 +08:00
parent 449328c726
commit 547b9dde7c
10 changed files with 242 additions and 66 deletions

View File

@@ -7,7 +7,6 @@ CREATE TABLE `kiosk_category`
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产品名称', `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '产品名称',
`image_url` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '目录图片地址', `image_url` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '目录图片地址',
`photo_limit` int NULL DEFAULT 1 COMMENT '照片数量', `photo_limit` int NULL DEFAULT 1 COMMENT '照片数量',
`shape` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '形状',
`create_user` bigint NULL DEFAULT NULL COMMENT '创建人', `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
`create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门', `create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
@@ -23,22 +22,33 @@ CREATE TABLE `kiosk_category`
DROP TABLE IF EXISTS `kiosk_price_list`; DROP TABLE IF EXISTS `kiosk_price_list`;
CREATE TABLE `kiosk_price_list` CREATE TABLE `kiosk_price_list`
( (
`id` bigint AUTO_INCREMENT NOT NULL COMMENT '主键', `id` bigint AUTO_INCREMENT NOT NULL COMMENT '主键',
`tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID', `tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
`category_id` bigint NOT NULL COMMENT 'cid', `category_id` bigint NOT NULL COMMENT 'cid',
`shape` int NOT NULL DEFAULT 0 COMMENT '形状', `shape` int NULL DEFAULT 0 COMMENT '形状',
`material` int NOT NULL DEFAULT 0 COMMENT '材质', `material` int NULL DEFAULT 0 COMMENT '材质',
`size` int NOT NULL DEFAULT 0 COMMENT '尺寸', `size` int NULL DEFAULT 0 COMMENT '尺寸',
`currency` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '货币', `size_description` varchar(255) NULL DEFAULT '' COMMENT '尺寸描述',
`price` decimal(10, 2) NOT NULL DEFAULT 0 COMMENT '单价', `style` int NULL DEFAULT 0 COMMENT '风格',
`dept_id` bigint NULL DEFAULT NULL COMMENT '目标部门', `currency` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '货币',
`create_user` bigint NULL DEFAULT NULL COMMENT '创建人', `original_price` decimal(10, 2) NOT NULL DEFAULT 0 COMMENT '原价',
`create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门', `actual_price` decimal(10, 2) NULL DEFAULT 0 COMMENT '售价',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', `back_print` int NULL DEFAULT 1 COMMENT '背面打印',
`update_user` bigint NULL DEFAULT NULL COMMENT '修改人', `back_print_price` decimal(10, 2) NULL DEFAULT 0 COMMENT '背面打印价格',
`update_time` datetime NULL DEFAULT NULL COMMENT '修改时间', `size_upgrade` int NULL DEFAULT 1 COMMENT '尺寸升级',
`status` int NULL DEFAULT 1 COMMENT '状态', `size_upgrade_price` decimal(10, 2) NULL DEFAULT 0 COMMENT '尺寸升级价格',
`is_deleted` int NULL DEFAULT 0 COMMENT '是否已删除', `stand` int NULL DEFAULT 1 COMMENT '支架',
`stand_price` decimal(10, 2) NULL DEFAULT 0 COMMENT '支架价格',
`material_upgrade` int NULL DEFAULT 1 COMMENT '材料升级',
`material_upgrade_price` decimal(10, 2) NULL DEFAULT 0 COMMENT '材料升级价格',
`dept_id` bigint NULL DEFAULT NULL COMMENT '目标部门',
`create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
`create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_user` bigint NULL DEFAULT NULL COMMENT '修改人',
`update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
`status` int NULL DEFAULT 1 COMMENT '状态',
`is_deleted` int NULL DEFAULT 0 COMMENT '是否已删除',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
CHARACTER SET = utf8mb4 CHARACTER SET = utf8mb4

View File

@@ -97,6 +97,18 @@ public class KioskApiController {
return R.data(list); return R.data(list);
} }
/**
* 风格目录查询
*
* @return List<DictBizApiVO>
*/
@GetMapping("/style-list")
@Operation(summary = "风格目录")
public R<List<DictBizApiVO>> styleList() {
List<DictBizApiVO> list = kioskApiService.styleList();
return R.data(list);
}
/** /**
* 生成上传地址 * 生成上传地址
* *

View File

@@ -48,7 +48,7 @@
<if test="priceList.csize !=null"> <if test="priceList.csize !=null">
and kpl.size = #{csize} and kpl.size = #{csize}
</if> </if>
order by kpl.price, kc.type order by kpl.original_price, kc.type
</select> </select>
<select id="selectPriceList" resultType="org.springblade.modules.kiosk.pojo.vo.PriceListVO"> <select id="selectPriceList" resultType="org.springblade.modules.kiosk.pojo.vo.PriceListVO">
@@ -74,14 +74,16 @@
<if test="csize !=null"> <if test="csize !=null">
and kpl.size = #{csize} and kpl.size = #{csize}
</if> </if>
order by kpl.price, kc.type <if test="style !=null">
and kpl.style = #{style}
</if>
order by kpl.original_price, kc.type
</select> </select>
<insert id="initWallByCrossJoin"> <insert id="initWallByCrossJoin">
INSERT INTO kiosk_price_list (category_id, shape, material, size, dept_id, tenant_id, create_user, create_dept, INSERT INTO kiosk_price_list (category_id, material, size, dept_id, tenant_id, create_user, create_dept,
create_time, update_user, update_time) create_time, update_user, update_time)
SELECT c.id AS category_id, SELECT c.id AS category_id,
c.shape AS shape,
CAST(m.dict_key AS SIGNED) AS material, CAST(m.dict_key AS SIGNED) AS material,
CAST(s.dict_key AS SIGNED) AS size, CAST(s.dict_key AS SIGNED) AS size,
#{targetDept} AS dept_id, #{targetDept} AS dept_id,

View File

@@ -23,8 +23,8 @@ public class OrderApiRequest implements Serializable {
@Data @Data
public static class Item { public static class Item {
@NotNull(message = "category is missing") @NotNull(message = "priceList is missing")
private Long category; private Long priceList;
@NotEmpty(message = "snapshot is missing") @NotEmpty(message = "snapshot is missing")
private Long snapshot; private Long snapshot;
@@ -32,15 +32,14 @@ public class OrderApiRequest implements Serializable {
@NotEmpty(message = "photos is missing") @NotEmpty(message = "photos is missing")
private List<Photo> photos = List.of(); private List<Photo> photos = List.of();
@NotNull(message = "size is missing") private Text printBack;
private Integer size;
@NotNull(message = "material is missing") private Boolean extraStand;
private Integer material;
private Integer shape; private Boolean sizeUp;
private Boolean materialUp;
private List<Long> accessories = List.of();
} }
@Data @Data
@@ -49,6 +48,12 @@ public class OrderApiRequest implements Serializable {
private String content; private String content;
private String font; private String font;
private Integer size;
private Boolean bold;
private Boolean italic;
} }
@Data @Data

View File

@@ -68,10 +68,5 @@ public class CategoryEntity extends TenantEntity {
*/ */
@Schema(description = "照片数量") @Schema(description = "照片数量")
private Integer photoLimit; private Integer photoLimit;
/**
* 形状
*/
@Schema(description = "形状")
private String shape;
} }

View File

@@ -77,15 +77,70 @@ public class PriceListEntity extends TenantEntity {
@Schema(description = "尺寸") @Schema(description = "尺寸")
private Integer size; private Integer size;
/** /**
* 单价 * 尺寸描述
*/ */
@Schema(description = "单价") @Schema(description = "尺寸描述")
private String sizeDescription;
/**
* 风格
*/
@Schema(description = "风格")
private Integer style;
/**
* 货币单位
*/
@Schema(description = "货币单位")
private String currency; private String currency;
/** /**
* 单价 * 原价
*/ */
@Schema(description = "单价") @Schema(description = "原价")
private BigDecimal price; private BigDecimal originalPrice;
/**
* 售价
*/
@Schema(description = "售价")
private BigDecimal actualPrice;
/**
* 背面打印
*/
@Schema(description = "背面打印")
private Integer backPrint;
/**
* 背面打印价格
*/
@Schema(description = "背面打印价格")
private BigDecimal backPrintPrice;
/**
* 尺寸升级
*/
@Schema(description = "尺寸升级")
private Integer sizeUpgrade;
/**
* 尺寸升级价格
*/
@Schema(description = "尺寸升级价格")
private BigDecimal sizeUpgradePrice;
/**
* 材质升级
*/
@Schema(description = "材质升级")
private Integer materialUpgrade;
/**
* 材质升级价格
*/
@Schema(description = "材质升级价格")
private BigDecimal materialUpgradePrice;
/**
* 支架
*/
@Schema(description = "支架")
private Integer stand;
/**
* 支架价格
*/
@Schema(description = "支架价格")
private BigDecimal standPrice;
/** /**
* 目标部门 * 目标部门
*/ */

View File

@@ -44,14 +44,38 @@ public class PriceListApiVO implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long id;
private Integer shape; private Integer shape;
private Integer size; private Integer size;
private String sizeDescription;
private Integer material; private Integer material;
private Integer style;
private String currency; private String currency;
private BigDecimal price; private BigDecimal originalPrice;
private BigDecimal actualPrice;
private Integer backPrint;
private BigDecimal backPrintPrice;
private Integer sizeUpgrade;
private BigDecimal sizeUpgradePrice;
private Integer materialUpgrade;
private BigDecimal materialUpgradePrice;
private Integer stand;
private BigDecimal standPrice;
} }

View File

@@ -74,15 +74,70 @@ public class PriceListVO extends TenantEntity {
@Schema(description = "尺寸") @Schema(description = "尺寸")
private Integer csize; private Integer csize;
/** /**
* 单价 * 尺寸描述
*/ */
@Schema(description = "单价") @Schema(description = "尺寸描述")
private String sizeDescription;
/**
* 风格
*/
@Schema(description = "风格")
private Integer style;
/**
* 货币单位
*/
@Schema(description = "货币单位")
private String currency; private String currency;
/** /**
* 单价 * 原价
*/ */
@Schema(description = "单价") @Schema(description = "原价")
private BigDecimal price; private BigDecimal originalPrice;
/**
* 售价
*/
@Schema(description = "售价")
private BigDecimal actualPrice;
/**
* 背面打印
*/
@Schema(description = "背面打印")
private Integer printBack;
/**
* 背面打印价格
*/
@Schema(description = "背面打印价格")
private BigDecimal printBackPrice;
/**
* 尺寸升级
*/
@Schema(description = "尺寸升级")
private Integer sizeUpgrade;
/**
* 尺寸升级价格
*/
@Schema(description = "尺寸升级价格")
private BigDecimal sizeUpgradePrice;
/**
* 材质升级
*/
@Schema(description = "材质升级")
private Integer materialUpgrade;
/**
* 材质升级价格
*/
@Schema(description = "材质升级价格")
private BigDecimal materialUpgradePrice;
/**
* 支架
*/
@Schema(description = "支架")
private Integer stand;
/**
* 支架价格
*/
@Schema(description = "支架价格")
private BigDecimal standPrice;
/** /**
* 目标部门 * 目标部门
*/ */

View File

@@ -29,6 +29,8 @@ public interface IKioskApiService {
List<DictBizApiVO> shapeList(); List<DictBizApiVO> shapeList();
List<DictBizApiVO> styleList();
Long upload(String fileName, InputStream stream); Long upload(String fileName, InputStream stream);
List<PriceListApiVO> priceList(Long id); List<PriceListApiVO> priceList(Long id);

View File

@@ -69,6 +69,8 @@ public class KioskServiceImpl implements IKioskApiService {
private static final String materialType = "material_type"; private static final String materialType = "material_type";
private static final String styleType = "style_type";
private static final String categoryType = "category_type"; private static final String categoryType = "category_type";
private static final String autoCleanKey = "kiosk.default.autoCleanSeconds"; private static final String autoCleanKey = "kiosk.default.autoCleanSeconds";
@@ -187,31 +189,33 @@ public class KioskServiceImpl implements IKioskApiService {
OrderDetailEntity orderDetail = new OrderDetailEntity(); OrderDetailEntity orderDetail = new OrderDetailEntity();
orderDetail.setOrderId(order.getId()); orderDetail.setOrderId(order.getId());
CategoryEntity category = categoryService.getById(item.getCategory()); PriceListEntity priceList = priceListService.getById(item.getPriceList());
if (priceList == null) {
throw new ServiceException("Invalid price.");
}
CategoryEntity category = categoryService.getById(priceList.getCategoryId());
if (category == null) { if (category == null) {
throw new ServiceException("Invalid category."); throw new ServiceException("Invalid category.");
} }
if (category.getType() == 1 && item.getShape() == null) {
throw new ServiceException("Invalid shape."); orderDetail.setCategoryId(priceList.getCategoryId());
}
orderDetail.setCategoryId(item.getCategory());
orderDetail.setCategoryType(category.getType()); orderDetail.setCategoryType(category.getType());
orderDetail.setCategoryName(category.getName()); orderDetail.setCategoryName(category.getName());
String materialTypeValue = dictService.getValue(materialType, String.valueOf(item.getMaterial())); String materialTypeValue = dictService.getValue(materialType, String.valueOf(priceList.getMaterial()));
if (StringUtil.isBlank(materialTypeValue)) { if (StringUtil.isBlank(materialTypeValue)) {
throw new ServiceException("Invalid material."); throw new ServiceException("Invalid material.");
} }
orderDetail.setMaterial(materialTypeValue); orderDetail.setMaterial(materialTypeValue);
String sizeTypeValue = dictService.getValue(sizeType, String.valueOf(item.getSize())); String sizeTypeValue = dictService.getValue(sizeType, String.valueOf(priceList.getSize()));
if (StringUtil.isBlank(sizeTypeValue)) { if (StringUtil.isBlank(sizeTypeValue)) {
throw new ServiceException("Invalid size."); throw new ServiceException("Invalid size.");
} }
orderDetail.setSize(sizeTypeValue); orderDetail.setSize(sizeTypeValue);
String shapeTypeKey = category.getType() == 1 ? String.valueOf(item.getShape()) : category.getShape(); String shapeTypeValue = dictService.getValue(shapeType, String.valueOf(priceList.getShape()));
String shapeTypeValue = dictService.getValue(shapeType, shapeTypeKey);
if (StringUtil.isBlank(shapeTypeValue)) { if (StringUtil.isBlank(shapeTypeValue)) {
throw new ServiceException("Invalid shape."); throw new ServiceException("Invalid shape.");
} }
@@ -223,17 +227,9 @@ public class KioskServiceImpl implements IKioskApiService {
} }
orderDetail.setSnapshotLink(snapshotPhoto.getLink()); orderDetail.setSnapshotLink(snapshotPhoto.getLink());
PriceListEntity price = priceListService.getOne(Wrappers.<PriceListEntity>lambdaQuery()
.eq(PriceListEntity::getCategoryId, category.getId()) orderDetail.setTotalAmount(priceList.getActualPrice());
.eq(PriceListEntity::getShape, Integer.valueOf(shapeTypeKey)) totalAmount.add(priceList.getActualPrice());
.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()));
@@ -289,6 +285,16 @@ public class KioskServiceImpl implements IKioskApiService {
}).toList(); }).toList();
} }
@Override
public List<DictBizApiVO> styleList() {
return dictService.getList(styleType).stream().map(dictBiz -> {
DictBizApiVO vo = new DictBizApiVO();
vo.setKey(dictBiz.getDictKey());
vo.setValue(dictBiz.getDictValue());
return vo;
}).toList();
}
@Override @Override
public Long upload(String fileName, InputStream stream) { public Long upload(String fileName, InputStream stream) {
BladeUser user = AuthUtil.getUser(); BladeUser user = AuthUtil.getUser();
@@ -320,9 +326,19 @@ public class KioskServiceImpl implements IKioskApiService {
PriceListApiVO vo = new PriceListApiVO(); PriceListApiVO vo = new PriceListApiVO();
vo.setShape(p.getShape()); vo.setShape(p.getShape());
vo.setSize(p.getSize()); vo.setSize(p.getSize());
vo.setSizeDescription(p.getSizeDescription());
vo.setMaterial(p.getMaterial()); vo.setMaterial(p.getMaterial());
vo.setCurrency(p.getCurrency()); vo.setCurrency(p.getCurrency());
vo.setPrice(p.getPrice()); vo.setOriginalPrice(p.getOriginalPrice());
vo.setActualPrice(p.getActualPrice());
vo.setBackPrint(p.getBackPrint());
vo.setBackPrintPrice(p.getBackPrintPrice());
vo.setSizeUpgrade(p.getSizeUpgrade());
vo.setSizeUpgradePrice(p.getSizeUpgradePrice());
vo.setMaterialUpgrade(p.getMaterialUpgrade());
vo.setMaterialUpgradePrice(p.getMaterialUpgradePrice());
vo.setStand(p.getStand());
vo.setStandPrice(p.getStandPrice());
return vo; return vo;
}).toList(); }).toList();
} }