1、绿植统计下单客户总数
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1m42s

This commit is contained in:
dev_ljl 2025-07-07 14:16:01 +08:00
parent 9a34602030
commit 7b40b084c1
8 changed files with 139 additions and 51 deletions

View File

@ -153,6 +153,15 @@ public class PlantsRentalOrderController extends BaseController {
return R.ok(plantsRentalOrderService.countOrderAndAmount()); return R.ok(plantsRentalOrderService.countOrderAndAmount());
} }
/**
* 统计下单客户总数
* @return
*/
@GetMapping("/countCustomers")
public R<Map> countCustomers(){
return R.ok(plantsRentalOrderService.countCustomers());
}
} }

View File

@ -9,6 +9,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.*;
import java.util.List;
/** /**
* 绿植租赁-租赁方案-绿植业务对象 plants_plan_product * 绿植租赁-租赁方案-绿植业务对象 plants_plan_product
* *
@ -44,4 +46,10 @@ public class PlantsPlanProductBo extends BaseEntity {
private Integer productNum; private Integer productNum;
/**
* 产品id
*/
private List<Long> productIds;
} }

View File

@ -127,4 +127,14 @@ public class PlantsRentalOrderBo extends BaseEntity {
*/ */
private List<PlantsProductBo> productList; private List<PlantsProductBo> productList;
/**
* 产品id
*/
private List<Long> productIds;
/**
* 方案id
*/
private List<Long> planIds;
} }

View File

@ -101,5 +101,11 @@ public interface IPlantsRentalOrderService {
*/ */
Map<String,Object> countOrderAndAmount(); Map<String,Object> countOrderAndAmount();
/**
* 统计下单客户总数
* @return
*/
Map<String,Integer> countCustomers();
} }

View File

@ -1,5 +1,6 @@
package org.dromara.property.service.impl; 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.MapstructUtils;
import org.dromara.common.core.utils.StringUtils; import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -76,6 +77,7 @@ public class PlantsPlanProductServiceImpl implements IPlantsPlanProductService {
lqw.orderByAsc(PlantsPlanProduct::getId); lqw.orderByAsc(PlantsPlanProduct::getId);
lqw.eq(bo.getPlanId() != null, PlantsPlanProduct::getPlanId, bo.getPlanId()); lqw.eq(bo.getPlanId() != null, PlantsPlanProduct::getPlanId, bo.getPlanId());
lqw.eq(bo.getProductId() != null, PlantsPlanProduct::getProductId, bo.getProductId()); lqw.eq(bo.getProductId() != null, PlantsPlanProduct::getProductId, bo.getProductId());
lqw.in(CollectionUtils.isNotEmpty(bo.getProductIds()), PlantsPlanProduct::getProductId, bo.getProductIds());
return lqw; return lqw;
} }

View File

