feat(quotation): 完善价格配置和比例配置功能
- 在ModelPriceConfigVO中启用id字段用于数据标识 - 优化PriceConfigController中的条件查询逻辑,改进代码可读性 - 添加价格状态更新逻辑,当配置生效时自动更新相关价格记录状态 - 更新QuotationModelPriceMapper.xml查询语句,增加价格记录id返回 - 修改QuotationModelRatioAgentMapper.xml数据源,关联价格视图进行查询 - 重构RatioConfigController中代理商和直销比例配置的数据过滤逻辑 - 在RatioDirectConfigController中引入ProductModelSimpleVO简化数据传输 - 优化比例配置的数据检索方式,提升查询性能和准确性
This commit is contained in:
parent
24185b09e5
commit
e12dd45cd4
|
|
@ -13,7 +13,7 @@ import java.util.Objects;
|
|||
@Accessors(chain = true)
|
||||
public class ModelPriceConfigVO {
|
||||
|
||||
// private Long id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 机型表batch_number
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ public class PriceConfigController extends ControllerBase {
|
|||
List<QuotationModelPriceItemArea> areas = priceItemAreaService.lambdaQuery()
|
||||
.eq(QuotationModelPriceItemArea::getPriceId, price.getId())
|
||||
.and(wrapper -> wrapper.eq(QuotationModelPriceItemArea::getPriceItemId, 0).or()
|
||||
.in(CollectionUtil.isNotEmpty(items),QuotationModelPriceItemArea::getPriceItemId, items.stream()
|
||||
.in(CollectionUtil.isNotEmpty(items), QuotationModelPriceItemArea::getPriceItemId, items.stream()
|
||||
.map(QuotationModelPriceItem::getId)
|
||||
.collect(Collectors.toList())
|
||||
)
|
||||
|
|
@ -268,7 +268,7 @@ public class PriceConfigController extends ControllerBase {
|
|||
if (Objects.nonNull(area)) {
|
||||
area.setAmount(new BigDecimal(map.get(category.getCode())));
|
||||
areasForUpdate.add(area);
|
||||
}else {
|
||||
} else {
|
||||
areasForAdd.add(new QuotationModelPriceItemArea()
|
||||
.setAreaId(category.getId())
|
||||
.setPriceId(price.getId())
|
||||
|
|
@ -373,7 +373,7 @@ public class PriceConfigController extends ControllerBase {
|
|||
.orElse(null);
|
||||
if (Objects.nonNull(area)) {
|
||||
area.setAmount(new BigDecimal(map.get(category.getCode())));
|
||||
}else {
|
||||
} else {
|
||||
areasForAdd.add(new QuotationModelPriceItemArea()
|
||||
.setAreaId(category.getId())
|
||||
.setPriceId(price.getId())
|
||||
|
|
@ -429,6 +429,11 @@ public class PriceConfigController extends ControllerBase {
|
|||
.eq(QuotationModelConfig::getConfigStatus, 1)
|
||||
.one();
|
||||
if (Objects.nonNull(config)) {
|
||||
priceService.lambdaUpdate()
|
||||
.set(QuotationModelPrice::getPriceStatus, 2)
|
||||
.eq(QuotationModelPrice::getModelId, price.getModelId())
|
||||
.eq(QuotationModelPrice::getPriceStatus, 1)
|
||||
.update();
|
||||
price.setPriceStatus(1);
|
||||
price.setConfigId(config.getId());
|
||||
price.setPriceVersion("MP" + DateTimeUtil.format(LocalDateTime.now(), "yyMMddHHmm"));
|
||||
|
|
|
|||
|
|
@ -118,15 +118,22 @@ public class RatioConfigController extends ControllerBase {
|
|||
.eq(TBaseCustomer::getDelIs, 0)
|
||||
.eq(TBaseCustomer::getEnableState, 1)
|
||||
.list();
|
||||
List<QuotationModelRatioAgentItemDTO> agentItems = isMarketingDirector ? ratioAgentItemService.getEffectives() : null;
|
||||
List<QuotationModelRatioDirectItemDTO> directItems = ratioDirectItemService.getEffectives();
|
||||
pdatas.getRecords().forEach(data -> {
|
||||
RatioConfigSearchVO vo = new RatioConfigSearchVO().setModelNo(data.getModelNo());
|
||||
vos.add(vo);
|
||||
if (isMarketingDirector) {
|
||||
RatioConfigSearchVO voc1 = new RatioConfigSearchVO().setName("代理商");
|
||||
List<QuotationModelRatioAgentItemDTO> agentItems = ratioAgentItemService.getEffectives();
|
||||
if (CollectionUtil.isNotEmpty(agentItems)) {
|
||||
List<AppUser> users = appUserService.listByIds(agentItems.stream().map(QuotationModelRatioAgentItemDTO::getUserId).collect(Collectors.toList()));
|
||||
agentItems.stream()
|
||||
List<QuotationModelRatioAgentItemDTO> modelAgentItems= agentItems.stream()
|
||||
.filter(ai -> ai.getModelId().equals(data.getModelId()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(modelAgentItems)) {
|
||||
List<AppUser> users = appUserService.listByIds(modelAgentItems.stream()
|
||||
.map(QuotationModelRatioAgentItemDTO::getUserId)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
modelAgentItems.stream()
|
||||
.filter(QuotationModelRatioAgentItemDTO::getIsPrimary)
|
||||
.forEach(ai -> {
|
||||
//主账号
|
||||
|
|
@ -174,12 +181,17 @@ public class RatioConfigController extends ControllerBase {
|
|||
}
|
||||
vo.getChildren().add(voc1);
|
||||
RatioConfigSearchVO voc2 = new RatioConfigSearchVO().setName("直销");
|
||||
List<QuotationModelRatioDirectItemDTO> directItems = ratioDirectItemService.getEffectives();
|
||||
if (CollectionUtil.isNotEmpty(directItems)) {
|
||||
List<QuotationModelRatioDirectItemDTO> modelDirectItems = directItems.stream()
|
||||
.filter(di -> di.getModelId().equals(data.getModelId()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(modelDirectItems)) {
|
||||
List<AdminUser> adminUsers = adminUserService.lambdaQuery()
|
||||
.in(AdminUser::getId, directItems.stream().map(QuotationModelRatioDirectItemDTO::getUserId).collect(Collectors.toList()))
|
||||
.in(AdminUser::getId, modelDirectItems.stream()
|
||||
.map(QuotationModelRatioDirectItemDTO::getUserId)
|
||||
.collect(Collectors.toList())
|
||||
)
|
||||
.list();
|
||||
directItems.stream()
|
||||
modelDirectItems.stream()
|
||||
.filter(item -> item.getParentId().equals(AdminUserUtil.getUserId()))
|
||||
.forEach(directItem -> {
|
||||
AdminUser user = adminUsers.stream()
|
||||
|
|
@ -220,7 +232,6 @@ public class RatioConfigController extends ControllerBase {
|
|||
}
|
||||
vo.getChildren().add(voc2);
|
||||
} else {
|
||||
List<QuotationModelRatioDirectItemDTO> directItems = ratioDirectItemService.getEffectives();
|
||||
RatioConfigSearchVO vop = new RatioConfigSearchVO()
|
||||
.setName(AdminUserUtil.getUserName())
|
||||
.setCategoryName(AdminUserUtil.getCategoryName());
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.nflg.mobilebroken.common.pojo.request.ModelRatioDirectUserSearchReque
|
|||
import com.nflg.mobilebroken.common.pojo.vo.DynamicHeaderVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.DynamicTableVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ModelPriceVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.ProductModelSimpleVO;
|
||||
import com.nflg.mobilebroken.common.util.*;
|
||||
import com.nflg.mobilebroken.quotation.controller.ControllerBase;
|
||||
import com.nflg.mobilebroken.quotation.pojo.vo.QuotationModelRatioVO;
|
||||
|
|
@ -58,6 +59,9 @@ public class RatioDirectConfigController extends ControllerBase {
|
|||
@Resource
|
||||
private IProductModelService productModelService;
|
||||
|
||||
@Resource
|
||||
private IQuotationModelRatioAgentService ratioAgentService;
|
||||
|
||||
/**
|
||||
* 获取动态表头
|
||||
*/
|
||||
|
|
@ -153,7 +157,7 @@ public class RatioDirectConfigController extends ControllerBase {
|
|||
Long departmentId = AdminUserUtil.getDepartmentId();
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(departmentId)).throwMessage("未设置部门,请联系管理员");
|
||||
QuotationModelRatioDirect ratioAgent = ratioDirectService.getEffectiveByUser(AdminUserUtil.getUserId());
|
||||
IPage<ProductModel> pdatas = productModelService.searchForQuotation(request);
|
||||
IPage<ProductModelSimpleVO> pdatas = ratioAgentService.search(request);
|
||||
if (CollectionUtil.isEmpty(pdatas.getRecords())) {
|
||||
return ApiResult.successWithExtras(Convert.convert(QuotationModelRatioVO.class, ratioAgent));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
<mapper namespace="com.nflg.mobilebroken.repository.mapper.QuotationModelPriceMapper">
|
||||
|
||||
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.ModelPriceConfigVO">
|
||||
SELECT pm.batch_number as 'modelId',pm.`no` as 'modelNo',qmp.id as 'priceId',pm.`no` as 'partName',qmp.price_version
|
||||
,qmp.price_status,qmp.update_by,qmp.update_time
|
||||
SELECT qmp.id,pm.batch_number as 'modelId',pm.`no` as 'modelNo',qmp.id as 'priceId',pm.`no` as 'partName'
|
||||
,qmp.price_version,qmp.price_status,qmp.update_by,qmp.update_time
|
||||
,if(qmp.price_status=1,qmc2.config_version,qmc1.config_version) as 'configVersion'
|
||||
,if(qmp.price_status=1,qmc2.id,qmc1.id) as 'configId'
|
||||
FROM quotation_model_config qmc1
|
||||
|
|
|
|||
|
|
@ -4,23 +4,25 @@
|
|||
|
||||
<select id="search" resultType="com.nflg.mobilebroken.common.pojo.vo.ProductModelSimpleVO">
|
||||
SELECT pm.batch_number,pm.no
|
||||
FROM product_model pm
|
||||
FROM v_quotation_model_price vqmp
|
||||
LEFT JOIN product_model pm on vqmp.model_id=pm.batch_number and pm.state=1
|
||||
LEFT JOIN product_type pt on pm.type_number=pt.batch_number AND pt.state=1
|
||||
LEFT JOIN product_series ps ON pm.series_number=ps.batch_number AND ps.state=1
|
||||
LEFT JOIN dictionary_item di ON di.id=pm.module_id
|
||||
WHERE pm.state=1
|
||||
<if test="request.moduleId!=null">
|
||||
AND pm.module_id=#{request.moduleId}
|
||||
</if>
|
||||
<if test="request.seriesNumber!=null">
|
||||
AND pm.series_number=#{request.seriesNumber}
|
||||
</if>
|
||||
<if test="request.typeNumber!=null">
|
||||
AND pm.type_number=#{request.typeNumber}
|
||||
</if>
|
||||
<if test="request.no!=null and request.no!=''">
|
||||
AND pm.`no` like concat('%', #{request.no}, '%')
|
||||
</if>
|
||||
order by pm.id
|
||||
<where>
|
||||
<if test="request.moduleId!=null">
|
||||
AND pm.module_id=#{request.moduleId}
|
||||
</if>
|
||||
<if test="request.seriesNumber!=null">
|
||||
AND pm.series_number=#{request.seriesNumber}
|
||||
</if>
|
||||
<if test="request.typeNumber!=null">
|
||||
AND pm.type_number=#{request.typeNumber}
|
||||
</if>
|
||||
<if test="request.no!=null and request.no!=''">
|
||||
AND pm.`no` like concat('%', #{request.no}, '%')
|
||||
</if>
|
||||
</where>
|
||||
order by vqmp.id desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue