fix(shopping): 修复购物车选配件价格及金额计算问题
- 注释掉 ModelConfigSearchRequest 中 planId 的 @JsonIgnore 注解取消忽略 - 注释掉 PlanController 中根据 planId 设置请求参数的代码 - PriceConfigController 中标记价格配置是否可用字段 enable - 将 QuotationPriceUpdateItemRequest 中 parts 重命名为 optionalParts - 调整 QuotationUserPlanModelItemMapper 查询,优化关联表及条件 - 修复购物车金额计算,增加对children非空判断避免空指针 - 修改购物车选配件处理逻辑,支持 optionalParts 及相关购物车项更新 - 确保批量更新购物车选配和购物车本身数据
This commit is contained in:
parent
a80015986f
commit
492f57ebbe
|
|
@ -28,6 +28,6 @@ public class ModelConfigSearchRequest extends PageRequest {
|
||||||
*/
|
*/
|
||||||
private Long typeNumber;
|
private Long typeNumber;
|
||||||
|
|
||||||
@JsonIgnore
|
// @JsonIgnore
|
||||||
private Long planId;
|
// private Long planId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,8 @@ public class PriceConfigController extends ControllerBase {
|
||||||
md.put("children", new ArrayList<>());
|
md.put("children", new ArrayList<>());
|
||||||
vo.getChildren().forEach(item -> convert(md, item));
|
vo.getChildren().forEach(item -> convert(md, item));
|
||||||
}
|
}
|
||||||
|
//是否可以配置价格
|
||||||
|
md.put("enable", CollectionUtil.isEmpty(vo.getChildren()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -154,9 +154,9 @@ public class PlanController extends ControllerBase {
|
||||||
.eq(QuotationUserPlanModel::getCreateById, AppUserUtil.getUserId())
|
.eq(QuotationUserPlanModel::getCreateById, AppUserUtil.getUserId())
|
||||||
.one();
|
.one();
|
||||||
vo.setInfo(Convert.convert(QuotationModelRatioVO.class, plan));
|
vo.setInfo(Convert.convert(QuotationModelRatioVO.class, plan));
|
||||||
if (Objects.nonNull(plan)) {
|
// if (Objects.nonNull(plan)) {
|
||||||
request.setPlanId(plan.getId());
|
// request.setPlanId(plan.getId());
|
||||||
}
|
// }
|
||||||
List<PlanSearchItemVO> items = planModelItemService.search(request, AppUserUtil.isAgent() ? 1 : 0, AppUserUtil.getUserId());
|
List<PlanSearchItemVO> items = planModelItemService.search(request, AppUserUtil.isAgent() ? 1 : 0, AppUserUtil.getUserId());
|
||||||
int index = 0, startIndex = (request.getPage() - 1) * request.getPageSize(), endIndex = request.getPage() * request.getPageSize();
|
int index = 0, startIndex = (request.getPage() - 1) * request.getPageSize(), endIndex = request.getPage() * request.getPageSize();
|
||||||
PageData<PlanSearchItemVO> pageData = new PageData<>();
|
PageData<PlanSearchItemVO> pageData = new PageData<>();
|
||||||
|
|
|
||||||
|
|
@ -514,15 +514,15 @@ public class ShoppingController extends ControllerBase {
|
||||||
List<ModelConfigEffectiveDTO> children = parts.stream()
|
List<ModelConfigEffectiveDTO> children = parts.stream()
|
||||||
.filter(pi -> pi.getParentId().equals(part.getId()))
|
.filter(pi -> pi.getParentId().equals(part.getId()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
vi.setAmount(
|
if (CollectionUtil.isNotEmpty(children)) {
|
||||||
vi.getAmount().add(
|
vi.setAmount(
|
||||||
children.stream()
|
children.stream()
|
||||||
.map(ModelConfigEffectiveDTO::getAmount)
|
.map(ModelConfigEffectiveDTO::getAmount)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.reduce(BigDecimal::add)
|
.reduce(BigDecimal::add)
|
||||||
.orElse(BigDecimal.ZERO)
|
.orElse(BigDecimal.ZERO)
|
||||||
)
|
);
|
||||||
);
|
}
|
||||||
vi.setChildren(
|
vi.setChildren(
|
||||||
children.stream()
|
children.stream()
|
||||||
.map(pi -> {
|
.map(pi -> {
|
||||||
|
|
@ -816,15 +816,15 @@ public class ShoppingController extends ControllerBase {
|
||||||
List<ModelConfigEffectiveDTO> children = parts.stream()
|
List<ModelConfigEffectiveDTO> children = parts.stream()
|
||||||
.filter(pi -> pi.getParentId().equals(part.getId()))
|
.filter(pi -> pi.getParentId().equals(part.getId()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
vi.setAmount(
|
if (CollectionUtil.isNotEmpty(children)) {
|
||||||
vi.getAmount().add(
|
vi.setAmount(
|
||||||
children.stream()
|
children.stream()
|
||||||
.filter(pi -> pi.getType() == 0)
|
.filter(pi -> pi.getType() == 0)
|
||||||
.map(ModelConfigEffectiveDTO::getAmount)
|
.map(ModelConfigEffectiveDTO::getAmount)
|
||||||
.reduce(BigDecimal::add)
|
.reduce(BigDecimal::add)
|
||||||
.orElse(BigDecimal.ZERO)
|
.orElse(BigDecimal.ZERO)
|
||||||
)
|
);
|
||||||
);
|
}
|
||||||
vi.setChildren(
|
vi.setChildren(
|
||||||
children.stream()
|
children.stream()
|
||||||
.map(pi -> convert(pi, BigDecimal.ONE))
|
.map(pi -> convert(pi, BigDecimal.ONE))
|
||||||
|
|
@ -1072,15 +1072,29 @@ public class ShoppingController extends ControllerBase {
|
||||||
.setOldFee(item.getOldStandardFee())
|
.setOldFee(item.getOldStandardFee())
|
||||||
.setNewFee(item.getNewStandardFee())
|
.setNewFee(item.getNewStandardFee())
|
||||||
);
|
);
|
||||||
if (CollectionUtil.isNotEmpty(item.getParts())) {
|
if (CollectionUtil.isNotEmpty(item.getOptionalParts())) {
|
||||||
cart.setOptionalFee(cart.getOptionalFee()
|
cart.setOptionalFee(cart.getOptionalFee()
|
||||||
.add(item.getParts()
|
.add(item.getOptionalParts()
|
||||||
.stream()
|
.stream()
|
||||||
.map(QuotationPriceUpdateItemPartRequest::getSpread)
|
.map(QuotationPriceUpdateItemPartRequest::getSpread)
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add)
|
.reduce(BigDecimal.ZERO, BigDecimal::add)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
item.getParts().forEach(part -> {
|
List<QuotationShoppingCartItem> optionalParts = shoppingCartItemService.lambdaQuery()
|
||||||
|
.eq(QuotationShoppingCartItem::getCartId, item.getCartId())
|
||||||
|
.in(QuotationShoppingCartItem::getConfigItemId, item.getOptionalParts()
|
||||||
|
.stream()
|
||||||
|
.map(QuotationPriceUpdateItemPartRequest::getConfigItemId)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
)
|
||||||
|
.list();
|
||||||
|
item.getOptionalParts().forEach(part -> {
|
||||||
|
QuotationShoppingCartItem optionalPart = optionalParts.stream()
|
||||||
|
.filter(p -> Objects.equals(p.getConfigItemId(), part.getConfigItemId()))
|
||||||
|
.findFirst()
|
||||||
|
.get();
|
||||||
|
optionalPart.setAmount(part.getNewStandardFee());
|
||||||
|
optionalPart.setDiscount(part.getSpread());
|
||||||
adjustItems.add(
|
adjustItems.add(
|
||||||
new QuotationShoppingOrderAdjustItem()
|
new QuotationShoppingOrderAdjustItem()
|
||||||
.setAdjustId(adjust.getId())
|
.setAdjustId(adjust.getId())
|
||||||
|
|
@ -1091,10 +1105,16 @@ public class ShoppingController extends ControllerBase {
|
||||||
.setNewFee(part.getNewStandardFee())
|
.setNewFee(part.getNewStandardFee())
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
if (CollectionUtil.isNotEmpty(optionalParts)) {
|
||||||
|
shoppingCartItemService.updateBatchById(optionalParts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
shoppingOrderAdjustItemService.saveBatch(adjustItems);
|
shoppingOrderAdjustItemService.saveBatch(adjustItems);
|
||||||
shoppingOrderAdjustService.save(adjust);
|
shoppingOrderAdjustService.save(adjust);
|
||||||
|
if (CollectionUtil.isNotEmpty(carts)) {
|
||||||
|
shoppingCartService.updateBatchById(carts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
shoppingOrderService.lambdaUpdate()
|
shoppingOrderService.lambdaUpdate()
|
||||||
.set(Objects.nonNull(request.getActualFee()), QuotationShoppingOrder::getActualFee, request.getActualFee())
|
.set(Objects.nonNull(request.getActualFee()), QuotationShoppingOrder::getActualFee, request.getActualFee())
|
||||||
|
|
|
||||||
|
|
@ -32,5 +32,5 @@ public class QuotationPriceUpdateItemRequest {
|
||||||
* 选配调价
|
* 选配调价
|
||||||
*/
|
*/
|
||||||
@Valid
|
@Valid
|
||||||
List<QuotationPriceUpdateItemPartRequest> parts;
|
List<QuotationPriceUpdateItemPartRequest> optionalParts;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,12 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.PlanSearchItemVO">
|
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.PlanSearchItemVO">
|
||||||
SELECT qupmi.id,qupmi.plan_id,pm.batch_number as 'modelId',pm.`no` as
|
SELECT vqupm.id,vqupm.plan_id,pm.batch_number as 'modelId',pm.`no` as 'modelNo',vqupm.`name`,vqupm.ratio
|
||||||
'modelNo',qupmi.`name`,qupmi.ratio,qupmi.is_default,qupmi.area_id
|
,vqupm.is_default,vqupm.area_id
|
||||||
FROM v_quotation_model_price vqmp
|
FROM v_quotation_model_price vqmp
|
||||||
inner join product_model pm on vqmp.model_id=pm.batch_number
|
inner join product_model pm on vqmp.model_id=pm.batch_number
|
||||||
LEFT JOIN quotation_user_plan_model_item qupmi ON qupmi.model_id=pm.batch_number
|
LEFT JOIN v_quotation_user_plan_model vqupm ON vqupm.model_id=pm.batch_number and vqupm.create_by_type=1 and vqupm.create_by_id=14
|
||||||
left join quotation_user_plan_model qupm on qupmi.plan_id=qupm.id and qupm.create_by_type=#{userType} and qupm.create_by_id=#{userId}
|
WHERE pm.state=1
|
||||||
WHERE pm.state=1 and qupm.`status`=1
|
|
||||||
<if test="request.planId!=null">
|
|
||||||
and qupmi.plan_id=#{request.planId}
|
|
||||||
</if>
|
|
||||||
<if test="request.no!=null and request.no!=''">
|
<if test="request.no!=null and request.no!=''">
|
||||||
and pm.no like CONCAT('%', #{request.no}, '%')
|
and pm.no like CONCAT('%', #{request.no}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue