1、绿植统计下单客户总数
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1m42s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1m42s
This commit is contained in:
parent
9a34602030
commit
7b40b084c1
@ -153,6 +153,15 @@ public class PlantsRentalOrderController extends BaseController {
|
||||
return R.ok(plantsRentalOrderService.countOrderAndAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计下单客户总数
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/countCustomers")
|
||||
public R<Map> countCustomers(){
|
||||
return R.ok(plantsRentalOrderService.countCustomers());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 绿植租赁-租赁方案-绿植业务对象 plants_plan_product
|
||||
*
|
||||
@ -44,4 +46,10 @@ public class PlantsPlanProductBo extends BaseEntity {
|
||||
private Integer productNum;
|
||||
|
||||
|
||||
/**
|
||||
* 产品id
|
||||
*/
|
||||
private List<Long> productIds;
|
||||
|
||||
|
||||
}
|
||||
|
@ -127,4 +127,14 @@ public class PlantsRentalOrderBo extends BaseEntity {
|
||||
*/
|
||||
private List<PlantsProductBo> productList;
|
||||
|
||||
/**
|
||||
* 产品id
|
||||
*/
|
||||
private List<Long> productIds;
|
||||
|
||||
/**
|
||||
* 方案id
|
||||
*/
|
||||
private List<Long> planIds;
|
||||
|
||||
}
|
||||
|
@ -101,5 +101,11 @@ public interface IPlantsRentalOrderService {
|
||||
*/
|
||||
Map<String,Object> countOrderAndAmount();
|
||||
|
||||
/**
|
||||
* 统计下单客户总数
|
||||
* @return
|
||||
*/
|
||||
Map<String,Integer> countCustomers();
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
@ -76,6 +77,7 @@ public class PlantsPlanProductServiceImpl implements IPlantsPlanProductService {
|
||||
lqw.orderByAsc(PlantsPlanProduct::getId);
|
||||
lqw.eq(bo.getPlanId() != null, PlantsPlanProduct::getPlanId, bo.getPlanId());
|
||||
lqw.eq(bo.getProductId() != null, PlantsPlanProduct::getProductId, bo.getProductId());
|
||||
lqw.in(CollectionUtils.isNotEmpty(bo.getProductIds()), PlantsPlanProduct::getProductId, bo.getProductIds());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
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.utils.MapstructUtils;
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
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.dromara.property.domain.bo.PlantsProductBo;
|
||||
import org.dromara.property.domain.vo.PlantsProductVo;
|
||||
@ -29,11 +38,17 @@ import java.util.Collection;
|
||||
* @date 2025-06-25
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
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) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,7 +151,15 @@ public class PlantsProductServiceImpl implements IPlantsProductService {
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean 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;
|
||||
}
|
||||
|
@ -9,9 +9,7 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
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.PlantsProduct;
|
||||
import org.dromara.property.domain.bo.PlantsOrderChargeBo;
|
||||
import org.dromara.property.domain.bo.PlantsOrderMaintainBo;
|
||||
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.system.api.RemoteDictService;
|
||||
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.dromara.property.domain.bo.PlantsRentalOrderBo;
|
||||
import org.dromara.property.domain.PlantsRentalOrder;
|
||||
@ -34,21 +34,24 @@ import java.util.*;
|
||||
* @date 2025-06-30
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class PlantsRentalOrderServiceImpl implements IPlantsRentalOrderService {
|
||||
|
||||
private final PlantsRentalOrderMapper baseMapper;
|
||||
|
||||
private final RemoteDictService dictService;
|
||||
|
||||
private final IPlantsProductService productService;
|
||||
|
||||
private final IPlantsPlanProductService planProductService;
|
||||
|
||||
// private final IPlantsOrderMaintainService maintainService;
|
||||
//
|
||||
// private final IPlantsOrderChargeService chargeService;
|
||||
@Autowired
|
||||
private PlantsRentalOrderMapper baseMapper;
|
||||
@Autowired
|
||||
private RemoteDictService dictService;
|
||||
@Autowired
|
||||
private IPlantsProductService productService;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private IPlantsPlanProductService planProductService;
|
||||
@Autowired
|
||||
@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.getContractStatus() != null, PlantsRentalOrder::getContractStatus, bo.getContractStatus());
|
||||
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;
|
||||
}
|
||||
|
||||
@ -191,38 +196,38 @@ public class PlantsRentalOrderServiceImpl implements IPlantsRentalOrderService {
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//有订单收费或订单维护数据不可删除
|
||||
// PlantsOrderChargeBo chargeBo = new PlantsOrderChargeBo();
|
||||
// chargeBo.setOrderIds(ids.stream().toList());
|
||||
// List<PlantsOrderChargeVo> chargeList = chargeService.queryList(chargeBo);
|
||||
// PlantsOrderMaintainBo maintainBo = new PlantsOrderMaintainBo();
|
||||
// maintainBo.setOrderIds(ids.stream().toList());
|
||||
// List<PlantsOrderMaintainVo> maintainList = maintainService.queryList(maintainBo);
|
||||
// if(CollectionUtils.isNotEmpty(maintainList)||CollectionUtils.isNotEmpty(chargeList)){
|
||||
// throw new ServiceException("所选订单不可删除");
|
||||
// }else {
|
||||
// //恢复产品库存
|
||||
// ArrayList<PlantsProductBo> 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<PlantsPlanProductVo> 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("删除订单失败。");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
PlantsOrderChargeBo chargeBo = new PlantsOrderChargeBo();
|
||||
chargeBo.setOrderIds(ids.stream().toList());
|
||||
List<PlantsOrderChargeVo> chargeList = chargeService.queryList(chargeBo);
|
||||
PlantsOrderMaintainBo maintainBo = new PlantsOrderMaintainBo();
|
||||
maintainBo.setOrderIds(ids.stream().toList());
|
||||
List<PlantsOrderMaintainVo> maintainList = maintainService.queryList(maintainBo);
|
||||
if(CollectionUtils.isNotEmpty(maintainList)||CollectionUtils.isNotEmpty(chargeList)){
|
||||
throw new ServiceException("所选订单不可删除");
|
||||
}else {
|
||||
//恢复产品库存
|
||||
ArrayList<PlantsProductBo> 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<PlantsPlanProductVo> 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;
|
||||
}
|
||||
@ -393,4 +398,18 @@ public class PlantsRentalOrderServiceImpl implements IPlantsRentalOrderService {
|
||||
public Map<String, Object> 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;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
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.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@ -12,9 +13,12 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.property.domain.PlantsPlanProduct;
|
||||
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.IPlantsProductService;
|
||||
import org.dromara.property.service.IPlantsRentalOrderService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.property.domain.bo.PlantsRentalPlanBo;
|
||||
import org.dromara.property.domain.vo.PlantsRentalPlanVo;
|
||||
@ -39,6 +43,8 @@ public class PlantsRentalPlanServiceImpl implements IPlantsRentalPlanService {
|
||||
|
||||
private final IPlantsPlanProductService planProductService;
|
||||
|
||||
private final IPlantsRentalOrderService rentalOrderService;
|
||||
|
||||
/**
|
||||
* 查询绿植租赁-租赁方案
|
||||
*
|
||||
@ -162,7 +168,12 @@ public class PlantsRentalPlanServiceImpl implements IPlantsRentalPlanService {
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user