diff --git a/db/800pjcloudx_hardware.sql b/db/800pjcloudx_hardware.sql index f72ad8d0e..cd04b8c58 100644 --- a/db/800pjcloudx_hardware.sql +++ b/db/800pjcloudx_hardware.sql @@ -233,6 +233,7 @@ CREATE TABLE hard_after_sale_car product_name varchar(128) NOT NULL COMMENT '商品名', product_pic varchar(256) NOT NULL COMMENT '商品图片', product_price bigint NOT NULL COMMENT '商品价格', + product_nature varchar(64) DEFAULT NULL COMMENT '商品性质', product_count int NOT NULL COMMENT '数量', product_weight decimal(10, 2) COMMENT '重量', total_price bigint COMMENT '总价(分)', diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/order/HardOrderStatusEnum.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/order/HardOrderStatusEnum.java index f4a70ed82..742a76838 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/order/HardOrderStatusEnum.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/order/HardOrderStatusEnum.java @@ -45,7 +45,7 @@ public enum HardOrderStatusEnum { ); } - public static HardOrderStatusEnum valueOfByType(Integer type) { + public static HardOrderStatusEnum valueOfByType(String type) { if (ObjectUtil.isEmpty(type)) return null; return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get(); } diff --git a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/order/HardPayTypeEnum.java b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/order/HardPayTypeEnum.java index 20d56f2b4..07d252638 100644 --- a/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/order/HardPayTypeEnum.java +++ b/pjcloud-hardware/pjcloud-hardware-api/src/main/java/com/bsd/pjcloud/hard/api/constant/order/HardPayTypeEnum.java @@ -68,6 +68,11 @@ public enum HardPayTypeEnum { CSXFK ); + // 简单支付(没有购物车) + public static final List isSimplePayList = List.of( + WALLET_QR_CODE_SCAN + ); + public static HardPayTypeEnum valueOfByType(String type) { if (ObjectUtil.isEmpty(type)) return null; return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get(); diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardCarController.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardCarController.java index 933598f32..3c9263f94 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardCarController.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardCarController.java @@ -81,11 +81,9 @@ public class HardCarController { @GetMapping("/order-id") @Operation(summary = "根据订单id查询购物车") public R> orderId(@ParameterObject Page page, @RequestParam Long orderId) { - if (ObjectUtil.isEmpty(orderId)) { - R.ok(null); - } + if (ObjectUtil.isEmpty(orderId)) R.ok(null); HardOrderEntity order = hardOrderService.getById(orderId); - if (ObjectUtil.isEmpty(order) || ObjectUtil.isEmpty(order.getParentCarId())) return null; + if (ObjectUtil.isEmpty(order) || ObjectUtil.isEmpty(order.getParentCarId())) return R.ok(null); HardCarDto dto = new HardCarDto(); dto.setParentCarId(order.getParentCarId()); return R.ok(hardCarService.pageJoin(page, dto)); diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java index d657a0da1..246cf0248 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardAfterSaleServiceImpl.java @@ -528,26 +528,38 @@ public class HardAfterSaleServiceImpl extends ServiceImpl computerCarList = dto.getCarList().stream().map((item) -> { - HardCreateCarDto entity = new HardCreateCarDto(); - entity.setParentCarId(item.getParentCarId()); - entity.setProductId(item.getProductId()); - entity.setProductNature(HardProductNatureEnum.valueOfByType(item.getProductNature())); - entity.setProductCount(item.getProductCount()); - entity.setProductWeight(item.getProductWeight()); - return entity; - }).toList(); - int refundPrice = hardCarService.computerCarTotalPrice(HardTypeEnum.valueOfByType(order.getSysType()), HardOrderTypeEnum.valueOfByType(order.getOrderType()), computerCarList); + int refundPrice = order.getPayPrice(); + if (!isSimplePayList) { + List computerCarList = dto.getCarList().stream().map((item) -> { + HardCreateCarDto entity = new HardCreateCarDto(); + entity.setParentCarId(item.getParentCarId()); + entity.setProductId(item.getProductId()); + entity.setProductNature(HardProductNatureEnum.valueOfByType(item.getProductNature())); + entity.setProductCount(item.getProductCount()); + entity.setProductWeight(item.getProductWeight()); + return entity; + }).toList(); + refundPrice = hardCarService.computerCarTotalPrice(HardTypeEnum.valueOfByType(order.getSysType()), HardOrderTypeEnum.valueOfByType(order.getOrderType()), computerCarList); + } saveObj.setType(HardSaleTypeEnum.AFTER_SALE.getType()); saveObj.setStatus(HardSaleStatusEnum.COMPLETE.getStatus()); @@ -560,7 +572,9 @@ public class HardAfterSaleServiceImpl extends ServiceImpl carList = dto.getCarList().stream().map((item) -> + HardCarEntity.builder() + .productId(item.getProductId()) + .productCount(item.getProductCount()) + .productWeight(item.getProductWeight()) + .productNature(item.getProductName()) + .build() + ).toList(); + hardOrderService.fastenerInventory(order, carList, YesNoEnum.NO); + } // 执行退款 getSelf().refund(saveObj.getId()); - // 退库存 - List carList = dto.getCarList().stream().map((item) -> - HardCarEntity.builder() - .productId(item.getProductId()) - .productCount(item.getProductCount()) - .productWeight(item.getProductWeight()) - .productNature(item.getProductName()) - .build() - ).toList(); - hardOrderService.fastenerInventory(order, carList, YesNoEnum.NO); return true; }