Compare commits

..

2 Commits

Author SHA1 Message Date
曹鹏飞 0e2b46713f feat(shopping-cart): 添加购物车其他要求相关功能
- 新增QuotationShoppingCartOther实体及其Mapper和Service实现
- 新增ShoppingCartOtherRequest请求对象并添加字段校验
- 在ShoppingSaveRequest中增加others字段支持其他要求
- 修改ShoppingController增加对其他要求的保存逻辑
- 修正部分代码格式与空格规范
- 增加依赖注入IQuotationShoppingCartOtherService以便操作其他要求数据
2026-05-15 10:52:50 +08:00
曹鹏飞 9e90022fed refactor(quotation): 优化PlanSearchItemVO对象构造及查询逻辑
- 替换多区域字典代码为DirectSalesCategory以准确获取分类ID
- 在分页数据中设置总数以支持分页展示
- 修改循环中对象处理,避免直接修改原有对象,改为构建新的PlanSearchItemVO对象
- 新建PlanSearchItemVO实例时链式调用设置属性,保证数据完整性和代码简洁
- 在PlanSearchItemVO类上添加@Accessors(chain = true)注解支持链式调用
2026-05-15 10:39:33 +08:00
9 changed files with 167 additions and 10 deletions

View File

@ -2,6 +2,8 @@ package com.nflg.mobilebroken.common.pojo.vo;
import com.nflg.mobilebroken.common.util.NumberUtil; import com.nflg.mobilebroken.common.util.NumberUtil;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.AccessType;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -9,6 +11,7 @@ import java.math.BigDecimal;
import java.util.Objects; import java.util.Objects;
@Data @Data
@Accessors(chain = true)
public class PlanSearchItemVO { public class PlanSearchItemVO {
private Long id; private Long id;

View File

@ -137,7 +137,7 @@ public class PlanController extends ControllerBase {
boolean multiRegionQuotations = isMultiRegionQuotationsUser(); boolean multiRegionQuotations = isMultiRegionQuotationsUser();
List<Long> categoryIds = new ArrayList<>(); List<Long> categoryIds = new ArrayList<>();
if (multiRegionQuotations) { if (multiRegionQuotations) {
categoryIds = dictionaryItemService.getListByDictionaryCode("MultiRegionQuotationsSupplier") categoryIds = dictionaryItemService.getListByDictionaryCode("DirectSalesCategory")
.stream() .stream()
.map(DictionaryItem::getId) .map(DictionaryItem::getId)
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -146,6 +146,7 @@ public class PlanController extends ControllerBase {
} }
List<ModelPriceVO> prices = priceService.getAllModelPrice(); List<ModelPriceVO> prices = priceService.getAllModelPrice();
Map<Long, List<PlanSearchItemVO>> fgroup = items.stream().collect(Collectors.groupingBy(PlanSearchItemVO::getModelId)); Map<Long, List<PlanSearchItemVO>> fgroup = items.stream().collect(Collectors.groupingBy(PlanSearchItemVO::getModelId));
pageData.setTotal(fgroup.size());
for (Map.Entry<Long, List<PlanSearchItemVO>> entry : fgroup.entrySet()) { for (Map.Entry<Long, List<PlanSearchItemVO>> entry : fgroup.entrySet()) {
if (index >= startIndex && index < endIndex) { if (index >= startIndex && index < endIndex) {
categoryIds.forEach(categoryId -> { categoryIds.forEach(categoryId -> {
@ -156,14 +157,30 @@ public class PlanController extends ControllerBase {
.collect(Collectors.toList()); .collect(Collectors.toList());
if (CollectionUtil.isEmpty(vos)) { if (CollectionUtil.isEmpty(vos)) {
entry.getValue().forEach(item -> { entry.getValue().forEach(item -> {
item.setStandardPrice(salePrice); datas.add(new PlanSearchItemVO()
item.setAreaId(categoryId); .setPlanId(item.getPlanId())
datas.add(item); .setIsDefault(item.getIsDefault())
.setModelId(item.getModelId())
.setModelNo(item.getModelNo())
.setName(item.getName())
.setRatio(item.getRatio())
.setAreaId(categoryId)
.setStandardPrice(salePrice)
);
}); });
} else { } else {
vos.forEach(item -> { vos.forEach(item -> {
item.setStandardPrice(salePrice); datas.add(new PlanSearchItemVO()
datas.add(item); .setId(item.getId())
.setPlanId(item.getPlanId())
.setIsDefault(item.getIsDefault())
.setModelId(item.getModelId())
.setModelNo(item.getModelNo())
.setName(item.getName())
.setRatio(item.getRatio())
.setAreaId(categoryId)
.setStandardPrice(salePrice)
);
}); });
} }
}); });

View File

@ -101,6 +101,9 @@ public class ShoppingController extends ControllerBase {
@Resource @Resource
private IQuotationShoppingCartServiceService shoppingCartServiceService; private IQuotationShoppingCartServiceService shoppingCartServiceService;
@Resource
private IQuotationShoppingCartOtherService shoppingCartOtherService;
@Resource @Resource
private IQuotationShoppingOrderService shoppingOrderService; private IQuotationShoppingOrderService shoppingOrderService;
@ -357,6 +360,16 @@ public class ShoppingController extends ControllerBase {
).collect(Collectors.toList()) ).collect(Collectors.toList())
); );
} }
if (CollectionUtil.isNotEmpty(request.getOthers())) {
shoppingCartOtherService.saveBatch(
request.getOthers().stream().map(as -> {
QuotationShoppingCartOther ci = Convert.convert(QuotationShoppingCartOther.class, as);
ci.setCartId(cartId);
return ci;
}
).collect(Collectors.toList())
);
}
shoppingCartService.save(cart); shoppingCartService.save(cart);
return ApiResult.success(cartId); return ApiResult.success(cartId);
} }
@ -1025,20 +1038,20 @@ public class ShoppingController extends ControllerBase {
* 获取下属报价单 * 获取下属报价单
*/ */
@PostMapping("/getQuotationOfSubordinate") @PostMapping("/getQuotationOfSubordinate")
public ApiResult<PageData<QuotationSearchVO>> getQuotationOfSubordinate(@Valid @RequestBody SubordinateQuotationSearchRequest request){ public ApiResult<PageData<QuotationSearchVO>> getQuotationOfSubordinate(@Valid @RequestBody SubordinateQuotationSearchRequest request) {
VUtils.trueThrowBusinessError(AppUserUtil.isAgent() && !AppUserUtil.isPrimary()) VUtils.trueThrowBusinessError(AppUserUtil.isAgent() && !AppUserUtil.isPrimary())
.throwMessage("你不是代理商主账号无权查看"); .throwMessage("你不是代理商主账号无权查看");
if (Objects.isNull(request.getCreateById())){ if (Objects.isNull(request.getCreateById())) {
request.setCreateByIds( request.setCreateByIds(
appUserService.getChildren(appUserService.getById(AppUserUtil.getUserId())) appUserService.getChildren(appUserService.getById(AppUserUtil.getUserId()))
.stream() .stream()
.map(AppUser::getId) .map(AppUser::getId)
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
}else { } else {
request.setCreateByIds(List.of(request.getCreateById())); request.setCreateByIds(List.of(request.getCreateById()));
} }
if (!AppUserUtil.isAgent()){ if (!AppUserUtil.isAgent()) {
request.setTargetId(null); request.setTargetId(null);
} }
return ApiResult.success(shoppingOrderService.getQuotationOfSubordinate(request)); return ApiResult.success(shoppingOrderService.getQuotationOfSubordinate(request));

View File

@ -0,0 +1,23 @@
package com.nflg.mobilebroken.quotation.pojo.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Data
public class ShoppingCartOtherRequest {
/**
* 要求说明
*/
@NotBlank(message = "要求说明不能为空")
private String desc;
/**
* 费用
*/
@NotNull(message = "费用不能为空")
private BigDecimal fee;
}

View File

@ -148,4 +148,10 @@ public class ShoppingSaveRequest {
*/ */
@Valid @Valid
private List<ShoppingSaveServiceRequest> services; private List<ShoppingSaveServiceRequest> services;
/**
* 其他要求
*/
@Valid
private List<ShoppingCartOtherRequest> others;
} }

View File

@ -0,0 +1,43 @@
package com.nflg.mobilebroken.repository.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* <p>
* 报价-购物车-其他要求
* </p>
* @author 代码生成器生成
* @since 2026
*/
@Getter
@Setter
@Accessors(chain = true)
@TableName("quotation_shopping_cart_other")
public class QuotationShoppingCartOther implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
/**
* 购物车id
*/
private Long cartId;
/**
* 要求说明
*/
private String desc;
/**
* 费用
*/
private BigDecimal fee;
}

View File

@ -0,0 +1,16 @@
package com.nflg.mobilebroken.repository.mapper;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingCartOther;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 报价-购物车-其他要求 Mapper 接口
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
public interface QuotationShoppingCartOtherMapper extends BaseMapper<QuotationShoppingCartOther> {
}

View File

@ -0,0 +1,16 @@
package com.nflg.mobilebroken.repository.service;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingCartOther;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 报价-购物车-其他要求 服务类
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
public interface IQuotationShoppingCartOtherService extends IService<QuotationShoppingCartOther> {
}

View File

@ -0,0 +1,20 @@
package com.nflg.mobilebroken.repository.service.impl;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingCartOther;
import com.nflg.mobilebroken.repository.mapper.QuotationShoppingCartOtherMapper;
import com.nflg.mobilebroken.repository.service.IQuotationShoppingCartOtherService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 报价-购物车-其他要求 服务实现类
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
@Service
public class QuotationShoppingCartOtherServiceImpl extends ServiceImpl<QuotationShoppingCartOtherMapper, QuotationShoppingCartOther> implements IQuotationShoppingCartOtherService {
}