@ -1,5 +1,6 @@
package org.dromara.property.service.impl; package org.dromara.property.service.impl;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils; import org.dromara.common.core.utils.StringUtils;
@ -10,6 +11,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.dromara.property.domain.bo.PlantsPlanProductBo;
import org.dromara.property.domain.bo.PlantsRentalOrderBo;
import org.dromara.property.domain.vo.PlantsPlanProductVo;
import org.dromara.property.domain.vo.PlantsRentalOrderVo;
import org.dromara.property.service.IPlantsPlanProductService;
import org.dromara.property.service.IPlantsRentalOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.dromara.property.domain.bo.PlantsProductBo; import org.dromara.property.domain.bo.PlantsProductBo;
import org.dromara.property.domain.vo.PlantsProductVo; import org.dromara.property.domain.vo.PlantsProductVo;
@ -29,11 +38,17 @@ import java.util.Collection;
* @date 2025-06-25 * @date 2025-06-25
*/ */
@Slf4j @Slf4j
@RequiredArgsConstructor
@Service @Service
public class PlantsProductServiceImpl implements IPlantsProductService { public class PlantsProductServiceImpl implements IPlantsProductService {
private final PlantsProductMapper baseMapper; @Autowired
private PlantsProductMapper baseMapper;
@Autowired
@Lazy
private IPlantsRentalOrderService rentalOrderService;
@Autowired
@Lazy
private IPlantsPlanProductService planProductService;
/** /**
* 查询绿植租赁-绿植产品 * 查询绿植租赁-绿植产品
@ -123,7 +138,7 @@ public class PlantsProductServiceImpl implements IPlantsProductService {
* 保存前的数据校验 * 保存前的数据校验
*/ */
private void validEntityBeforeSave(PlantsProduct entity) { private void validEntityBeforeSave(PlantsProduct entity) {
//TODO 做一些数据校验,如唯一约束
} }
/** /**
@ -136,7 +151,15 @@ public class PlantsProductServiceImpl implements IPlantsProductService {
@Override @Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if (isValid) { if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验 PlantsRentalOrderBo order = new PlantsRentalOrderBo();
order.setProductIds(ids.stream().toList());
List<PlantsRentalOrderVo> orderVos = rentalOrderService.queryList(order);
PlantsPlanProductBo plantsPlanProductBo = new PlantsPlanProductBo();
plantsPlanProductBo.setProductIds(ids.stream().toList());
List<PlantsPlanProductVo> planProductVos = planProductService.queryList(plantsPlanProductBo);
if(CollectionUtils.isNotEmpty(orderVos)||CollectionUtils.isNotEmpty(planProductVos)){
throw new ServiceException("当前选中绿植产品不可删除。");
}
} }
return baseMapper.deleteByIds(ids) > 0; return baseMapper.deleteByIds(ids) > 0;
} }

View File

@ -9,9 +9,7 @@ import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.dromara.property.domain.PlantsProduct;
import org.dromara.property.domain.bo.PlantsOrderChargeBo; import org.dromara.property.domain.bo.PlantsOrderChargeBo;
import org.dromara.property.domain.bo.PlantsOrderMaintainBo; import org.dromara.property.domain.bo.PlantsOrderMaintainBo;
import org.dromara.property.domain.bo.PlantsProductBo; import org.dromara.property.domain.bo.PlantsProductBo;
@ -19,6 +17,8 @@ import org.dromara.property.domain.vo.*;
import org.dromara.property.service.*; import org.dromara.property.service.*;
import org.dromara.system.api.RemoteDictService; import org.dromara.system.api.RemoteDictService;
import org.dromara.system.api.domain.vo.RemoteDictDataVo; import org.dromara.system.api.domain.vo.RemoteDictDataVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.dromara.property.domain.bo.PlantsRentalOrderBo; import org.dromara.property.domain.bo.PlantsRentalOrderBo;
import org.dromara.property.domain.PlantsRentalOrder; import org.dromara.property.domain.PlantsRentalOrder;
@ -34,21 +34,24 @@ import java.util.*;
* @date 2025-06-30 * @date 2025-06-30
*/ */
@Slf4j @Slf4j
@RequiredArgsConstructor
@Service @Service
public class PlantsRentalOrderServiceImpl implements IPlantsRentalOrderService { public class PlantsRentalOrderServiceImpl implements IPlantsRentalOrderService {
private final PlantsRentalOrderMapper baseMapper; @Autowired
private PlantsRentalOrderMapper baseMapper;
private final RemoteDictService dictService; @Autowired
private RemoteDictService dictService;
private final IPlantsProductService productService; @Autowired
private IPlantsProductService productService;
private final IPlantsPlanProductService planProductService; @Autowired
@Lazy
// private final IPlantsOrderMaintainService maintainService; private IPlantsPlanProductService planProductService;
// @Autowired
// private final IPlantsOrderChargeService chargeService; @Lazy
private IPlantsOrderMaintainService maintainService;
@Autowired
@Lazy
private IPlantsOrderChargeService chargeService;
/** /**
* 查询绿植租赁-订单管理 * 查询绿植租赁-订单管理
@ -121,6 +124,8 @@ public class PlantsRentalOrderServiceImpl implements IPlantsRentalOrderService {
lqw.eq(bo.getIsRelet() != null, PlantsRentalOrder::getIsRelet, bo.getIsRelet()); lqw.eq(bo.getIsRelet() != null, PlantsRentalOrder::getIsRelet, bo.getIsRelet());
lqw.eq(bo.getContractStatus() != null, PlantsRentalOrder::getContractStatus, bo.getContractStatus()); lqw.eq(bo.getContractStatus() != null, PlantsRentalOrder::getContractStatus, bo.getContractStatus());
lqw.eq(bo.getSignTime() != null, PlantsRentalOrder::getSignTime, bo.getSignTime()); lqw.eq(bo.getSignTime() != null, PlantsRentalOrder::getSignTime, bo.getSignTime());
lqw.in(CollectionUtils.isNotEmpty(bo.getProductIds()),PlantsRentalOrder::getProductId,bo.getProductIds());
lqw.in(CollectionUtils.isNotEmpty(bo.getPlanIds()),PlantsRentalOrder::getPlanId,bo.getPlanIds());
return lqw; return lqw;
} }
@ -191,38 +196,38 @@ public class PlantsRentalOrderServiceImpl implements IPlantsRentalOrderService {
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if (isValid) { if (isValid) {
//有订单收费或订单维护数据不可删除 //有订单收费或订单维护数据不可删除
// PlantsOrderChargeBo chargeBo = new PlantsOrderChargeBo(); PlantsOrderChargeBo chargeBo = new PlantsOrderChargeBo();
// chargeBo.setOrderIds(ids.stream().toList()); chargeBo.setOrderIds(ids.stream().toList());
// List<PlantsOrderChargeVo> chargeList = chargeService.queryList(chargeBo); List<PlantsOrderChargeVo> chargeList = chargeService.queryList(chargeBo);
// PlantsOrderMaintainBo maintainBo = new PlantsOrderMaintainBo(); PlantsOrderMaintainBo maintainBo = new PlantsOrderMaintainBo();
// maintainBo.setOrderIds(ids.stream().toList()); maintainBo.setOrderIds(ids.stream().toList());
// List<PlantsOrderMaintainVo> maintainList = maintainService.queryList(maintainBo); List<PlantsOrderMaintainVo> maintainList = maintainService.queryList(maintainBo);
// if(CollectionUtils.isNotEmpty(maintainList)||CollectionUtils.isNotEmpty(chargeList)){ if(CollectionUtils.isNotEmpty(maintainList)||CollectionUtils.isNotEmpty(chargeList)){
// throw new ServiceException("所选订单不可删除"); throw new ServiceException("所选订单不可删除");
// }else { }else {
// //恢复产品库存 //恢复产品库存
// ArrayList<PlantsProductBo> productList = new ArrayList<>(); ArrayList<PlantsProductBo> productList = new ArrayList<>();
// for (Long id : ids) { for (Long id : ids) {
// PlantsRentalOrder order = baseMapper.selectById(id); PlantsRentalOrder order = baseMapper.selectById(id);
// if("1".equals(order.getRentalType())){ if("1".equals(order.getRentalType())){
// Long productId = order.getProductId(); Long productId = order.getProductId();
// Integer productNum = order.getProductNum(); Integer productNum = order.getProductNum();
// productList.add(new PlantsProductBo(productId,productNum)); productList.add(new PlantsProductBo(productId,productNum));
// }else { }else {
// Long planId = order.getPlanId(); Long planId = order.getPlanId();
// List<PlantsPlanProductVo> planProductVos = planProductService.queryPlanProductsInfo(planId); List<PlantsPlanProductVo> planProductVos = planProductService.queryPlanProductsInfo(planId);
// for (PlantsPlanProductVo planProductVo : planProductVos) { for (PlantsPlanProductVo planProductVo : planProductVos) {
// productList.add(new PlantsProductBo(planProductVo.getProductId(),planProductVo.getProductNum())); productList.add(new PlantsProductBo(planProductVo.getProductId(),planProductVo.getProductNum()));
// } }
// } }
// } }
// if(CollectionUtils.isNotEmpty(productList)){ if(CollectionUtils.isNotEmpty(productList)){
// Boolean b = productService.addStock(productList); Boolean b = productService.addStock(productList);
// if(!b){ if(!b){
// throw new ServiceException("删除订单失败。"); throw new ServiceException("删除订单失败。");
// } }
// } }
// } }
} }
return baseMapper.deleteByIds(ids) > 0; return baseMapper.deleteByIds(ids) > 0;
} }
@ -393,4 +398,18 @@ public class PlantsRentalOrderServiceImpl implements IPlantsRentalOrderService {
public Map<String, Object> countOrderAndAmount() { public Map<String, Object> countOrderAndAmount() {
return baseMapper.countOrderAndAmount(); return baseMapper.countOrderAndAmount();
} }
/**
* 统计下单客户总数
* @return
*/
@Override
public Map<String, Integer> countCustomers() {
LambdaQueryWrapper<PlantsRentalOrder> lqw = Wrappers.lambdaQuery();
lqw.groupBy(PlantsRentalOrder::getCustomerName);
Map<String, Integer> map = new HashMap<>();
map.put("count",baseMapper.selectVoList(lqw).size());
return map;
}
} }

View File

@ -1,6 +1,7 @@
package org.dromara.property.service.impl; package org.dromara.property.service.impl;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils; import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -12,9 +13,12 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.dromara.property.domain.PlantsPlanProduct; import org.dromara.property.domain.PlantsPlanProduct;
import org.dromara.property.domain.bo.PlantsPlanProductBo; import org.dromara.property.domain.bo.PlantsPlanProductBo;
import org.dromara.property.domain.bo.PlantsRentalOrderBo;
import org.dromara.property.domain.vo.PlantsPlanProductVo; import org.dromara.property.domain.vo.PlantsPlanProductVo;
import org.dromara.property.domain.vo.PlantsRentalOrderVo;
import org.dromara.property.service.IPlantsPlanProductService; import org.dromara.property.service.IPlantsPlanProductService;
import org.dromara.property.service.IPlantsProductService; import org.dromara.property.service.IPlantsProductService;
import org.dromara.property.service.IPlantsRentalOrderService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.dromara.property.domain.bo.PlantsRentalPlanBo; import org.dromara.property.domain.bo.PlantsRentalPlanBo;
import org.dromara.property.domain.vo.PlantsRentalPlanVo; import org.dromara.property.domain.vo.PlantsRentalPlanVo;
@ -39,6 +43,8 @@ public class PlantsRentalPlanServiceImpl implements IPlantsRentalPlanService {
private final IPlantsPlanProductService planProductService; private final IPlantsPlanProductService planProductService;
private final IPlantsRentalOrderService rentalOrderService;
/** /**
* 查询绿植租赁-租赁方案 * 查询绿植租赁-租赁方案
* *
@ -162,7 +168,12 @@ public class PlantsRentalPlanServiceImpl implements IPlantsRentalPlanService {
@Override @Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){ if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验 PlantsRentalOrderBo plantsRentalOrderBo = new PlantsRentalOrderBo();
plantsRentalOrderBo.setPlanIds(ids.stream().toList());
List<PlantsRentalOrderVo> plantsRentalOrderVos = rentalOrderService.queryList(plantsRentalOrderBo);
if(CollectionUtils.isNotEmpty(plantsRentalOrderVos)){
throw new ServiceException("当前选中租赁方案不可删除");
}
} }
return baseMapper.deleteByIds(ids) > 0; return baseMapper.deleteByIds(ids) > 0;
} }