From 9a34602030900babd42dcf1f25d3f9a1974894b3 Mon Sep 17 00:00:00 2001 From: dev_ljl <2590379346@qq.com> Date: Sat, 5 Jul 2025 17:38:27 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E7=A7=9F=E8=B5=81=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlantsOrderMaintainController.java | 2 +- .../property/domain/PlantsOrderMaintain.java | 15 +---- .../property/domain/PlantsProduct.java | 3 +- .../property/domain/PlantsRentalOrder.java | 6 +- .../domain/bo/PlantsOrderChargeBo.java | 7 ++ .../domain/bo/PlantsOrderMaintainBo.java | 25 +++----- .../property/domain/bo/PlantsProductBo.java | 8 ++- .../domain/bo/PlantsRentalOrderBo.java | 6 +- .../domain/vo/PlantsOrderMaintainVo.java | 23 ++++--- .../property/domain/vo/PlantsProductVo.java | 8 ++- .../domain/vo/PlantsRentalOrderVo.java | 14 +++- .../mapper/PlantsOrderMaintainMapper.java | 4 +- .../service/IPlantsOrderMaintainService.java | 2 +- .../service/IPlantsProductService.java | 7 ++ .../impl/PlantsOrderChargeServiceImpl.java | 3 + .../impl/PlantsOrderMaintainServiceImpl.java | 32 +++++++--- .../impl/PlantsProductServiceImpl.java | 19 ++++++ .../impl/PlantsRentalOrderServiceImpl.java | 64 +++++++++++++++++-- .../Property/PlantsPlanProductMapper.xml | 2 + 19 files changed, 180 insertions(+), 70 deletions(-) diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/PlantsOrderMaintainController.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/PlantsOrderMaintainController.java index 115e5e3..cf4a824 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/PlantsOrderMaintainController.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/PlantsOrderMaintainController.java @@ -129,7 +129,7 @@ public class PlantsOrderMaintainController extends BaseController { * @return */ @GetMapping("/countAchievedRate") - public R countAchievedRate(){ + public R countAchievedRate(){ return R.ok(plantsOrderMaintainService.countAchievedRate()); } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/PlantsOrderMaintain.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/PlantsOrderMaintain.java index 15d6130..25fabdf 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/PlantsOrderMaintain.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/PlantsOrderMaintain.java @@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import lombok.EqualsAndHashCode; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import java.io.Serial; @@ -35,19 +34,9 @@ public class PlantsOrderMaintain extends BaseEntity { private String maintainName; /** - * 小区id + * 房间id */ - private Long communityId; - - /** - * 建筑id - */ - private Long buildingId; - - /** - * 楼层id - */ - private Long floorId; + private Long roomId; /** * 服务类型 diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/PlantsProduct.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/PlantsProduct.java index 0df44cd..da0bbf0 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/PlantsProduct.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/PlantsProduct.java @@ -6,6 +6,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serial; +import java.math.BigDecimal; /** * 绿植租赁-绿植产品对象 plants_product @@ -55,7 +56,7 @@ public class PlantsProduct extends BaseEntity { /** * 租金 */ - private Long rent; + private BigDecimal rent; /** * 库存数量 diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/PlantsRentalOrder.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/PlantsRentalOrder.java index 5b011a0..515bcff 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/PlantsRentalOrder.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/PlantsRentalOrder.java @@ -4,6 +4,8 @@ import org.dromara.common.mybatis.core.domain.BaseEntity; import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; @@ -62,7 +64,7 @@ public class PlantsRentalOrder extends BaseEntity { /** * 应付总额 */ - private Long totalAmount; + private BigDecimal totalAmount; /** * 租赁方式 @@ -82,7 +84,7 @@ public class PlantsRentalOrder extends BaseEntity { /** * 租赁产品数量 */ - private Long productNum; + private Integer productNum; /** * 支付状态 diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsOrderChargeBo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsOrderChargeBo.java index 119a8cd..128cd02 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsOrderChargeBo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsOrderChargeBo.java @@ -11,6 +11,8 @@ import jakarta.validation.constraints.*; import java.math.BigDecimal; import java.util.Date; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonFormat; /** @@ -100,5 +102,10 @@ public class PlantsOrderChargeBo extends BaseEntity { @NotNull(message = "收费状态不能为空", groups = { AddGroup.class, EditGroup.class }) private Long chargeStatus; + /** + * 订单id + */ + private List orderIds; + } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsOrderMaintainBo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsOrderMaintainBo.java index 98fb3a8..1927a50 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsOrderMaintainBo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsOrderMaintainBo.java @@ -9,7 +9,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import jakarta.validation.constraints.*; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; +import java.util.List; /** * 绿植租赁-订单养护管理业务对象 plants_order_maintain @@ -34,22 +34,10 @@ public class PlantsOrderMaintainBo extends BaseEntity { private String maintainName; /** - * 小区id + * 房间id */ - - private Long communityId; - - /** - * 建筑id - */ - - private Long buildingId; - - /** - * 楼层id - */ - - private Long floorId; + @NotNull(message = "服务地点不能为空", groups = { AddGroup.class, EditGroup.class }) + private Long roomId; /** * 服务类型 @@ -112,5 +100,10 @@ public class PlantsOrderMaintainBo extends BaseEntity { */ private Long state; + /** + * 订单id + */ + private List orderIds; + } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsProductBo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsProductBo.java index e9b5c54..163c3bc 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsProductBo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsProductBo.java @@ -11,6 +11,8 @@ import lombok.Data; import lombok.EqualsAndHashCode; import jakarta.validation.constraints.*; +import java.math.BigDecimal; + /** * 绿植租赁-绿植产品业务对象 plants_product * @@ -62,13 +64,13 @@ public class PlantsProductBo extends BaseEntity { * 租金 */ @NotNull(message = "租金不能为空", groups = { AddGroup.class, EditGroup.class }) - private Long rent; + private BigDecimal rent; /** * 库存数量 */ @NotNull(message = "库存数量不能为空", groups = { AddGroup.class, EditGroup.class }) - private Long inventory; + private Integer inventory; /** * 状态(0下架 1上架 ) @@ -81,7 +83,7 @@ public class PlantsProductBo extends BaseEntity { */ private String remark; - public PlantsProductBo(Long id, Long inventory) { + public PlantsProductBo(Long id, Integer inventory) { this.id = id; this.inventory = inventory; } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsRentalOrderBo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsRentalOrderBo.java index 573018f..b0b95ff 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsRentalOrderBo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/PlantsRentalOrderBo.java @@ -10,6 +10,8 @@ import io.github.linpeilie.annotations.AutoMapper; import lombok.Data; import lombok.EqualsAndHashCode; import jakarta.validation.constraints.*; + +import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -72,7 +74,7 @@ public class PlantsRentalOrderBo extends BaseEntity { * 应付总额 */ @NotNull(message = "应付总额不能为空", groups = { AddGroup.class, EditGroup.class }) - private Long totalAmount; + private BigDecimal totalAmount; /** * 租赁方式 @@ -93,7 +95,7 @@ public class PlantsRentalOrderBo extends BaseEntity { /** * 租赁产品数量 */ - private Long productNum; + private Integer productNum; /** * 支付状态 diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/PlantsOrderMaintainVo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/PlantsOrderMaintainVo.java index f98bdb0..610e585 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/PlantsOrderMaintainVo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/PlantsOrderMaintainVo.java @@ -43,22 +43,16 @@ public class PlantsOrderMaintainVo implements Serializable { private String maintainName; /** - * 小区id + * 房间id */ - @ExcelProperty(value = "小区id") - private Long communityId; + + private Long roomId; /** - * 建筑id + * 服务地点 */ - @ExcelProperty(value = "建筑id") - private Long buildingId; - - /** - * 楼层id - */ - @ExcelProperty(value = "楼层id") - private Long floorId; + @ExcelProperty(value = "服务地点") + private String roomName; /** * 服务类型 @@ -127,5 +121,10 @@ public class PlantsOrderMaintainVo implements Serializable { @ExcelProperty(value = "处理状态") private Long state; + /** + * 租赁订单 + */ + private PlantsRentalOrderVo rentalOrder; + } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/PlantsProductVo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/PlantsProductVo.java index e5244ec..ccffa62 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/PlantsProductVo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/PlantsProductVo.java @@ -10,6 +10,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; @@ -68,7 +69,7 @@ public class PlantsProductVo implements Serializable { * 租金 */ @ExcelProperty(value = "租金") - private Long rent; + private BigDecimal rent; /** * 库存数量 @@ -95,5 +96,10 @@ public class PlantsProductVo implements Serializable { @ExcelProperty(value = "创建时间") private Date createTime; + /** + * 方案产品数量 + */ + private Integer planProNumber; + } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/PlantsRentalOrderVo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/PlantsRentalOrderVo.java index cf51261..571f758 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/PlantsRentalOrderVo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/PlantsRentalOrderVo.java @@ -1,6 +1,8 @@ package org.dromara.property.domain.vo; +import java.math.BigDecimal; import java.util.Date; + import com.fasterxml.jackson.annotation.JsonFormat; import org.dromara.property.domain.PlantsRentalOrder; import cn.idev.excel.annotation.ExcelIgnoreUnannotated; @@ -13,7 +15,7 @@ import lombok.Data; import java.io.Serial; import java.io.Serializable; import java.util.Date; - +import java.util.List; /** @@ -78,7 +80,7 @@ public class PlantsRentalOrderVo implements Serializable { * 应付总额 */ @ExcelProperty(value = "应付总额") - private Long totalAmount; + private BigDecimal totalAmount; /** * 租赁方式 @@ -102,7 +104,7 @@ public class PlantsRentalOrderVo implements Serializable { * 租赁产品数量 */ @ExcelProperty(value = "租赁产品数量") - private Long productNum; + private Integer productNum; /** * 支付状态 @@ -125,6 +127,7 @@ public class PlantsRentalOrderVo implements Serializable { /** * 合同编号 */ + @ExcelProperty(value = "合同编号") private String contractCode; /** @@ -133,5 +136,10 @@ public class PlantsRentalOrderVo implements Serializable { @ExcelProperty(value = "签署时间") private Date signTime; + /** + * 绿植产品 + */ + private List productList; + } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/mapper/PlantsOrderMaintainMapper.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/mapper/PlantsOrderMaintainMapper.java index b5d968d..d6ad8dc 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/mapper/PlantsOrderMaintainMapper.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/mapper/PlantsOrderMaintainMapper.java @@ -17,7 +17,7 @@ import java.util.Map; public interface PlantsOrderMaintainMapper extends BaseMapperPlus { @Select("SELECT " + - "(CASE WHEN 1 THEN '一星'" + + "(CASE customer_score WHEN 1 THEN '一星'" + "WHEN 2 THEN '二星'" + "WHEN 3 THEN '三星'" + "WHEN 4 THEN '四星'" + @@ -32,7 +32,7 @@ public interface PlantsOrderMaintainMapper extends BaseMapperPlus> countAchieved(); diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IPlantsOrderMaintainService.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IPlantsOrderMaintainService.java index 6b83220..eb3f44c 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IPlantsOrderMaintainService.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IPlantsOrderMaintainService.java @@ -84,5 +84,5 @@ public interface IPlantsOrderMaintainService { * 计算绿植养护完成率 * @return */ - String countAchievedRate(); + Map countAchievedRate(); } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IPlantsProductService.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IPlantsProductService.java index 77a1a08..dd8a1f6 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IPlantsProductService.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/IPlantsProductService.java @@ -73,4 +73,11 @@ public interface IPlantsProductService { * @return 是否扣除成功 */ Boolean deductStock(List products); + + /** + * 添加商品库存 + * @param products 商品 + * @return 是否添加成功 + */ + Boolean addStock(List products); } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsOrderChargeServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsOrderChargeServiceImpl.java index c948108..1dd6f55 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsOrderChargeServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsOrderChargeServiceImpl.java @@ -1,5 +1,6 @@ package org.dromara.property.service.impl; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.core.page.TableDataInfo; @@ -9,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.dromara.property.domain.PlantsOrderMaintain; import org.dromara.property.domain.vo.PlantsRentalOrderVo; import org.dromara.property.service.IPlantsRentalOrderService; import org.springframework.stereotype.Service; @@ -94,6 +96,7 @@ public class PlantsOrderChargeServiceImpl implements IPlantsOrderChargeService { lqw.eq(bo.getInvoiceStatus() != null, PlantsOrderCharge::getInvoiceStatus, bo.getInvoiceStatus()); lqw.eq(bo.getInvoiceType() != null, PlantsOrderCharge::getInvoiceType, bo.getInvoiceType()); lqw.eq(bo.getChargeStatus() != null, PlantsOrderCharge::getChargeStatus, bo.getChargeStatus()); + lqw.in(CollectionUtils.isNotEmpty(bo.getOrderIds()), PlantsOrderCharge::getOrderId,bo.getOrderIds()); return lqw; } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsOrderMaintainServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsOrderMaintainServiceImpl.java index e75082c..9127323 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsOrderMaintainServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsOrderMaintainServiceImpl.java @@ -10,6 +10,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.dromara.property.domain.vo.PlantsRentalOrderVo; +import org.dromara.property.service.IPlantsRentalOrderService; +import org.dromara.property.service.ITbRoomService; import org.dromara.system.api.RemoteDictService; import org.dromara.system.api.domain.vo.RemoteDictDataVo; import org.springframework.stereotype.Service; @@ -36,6 +39,10 @@ public class PlantsOrderMaintainServiceImpl implements IPlantsOrderMaintainServi private final RemoteDictService dictService; + private final IPlantsRentalOrderService plantsRentalOrderService; + + private final ITbRoomService roomService; + /** * 查询绿植租赁-订单养护管理 * @@ -44,7 +51,14 @@ public class PlantsOrderMaintainServiceImpl implements IPlantsOrderMaintainServi */ @Override public PlantsOrderMaintainVo queryById(Long id) { - return baseMapper.selectVoById(id); + PlantsOrderMaintainVo vo = baseMapper.selectVoById(id); + if(vo!=null){ + PlantsRentalOrderVo orderVo = plantsRentalOrderService.queryById(vo.getOrderId()); + vo.setRentalOrder(orderVo); + String roomName = roomService.queryRoomName(vo.getRoomId()); + vo.setRoomName(roomName); + } + return vo; } /** @@ -78,9 +92,7 @@ public class PlantsOrderMaintainServiceImpl implements IPlantsOrderMaintainServi LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); lqw.orderByAsc(PlantsOrderMaintain::getId); lqw.like(StringUtils.isNotBlank(bo.getMaintainName()), PlantsOrderMaintain::getMaintainName, bo.getMaintainName()); - lqw.eq(bo.getCommunityId() != null, PlantsOrderMaintain::getCommunityId, bo.getCommunityId()); - lqw.eq(bo.getBuildingId() != null, PlantsOrderMaintain::getBuildingId, bo.getBuildingId()); - lqw.eq(bo.getFloorId() != null, PlantsOrderMaintain::getFloorId, bo.getFloorId()); + lqw.eq(bo.getRoomId() != null, PlantsOrderMaintain::getRoomId, bo.getRoomId()); lqw.eq(bo.getServeType() != null, PlantsOrderMaintain::getServeType, bo.getServeType()); lqw.eq(bo.getPeriodType() != null, PlantsOrderMaintain::getPeriodType, bo.getPeriodType()); lqw.eq(bo.getPeriodFrequency() != null, PlantsOrderMaintain::getPeriodFrequency, bo.getPeriodFrequency()); @@ -92,6 +104,7 @@ public class PlantsOrderMaintainServiceImpl implements IPlantsOrderMaintainServi lqw.eq(bo.getCustomerScore() != null, PlantsOrderMaintain::getCustomerScore, bo.getCustomerScore()); lqw.eq(StringUtils.isNotBlank(bo.getCustomerAdvice()), PlantsOrderMaintain::getCustomerAdvice, bo.getCustomerAdvice()); lqw.eq(bo.getState() != null, PlantsOrderMaintain::getState, bo.getState()); + lqw.in(CollectionUtils.isNotEmpty(bo.getOrderIds()),PlantsOrderMaintain::getOrderId,bo.getOrderIds()); return lqw; } @@ -169,7 +182,7 @@ public class PlantsOrderMaintainServiceImpl implements IPlantsOrderMaintainServi List total = new ArrayList<>(); List finish = new ArrayList<>(); List rate = new ArrayList<>(); - List typeList = dictService.selectDictDataByType(""); + List typeList = dictService.selectDictDataByType("pro_service_type"); if (CollectionUtils.isNotEmpty(typeList)) { typeList.forEach(item -> { type.add(item.getDictValue()); @@ -203,11 +216,14 @@ public class PlantsOrderMaintainServiceImpl implements IPlantsOrderMaintainServi * @return 绿植养护完成率 */ @Override - public String countAchievedRate() { + public Map countAchievedRate() { Double rate = baseMapper.countAchievedRate(); + Map map = new HashMap<>(); + String s="0%"; if (rate != null) { - return rate + "%"; + s= rate + "%"; } - return "0%"; + map.put("rate", s); + return map; } } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsProductServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsProductServiceImpl.java index ae4f92c..07ed5f5 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsProductServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsProductServiceImpl.java @@ -162,4 +162,23 @@ public class PlantsProductServiceImpl implements IPlantsProductService { } return flag; } + + /** + * 添加商品库存 + * @param products 商品 + * @return 是否添加成功 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public Boolean addStock(List products) { + Boolean flag = false; + for (PlantsProductBo product : products) { + PlantsProduct p = baseMapper.selectById(product.getId()); + if(p!=null){ + p.setInventory(p.getInventory() + product.getInventory()); + flag = baseMapper.updateById(p) > 0; + } + } + return flag; + } } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsRentalOrderServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsRentalOrderServiceImpl.java index 5ee1f4c..136bfc1 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsRentalOrderServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/PlantsRentalOrderServiceImpl.java @@ -12,16 +12,17 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.dromara.property.domain.PlantsProduct; +import org.dromara.property.domain.bo.PlantsOrderChargeBo; +import org.dromara.property.domain.bo.PlantsOrderMaintainBo; import org.dromara.property.domain.bo.PlantsProductBo; -import org.dromara.property.service.IPlantsProductService; +import org.dromara.property.domain.vo.*; +import org.dromara.property.service.*; import org.dromara.system.api.RemoteDictService; import org.dromara.system.api.domain.vo.RemoteDictDataVo; import org.springframework.stereotype.Service; import org.dromara.property.domain.bo.PlantsRentalOrderBo; -import org.dromara.property.domain.vo.PlantsRentalOrderVo; import org.dromara.property.domain.PlantsRentalOrder; import org.dromara.property.mapper.PlantsRentalOrderMapper; -import org.dromara.property.service.IPlantsRentalOrderService; import java.time.YearMonth; import java.util.*; @@ -43,6 +44,12 @@ public class PlantsRentalOrderServiceImpl implements IPlantsRentalOrderService { private final IPlantsProductService productService; + private final IPlantsPlanProductService planProductService; + +// private final IPlantsOrderMaintainService maintainService; +// +// private final IPlantsOrderChargeService chargeService; + /** * 查询绿植租赁-订单管理 * @@ -51,7 +58,22 @@ public class PlantsRentalOrderServiceImpl implements IPlantsRentalOrderService { */ @Override public PlantsRentalOrderVo queryById(Long id) { - return baseMapper.selectVoById(id); + PlantsRentalOrderVo orderVo = baseMapper.selectVoById(id); + ArrayList list = new ArrayList<>(); + if("1".equals(orderVo.getRentalType())){ + PlantsProductVo productVo = productService.queryById(orderVo.getProductId()); + productVo.setPlanProNumber(orderVo.getProductNum()); + list.add(productVo); + }else { + List planProductVos = planProductService.queryPlanProductsInfo(orderVo.getPlanId()); + for (PlantsPlanProductVo planProductVo : planProductVos) { + PlantsProductVo product = planProductVo.getProduct(); + product.setPlanProNumber(planProductVo.getProductNum()); + list.add(product); + } + } + orderVo.setProductList(list); + return orderVo; } /** @@ -168,7 +190,39 @@ public class PlantsRentalOrderServiceImpl implements IPlantsRentalOrderService { @Override public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { if (isValid) { - //TODO 做一些业务上的校验,判断是否需要校验 + //有订单收费或订单维护数据不可删除 +// PlantsOrderChargeBo chargeBo = new PlantsOrderChargeBo(); +// chargeBo.setOrderIds(ids.stream().toList()); +// List chargeList = chargeService.queryList(chargeBo); +// PlantsOrderMaintainBo maintainBo = new PlantsOrderMaintainBo(); +// maintainBo.setOrderIds(ids.stream().toList()); +// List maintainList = maintainService.queryList(maintainBo); +// if(CollectionUtils.isNotEmpty(maintainList)||CollectionUtils.isNotEmpty(chargeList)){ +// throw new ServiceException("所选订单不可删除"); +// }else { +// //恢复产品库存 +// ArrayList productList = new ArrayList<>(); +// for (Long id : ids) { +// PlantsRentalOrder order = baseMapper.selectById(id); +// if("1".equals(order.getRentalType())){ +// Long productId = order.getProductId(); +// Integer productNum = order.getProductNum(); +// productList.add(new PlantsProductBo(productId,productNum)); +// }else { +// Long planId = order.getPlanId(); +// List planProductVos = planProductService.queryPlanProductsInfo(planId); +// for (PlantsPlanProductVo planProductVo : planProductVos) { +// productList.add(new PlantsProductBo(planProductVo.getProductId(),planProductVo.getProductNum())); +// } +// } +// } +// if(CollectionUtils.isNotEmpty(productList)){ +// Boolean b = productService.addStock(productList); +// if(!b){ +// throw new ServiceException("删除订单失败。"); +// } +// } +// } } return baseMapper.deleteByIds(ids) > 0; } diff --git a/ruoyi-modules/Property/src/main/resources/mapper/Property/PlantsPlanProductMapper.xml b/ruoyi-modules/Property/src/main/resources/mapper/Property/PlantsPlanProductMapper.xml index e675ba8..f46532f 100644 --- a/ruoyi-modules/Property/src/main/resources/mapper/Property/PlantsPlanProductMapper.xml +++ b/ruoyi-modules/Property/src/main/resources/mapper/Property/PlantsPlanProductMapper.xml @@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -30,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" c.id pid, c.plan_id, c.product_id, + c.product_num, p.* from plants_plan_product c left join plants_product p on c.product_id = p.id